Reduce graph breaks and recompiles#547
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR modifies the data collation pipeline to pad the lengths tensor to a minimum size of 4 elements, replacing direct tensor construction with a padded version using ChangesData Collation Tensor Padding
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/speculators/train/data.py (1)
469-472: ⚡ Quick winConvert
lengthtensor scalars to Python ints before rebuildinglengths.In
src/speculators/train/data.py(create_collate_fn), iteratingfor length in lengths:yields 0-d tensor scalars; mixing them withcum_length(Pythonint) and collecting them intonew_lengthsmakestorch.tensor(new_lengths, ...)less idiomatic/stable. Convert withlength.item()and keepcum_length/the condition as pure ints.Proposed diff
lengths = collated_data["lengths"] new_lengths = [] cum_length = 0 for length in lengths: - if length + cum_length >= max_len: + length_i = int(length.item()) + if length_i + cum_length >= max_len: new_lengths.append(max_len - cum_length) break - new_lengths.append(length) - cum_length += length + new_lengths.append(length_i) + cum_length += length_i lengths = torch.tensor(new_lengths, dtype=torch.long) # Pad to at least size 4 to avoid torch.compile recompiling on sizes 0/1 pad_to = max(4, lengths.shape[0]) collated_data["lengths"] = F.pad(lengths, (0, pad_to - lengths.shape[0]))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/speculators/train/data.py` around lines 469 - 472, In create_collate_fn, when iterating the tensor variable lengths you should convert each 0-dim tensor to a Python int (use length.item()) before comparing/adding to cum_length and appending to new_lengths; ensure cum_length stays an int and the condition uses ints so new_lengths is a list of ints, then rebuild lengths with torch.tensor(new_lengths, dtype=torch.long) and apply the existing padding logic (pad_to, F.pad) as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/speculators/train/data.py`:
- Around line 469-472: In create_collate_fn, when iterating the tensor variable
lengths you should convert each 0-dim tensor to a Python int (use length.item())
before comparing/adding to cum_length and appending to new_lengths; ensure
cum_length stays an int and the condition uses ints so new_lengths is a list of
ints, then rebuild lengths with torch.tensor(new_lengths, dtype=torch.long) and
apply the existing padding logic (pad_to, F.pad) as before.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d4014969-132a-4a0f-b139-3ddfff652ab0
📒 Files selected for processing (1)
src/speculators/train/data.py
|
The quality checks have failed. Please run |
|
Rebased |
|
This pull request has merge conflicts that must be resolved before it can be |
…flex_attention (vllm-project#531) Walk back the premature 'verified end-to-end' claim: training never completes a step on NPU. Document the real blocker found by checking the repo issues: - DFlash (and EAGLE3/PEAGLE) force simple_flex_attention; PyTorch flex_attention rejects npu devices (issue vllm-project#531, open). Only MTP uses eager attention. - @torch.compile on the dflash forward fails triton-ascend codegen with block_size=16 (NPU flavor of vllm-project#544 / PR vllm-project#547); TORCHDYNAMO_DISABLE=1 gets past it but then hits vllm-project#531. - add §9 with the algorithm/attention support table and options (train MTP, patch DFlash to eager/dense-mask attention, or track upstream). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…flex_attention (vllm-project#531) Walk back the premature 'verified end-to-end' claim: training never completes a step on NPU. Document the real blocker found by checking the repo issues: - DFlash (and EAGLE3/PEAGLE) force simple_flex_attention; PyTorch flex_attention rejects npu devices (issue vllm-project#531, open). Only MTP uses eager attention. - @torch.compile on the dflash forward fails triton-ascend codegen with block_size=16 (NPU flavor of vllm-project#544 / PR vllm-project#547); TORCHDYNAMO_DISABLE=1 gets past it but then hits vllm-project#531. - add §9 with the algorithm/attention support table and options (train MTP, patch DFlash to eager/dense-mask attention, or track upstream). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Mark lengths dynamic to avoid recompiling on it Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
|
E2E (vllm@nightly, transformers<5.0, this branch): https://github.com/neuralmagic/llm-compressor-testing/actions/runs/27716366270/job/81990214563 |
PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.
Purpose
Late in epoch graph recompiles can cause training to crash after a substantial number of batches have been processed. This pr works to decrease these occurrences and also reduce the number of graph breaks in the compiled code.
Related Issue
I think this should resolve #544.
Tests
Will add some tests to this pr.
I have filled in: