Account for DSA in model FLOPs - #6331
Draft
yaoyu-33 wants to merge 1 commit into
Draft
Conversation
Signed-off-by: yaoyu-33 <yuya@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.
What does this PR do?
Accounts for Dynamic Sparse Attention (DSA) in the training model-FLOPs numerator instead of falling through to dense MLA accounting.
This mirrors NVIDIA-NeMo/Megatron-Bridge#5324 into Megatron-LM's
num_floating_point_operationsimplementation and adapts it to the current token-linear / packed-sequence FLOPs split.The DSA branch includes:
For packed sequences, dense causal pairs remain exact from
sum(L)andsum(L^2). Sparse pairs use the same token-weighted effective-length approximation documented in the Bridge change because the existing metadata cannot recover each individual sequence length.Issue tracking
Linked issue: N/A — small bug fix mirrored from NVIDIA-NeMo/Megatron-Bridge#5324.
Contribution process
Pre-checks
Validation
uvx ruff check megatron/training/training.py tests/unit_tests/test_num_floating_point_operations.pyuvx isort --check-only megatron/training/training.py tests/unit_tests/test_num_floating_point_operations.pypython3 -m py_compile megatron/training/training.py tests/unit_tests/test_num_floating_point_operations.pygit diff --checkThe repository's
uvenvironment and distributed pytest suite could not run on this Apple Silicon host becausenvidia-cudnn-frontend==1.26.0has no macOS wheel. CI should run the focused unit tests in the supported CUDA environment.