Skip to content

Pipeline parallel: accept Qwen4Exp QSA layers under the transformers 5.17 name (qwen_sparse_attention) - #17895

Merged
danielhanchen merged 1 commit into
mainfrom
fix-pp-qwen4exp-layer-type
Nov 16, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-pp-qwen4exp-layer-type

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Repo tests (CPU, gloo) has failed on main since #17785 (FSDP2, TP and PP for Qwen3.8-Flash-Next and DeepSeek-V4.1). Every pipeline-parallel cell of tests/test_qwen4exp_parallel_gloo.py and tests/test_frozen_table_pp_gloo.py exits with rank exit codes [1, 1] (15 tests):

ValueError: Unsloth: pipeline parallelism v1 does not support hybrid layer stacks (layer_types ['qwen_sparse_attention']).

#17785 allow-lists Qwen4Exp's layer types for PP as {"linear_attention", "indexed_attention"}. That is what transformers 5.23 calls the QSA layer. transformers 5.17, unsloth's default pin and what the CPU shards install, calls the same layer "qwen_sparse_attention"; the configuration converts full_attention entries into it. So on 5.17 the guard refuses the exact stack the PR proved, and users on that pin cannot use PP for Qwen4Exp either.

Change

  • unsloth/models/pp_native.py: _PP_HYBRID_FAMILIES["Qwen4ExpForCausalLM"] also allows "qwen_sparse_attention". The comment notes the rename.
  • tests/test_qwen4exp_parallel_gloo.py: new test_pp_accepts_the_qsa_layer_name_of_every_transformers, parametrized over both names. It sets the built model's layer_types to each name and checks _refuse_unsupported does not refuse. It runs on whichever transformers is installed.

Verification

transformers 5.17.0, tests/test_frozen_table_pp_gloo.py tests/test_qwen4exp_parallel_gloo.py:

result
main 15 failed
this branch 22 passed (+2 new)
this branch with the pp_native.py change reverted the qwen_sparse_attention case of the new test fails, indexed_attention passes

… 5.1x name too

#17785 proved PP for Qwen4Exp hybrid stacks and allow-listed the QSA layer as "indexed_attention",
the name transformers 5.23 uses. transformers 5.17 (unsloth's default pin) calls it
"qwen_sparse_attention", so _refuse_unsupported raised 'does not support hybrid layer stacks' and every
PP cell of test_qwen4exp_parallel_gloo.py and test_frozen_table_pp_gloo.py failed in the gloo shard on
main. Allow both names; a test pins each.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T03:53:05.353366Z 7adfdcc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 7adfdcc1a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit 904919c into main Nov 16, 2026
@danielhanchen
danielhanchen deleted the fix-pp-qwen4exp-layer-type branch November 16, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant