Repository navigation
ROCm: pack hybrid models by default when flash varlen passes its self-check - #18611
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #18313 and #17738.
Why ROCm was opt-in
#13383 made hybrid packing (Qwen3.5, Qwen3.5-MoE, Qwen3-Next, and the PLE layers from #14011) default-on for CUDA only. At the time
UNSLOTH_EXPERIMENTAL_HYBRID_PACKING=1failed closed on gfx1151 because the boundary-aware causal conv was not allowed on HIP (unsloth-zoo #2503 fixed that), and once it worked, the full attention layers still ran SDPA over a dense(T, T)mask on ROCm, so packing was a wash (#17738). #18313 moved ROCm packed rows onto torch's flash varlen behind a one-time self-check, which removes that cost.Change
With the variable unset,
_auto_hybrid_device_oknow also accepts a ROCm GPU when the #18313 self-check (hf_packed_attention._torch_varlen) passes on that device. The check runs once per device (about 0.3 s on gfx1151) and is cached. Everything else is unchanged:=0still turns packing off and=1still opts in Mamba2 / split QKV mixers and other devices.The opt-in note from #17751 now says the path is "not on by default on this device" instead of naming CUDA only.
gfx1151, Linux, torch 2.11.0+rocm7.13, transformers 5.5.4
Fake Qwen3.5-4B shaped model (real 4B layer sizes, 4 layers, random weights), LoRA r=16,
packing = True,max_length 2048, batch 4, variable unset vs=0. Two runs per arm.=0=0Default ROCm runs now pack and train at about 1.42x the padded throughput. The packed losses are the same values #18313 measured for the opt-in path, and
=0is unchanged.Tests
tests/utils/test_hybrid_packing_default.pyadds a case with a ROCm GPU weight where the self-check passes (default-on) and fails (padded, reported as an opt-in device). Reverting the change fails the passing case.