Skip to content

Refactor Qwen3.5 runtime to reuse shared modules - #1356

Merged
0xShug0 merged 1 commit into
mainfrom
refactor/qwen35-runtime
Nov 21, 2026
Merged

0xShug0 merged 1 commit into
mainfrom
refactor/qwen35-runtime

Conversation

@0xShug0

@0xShug0 0xShug0 commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Qwen3.5 decoder execution duplicates Gated DeltaNet, FFN and attention construction across forward, prefill and decode. Reuse the existing GatedDeltaNetModule and GatedFeedForwardModule, consolidate common attention construction, and share immutable initial recurrent state across layers while retaining separate mutable decode states.

The change is confined to qwen35_decoder_runtime.cpp. Public APIs, model wiring, kernels, precision, rounding boundaries and cache capacities are unchanged. Graphs and buffers remain session-owned and reused.

Performance

RTX 5090, Debug build, eight threads, native model precision. Sequential warmed main-versus-branch A→B→B→A; 12 measured requests per revision for translation/ASR and eight for generation. RTF uses end-to-end session time; VRAM is process peak.

CUDA profile Main RTF PR RTF RTF reduction Peak VRAM main → PR
Index Echo translation 0.04617 0.04540 1.7% 5,932 → 5,936 MiB
FireRedAudio ASR 0.03361 0.02992 11.0% 19,464 → 19,354 MiB
FireRedAudio speech generation 0.51233 0.46937 8.4% 21,502 → 21,392 MiB

Both PR measurement blocks were faster than both baseline blocks. Index Echo's improvement is modest; FireRed saves 110 MiB peak VRAM in both routes.

Validation

  • Tested model text/timestamps match main exactly; generated FireRed PCM is byte-identical. Repeated requests remain stable.
  • 240 controlled runtime output comparisons match exactly: 144 CUDA, 48 CPU and 48 Vulkan, covering F32/BF16/Q8, BF16 rounding, equal/repeated GDN heads, forward, prefill, teacher-forced decode, embedding and LM head.
  • Shape changes, reset and release/reprepare preserve outputs.
  • Vulkan runs pass for both callers, including speech generation, with exact main-versus-PR outputs. Vulkan measurements are functionality checks with limited samples, rather than a performance claim.
  • Parallel Debug build passes. CPU coverage is runtime-level correctness/lifecycle testing; full-model CPU performance, HIP and Metal were not tested. These routes are offline, so streaming TTFA does not apply.

@0xShug0
0xShug0 merged commit fb34c74 into main Nov 21, 2026
7 checks passed
@0xShug0
0xShug0 deleted the refactor/qwen35-runtime branch November 21, 2026 01:02
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