Add FMoE run_config mismatch diagnostics#3111
Open
zihaomu wants to merge 1 commit into
Open
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds compact, failure-only diagnostics to the FMoE run_config validation path so that tuner “mismatch” and “all-zero output” failures include actionable tensor comparison summaries rather than only an err_ratio.
Changes:
- Introduces
tensor_compare_diagnostics()to summarize shape/dtype/numel plus sampled mismatch/error statistics and a few example mismatches. - Enhances
run_config()failure statuses (“all zeros” and “mismatch”) to append the new diagnostics output. - Keeps the existing
checkAllclose()-computed error ratio as the primary pass/fail metric.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+134
to
+158
| parts = [ | ||
| f"shape=out{tuple(res.shape)},ref{tuple(ref.shape)}", | ||
| f"dtype=out={res.dtype},ref={ref.dtype}", | ||
| f"numel=out={res_numel},ref={ref_numel}", | ||
| ] | ||
|
|
||
| if sample_count: | ||
| sample_idx = torch.arange( | ||
| sample_count, device=ref_flat.device, dtype=torch.long | ||
| ) | ||
| sample_idx = sample_idx * total // sample_count | ||
| ref_f = ref_flat[sample_idx].float() | ||
| res_f = res_flat[sample_idx].float() | ||
| delta = (res_f - ref_f).abs() | ||
| close = torch.isclose(res_f, ref_f, rtol=rtol, atol=atol) | ||
| mismatch = ~close | ||
|
|
||
| sample_mismatch = int(mismatch.sum().item()) | ||
| parts.extend( | ||
| [ | ||
| f"sampled={sample_count}/{total}", | ||
| f"sample_mismatch={sample_mismatch}/{sample_count}", | ||
| f"sample_max_abs={float(delta.max().item()):.6g}", | ||
| f"sample_mean_abs={float(delta.mean().item()):.6g}", | ||
| ] |
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.
Motivation
Add compact diagnostics for FMoE run_config compare failures, including mismatch counts, absolute error stats, norms, and top mismatched values.
Technical Details
examples.
Befor this patch:
When your met FMoE tuner error, you get like this:
With this patch:
Test Result
Submission Checklist