[not for land] repro for slow inductor codegen in bwd #2768
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.
Repro steps
rm -rf /tmp/torchinductor_${USER}; TORCH_TRACE=/tmp/repro-08-13 python benchmarks/prototype/moe_training/benchmark_scaled_grouped_mm_dq.py --compile --profile
This will benchmark and profile:
torch._grouped_mm
=>torch._scaled_grouped_mm
.Profiles of
bf16_profile.json
andscaled_profile.json
will be saved to local working directory and can be viewed in Perfetto.Note: this PR is a branch off of the stack #2767, and here we simply replace the triton kernel for transposing + quantizing the expert weights, with plain torch code and let inductor codegen it.
torch.compile for quantizing non-transposed expert weights in backward:
handwritten kernel for quantizing non-transposed expert weights in backward:
As you can see fp8 rowwise currently results in a slowdown either way, but the slowdown is worse when using torch.compile for quantizing expert weights in backward. Even the handwritten kernel is quite slow actually, it only achieves ~36% peak memory bandwidth.
Tlparse link for run using torch.compile for transposed expert weights quant: https://manifold.edge.x2p.facebook.net/v0/read/tree/logs/.tmpoDQmWo/index.html?bucketName=tlparse_reports&apiKey=tlparse_reports-key&withPayload=1&timeoutMsec=10000