Skip to content

Train the float8 FSDP2 reference in a fresh process like the sharded ranks - #15250

Merged
danielhanchen merged 1 commit into
mainfrom
ci-float8-fsdp2-fresh-reference
Oct 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-float8-fsdp2-fresh-reference

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

tests/test_float8_training_fsdp2_gloo.py::test_float8_linear_trains_under_native_fsdp2 fails in the Repo tests (CPU, rest) shard on unrelated PRs (#15212, #15217, #15218) and passes when run on its own:

Mismatched elements: 1 / 4:  Max relative difference: 6.84e-05
Index | Obtained          | Expected
3     | 5.603824138641357 | 5.603440761566162 ± 5.6e-05

The sharded run is the correct one. Training the same unsharded fp8 model in a clean process gives 5.603824139 at step 4, and the result is identical with 1, 2, 4 and 8 threads. The value that moved is the reference. The test trained it inside the pytest worker, so it inherited whatever earlier tests in the shard had left in that process, while the two gloo ranks start fresh under spawn. The tolerance is fine. The two sides were simply not run under the same conditions.

Change

  • The unsharded reference trains in its own spawned process (_reference_worker, nprocs = 1), so both sides of the comparison start from a clean interpreter. The tolerance is unchanged (rel = 1e-5, abs = 1e-6).
  • The JSON reads and both writes name encoding = "utf-8".

Verification

  • tests/test_float8_training_fsdp2_gloo.py: passes, and the clean reference matches the sharded losses exactly.
  • Sabotage 1 (the CI failure): a pytest plugin that changes only the parent process (scales F.cross_entropy by 1 + 1e-4, which spawn children do not inherit). The old test fails with Max relative difference: 2.0e-04. The new test passes.
  • Sabotage 2 (the guard still bites): scaling the sharded ranks' losses by 1 + 1e-4 makes the new test fail.

I did not pin down which earlier test leaves the state behind. With this change, the comparison no longer depends on it.

@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-25T10:58:52.555704Z f97ace2 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. 🚀

Reviewed commit: f97ace2378

ℹ️ 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 c9e0db6 into main Oct 25, 2026
0 of 14 checks passed
@danielhanchen
danielhanchen deleted the ci-float8-fsdp2-fresh-reference branch October 25, 2026 11:04
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