Skip to content

[graph_trainer] Add bitwise numerics coverage for Muse Glimmer - #5836

Merged
SherlockNoMad merged 1 commit into
mainfrom
SherlockNoMad/gt_muse_glimmer
Nov 9, 2026
Merged

SherlockNoMad merged 1 commit into
mainfrom
SherlockNoMad/gt_muse_glimmer

Conversation

@SherlockNoMad

Copy link
Copy Markdown
Contributor

Stacked on #5835.

Summary (human-written)

Why

GraphTrainer already runs Muse Glimmer in its integration tests, but nothing
checks its numerics against eager, so a GraphTrainer change could silently
alter Muse Glimmer's loss. The vision flavor (debugmodel_mm) also fails deep
in tracing with a data-dependent-shape error instead of a clear message.

Example.

to_graph_trainer_config(muse_glimmer_debugmodel_mm(), GraphTrainerMuseGlimmerModel.Config)
# Before: fails during make_fx with a data-dependent-shape error
# After:  ValueError at config time: GraphTrainer MuseGlimmer supports
#         text-only flavors; got a vision encoder.

What changed

  • graph_trainer/muse_glimmer/model.py: the config rejects a vision encoder
    with ValueError, like Kimi K3, Kimi K2.7, and Qwen3.5 earlier in this stack.
  • Bitwise harness classes for Varlen and FlexAttention; a FlexAttention test
    recipe; 4-GPU numerics configs (FSDP2 + TP2); README row.

Numerics

Eager FSDP2 vs GraphTrainer, seed 42, deterministic,
scripts/loss_compare.py --assert-equal. Measured on base 0f3481537.
Rebasing onto d0ab95e46 changed only recipe field names in this diff
(#5776, #5779); re-verification on the new base is in progress.

Config GPUs Result
debugmodel, FlexAttention, FSDP2 + TP2, 20 steps 4x GB300 loss and grad_norm bitwise identical
debugmodel, PP2 Interleaved1F1B, 10 steps 2x GB300 loss and grad_norm bitwise identical

The 4-GPU comparison uses FlexAttention. FA4's Varlen backward is not
deterministic for full causal attention on Blackwell, so two Varlen eager runs
with FSDP2 + TP2 already differ in grad_norm at step 1.

Testing

  • test_bitwise_deterministic.py::TestMuseGlimmerBitwiseDeterministic and
    TestMuseGlimmerFlexAttnBitwiseDeterministic (1 GPU): eager vs
    aot_fx_trace, trace vs precompile, and numerics_changing_optim run-to-run
    produce bitwise identical loss, model hash, and gradient hash.
  • test_numerics.py::test_dense_muse_glimmer_aot_fx_trace_vs_eager (4 GPUs):
    the FSDP2 + TP2 row above.
  • The PP row was run locally; it is not a CI test.

Known issues / follow-ups

  • CP is not covered.
  • Next in the stack: Muse Spark (in progress).

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 4, 2026
GraphTrainer already ran Muse Glimmer through its integration tests, but
nothing checked its numerics against eager. Add the bitwise harness classes
(Varlen and FlexAttention) and a four-GPU eager vs GraphTrainer loss compare.

The vision flavor (debugmodel_mm) failed deep in tracing with a
data-dependent-shape error; the GraphTrainer config now rejects a vision
encoder with a ValueError.

The loss compare uses FlexAttention: FA4's Varlen backward is not
deterministic for full causal attention on Blackwell, so two Varlen eager
runs with FSDP2+TP2 already differ in grad_norm at step 1.

Testing:
- test_bitwise_deterministic.py::TestMuseGlimmerBitwiseDeterministic and
  TestMuseGlimmerFlexAttnBitwiseDeterministic: eager vs aot_fx_trace, trace
  vs precompile, and numerics_changing_optim run-to-run are bitwise identical
  in loss, model hash, and gradient hash (GB300).
- test_numerics.py::test_dense_muse_glimmer_aot_fx_trace_vs_eager: eager
  FSDP2 vs GraphTrainer with FSDP2+TP2 on 4 GPUs, loss and grad_norm bitwise
  identical for 20 steps.
- Local: Interleaved1F1B PP2 eager vs GraphTrainer on 2 GPUs, loss and
  grad_norm bitwise identical for 10 steps.
@SherlockNoMad
SherlockNoMad changed the base branch from SherlockNoMad/gt_kimi_k2_7 to main November 9, 2026 20:42
@pytorch-bot pytorch-bot Bot added the ciflow/rl label Nov 9, 2026
@SherlockNoMad
SherlockNoMad force-pushed the SherlockNoMad/gt_muse_glimmer branch from 7664160 to 6c86f1b Compare November 9, 2026 20:42
@SherlockNoMad
SherlockNoMad marked this pull request as ready for review November 9, 2026 20:43
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 9, 2026
pass
def __post_init__(self) -> None:
MuseGlimmerModel.Config.__post_init__(self)
# TODO: The vision encoder reads image grids on the host and builds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to support this in GT in the future?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, depending if anyone needs it.

@SherlockNoMad
SherlockNoMad merged commit 5a49006 into main Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants