Skip to content

TP / PP gloo tests: build from pinned tiny-repo revisions - #18425

Merged
danielhanchen merged 2 commits into
mainfrom
ci/tp-kv-test-pin-head-dim
Nov 19, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
ci/tp-kv-test-pin-head-dim

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Two gloo tests started failing in the CPU tensor-parallel shards on several unrelated PRs (#18290, #17550):

tests/test_tp_kv_replicated_gloo.py::test_kv_heads_below_tp_are_replicated_per_rank
E   assert (0, 16) == (0, 128)

tests/test_tp_native_gloo.py::test_tp2_tied_norm_weight_is_summed_once
E   Max absolute difference: 7.361173629760742e-06   (tolerance 3.4e-06)

On a host with a cold Hugging Face cache, both fail every time, including on commits from before any recent tensor-parallel change.

Cause

Not a code change. The gloo tensor and pipeline parallel builders (build() in tests/test_tp_native_oracle.py and tests/test_pp_native_gloo.py) read a tiny Hub repo's config.json at its latest revision and build random weights from it. trl-internal-testing/tiny-Qwen3ForCausalLM was re-uploaded upstream on 2026-11-19 (commit 92ee0a3c80), and its config changed head_dim from 128 to 16:

revision hidden_size heads / KV heads head_dim
25bb9b8963 (previous) 8 4 / 2 128
92ee0a3c80 (current) 8 4 / 2 16
  • test_kv_heads_below_tp_are_replicated_per_rank hardcoded 128 for the expected per-rank KV row slice.
  • test_tp2_tied_norm_weight_is_summed_once compares parity values that the new shapes move just past their tolerance.

Runners that still have the old config cached pass and fresh fetches fail. That is why the same base, with the same package versions (transformers 5.18.0, torch 2.10.0), was green on some PRs and red on others. trl-internal-testing/tiny-Qwen3MoeForCausalLM was re-uploaded the same day.

The tensor-parallel code is correct. It slices by the config's head_dim.

Fix

Test-only:

  • tests/_tiny_fixture_revisions.py pins a full commit id for every tiny repo the two builders use:
    • Qwen3 and Qwen3-MoE at the revision before the re-upload;
    • the rest at their current revision, the one CI has been green on.
  • Both builders load the config with AutoConfig.from_pretrained(repo, revision = revision(repo)). Moving a fixture is now a deliberate edit to the pin table.
  • tests/test_tiny_fixture_revisions_pinned.py fails if either builder module names a tiny repo without a pin, if a pin is not a full commit id, or if a builder stops loading at the pin.
  • test_kv_heads_below_tp_are_replicated_per_rank also pins head_dim in its own overrides and derives the expected rows from it, so it states the shape it checks.

Verification

result
test_tp_kv_replicated_gloo.py, main 1 failed, 10 passed
test_tp_kv_replicated_gloo.py, this branch 11 passed
test_tp_native_gloo.py (tied_norm), main 1 failed
test_tp_native_gloo.py, this branch 57 passed
test_pp_native_gloo.py, this branch 24 passed
test_tiny_fixture_revisions_pinned.py 3 passed
tp_native.py sabotaged to give every rank KV head 0 the KV test fails on ranks 2 and 3 ((0, 16))

So the per-rank KV head check still catches wrong slicing. ruff is clean.

…3 default

trl-internal-testing/tiny-Qwen3ForCausalLM was re-uploaded (92ee0a3c80)
with head_dim 16 instead of 128. test_kv_heads_below_tp_are_replicated_per_rank
hardcoded 128 for the expected per-rank KV rows, so it fails wherever the
new config is fetched (always on a cold Hub cache, intermittently in the
gloo-tp-env shard). Pin head_dim in the test's own overrides and derive
the expected rows from it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 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-19T07:05:25.708709Z ef70886 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. Delightful!

Reviewed commit: d0b96a7846

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

The gloo tensor and pipeline parallel builders read a tiny Hub repo's
config.json at its latest revision and build random weights from it, so
an upstream re-upload changes every compared number.
trl-internal-testing/tiny-Qwen3ForCausalLM's re-upload (head_dim 128 to
16) also moved test_tp2_tied_norm_weight_is_summed_once past its parity
tolerance (7.4e-6 vs 3.4e-6), and tiny-Qwen3MoeForCausalLM was
re-uploaded the same day.

Pin every fixture repo the two builders use in
tests/_tiny_fixture_revisions.py (Qwen3 and Qwen3-MoE at the revision
before the re-upload, the rest at their current revision), load configs
at the pin, and add a guard that fails when a builder module names a
tiny repo without a pin.
@danielhanchen danielhanchen changed the title TP KV-replicated test: pin head_dim instead of assuming the tiny Qwen3 default TP / PP gloo tests: build from pinned tiny-repo revisions Nov 19, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: ef708867b2

ℹ️ 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 e1fd0c0 into main Nov 19, 2026
@danielhanchen
danielhanchen deleted the ci/tp-kv-test-pin-head-dim branch November 19, 2026 07:14
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