-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add patch to locomanipulation SDG pipeline to avoid use of flash attn #5596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kellyguo11
merged 7 commits into
isaac-sim:develop
from
jaybdub:jwelsh/locomanip_sdg_no_flash_attn_patch
May 15, 2026
+83
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ceebcf
add patch to avoid using flash-attn in locomanipulation sdg policy
jaybdub 511bc8d
add fix to policy rollout
jaybdub 15c318f
Merge branch 'develop' into jwelsh/locomanip_sdg_no_flash_attn_patch
jaybdub 1c3f993
Merge branch 'develop' into jwelsh/locomanip_sdg_no_flash_attn_patch
jaybdub e3868cf
Merge branch 'develop' into jwelsh/locomanip_sdg_no_flash_attn_patch
jaybdub 969753e
Merge branch 'develop' into jwelsh/locomanip_sdg_no_flash_attn_patch
jaybdub 40cc4a9
Merge branch 'develop' into jwelsh/locomanip_sdg_no_flash_attn_patch
kellyguo11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
scripts/imitation_learning/locomanipulation_sdg/gr00t/no_flash_attn.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| diff --git a/gr00t/model/backbone/eagle2_hg_model/config.json b/gr00t/model/backbone/eagle2_hg_model/config.json | ||
| index 3894adf..f1b95aa 100644 | ||
| --- a/gr00t/model/backbone/eagle2_hg_model/config.json | ||
| +++ b/gr00t/model/backbone/eagle2_hg_model/config.json | ||
| @@ -1,5 +1,5 @@ | ||
| { | ||
| - "_attn_implementation": "flash_attention_2", | ||
| + "_attn_implementation": "sdpa", | ||
| "_commit_hash": null, | ||
| "architectures": [ | ||
| "Eagle2_5_VLForConditionalGeneration" | ||
| diff --git a/gr00t/model/backbone/eagle2_hg_model/modeling_eagle2_5_vl.py b/gr00t/model/backbone/eagle2_hg_model/modeling_eagle2_5_vl.py | ||
| index a9649d5..d99b496 100755 | ||
| --- a/gr00t/model/backbone/eagle2_hg_model/modeling_eagle2_5_vl.py | ||
| +++ b/gr00t/model/backbone/eagle2_hg_model/modeling_eagle2_5_vl.py | ||
| @@ -108,7 +108,7 @@ class Eagle2_5_VLForConditionalGeneration(Eagle2_5_VLPreTrainedModel, Generation | ||
| self.vision_model = vision_model | ||
| else: | ||
| if config.vision_config.model_type == "siglip_vision_model": | ||
| - config.vision_config._attn_implementation = "flash_attention_2" | ||
| + config.vision_config._attn_implementation = "sdpa" | ||
| self.vision_model = SiglipVisionModel(config.vision_config) | ||
| elif config.vision_config.model_type == "radio": | ||
| self.vision_model = RADIOModel(config.vision_config) | ||
| @@ -124,9 +124,7 @@ class Eagle2_5_VLForConditionalGeneration(Eagle2_5_VLPreTrainedModel, Generation | ||
| raise NotImplementedError("Phi3 is not implemented.") | ||
| # self.language_model = Phi3ForCausalLM(config.text_config) | ||
| elif config.text_config.architectures[0] == "Qwen2ForCausalLM": | ||
| - assert ( | ||
| - config.text_config._attn_implementation == "flash_attention_2" | ||
| - ), f"Qwen2 must use flash_attention_2 but got {config.text_config._attn_implementation}" | ||
| + config.text_config._attn_implementation = "sdpa" | ||
| self.language_model = Qwen2ForCausalLM(config.text_config) | ||
| elif config.text_config.architectures[0] == "Qwen3ForCausalLM": | ||
| self.language_model = Qwen3ForCausalLM(config.text_config) | ||
| diff --git a/gr00t/model/backbone/eagle2_hg_model/radio_model.py b/gr00t/model/backbone/eagle2_hg_model/radio_model.py | ||
| index 2df0415..eb9b741 100644 | ||
| --- a/gr00t/model/backbone/eagle2_hg_model/radio_model.py | ||
| +++ b/gr00t/model/backbone/eagle2_hg_model/radio_model.py | ||
| @@ -44,12 +44,18 @@ from transformers.utils import ModelOutput | ||
|
|
||
| try: # v1 | ||
| from flash_attn.flash_attn_interface import flash_attn_unpadded_qkvpacked_func | ||
| -except ImportError: # v2 | ||
| - from flash_attn.flash_attn_interface import ( | ||
| - flash_attn_varlen_qkvpacked_func as flash_attn_unpadded_qkvpacked_func, | ||
| - ) | ||
| +except ImportError: | ||
| + try: # v2 | ||
| + from flash_attn.flash_attn_interface import ( | ||
| + flash_attn_varlen_qkvpacked_func as flash_attn_unpadded_qkvpacked_func, | ||
| + ) | ||
| + except ImportError: # flash-attn unavailable — RADIO vision won't work, SigLIP does | ||
| + flash_attn_unpadded_qkvpacked_func = None | ||
|
|
||
| -from flash_attn.bert_padding import pad_input, unpad_input | ||
| +try: | ||
| + from flash_attn.bert_padding import pad_input, unpad_input | ||
| +except ImportError: | ||
| + pad_input = unpad_input = None | ||
|
|
||
|
|
||
| class FlashAttention(nn.Module): | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this git patch sensitive to the particular commit of GR00T? I.e. if someone changes to a different commit and the code changes slightly this will result in a git apply failure. Maybe worth mentioning in the docs the particular commit that this patch works against.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gr00t checkout is already pinned to a specific version in the documentation that matches the patch