feat: unify shared-prefix Megatron execution#739
Open
bradhilton wants to merge 34 commits into
Open
Conversation
This was referenced Jun 25, 2026
Closed
This reverts commit 5474538.
5f1a400 to
e8d17f2
Compare
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.
Summary
Adds support for deeper shared-prefixes and multi-LoRA slots while simplifying the code. Also adds a dev script for validation and some tests.
What changed
pack_shared_prefixes(...)and shared-prefix tree/parser coverage for depth 0 through deeper branchy trees.create_block_mask, including full/partial block metadata rather than onlymask_modbehavior.dev/megatron_review_perf.pyfor Austin-focused block-mask, FlexAttention, and CP planning measurements.Validation
Local on this branch:
uv run --no-sync prek run --all-files: passed.uv run pytest tests/unit/test_shared_prefix_attention_builder.py tests/unit/test_shared_prefix_tree.py tests/unit/test_shared_prefix_packing.py tests/unit/test_shared_prefix_grad_parity.py tests/integration/megatron/lora/test_lora_disk_codecs.py:30 passed, 9 skippedlocally; GPU/Megatron/vLLM portions are skipped on local macOS.4x H200 SkyPilot (
codex-trainer-rank-h200) on this branch:48 passed.17 passed.Qwen/Qwen3.5-35B-A3B-style packed shape, CP=4, 198k packed tokens, 2.448M logical tokens:60.54ms1.865ms136.503ms3.478ms, CP planning12.916msmain, speed was statistically indistinguishable, both about 33k tok/s.