Skip to content

MFU logging under fullgraph, NCCL logs under distributed debug, token-budget metrics across ranks - #14207

Merged
danielhanchen merged 3 commits into
mainfrom
dh/fu-misc-optin
Oct 19, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
dh/fu-misc-optin

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Three follow-ups on opt-in features. Default runs are unchanged.

  1. MFU logging (Add opt-in TFLOPs and MFU logging with LoRA aware FLOP counts #13885). For packed batches that carry only position_ids, the token count branched on data, which broke fullgraph = True compilation and added a host sync per micro-batch. It is now computed without a data-dependent branch. Also adds an H200 NVL entry at 835.5 dense TFLOPS (half of NVIDIA's 1,671 with-sparsity figure); it was being measured against the H200 SXM peak.
  2. NCCL INFO logs under UNSLOTH_DEBUG_DISTRIBUTED (Add unsloth doctor --gpus multi-GPU preflight and UNSLOTH_DEBUG_DISTRIBUTED #13884). Importing unsloth_zoo sets NCCL_DEBUG=WARN whenever a logging or compile-debug switch is on, so the debug flag lost the NCCL INFO logs it asks for. With UNSLOTH_DEBUG_DISTRIBUTED set, unsloth now saves NCCL_DEBUG before that import and restores it after.
  3. Token-budget split metrics across ranks (Opt-in token-balanced and token-budget SFT micro-batches #13878). Logged accuracy and entropy from split chunks were averaged per rank. Each chunk is now weighted by its token count summed across ranks. The decision to merge is folded into the existing chunk-count collective, so every rank merges or none do: no extra collective and no chance of one rank waiting on another.

Tests

File main this PR
tests/test_mfu_logging.py 2 failed pass
tests/test_debug_distributed_env.py 2 failed (real zoo import) pass
tests/test_token_budget_metrics_distributed.py (2 gloo ranks) 3 failed pass

53 passed in total.

Not covered here

  • No real multi-rank NCCL run; the distributed tests use gloo.
  • The H200 NVL device-name string is assumed to contain "H200 NVL".
  • A NCCL_DEBUG you export yourself is still overwritten when the debug flag is off; that needs a change in unsloth_zoo.

…; add H200 NVL peak

Position-id-only padding free batches used torch.nonzero plus a Python branch on its size,
which host-syncs every micro batch and fails torch.compile(fullgraph=True). Build a fixed
shape [N] zero padded length vector instead. H200 NVL matched the generic H200 entry (989);
NVIDIA lists 1,671 TFLOPS BF16 with sparsity, i.e. 835.5 dense.
…o import

unsloth_zoo sets NCCL_DEBUG=WARN on import when UNSLOTH_ENABLE_LOGGING=1 or
UNSLOTH_COMPILE_DEBUG=1, which dropped the NCCL INFO logs the distributed debug
switch selects (and any value the user exported). Snapshot NCCL_DEBUG before
the zoo import and restore it after, only when UNSLOTH_DEBUG_DISTRIBUTED is set.
…runs

TRL gathers each forward's accuracy (and, from 1.3, entropy) sums across ranks, so
per-chunk entries were left unfolded and averaged equally under DDP. All-reduce the
per-chunk token counts and weight by them. Older TRL entropy averages per-rank
ratios and stays unfolded; Liger and uninitialized process groups are skipped.

Every rank agrees to fold in the existing chunk-count collective, so the extra all-reduce runs on
every rank or on none (a rank declining to fold, e.g. a second label source, would otherwise
leave its peers waiting in the all-reduce).
@danielhanchen danielhanchen self-assigned this Oct 19, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T07:01:18.275888Z c16e035 Manual request
🔒 Security Review ✅ Completed 2026-10-19T06:39:33.029679Z c16e035 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: c16e035c5b

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: c16e035c5b

ℹ️ 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 9f78f5e into main Oct 19, 2026
@danielhanchen
danielhanchen deleted the dh/fu-misc-optin branch October 19, 2026 14:21
danielhanchen added a commit that referenced this pull request Oct 19, 2026
## Summary

The `Core zoo` cells in `consolidated-tests-ci.yml` keep hitting their
25 minute job cap after the tests have already passed. In one cancelled
cell:

- the zoo `pytest -n 4` step ran from 08:41 to 09:03 and passed (3015
passed, 620 skipped),
- the job was then cancelled at 25:17 during `test_apply_fused_lm_head`
and the pip cache save.

The comment above the cap assumed a ~7.6 min zoo suite. It now takes up
to about 23 minutes on a busy runner, so the cap cancels cells that have
already passed. Today that cancelled Core zoo cells on #14152, #14165,
#14188, #14192, #14199 and #14207, and on staging runs. Each one needs a
manual rerun before the PR can merge.

This raises the cap to 35 minutes, the same as `consolidated`. Hung
tests are still bounded: `PYTEST_TIMEOUT: 300` in the step still names
the culprit per test.

## Tests

The workflow-parsing tests (`git grep -l consolidated-tests-ci --
tests`): 158 passed, 3 skipped.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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