Skip to content

Add quantized-pair rowwise symmetric-memory kernels#785

Merged
AkshitaB merged 3 commits into
akshitab/moe-v2-corefrom
akshitab/rowwise-quantized-pair-kernels
Jul 19, 2026
Merged

Add quantized-pair rowwise symmetric-memory kernels#785
AkshitaB merged 3 commits into
akshitab/moe-v2-corefrom
akshitab/rowwise-quantized-pair-kernels

Conversation

@AkshitaB

Copy link
Copy Markdown
Contributor

Adds the direct-NVSHMEM quantized-pair rowwise expert-parallel transport kernels as a reference/tuning path.

What

  • CUDA kernels (olmo_symm_mem_rowwise_kernels.cuh): dispatchRowsPutPair, dispatchRowsPutScaledWeighted, and gatherRowsGetPair, plus the MXFP8 quantize device helpers they use.
  • Host launchers (olmo_symm_mem_rowwise.cuh): rowwise_dispatch_put_pair, rowwise_dispatch_put_scaled_weighted, rowwise_gather_get_pair.
  • Bindings + Python wrappers (olmo_symm_mem_bindings.cpp, symm_mem_vdev2d.py): the corresponding pybind entries and @torch.compiler.disable Python wrappers.
  • Preflight (olmo_symm_mem_runtime.cuh): restores the collective-launch grid validation for these kernels.

Why

These fuse the FP8 quantized values and their block scales into a single symmetric nvshmem put/get (the current production path stages q and scales as separate buffers; dispatchRowsPutScaledWeighted additionally folds top-k weighting + scaling into the dispatch). On tested hardware this direct path is bit-exact against the materialized path but not faster at the usual block-count settings, so it is provided as a reference / tuning target: compiled, callable, and preflight-validated, but not wired into the rowwise forward, which continues to use the materialized transport.

Testing

Python side (import + make checks) is clean. The kernels compile GPU-side and are grid-validated by the symmetric-memory extension build in the MoE-kernels GPU CI job.

Port the direct-NVSHMEM quantized-pair rowwise transport kernels and expose them
at parity with the reference implementation: dispatchRowsPutPair,
dispatchRowsPutScaledWeighted, and gatherRowsGetPair (plus the MXFP8 quant device
helpers they use), their host launchers, pybind entries, and Python wrappers. Also
restores the collective-launch preflight blocks for these kernels.

These fuse the FP8 quantized values and their block scales into a single symmetric
put/get (vs the materialized path that stages q and scales separately). They are a
reference/tuning path — compiled, callable, and preflight-validated, but not wired
into the rowwise forward, which continues to use the materialized transport.

Co-Authored-By: Tianhua Tao <tianhuatao@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

AkshitaB and others added 2 commits July 19, 2026 00:40
The quantized-pair rowwise kernels reference ROWWISE_MXFP8_BLOCK_SIZE,
ROWWISE_MXFP8_Q_CHUNK_BLOCKS, and ROWWISE_MXFP8_MAX_SCALE_GROUPS, which live in
the shared symm-mem common header. Add the three defines so the extension builds.

Co-Authored-By: Tianhua Tao <tianhuatao@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The kernel's per-warp shared staging buffers need ~80 KB of static shared memory,
over the 48 KB limit on pre-SM100 GPUs, so device linking failed for the sm_90
build. It is an SM100+ reference/tuning kernel that is fail-closed at runtime below
SM100, so compile a trap stub for __CUDA_ARCH__ < 1000 and keep the full body for
SM100+.

Co-Authored-By: Tianhua Tao <tianhuatao@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AkshitaB
AkshitaB merged commit 760d4ef into akshitab/moe-v2-core Jul 19, 2026
23 of 24 checks passed
@AkshitaB
AkshitaB deleted the akshitab/rowwise-quantized-pair-kernels branch July 19, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant