feat(nvidia): add moe_align_block_size operator#804
Merged
Conversation
voltjia
force-pushed
the
feat/nvidia-moe-align-block-size
branch
3 times, most recently
from
July 23, 2026 00:15
b04ef7c to
53a686a
Compare
moe_align_block_size operator
voltjia
marked this pull request as ready for review
July 23, 2026 02:22
voltjia
force-pushed
the
feat/nvidia-moe-align-block-size
branch
from
July 23, 2026 02:33
53a686a to
63296a2
Compare
20 tasks
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
moe_align_block_sizeoperator and generated Python binding.expert_map, deterministic expert grouping, block padding, non-default streams, and multi-GPU device guards.Motivation
moe_align_block_sizeprepares routed token indices and expert block IDs for blockwise MoE GEMM. It is an independent vLLM MoE primitive needed while moving serving kernels behind InfiniOps.This PR aligns with the low-level stable vLLM operator, not the higher-level Python allocation helper. InfiniOps keeps its repository-wide execution convention of input tensors first, scalar attributes next, and mutable outputs last.
Alignment reference (pinned to vLLM commit
2f75e7f):moe_align_block_size(topk_ids, num_experts, block_size, sorted_token_ids, experts_ids, num_tokens_post_pad)moe_align_block_size(topk_ids, expert_map, num_experts, block_size, sorted_token_ids, experts_ids, num_tokens_post_pad)moe_align_block_size(topk_ids, num_experts, block_size, sorted_token_ids, experts_ids, num_tokens_post_pad, maybe_expert_map)N/A - no linked issue.
Type of Change
feat- new feature / new operator / new platformfix- bug fixperf- performance improvement (no behavioral change)refactor- code restructuring without behavior changetest- adding or fixing tests onlydocs- documentation onlybuild/ci- build system or CI configurationchore- tooling, formatting, or other non-code changesPlatforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
The operator implementation and focused test at rebased commit
63296a2bare byte-for-byte identical to validated commit53a686af. That tree was tested from a clean archive onssh nvidiausingaccelerator-dev/nvidia:latest(sha256:dd94fce2f83a...), NVIDIA A100-SXM4-80GB, and PyTorch2.10.0a0+b4e4ee8.After #803 merged, this PR no longer adds
moe_align_block_sizeto the permanent smoke build or smoke matcher. The existingmoe_sumcase represents the vLLM MoE integration in the routine smoke suite; this operator remains covered by its focused test file.Test Results on Supported Platforms
moe_sumfrom #803moe_align_block_size: 18 passed, 1 skipped; full suite intentionally not runFocused coverage
The focused suite checks exact deterministic token ordering, five repeated launches, invalid raw and mapped expert IDs, sparse and zero-token experts, more than 256 routes, the
num_experts=257/block_size=128boundary, non-default streams, multi-GPU device selection, and safe descriptor reuse. Descriptor reuse permits fresh data pointers with identical metadata and rejects changed attributes, tensor metadata, orexpert_mappresence before launch.Benchmark / Performance Impact
N/A - this PR establishes the aligned interface and deterministic correctness baseline; it makes no performance claim.
Notes for Reviewers
-1expert sentinel.O(N)phase. It avoids nondeterministic atomic placement, but very large route counts may warrant a separately benchmarked parallel optimization later.moe_sumwas merged independently in feat(nvidia): addmoe_sumoperator #803 and supplies the vLLM MoE smoke coverage.