[None][perf] Add GreenContext SM-partitioned overlap for MoE DenseGEMM FC1+Router#12802
Draft
JacobHu-NV wants to merge 1 commit intoNVIDIA:mainfrom
Draft
[None][perf] Add GreenContext SM-partitioned overlap for MoE DenseGEMM FC1+Router#12802JacobHu-NV wants to merge 1 commit intoNVIDIA:mainfrom
JacobHu-NV wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
…M FC1+Router Introduce hardware-level SM isolation via CUDA GreenContext so that the FC1 GEMM and Router GEMM can execute truly in parallel without SM contention in the DenseGEMM MoE path. Key changes: - green_context.py: CUDA Driver API helpers (create_sm_only_gc_streams, create_wq_isolated_gc_streams, get_current_stream_gc_sm_count) that bypass PyTorch's GreenContext API to create cuGreenCtxStreamCreate- bound streams. These streams survive CUDA Graph capture/replay with their SM partition intact, unlike streams created inside GreenContext.set_context(). - fused_moe_densegemm.py: Add DenseGEMMGCSMRunner (TunableRunner) that sweeps FC1 SM count candidates via the AutoTuner framework to find the optimal SM split for FC1/Router overlap. Extend DenseGEMMFusedMoE with a _gc_stream_pool pre-created at init time for all candidate SM splits, enabling CUDA-graph-safe autotuning. - cute_dsl_custom_ops.py: Add sm_budget parameter to CuteDSLNVFP4DenseGemmSwigluRunner (excluded from unique_id so inner tuning is shared across GC splits); register new custom ops cute_dsl_nvfp4_dynamic_dense_gemm_swiglu_blackwell, cute_dsl_bf16_bmm_blackwell, and cute_dsl_bf16_gemm_blackwell. Signed-off-by: JacobHu-NV <266902545+JacobHu-NV@users.noreply.github.com>
ce51764 to
e9f45af
Compare
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
green_context.py: CUDA Driver API helpers (create_sm_only_gc_streams,create_wq_isolated_gc_streams,get_current_stream_gc_sm_count) that createcuGreenCtxStreamCreate-bound streams directly via the Driver API. Unlike streamscreated inside
GreenContext.set_context(), these survive CUDA Graph capture/replaywith their SM partition intact.
DenseGEMMGCSMRunner(TunableRunner) infused_moe_densegemm.pythat sweepsFC1 SM count candidates via the AutoTuner framework to find the optimal SM split for
FC1/Router overlap.
DenseGEMMFusedMoEwith a_gc_stream_poolpre-created at init time for allcandidate SM splits, enabling CUDA-graph-safe autotuning without re-creating
GreenContext streams at runtime.
sm_budgetparameter toCuteDSLNVFP4DenseGemmSwigluRunnerincute_dsl_custom_ops.py(excluded fromunique_idso inner tuning is shared acrossGC splits); register new custom ops
cute_dsl_nvfp4_dynamic_dense_gemm_swiglu_blackwell,cute_dsl_bf16_bmm_blackwell, andcute_dsl_bf16_gemm_blackwell.Motivation
The DenseGEMM MoE path overlaps FC1 and Router GEMM to hide router latency. Previous
attempts used soft
sm_budgethints (max_active_clusters) which don't prevent SMcontention at the hardware level. CUDA GreenContext provides true hardware SM isolation —
FC1 and Router CTAs are dispatched to disjoint SM partitions with no interference.