Repository navigation
Conversation
Reuse get_moe_permute_scratch for FP8 and W4A8 CUTLASS experts so sequential layers share metadata within the current workspace ubatch and lane. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: ahmed xijiaat <52128022+xijiaat@users.noreply.github.com>
|
@mgoin, could you please take a look when you have time? This addresses the CUTLASS cross-layer scratch sharing follow-up mentioned in #60447, using the existing persistent-resource helper. H20 before/after validation results are included in the description. Happy to rebase on #60447 depending on the preferred merge order. |
|
Hey @xijiaat thanks for the PR but based on issues encountered in CI in mine, I may need to address CUTLASS paths myself. Stay tuned for the final state of my PR |
|
This pull request has merge conflicts that must be resolved before it can be |
|
Thanks @mgoin for incorporating the CUTLASS paths in #60447. I checked the merged implementation: both CutlassExpertsFp8Base and CutlassExpertsW4A8Fp8 now use get_moe_permute_scratch rather than per-instance scratch, retaining isolation by workspace ubatch/lane. This covers the production-code changes proposed here, so I am closing this PR as superseded by #60447 rather than rebasing a duplicate change. Thanks for the fix and review! |
Overview
Use the existing
get_moe_permute_scratchhelper in the FP8 and W4A8 CUTLASS experts instead of retaining a separate scratch object in every layer. This is the CUTLASS cross-layer sharing follow-up explicitly left out of #60447, not another scratch-capacity fix.Claims
Validation
Validated before/after on one otherwise idle NVIDIA H20 (SM90). Python source is main
81198e97ba7eee2a22540caaa756b7fdddcb4d93with/without this patch; compiled CUDA extensions and dependencies are fromvllm/vllm-openai:v0.31.0(PyTorch 2.13.0+cu130), not newly compiled main binaries.The scratch measurement is synthetic metadata storage (about 145 MiB to 2.27 MiB), not total memory saved by a loaded model. Same-lane sharing and separate-lane isolation were checked with real CUDA allocations. The 27 numerical cases call existing upstream test functions directly with an initialized workspace manager; this is not a claim that the whole upstream pytest suite passed. Expert-map partition cases run on one GPU, not distributed EP.
pre-commit run --files vllm/model_executor/layers/fused_moe/experts/cutlass_moe.py tests/kernels/moe/test_cutlass_moe.py: passed, including mypy.git diff --check: passed.--confcutdirexcludes unrelated root-conftest dependencies missing from the runtime image; the test itself imports the real vLLM modules and mocks the scratch constructor as written in this PR:No full-model evaluation, throughput benchmark, multi-GPU communication test, or full W4A8 GEMM-layer numerical validation is claimed. W4A8 GPU coverage is the changed getter, real scratch allocation, and permute/unpermute kernels. The PR remains Draft.
The human submitter confirmed line-by-line review and personal testing of this patch. AI assistance was used for analysis, implementation, and the validation above.
Details
CutlassExpertsFp8BaseandCutlassExpertsW4A8Fp8each lazily allocatedself._permute_scratch. Consequently, sequential layers with identical configurations kept separate metadata and sorting buffers for their lifetimes. Both now use the existing persistent-resource helper already used elsewhere in the MoE path. The unsupported-device fallback remainsNone.This is distinct from #60447: that PR changes capacity growth and scratch contents but explicitly retains one CUTLASS scratch per layer. This change leaves the capacity calculation untouched. The two changes may require a small interface rebase depending on merge order. Searches for open
permute scratchPRs and references to #60447 found no existing CUTLASS cross-layer-sharing patch.As with the existing helper's contract, a workspace manager must be initialized for sharing, and all required ubatch/lane resources must be warmed before locking. Without a manager the helper allocates per call; standalone callers no longer get the old per-layer cache. The added test is one parameterized test covering both expert classes.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.