Skip to content

Share MoE FFN and Gated DeltaNet graph construction - #1293

Merged
0xShug0 merged 2 commits into
mainfrom
feature/framework-extension
Nov 15, 2026
Merged

0xShug0 merged 2 commits into
mainfrom
feature/framework-extension

Conversation

@0xShug0

@0xShug0 0xShug0 commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Consolidate repeated MoE feed-forward and Gated DeltaNet graph construction into shared framework modules, reducing model-local duplication while preserving each model's mathematical configuration and execution ownership.

  • Add stateless MoeFeedForwardModule for routed/shared expert composition, external routing, latent projections and staged output combination. Migrate Drama3, Nemotron Transcribe, Ming3 Audio, Zonos2 and Zonos3.
  • Add stateless GatedDeltaNetModule for Drama3 and Zonos3, with explicit projection layouts, Q/K normalization and BF16 rounding boundaries.
  • Extend the existing gated FFN module with opt-in gate-first packing, fused SwiGLU and rounding controls. Existing flags default to false.
  • Reuse the existing grouped MoE router for Ming3 Audio. Keep graph/state ownership, caching, weight placement, shared/residual composition and execution policies with the existing runtimes.
  • Add numerical and state-reuse coverage to the existing module tests. No GGML kernel, CLI/server schema or public model-option changes.

Validation

Compared main 0a71e38ba with production revision 8ab2001a6 on an RTX 5090, using matching Debug builds, gcc 13.3.0, CUDA 12.9, OpenMP, CUDA graphs and eight inference threads.

  • 76/76 paired comparisons have exact outputs across 18 CUDA/Vulkan configurations. TTS WAVs are byte-identical; ASR text and WER are unchanged. Output schemas and non-timing metadata match.
  • No reproducible RTF regression or peak-VRAM increase in the tested configurations.
  • MoE FFN, Gated DeltaNet and MoE routing/expert fixtures pass on CPU, CUDA and Vulkan. Coverage includes default FFNs, packed/separate projections, BF16 boundaries, external routing with remapped bank IDs, unequal latent dimensions, grouped selection, padded experts, zero Q/K, state continuity and graph reuse.
  • Allocation/recovery tests pass on CUDA/Vulkan. Drama3 and Zonos3 unload/reload replay produces identical WAVs and returns retained VRAM to the initial short-request level.
  • Full models run on CUDA/Vulkan only; CPU validation uses small synthetic fixtures. Existing GPU-led hybrid expert placement is retained.

Each persistent-server configuration warms a short and long input, then measures both twice. TTS includes a multi-sentence long input; Zonos2 and Zonos3 produce six chunks. ASR uses approximately 28 and 60 seconds of real speech. Staged dispatch is confirmed by expert-load/cache activity, and Ming hybrid execution by CPU-assignment logs.

RTF uses session.wall_ms, excluding load/warmup, divided by audio duration. Peak VRAM is process memory sampled every 20 ms across load, warmup and measured requests. Positive RTF delta means slower. All measured repetitions contribute to the table.

Performance results

Model Backend Mode Main RTF Refactor RTF RTF Δ Main / refactor peak VRAM (MiB) VRAM Δ (MiB)
Drama3 CUDA Fused FFN 0.22673 0.22199 -2.09% 22670.00 / 22668.00 -2.00
Drama3 CUDA Default/resident 0.24125 0.23592 -2.21% 22692.00 / 22690.00 -2.00
Drama3 CUDA Staged 1.96553 1.96091 -0.23% 7220.00 / 7214.00 -6.00
Drama3 Vulkan Fused FFN 0.31922 0.31576 -1.09% 23471.22 / 23469.22 -2.00
Drama3 Vulkan Default/resident 0.32724 0.32323 -1.22% 23787.28 / 23785.28 -2.00
Drama3 Vulkan Staged 2.51649 2.52104 +0.18% 6846.28 / 6844.28 -2.00
Ming3 Audio CUDA Default/resident 0.01615 0.01595 -1.22% 7660.00 / 7660.00 +0.00
Ming3 Audio CUDA Hybrid staged 0.05172 0.05110 -1.21% 4156.00 / 4156.00 +0.00
Ming3 Audio Vulkan Default/resident 0.01960 0.01900 -3.04% 7138.84 / 7138.84 +0.00
Nemotron Transcribe CUDA Default/resident 0.01750 0.01749 -0.05% 22014.00 / 22014.00 +0.00
Nemotron Transcribe CUDA Staged 0.24396 0.24347 -0.20% 6232.00 / 6232.00 +0.00
Nemotron Transcribe Vulkan Default/resident 0.02099 0.02083 -0.78% 21454.03 / 21454.03 +0.00
Zonos2 CUDA Default/resident 0.23639 0.23593 -0.19% 9882.00 / 9882.00 +0.00
Zonos2 CUDA Staged 0.61595 0.54696 -11.20% 6266.00 / 6266.00 +0.00
Zonos2 Vulkan Default/resident 0.29225 0.29141 -0.28% 9665.84 / 9665.84 +0.00
Zonos3 CUDA Default/resident 0.02912 0.02924 +0.40% 1948.00 / 1948.00 +0.00
Zonos3 CUDA Staged 0.04438 0.04460 +0.50% 1676.00 / 1676.00 +0.00
Zonos3 Vulkan Default/resident 0.03780 0.03744 -0.96% 1460.22 / 1460.22 +0.00

Drama3 defaults retain four CPU expert layers. Fused FFN enables only fish_drama3.fused_moe=true. Staged configurations use eight cache slots; Ming hybrid uses moe_cpu_share=0.5. Settings are identical between baseline and refactor.

Small positive timing deltas are within observed repeat variation. The larger Zonos2 staged improvement has noticeable timing variability and should not be interpreted as a guaranteed speedup. Memory sampling can miss peaks shorter than 20 ms.

Scope and remaining API limitation

Validation covers one checkpoint per model and the listed execution paths. Metal, HIP, WebGPU and separate streaming TTFA were not measured.

The new gated FFN API currently accepts fused_swiglu=true together with round_activation=true, but fusion skips the requested intermediate activation rounding. This combination should be rejected, consistent with MoeModule. Current migrated callers avoid it, so it does not affect the validated existing model paths.

@0xShug0
0xShug0 merged commit 6b0260e into main Nov 15, 2026
7 checks passed
@0xShug0
0xShug0 deleted the feature/framework-extension branch November 15, 2026 04:06
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