Repository navigation
Conversation
…(GB10) Follow-up to flashinfer-ai#169. PR flashinfer-ai#169 introduced `sm120_dsmem_auto_enabled` with a single-wave cluster cap (`n_blocks <= (active_sms // split_k) * 2`). On 188-SM SM120 GPUs this permits `n_blocks <= 188` at `split_k=2` and `<= 94` at `split_k=4`, covering decode projections such as `qkv_a` (112 blocks) and `wo_a` (128 blocks). On 48-SM SM121 (DGX Spark GB10), however, the same cap restricts auto DSMEM to `n_blocks <= 48` (`N <= 768`) at `split_k=2` and `<= 24` (`N <= 384`) at `split_k=4`, silently gating DSMEM off on every major decode projection even when `B12X_TC_GEMV_DSMEM_SPLIT=1` is set. Cold-L2 CUDA-graph measurements on NVIDIA GB10 (SM121, 48 SMs, 0-2350 MHz cap, 128 MiB L2 flush) show multi-wave `split_k in (2, 4)` DSMEM clusters beat L2 split-K across all 16 tested cases (-4.1% to -13.7% latency, 0-ULP parity, 0 scratch VRAM) and beat `split_k=1` on medium/large projections (`qkv_a 1792x5120`: -6.5%; `2048x5120`: -7.9% to -8.5%; `o_proj 5120x2048`: -9.3% to -9.9%; `woa_mxfp8 2x1024x4096`: -3.8% to -4.7%; `8192x5120`: -11.3% to -11.4%; `bf16_lm 32320x5120`: -3.5% to -3.8%). Changes: - Add `sm120_dsmem_requires_single_wave(device, *, stream=None)` in `flashinfer/experimental/b12x/_lib/utils/dsmem.py`: - Returns `True` for all non-SM121 devices (100% unchanged SM120 behavior) and for non-CUDA inputs. - Returns `False` on full-device SM121 (`active_sms >= total_sms`) while reverting to `True` on partitioned SM121 green contexts (`active_sms < total_sms`). - Use `sm120_dsmem_requires_single_wave` in `sm120_dsmem_auto_enabled` and in the `require_single_wave` check across all 4 TC-GEMV compiler modules (`_dual_tc.py`, `_tensor_core.py`, `_mxfp8_tc_gemv.py`, `wo_projection/_tc_gemv.py`). Opt-in policy (`B12X_TC_GEMV_DSMEM_SPLIT=1`, `default=False`) and all safety guards (`split_k in (2, 4)`, `n_tiles == 1`, `max_rows_for_split4`, `ctas_per_sm >= 1`, `potential >= cluster_size`, `active_clusters >= 1`) remain unchanged. - Add SM121 multi-wave unit tests, green-context partition checks, and real GB10 multi-wave `0-ULP` parity tests in `tests/experimental/b12x/test_sm120_dsmem_splitk.py`, and clear `get_sm_version`'s `@lru_cache` between mocked tests. Verification (NVIDIA GB10, SM121): - `FLARE_RUN_CUDA_TESTS=1 pytest -v tests/experimental/b12x/test_sm120_dsmem_splitk.py`: 15 passed, 0 failed in 14.64s. Signed-off-by: Jonathan Gutierrez <john.gtz@icloud.com>
|
Two pieces from this PR are still missing on
|
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
Follow-up to #169.
sm120_dsmem_auto_enabledenforces a single-wave cluster residency bound (n_blocks <= (active_sms // split_k) * 2). On 188-SM SM120 GPUs this covers decode projections up ton_blocks <= 188(split_k=2) and<= 94(split_k=4), but on 48-SM SM121 (DGX Spark GB10) it caps auto DSMEM atn_blocks <= 48(N <= 768) forsplit_k=2and<= 24(N <= 384) forsplit_k=4— silently disabling DSMEM on every major decode projection (qkv_a,wo_a,o_proj,dual_bf16,lm_head) even whenB12X_TC_GEMV_DSMEM_SPLIT=1is set.This PR adds
sm120_dsmem_requires_single_wave(device, *, stream=None):120) behavior is 100% unchanged (always returnsTrue).B12X_TC_GEMV_DSMEM_SPLIT=1,default=False).active_sms >= total_sms) allows multi-wavesplit_k in (2, 4)DSMEM clusters while retaining all occupancy & safety guards (n_tiles == 1,max_rows_for_split4,ctas_per_sm >= 1,potential >= cluster_size,active_clusters >= 1).active_sms < total_sms) retain the single-wave cap and safely fall back to L2 split-K.Changes
flashinfer/experimental/b12x/_lib/utils/dsmem.py:sm120_dsmem_requires_single_wave(resolving_cuda_device_ordinalbeforeget_sm_versionso non-CUDA devices safely returnTrue), export in__all__, and wire intosm120_dsmem_auto_enabled.flashinfer/experimental/b12x/gemm/bf16_gemv/_dual_tc.py,_tensor_core.py,blockscaled/_mxfp8_tc_gemv.py,wo_projection/_tc_gemv.py:require_single_wave=auto_dsmem and sm120_dsmem_requires_single_wave(ordinal)tovalidate_launcher_dsmem_cluster.tests/experimental/b12x/test_sm120_dsmem_splitk.py:_clear_sm_version_cacheautouse fixture +major=12, minor=0intest_dsmem_offline_compile_worker_never_calls_cuda_driverto prevent@lru_cachecross-test leakage.act_primary >= 72assertion intest_dsmem_real_green_ctx_occupancy_and_zero_scratch_bloatto checkact_primary > act_greenon SM121.test_sm121_dsmem_multiwave_auto_gating_and_green_ctxand real GB10test_sm121_multiwave_dsmem_0ulp_parity(qkv_a 1792x5120 sk=4,wo_a 2x1024x4096 sk=2, varied UE8M0 scales).Cold-L2 CUDA-Graph Evidence (NVIDIA GB10 / SM121, 48 SMs, 0–2350 MHz cap, 128 MiB L2 flush)
Negative latency delta = faster. All DSMEM outputs verified
0-ULPbit-exact vs L2 split-K with 0 L2 split-K scratch/flags VRAM.N × K)Mnblksk=1(µs)sk=2L2sk=2DSMEMsk=4L2sk=4DSMEMsk=1mxfp8(512×5120)0.0%/+1.4%-0.6%/-1.7%mxfp8(1792×5120)(qkv_a)-6.4%/-6.5%-7.5%/-8.0%mxfp8(2048×5120)-8.5%/-7.9%-8.6%/-8.0%mxfp8(5120×2048)(o_proj)-9.9%/-9.3%-10.9%/-10.2%mxfp8(8192×5120)-11.4%/-11.3%-13.7%/-13.7%dual_bf16(512+384×5120)-1.1%/-0.1%-5.0%/-6.0%woa_mxfp8(2×1024×4096)-4.7%/-3.8%-5.9%/-4.8%bf16_lm(32320×5120)-3.5%/-3.8%-10.0%/-8.6%Verification (NVIDIA GB10 / SM121)
Result:
15 passed, 0 failedin14.64s(including real CUDA green-context test and multi-wave0-ULPparity tests).