Add MXFP8 quantized_model_init memory profiler for FSDP2 qinit analysis#3008
Draft
savitha-eng wants to merge 5 commits into
Draft
Add MXFP8 quantized_model_init memory profiler for FSDP2 qinit analysis#3008savitha-eng wants to merge 5 commits into
savitha-eng wants to merge 5 commits into
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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
Standalone memory profiler script for diagnosing MXFP8
quantized_model_initmemory behavior with FSDP2. Creates one or morete.TransformerLayerblocks with 8B-scale dimensions, wraps with FSDP2fully_shard, and runs forward+backward+step iterations while recording PyTorch memory history.Issue observed: When using
quantized_model_init+ FSDP2, MXFP8 quantized weight tensors frommxfp8_tensor.py:quantize_implare never freed. FSDP2 calls.view(numel,)to flatten params, which triggers_ViewFuncdequantize fallback, and the intermediate tensors leak. With--num-layers 4, the leaked memory accumulates per layer.Quick repro (requires 2+ GPUs)
Snapshots saved to
/tmp/single_block_snapshots/— view at https://pytorch.org/memory_vizAvailable modes
baremxfp8fp8-no-qinitmxfp8-no-qinitbare-fsdp2mxfp8-fsdp2fp8-no-qinit-fsdp2mxfp8-no-qinit-fsdp2Additional flags:
--model-size {8b,70b},--num-layers N,--no-hpiv,--recipe {mxfp8,float8block,auto}Type of change
Changes
examples/pytorch/quantized_model_init/single_block_memory_profile.py— self-contained memory profiler with 8 modes for comparing BF16 vs MXFP8 vs FP8 autocast, with and without FSDP2