Repository navigation
PP gloo parity test: give gemma3 its own per-element grad tolerance - #15273
Merged
Merged
Conversation
Gemma3's step-0 LoRA grads differ from the one-process reference by about 1e-5 of each tensor (relative L2) on every layer, up to 2.1e-5 of the max per element, which is its fp32 reordering floor (the file already gives it a 30x looser step-0 norm bound). The shared 2e-5 per-element bound sat on that floor: 0.999 of it on this host, and over it on CI for test_pp2_x_tp2_matches_one_process[gemma3]. gemma3 now gets 1e-4; llama and qwen3 keep 2e-5, the 5e-5 relative L2 bound is unchanged, and the assert keeps assert_close's mismatch detail.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
added a commit
that referenced
this pull request
Oct 25, 2026
…ernels (#15286) 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/test_pp_fsdp2_gloo.py::test_pp2_x_tp2_matches_one_process[gemma3]fails now and then inRepo tests (CPU, rest), for example on #15222, which does not touch parallelism. The failure is onlyAssertionError: base_model.model.model.layers.0.self_attn.v_proj.lora_A.default.weightfrom the step-0 grads check.Cause
The tolerance, not the product. The step-0 grads check allows 2e-5 of each tensor's largest entry per element for every architecture. Measured on main on this host, gemma3's (pp 2, tp 2) grads differ from the one-process reference by:
The error is uniform across layers and tensors, the shape of fp32 reordering rather than a wrong slice or a missing reduction. Gemma3 already has its own looser step-0 norm bound in this file (
STEP0_NORM_REL["gemma3"] = 3e-4, against 1e-5 for llama and qwen3) for the same reason. The grads check had no per-architecture bound.Fix
GRAD_ATOL_RELgives gemma3 1e-4 and keeps llama and qwen3 at 2e-5. The two per-architecture tests pass it to_check.assert_close's mismatch detail. It used to print only the name.Verification
tests/test_pp_fsdp2_gloo.py: 12 passed.layers.0.self_attn.v_proj.lora_A, on both (pp 2, tp 2) and (pp 2, dp 2). Each fails the new gemma3 bound, and the clean results pass: