Repository navigation
Add a notebook that measures the fused LM head in SFTTrainer - #8733
Closed
behroozazarkhalili wants to merge 1 commit into
Closed
behroozazarkhalili wants to merge 1 commit into
behroozazarkhalili wants to merge 1 commit into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
Member
|
Closing, see #8686 (comment). |
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.
This adds
examples/sft_fused_lm_head/sft_fused_lm_head.ipynband its row in the examples overview.The notebook compares the fused LM head with a full-logits loss on Qwen3-0.6B, with the same tokens and sequence lengths from 1,024 to 40,960. In the committed run on a 10 GB slice of an H100, full logits run out of memory at 6,144 tokens and the fused head fits 40,960; at 4,096 tokens peak memory is 9.02 GB against 2.04 GB with equal losses. It then fine-tunes on Capybara with packed rows of 8,192 tokens at a peak of 3.14 GB.
It needs a GPU with bf16 support. The outputs come from one end-to-end run; I did not run it on a T4.
Note
Low Risk
Documentation and an example notebook only; no changes to training library code or runtime behavior.
Overview
This PR adds
examples/sft_fused_lm_head/sft_fused_lm_head.ipynband lists it indocs/source/example_overview.mdwith a Colab link (bf16 GPU required; not aimed at free T4 Colab).The notebook benchmarks TRL’s default fused LM head in
SFTTraineragainst a full-logits forward on Qwen3-0.6B with LoRA: it checks matching loss and gradients, sweeps sequence lengths 1,024–40,960 for peak GPU memory and step time, and finishes with a packed 8,192-token LoRA run on trl-lib/Capybara. Committed results on a 10 GB H100 MIG slice show full logits OOM at 6,144 tokens (peak 9.02 GB at 4,096) while the fused path reaches 40,960; training at 8,192-token rows peaks at 3.14 GB.Reviewed by Cursor Bugbot for commit 79d8330. Bugbot is set up for automated code reviews on this repo. Configure here.