Repository navigation
Conversation
BBaditi
force-pushed
the
qmoe-packed-gguf-cpu-offload
branch
from
November 10, 2026 08:16
2274f07 to
c5b16ce
Compare
BBaditi
force-pushed
the
qmoe-packed-gguf-moe-m8-verify-opt
branch
from
November 10, 2026 08:20
38747cc to
0612610
Compare
…U FC2 decode - CPU ExecuteMoEPackedColdRoutesCpuWithScratch (gguf_vec_dot_cpu.h): replace 96 per-step std::vector heap allocations with stack buffers for num_cold_routes <= 128, parallelize multi-token input Q8 quantization across M tokens, and add 2-route fused AVX2 grouped dot products (VecDotGgufRow4xQ8Batch2Avx2) so cold experts hit by >= 2 tokens unpack each GGUF weight sub-block once in registers for two routes. - GPU MoEPackedFc2Bf16TcKernel (kMaxSubTiles == 1, moe_packed.cu): remove 10.75 KB shared-memory activation staging (s_act_u4) and K-loop __syncthreads() barrier in favor of direct __ldg(act_base + ...) reads, stage GGUF lookup tables in shared memory (s_lut), and use 4 warps (64 output channels/CTA) in LaunchMoEPackedCuda and DispatchMoEPackedHotExpertsCuda to double CTA occupancy across SMs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BBaditi
force-pushed
the
qmoe-packed-gguf-moe-m8-verify-opt
branch
from
November 10, 2026 18:26
0612610 to
feb3aac
Compare
BBaditi
force-pushed
the
qmoe-packed-gguf-cpu-offload
branch
from
November 10, 2026 18:26
c5b16ce to
ad4314d
Compare
This branch has not been deployed
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
This PR optimizes
com.microsoft::MoEPackedmulti-token (M = 4, 8) speculative decoding verification across both the CPU hybrid cold-route path (gguf_vec_dot_cpu.h) and the GPU Tensor Core FC2 decode path (moe_packed.cu):CPU Multi-Token Cold-Route Execution (
ExecuteMoEPackedColdRoutesCpuWithScratchingguf_vec_dot_cpu.h):std::vector<int> sorted_candstd::vector<ColdExpertGroup> groupsallocations with stack buffers (sorted_c_stack[128],groups_stack[128]) fornum_cold_routes <= 128, eliminating96heap allocations/frees per 48-layer verify step.BF16 -> FP32 + QuantizeRowQ8Cpuacrossnum_unique_tokswhennum_unique_toks >= 2.VecDotGgufRow4xQ8Batch2Avx2&VecDotGgufGateUpRow2xQ8Batch2Cpu): WhenM = 4orM = 8verification batch route to the same cold expert (ColdExpertGroupwithgrp.count >= 2, where measured cold-route reuse1.39x-1.48xatM=4and1.86x-2.07xatM=8), each GGUF weight sub-block (IQ2_XXS,IQ2_XS,IQ2_S,IQ3_XXS,IQ4_NL,IQ4_XS,Q2_0) is unpacked once in AVX2 registers and multiplied against two routes' Q8 activations simultaneously with0ULP difference.GPU Tensor Core FC2 Decode/Verify (
MoEPackedFc2Bf16TcKernel<1>inmoe_packed.cu):10.75 KBs_act_u4shared-memory activation staging buffer, integer-division staging loop, and K-loop__syncthreads()barrier whenkMaxSubTiles == 1(total_routes <= 128), loadingfc1_outdirectly via 128-bit__ldg.iq2xxs_grid,iq2xs_grid,iq2s_grid,iq3xxs_grid) in shared memory (s_lut,DecodeGgufSubBlock8SmemLutTpl<kDownType>) and switches decode CTA geometry from8warps (128output channels/CTA) to4warps (64output channels/CTA) in bothDispatchMoEPackedHotExpertsCudaandLaunchMoEPackedFc2Bf16TcDispatch<1>, doubling CTA grid parallelism across SMs.Measured Performance Impact (48-Layer
Qwen3.8-Flash-Next+dflash2.onnxon NVIDIA A100-SXM4-80GB)Table A: 48-Layer Verify Step Latency Progression (
UD-IQ2_XS)UD-IQ2_XS)MoEPackedFC2 + CPU Batch-2)MatMulPacked&ReadU32Dev)100% GPUMoEPacked(48 nodes,M=1 / M=4 / M=8)10.74 / 15.82 / 20.29 ms10.23 / 15.05 / 18.81 ms10.28 / 15.32 / 19.24 ms-0.5 to -1.5 ms50/50 HybridMoEPacked(48 nodes,M=1 / M=4 / M=8)17.40 / 27.02 / 37.81 ms18.31 / 24.69 / 33.91 ms16.98 / 24.83 / 34.33 ms-2.3 to -3.9 ms100% GPUT_verify(M=4)34.48-35.10 ms29.02-29.73 ms26.46-27.32 ms-7.9 ms/step(-22.8%)100% GPUT_verify(M=8)50.32-51.68 ms35.76-38.05 ms32.90-35.27 ms-16.9 ms/step(-33.2%)50/50 HybridT_verify(M=4)38.68-52.97 ms31.73-41.84 ms29.64-39.80 ms-11.1 ms/step(-24.2%)50/50 HybridT_verify(M=8)56.08-80.69 ms41.46-56.03 ms38.69-53.59 ms-22.2 ms/step(-32.5%)Table B: End-to-End
dflash2.onnxSpeculative Decoding (64Generated Tokens / Prompt, Combined Stage 2)M=1Decode (ms/tok/tok/s)Fixed M=8Peak (P1_structured)Adaptive M={4,8}3-Prompt Mean (tok/s/Speedup)UD-IQ1_S100% GPU21.16 ms(47.3 tok/s)185.3 tok/s(3.93x)106.0 tok/s(86.2harm.,2.24x)64/64(100.0%)UD-IQ1_S50/50 Hybrid(-5.21 GB)24.27 ms(41.2 tok/s)129.6 tok/s(3.43x)90.2 tok/s(84.9harm.,2.23x)64/64(100.0%)UD-IQ2_XS100% GPU19.91 ms(50.2 tok/s)197.4 tok/s(3.93x)123.7 tok/s(111.3harm.,2.46x)64/64(100.0%)UD-IQ2_XS50/50 Hybrid(-5.78 GB)23.77 ms(42.1 tok/s)126.8 tok/s(3.32x)89.8 tok/s(82.7harm.,2.17x)64/64(100.0%)UD-IQ3_XXS100% GPU22.27 ms(44.9 tok/s)177.5 tok/s(3.96x)109.3 tok/s(98.1harm.,2.44x)64/64(100.0%)UD-IQ3_XXS50/50 Hybrid(-7.04 GB)27.77 ms(36.0 tok/s)115.7 tok/s(3.30x)80.1 tok/s(74.1harm.,2.22x)64/64(100.0%)Validation
/usr/bin/clang-format --dry-run --Werrorandgit diff --check: 0 issuesctest --output-on-failure -V -R "GgufQuantPackedTest": 2/2 passed (100%)pytest onnxruntime/test/python/transformers/test_gguf_packed_ops.py -v: 33 passed, 811 subtests passed (100%)