Skip to content

RMSNorm save output: skip inference tensor weights, keep the default path free of opt-in checks - #13981

Merged
danielhanchen merged 1 commit into
mainfrom
dh/rmsnorm-save-output-inference
Oct 16, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
dh/rmsnorm-save-output-inference

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #13868.

  1. With UNSLOTH_RMSNORM_SAVE_OUTPUT=1, a decoder forward over norm weights created inside torch.inference_mode() raised RuntimeError: Inference tensors do not track version counter. from _save_output_ok. Inference-tensor weights now fall back to saving X. The saved-Y path is also skipped when X needs no grad, since backward never runs and the weight check and its .item() would be wasted.
  2. Default path (flag off): fused LoRA no longer calls the saved-norm marker check on every forward, and RMSNorm backward only reshapes the saved tensor when it is Y. Results with the flag off are unchanged.

Tests: two new tests in tests/test_rmsnorm_save_output.py (both fail on main); RMSNorm and fused LoRA GPU tests pass (629 passed).

… free of the opt-in checks

UNSLOTH_RMSNORM_SAVE_OUTPUT=1 read W._version, which raises for weights created under
torch.inference_mode(). Skip the saved-Y path when X needs no grad (backward never runs) or W
is an inference tensor. With the flag off, fused LoRA no longer calls the saved-norm marker
check and RMSNorm backward no longer takes an extra view of the saved X.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T07:26:35.098848Z 0f227fa Manual request
🔒 Security Review ⚠️ Failed 2026-10-16T07:23:48.103989Z 0f227fa PR opened
ℹ️ 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. Nice work!

Reviewed commit: 0f227fa2e0

ℹ️ 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 adebbfa into main Oct 16, 2026
@danielhanchen
danielhanchen deleted the dh/rmsnorm-save-output-inference branch October 16, 2026 09:47
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