[examples] Add dynamic context parallel example#3892
Merged
Conversation
ec5a517 to
529ce57
Compare
Signed-off-by: ilml <tolong@nvidia.com>
529ce57 to
c2df21f
Compare
yaoyu-33
previously approved these changes
May 27, 2026
Signed-off-by: ilml <tolong@nvidia.com>
cuichenx
approved these changes
May 28, 2026
Contributor
|
/ok to test 51bb3c5 |
vasunvidia
pushed a commit
to vasunvidia/Megatron-Bridge
that referenced
this pull request
Jun 10, 2026
Signed-off-by: ilml <tolong@nvidia.com> Signed-off-by: Vasudevan Rengasamy <vrengasamy@nvidia.com>
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
DefaultDynamicCPSchedulerto schedule toy variable-length samples, then print the packed THD metadata per DPxCP rank:tokens.shape,cu_seqlens,max_seqlen, andlocal_cp_size.examples/training_features/long_context/README.mdexplaining how to run the demo, how to read the output, and how the printed metadata maps to the real DCP forward-step path.dynamic_context_parallel=True,sequence_packing_scheduler="default_dynamic_cp",max_seqlen_per_dp_cp_rank,min_dynamic_context_parallel_size, andmicro_batch_size=1.Testing
python -m py_compile examples/training_features/long_context/dynamic_context_parallel.pygit diff --check1, Docker container7366a763896aafter./scripts/switch_mcore.sh dev+uv sync:uv run python examples/training_features/long_context/dynamic_context_parallel.py(prints per-samplegpus_neededand scheduled packed microbatches withlocal_cp_size)1:uv run ruff check examples/training_features/long_context/dynamic_context_parallel.py src/megatron/bridge/training/initialize.py1:uv run ruff format --check examples/training_features/long_context/dynamic_context_parallel.py src/megatron/bridge/training/initialize.py1:uv run pre-commit run --all-files