Repository navigation
Add a packed SFT notebook that benchmarks the packed-rows layout - #8732
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 measures the packed-rows layout from #7804 more than it shows a task, and packing is already covered in the docs and SFT examples. Good to have the SDPA numbers on record here, thanks! |
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_packing_tldr/sft_packing_tldr.ipynband its row in the examples overview.The notebook measures what the packed-rows layout from #7804 does for SDPA training: padded batches, packed rows and the flattened layout are run on the same tokens with Qwen3-0.6B-Base. In the committed run, packed rows train 2.37x faster than the flattened layout and 1.24x faster than padded batches; with flash attention 2 the two layouts are within 5% of each other. It then fine-tunes on
trl-lib/tldrwith packing and checks the loss mask and the document boundaries in the packed rows.Peak GPU memory stays under 4 GB. The outputs come from one end-to-end run on a 10 GB slice of an H100; I did not run it on a T4.
Note
Low Risk
Documentation and example notebook only; no changes to TRL library training code or runtime behavior.
Overview
Adds
examples/sft_packing_tldr/sft_packing_tldr.ipynb, a Colab-oriented walkthrough forSFTTrainerpacking with SDPA. The notebook benchmarks three batch layouts on the same token budget (padded batches, TRL 1.19 packed rows withpadding_free=False, and the legacy flattened layout viapadding_free=True), optional flash-attention-2 runs, and reports tokens/s, padding fraction, step time, and peak GPU memory. It then runs a packed LoRA fine-tune of Qwen3-0.6B-Base ontrl-lib/tldrwith checks that completion-only loss masks and per-documentposition_idskeep packed documents isolated under SDPA.docs/source/example_overview.mdgains a new index row forsft_packing_tldrwith description and an Open in Colab badge, inserted in the SFT examples list.Reviewed by Cursor Bugbot for commit 31f481d. Bugbot is set up for automated code reviews on this repo. Configure here.