Add mcore-determinism-debug skill - #7262
Draft
ZhiyuLi-Nvidia wants to merge 1 commit into
Draft
Conversation
svcnvidia-nemo-ci
marked this pull request as draft
September 11, 2026 22:52
Contributor
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
ZhiyuLi-Nvidia
force-pushed
the
zhiyul/determinism-debug-skills
branch
4 times, most recently
from
September 11, 2026 23:02
fc6674e to
f731fc4
Compare
Two runs of a deterministic recipe that disagree give one number to work from: the iteration where the loss curves split. That is where the difference grew large enough to print, not where it started. This skill documents the method that answers which op first diverged. The method: run the job twice, fingerprint every op into a rank-local ordered stream, diff the two streams offline. The first record whose output differs while its inputs matched is the root cause -- everything before it matched byte for byte, so no hypothesis is needed, and forming one before that record is in hand is the most common way these investigations go wrong. SKILL.md carries the method: the capture ladder (loss curve -> semantic boundaries -> ATen ops -> targeted probe -> below the dispatcher), the multi-arm repro harness, how to read a first divergence, and how to turn a site into a mechanism with a discriminator table. references/tracing-setup.md covers arming the tracer: the capture layer, the call-site lifecycle, cost controls, read-only-container injection, and the hash function. references/reading-traces.md covers the three ways a correct trace yields a wrong conclusion -- the one-hop-later rule for kernels that bypass the dispatcher, known probe artifacts, and digest semantics. On hashing, the guidance is to use torch.hash_tensor and not design there: it is far faster than a hand-written position-weighted digest and allocates no measurable scratch, where the custom digest needs three times the input tensor in temporaries. Its one real gap is permutations -- xor over any permutation of 0..n-1 is identically zero, so routing maps and MoE dispatch outputs are invisible when reduced whole-tensor. The fix is granularity, not a different hash: hash_tensor takes dim=, and chunked reduction costs the same as whole-tensor while catching any permutation that crosses a granule. Benchmark constants are deliberately left out of the docs. They came from one GPU and one torch build; the ordering is the durable result. Signed-off-by: Zhiyu Li <zhiyul@nvidia.com>
ZhiyuLi-Nvidia
force-pushed
the
zhiyul/determinism-debug-skills
branch
from
September 11, 2026 23:10
f731fc4 to
45d0bf8
Compare
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.
Two runs of a deterministic recipe that disagree give one number to work from: the iteration where the loss curves split. That is where the difference grew large enough to print, not where it started. This skill documents the method that answers which op first diverged.
The method: run the job twice, fingerprint every op into a rank-local ordered stream, diff the two streams offline. The first record whose output differs while its inputs matched is the root cause -- everything before it matched byte for byte, so no hypothesis is needed, and forming one before that record is in hand is the most common way these investigations go wrong.
SKILL.md carries the method: the capture ladder (loss curve -> semantic boundaries -> ATen ops -> targeted probe -> below the dispatcher), the multi-arm repro harness, how to read a first divergence, and how to turn a site into a mechanism with a discriminator table.
references/tracing-setup.md covers arming the tracer: the capture layer, the call-site lifecycle, cost controls, read-only-container injection, and the hash function. references/reading-traces.md covers the three ways a correct trace yields a wrong conclusion -- the one-hop-later rule for kernels that bypass the dispatcher, known probe artifacts, and digest semantics.
On hashing, the guidance is to use torch.hash_tensor and not design there: it is far faster than a hand-written position-weighted digest and allocates no measurable scratch, where the custom digest needs three times the input tensor in temporaries. Its one real gap is permutations -- xor over any permutation of 0..n-1 is identically zero, so routing maps and MoE dispatch outputs are invisible when reduced whole-tensor. The fix is granularity, not a different hash: hash_tensor takes dim=, and chunked reduction costs the same as whole-tensor while catching any permutation that crosses a granule.
Benchmark constants are deliberately left out of the docs. They came from one GPU and one torch build; the ordering is the durable result.
What does this PR do?
Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.