Skip to content

PP gloo parity test: size gemma3's grad bounds to its noise on AVX2 kernels - #15286

Merged
danielhanchen merged 1 commit into
mainfrom
ci-pp-gemma3-isa-noise
Oct 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-pp-gemma3-isa-noise

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #15273. tests/test_pp_fsdp2_gloo.py::test_pp2_x_tp2_matches_one_process[gemma3] still fails on some CI runners, for example #15275, whose base includes #15273:

AssertionError: base_model.model.model.layers.0.self_attn.v_proj.lora_B.default.weight: Tensor-likes are not close!
Mismatched elements: 1 / 64 (1.6%)
Greatest absolute difference: 1.7233192920684814e-05 at index (14, 1) (up to 8.591873198747636e-06 allowed)

Cause

The bound I set in #15273 came from this host's AVX-512 kernels. Gemma3's tensor-parallel fp32 noise depends on which kernels MKL and oneDNN dispatch to.

Worst step-0 grad difference against the one-process reference, as a fraction of the tensor max / relative L2, same seed:

arch, layout AVX-512 (this host) MKL + oneDNN held to AVX2
gemma3, pp 2 x tp 2 2.8e-5 / 2.4e-5 1.6e-4 / 1.4e-4
gemma3, pp 2 x dp 2 3.8e-7 4.1e-7
llama, pp 2 x tp 2 2.5e-6 / 2.6e-6
qwen3, pp 2 x tp 2 5.8e-6 / 4.5e-6

The AVX2 run fails main's bounds the same way CI does: 18 of 168 tensors over gemma3's per-element bound, and the relative L2 over the shared 5e-5. A CI runner saw 2e-4 per element.

So gemma3 under tensor parallel sits about 30x above llama and qwen3 on the same code. The size moves with the instruction set, the signature of rounding amplified by the model's conditioning rather than a systematic error. The thread count makes no difference (1, 2 and 4 threads give identical numbers).

Fix

per element relative L2
gemma3 (GRAD_ATOL_REL / new GRAD_L2_REL) 1e-3 5e-4
llama, qwen3 (unchanged) 2e-5 5e-5

llama and qwen3 keep the strict bounds on the same tensor parallel code, which is architecture-generic. A gemma3-specific fault, such as a wrong shard or a missed reduction, is an O(1) difference.

Verification

  • test_pp2_x_tp2_matches_one_process, AVX2 emulation (DNNL_MAX_CPU_ISA=AVX2 MKL_ENABLE_INSTRUCTIONS=AVX2 ATEN_CPU_CAPABILITY=avx2): main 1 failed, 2 passed (the gemma3 case, as on CI); this PR 3 passed. On this host's default kernels both pass.
  • Whole file: 12 passed under both kernel sets.
  • Faults injected into gemma3's (pp 2, tp 2) step-0 v_proj.lora_B grad under AVX2. Each fails, and the clean results pass:
    • one entry off by 1e-2 of the tensor max;
    • the whole tensor with 5e-3 relative noise;
    • the tensor halved (a missing reduction);
    • the two tp shards swapped.

#15273 set gemma3's per-element bound from this host's AVX-512 MKL, where its
pp x tp step-0 grads differ from the reference by up to 2.8e-5. With MKL and
oneDNN held to AVX2 the same run reaches 1.6e-4 per element and 1.4e-4
relative L2, and a CI runner saw 2e-4 (#15275), so the test still failed
there. llama and qwen3 on that AVX2 run stay at 2.6e-6 and 5.8e-6.

gemma3 now gets 1e-3 per element and 5e-4 relative L2; llama and qwen3 keep
2e-5 and 5e-5 on the same tensor parallel code. Under AVX2, a 1e-2 error in
one entry, 5e-3 noise over a tensor, a halved tensor and swapped tp shards
each still fail.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-10-25T18:48:40.589867Z 907ba6a 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. Swish!

Reviewed commit: 907ba6aeb3

ℹ️ 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 4bdf6c4 into main Oct 25, 2026
0 of 14 checks passed
@danielhanchen
danielhanchen deleted the ci-pp-gemma3-isa-noise branch October 25, 2026 18:51
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