Skip to content

Capability registry: refuse tensor parallel where tp_native cannot shard, and add the zoo MoE families - #16709

Merged
danielhanchen merged 4 commits into
mainfrom
dh/cmp-registry-tp-moe-families
Nov 5, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
dh/cmp-registry-tp-moe-families

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Three places where unsloth/parallel_capabilities.py disagreed with what the code does. The composition matrix (tiny models, CPU gloo, 2 ranks) found them:

before after
OLMoE under UNSLOTH_TP_SIZE=2 registry: unverified, "tensor parallel MoE runs"; tp_native always refuses (q_norm normalizes 64 features, not one head) registry refuses with tp x model and tp_native's reason
DeepSeek-V3 under tp 2 same note; tp_native refuses multi-head latent attention refused, with tp_native's reason
zoo MoE matrix families (olmoe, mixtral, qwen2_moe, qwen3_next, qwen3_vl_moe, llama4, glm4_moe, ernie4_5_moe, nemotron_h, jamba, granitemoehybrid, gemma4, lfm2_moe) not in MOE_FAMILIES, no MoE rows MoE families with their rows
family of a multimodal MoE (Qwen3.5-MoE, Gemma-4, Llama-4) the text config's model_type (qwen3_5_moe_text), so the existing qwen3_5_moe rows never matched a real model _text dropped: qwen3_5_moe

Change

  • New Query.tp_blocker. query_from fills it from tp_native.derive_tp_plan(model, tp): the ValueError text, or empty. It is asked only of a decoder model tp_native can read that is not split yet; a split model was sharded, and its local shapes are not the model's. It is meta-device safe, since the sharded load already runs derive_tp_plan on the meta model.
  • New RULE tp x model, "tensor parallel on models tensor parallel has no sharding rule for (multi-head latent attention, a q / k norm over all heads)". The refusal message ends with tp_native's own reason. The existing direct-parameter (attention sinks) RULE is unchanged and still answers first for gpt-oss.
  • The cells notes for olmoe / deepseek_v3 x tp say they are refused by that rule.
  • MOE_FAMILIES gains the 13 families above. Each was checked on transformers 5.17 to build a stacked experts module ([E, ...] gate_up_proj / down_proj, nemotron_h up_proj / down_proj) and a router per MoE layer.
  • _model_traits drops a _text suffix from the family.
  • With UNSLOTH_PARALLEL_STRICT=1, the new families (and the *_moe_text configs now named by their family) are refused under DDP, FSDP2 or TP alone, since their MoE rows are unverified. Base already refuses qwen3_moe the same way under strict mode. Default mode is unchanged: across 60,528 enumerated queries (every new family, 8 dense families, all 38 *_text model types, 13 layouts, 4 precisions) no outcome differs from base.

Testing

New tests/test_parallel_capabilities_tp_blocked.py, CPU, meta-device models:

test base head
OLMoE and DeepSeek-V3 under tp 2: check_layout refuses with tp x model and tp_native's reason, nothing loaded (2 params) FAIL PASS
Qwen3-MoE (per-head norms) under tp 2 is not refused; no tp asks nothing FAIL PASS
cells notes for olmoe / deepseek_v3 x tp say refused FAIL PASS
the 13 matrix families are MoE families with rows FAIL PASS
a multimodal text config names the family without _text FAIL PASS

Suites on head, after merging main:

suite result
tests/test_parallel_capabilities*.py, tests/test_parallel_env.py, tests/test_tp_native_oracle.py 213 passed, 1 skipped
the above plus tests/test_tp_env_gloo.py, tests/test_context_parallel_compose_refusal.py, cp x tp gloo tests (before the merge) 269 passed, 3 skipped

Not covered

  • The new RULE fires only when a model reaches the registry before it is split. On the UNSLOTH_TP_SIZE env load path the model is sharded at load, and tp_native refuses there first, so users on that path still see tp_native's ValueError rather than the registry's message. The refusal still happens before any weight loads.
  • The new families get registry rows with notes, not parity evidence; their cells stay unverified (or refused under cp / pp by the existing gate).

…ard, and add the zoo MoE families

The registry answered "unverified, tensor parallel MoE runs" for OLMoE (its q / k
norms cover all heads' features) and DeepSeek-V3 (multi-head latent attention),
while models/tp_native.py always refuses both before any weight loads.
query_from now asks tp_native (derive_tp_plan on a model not split yet) and a new
tp x model RULE refuses with tp_native's own reason; the cells notes say so.

MOE_FAMILIES gains the 13 families of the zoo MoE matrix, each checked on
transformers 5.17 to carry a stacked experts module and a router per layer
(olmoe, mixtral, qwen2_moe, qwen3_next, qwen3_vl_moe, llama4, glm4_moe,
ernie4_5_moe, nemotron_h, jamba, granitemoehybrid, gemma4, lfm2_moe).

A multimodal model's family was its text config's model_type (qwen3_5_moe_text,
gemma4_text), so the qwen3_5_moe rows never matched a real Qwen3.5-MoE; the
"_text" suffix is dropped.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-05T00:09:22.985895Z 16f25e0 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. Breezy!

Reviewed commit: 16f25e0c6f

ℹ️ 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 fd50f8f into main Nov 5, 2026
@danielhanchen
danielhanchen deleted the dh/cmp-registry-tp-moe-families branch November 5, 2026 01:22
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