Skip to content

Refuse tensor parallel on blocks that own parameters in the registry - #16638

Merged
danielhanchen merged 6 commits into
mainfrom
dh/registry-gpt-oss-tp
Nov 4, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
dh/registry-gpt-oss-tp

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

tp_native refuses tensor parallel for any decoder attention / MLP block that owns a parameter directly instead of inside a projection ("tensor parallelism cannot shard '...': it owns the parameter '...' directly"). The gpt-oss attention sinks are one such parameter. The registry did not know this. For every MoE family under tp, _moe_note said "tensor parallel MoE runs", and gpt_oss x tp showed up as unverified. It ran unless UNSLOTH_PARALLEL_STRICT=1 was set, and then failed later inside apply_tensor_parallel. Under pp x tp the cell gate refused it, but gave a missing-evidence reason instead of the real one.

Change

unsloth/parallel_capabilities.py:

  • New Query.direct_params, filled by _direct_params(model). It walks the decoder layers with tp_native's own helpers (_decoder_layers, _ATTN_NAMES, _MLP_NAMES, _is_moe_block), skips MoE blocks as tp_native does, and reports whether a block owns a parameter itself. It reads only the module tree, so a meta-device model works. Objects without modules (config namespaces, model ids) give False.
  • New rule tp x model: q.tp > 1 and q.direct_params, with tp_native's reason, and "drop tp (DDP, or UNSLOTH_FSDP2=1, over the dp axis)" as the alternative.
  • The MoE cells table now notes the refusal for the gpt_oss x tp rows. Other families keep their note.

tp_native is unchanged. Its refusal stays a ValueError: tests/test_tp_native_oracle.py matches it as ValueError, and tp_env._apply catches ValueError.

Testing

New tests/test_parallel_capabilities_tp_model.py, CPU only, on the tiny gpt-oss checkpoint. It checks that tp 2, tp 4 and pp 2 x tp 2 on a meta-device model (no weights read) raise tp x model. It also checks that the loaded model is refused by both the registry and tp_native.derive_tp_plan (same model, same structure), that gpt-oss under DDP alone is not refused, that tiny Qwen3 and Qwen3-MoE are not flagged and still derive a tp plan, and that the cells table carries the note.

Test Base (main) Head
test_parallel_capabilities_tp_model.py 5 failed, 3 passed (tp 2 / tp 4 not refused; pp 2 x tp 2 refused for missing evidence; cells note says it runs) 8 passed
test_parallel_env.py, test_context_parallel_compose_refusal.py, test_parallel_cp_compose_gloo.py, test_tp_native_oracle.py, test_float8_training.py, test_fp8_lora.py, test_precision_registry.py, test_float8_training_fsdp2_gloo.py all passed (only the new file fails) all passed (447 passed, 3 skipped with the new file)

GPU-marked tests were not run (CPU-only host session).

tp_native refuses an attention or MLP block that owns a parameter
directly, such as the gpt-oss attention sinks, but the registry said
tensor parallel MoE runs for every family and reported gpt_oss x tp as
unverified. The query now reads that structure from the module tree
(direct_params) and a tp x model rule refuses it with tp_native's reason,
before the model is split. The cells table notes the refusal for gpt_oss.
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T18:07:31.972112Z 9447c64 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 9647786b20

ℹ️ 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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9447c64db5

ℹ️ 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 e2ffc74 into main Nov 4, 2026
@danielhanchen
danielhanchen deleted the dh/registry-gpt-oss-tp branch November 4, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant