[training] fix: Update DeepSeek-V4 FLOPs calculation - #4128
Conversation
Signed-off-by: Chen Cui <chcui@nvidia.com>
Code Review - DSv4 Hybrid FLOPsOverall the formula porting and test structure look solid. Two inline comments posted:
Missing test coverageThe two new tests cover the happy path (exact FLOPs) and one error path (ratio length mismatch). Consider adding:
Suggested test casesNo perf tests impacted. |
Light Code ReviewFindingsBug: unsupported compress ratios silently ignored If csa_compress_ratios contains a value outside {0, 4, 128}, that layer is counted in neither n_layers_r0, n_layers_r4, nor n_layers_r128. It contributes zero FLOPs for sparse attention, compressor, and indexer terms -- silently under-counting. A validation after the three sum(...) lines would catch this early. See inline comment. Test coverage gapsThe two new tests cover the happy path (exact FLOPs) and one validation (compress-ratio length). Consider adding:
Suggested test casesNo perf tests impacted. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Addressed Claude feedback in
Validation rerun:
Known local environment blockers:
|
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Follow-up for the later coverage note: added missing Validation rerun after this commit:
|
Signed-off-by: Chen Cui <chcui@nvidia.com> Signed-off-by: Vasudevan Rengasamy <vrengasamy@nvidia.com>
Summary
experimental_attention_variant == "dsv4_hybrid".Testing
uvx pre-commit run --all-filesuv run --no-sync python -m py_compile src/megatron/bridge/training/utils/flop_utils.py tests/unit_tests/training/utils/test_flop_utils.pygit diff --checkflop_utils.pywith local stubsNotes
uv run pre-commit run --all-fileswas attempted, but this host cannot resolvenvidia-resiliency-ext==0.6.0because the package only publishes manylinux_2_39 wheels while the host reports manylinux_2_31.modelopt.