Skip to content

Prepack constant CUDA SiLU-gated MoE weights - #33882

Open
Tianlei Wu (tianleiwu) with Copilot wants to merge 9 commits into
mainfrom
copilot/cuda-moe-performance-issue
Open

Tianlei Wu (tianleiwu) with Copilot wants to merge 9 commits into
mainfrom
copilot/cuda-moe-performance-issue

Conversation

Copilot AI commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Initialization: Pack constant FC1/FC3 weights once into per-expert [FC1 gate | FC3 value] buffers; retain shapes so original initializers can be released.
  • Inference: Reuse packed weights. Preserve existing behavior for dynamic or mixed constant/dynamic weights and disabled prepacking.

Motivation and Context

CUDA FP16 SiLU-gated MoE shows reported slowdowns of 3× for decode and 1.25× for prefill between 1.23.2 and 1.29.0. At Granite’s dimensions, per-inference weight repacking adds 64 device-to-device copies totaling 64 MiB—even when weights are constant.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CUDA MoE performance regression from 1.23 to 1.29 Prepack constant CUDA SiLU-gated MoE weights Nov 4, 2026
@tianleiwu
Tianlei Wu (tianleiwu) marked this pull request as ready for review November 6, 2026 17:37
Copilot AI balanced review requested due to automatic review settings November 6, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new FP16/BF16 tests fail on the TMA warp-specialized dispatch path because the backend’s SwiGLU gate/value chunk order conflicts with the test layout, requiring correction and explicit coverage.

1 open issue
What changed in this PR

This PR addresses the CUDA SiLU-gated MoE slowdown reported in #33864 by packing constant FC1/FC3 weights during initialization rather than on every inference.

Changes:

  • Cache per-expert [FC1 gate | FC3 value] weights and retain shapes after original initializers are released.
  • Reuse packed weights while preserving dynamic, mixed-weight, and disabled-prepacking paths.
  • Add CUDA tests for supported data types, repeated inference, prefill, and prepacking controls.
File Description
onnxruntime/​test/​contrib_ops/​moe_test.cc Adds correctness and prepack-count tests for CUDA SiLU-gated MoE.
onnxruntime/​contrib_ops/​cuda/​moe/​moe.h Declares the prepacking hook and cached weight state.
onnxruntime/​contrib_ops/​cuda/​moe/​moe.cc Packs constant weights at initialization and reuses them during inference.

Review effort: Balanced

Avoid fetching released FC1/FC3 initializers after prepacking. Use gate-first chunk ordering consistently in the TMA activation path, and add deterministic Hopper prepacking and fallback coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve verified FC1-gate/FC3-value activation order and explicit deterministic SM90 regression dispatch while bringing current-main CI fixes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tianleiwu

Tianlei Wu (tianleiwu) commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Final maintenance verification at a40151cd3a: the complete, freshly paginated all-20 audit at2026-11-09T15:00:56Z verifies this PR's complete current-head CI green (100 SUCCESS, one NEUTRAL, no pending or failed contexts), OPEN/non-draft/MERGEABLE state and zero unresolved feedback. Normal reviewer approval remains external; no merge or self-approval was performed.

The TMA main refresh, reviewer fixes, forced-SM90 gated-value/bias coverage and native Button testID navigation repair remain intact. CI maintenance preserves production TMA kernels, CPUIDInfo/CPUINFO/provider behavior and the original39a AsyncWorker header. The preceding zero-case98 iOS cancellation showed cold boot/setup and cleanup failures before app installation, not an executed native worker or TMA-kernel failure; no speculative kernel/worker change was made.

The retained98 CPUINFO repair changes only two Windows regression-test files. It observes real allocation cleanup after CPUIDInfo destruction and before later CRT/loader address reuse, repeats16 unload cycles and safely preserves process-lifetime result storage for delayed module callbacks. Mandatory initial-allocation validation and genuine deallocation checks remain enabled. Five native-loader protocol fixtures passed, but actual currenta401 Windows CPU Debug42618374821 supplies the decisive proof: real job129163863702 executed the mandatory cleanup detector successfully in5.16seconds, the refcount case in7.27seconds and35/35 CTest cases passed. Currenta401 Windows CUDA42618374597 also completed SUCCESS, including its separate actual test job.

The new two-file simulator preparation passed all nine regressions against actual TMA YAML/Node configuration. It only resets the uniquely configured simulator and waits for bootstatus/app-service readiness; no global CoreSimulator restart, relaxed240-second Detox deadline or weakened reinstall/cleanup/assertion policy is used. Actual currenta401 React Native42618374715 completed SUCCESS. Fresh Android artifact13676477466 and iOS artifact13677473990 each verify exactly three real passing MNIST, Basic Types and EPContext cases, no failures/errors/skips and the unchanged14/14 checks passed assertion in device logs/traces. Historical98/f8 outcomes and protocol mocks are not substituted for current device or Windows runtime execution.

All remaining non-mobile integrations, including the final WebGPU static-plugin, test and Dawn-package gates, have now succeeded on currenta401. No TMA behavior, tolerances, hardware gates, teardown tests or runtime assertions were bypassed. Local Hopper hardware remains unavailable; no local Hopper execution or performance result is claimed.

Target the accessible pressable instead of the wrong child text view selected on iOS. Exercise the actual Detox scenario on both platforms and retain the aggregate success assertion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The iOS Button accessibility label is duplicated on native wrappers. Keep its accessibility label but identify the pressable with a unique testID. Reproduce the duplicate-label failure, verify the actual rendered native identifier and navigation, and preserve the complete 14/14 device assertion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Observe the allocation after CPUIDInfo destruction and before later CRT/loader cleanup can reuse its address. Keep strict deallocation validation, repeat 16 load/unload cycles, and retain observer result storage safely when another module reference prevents unloading.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
iOS device runs have stalled during cold simulator setup before app installation. Reset only the simulator selected by the Detox configuration, then wait for boot and app services without restarting the global CoreSimulator service. Keep app reinstallation, device assertions, and the existing Detox setup deadline unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

CUDA MoE is up to 3x slower in 1.29 than in 1.23

3 participants