Skip to content

Expose YuE2 performance controls and cuda_perf preset - #1056

Merged
0xShug0 merged 3 commits into
mainfrom
expose-yue2-perf-control
Oct 23, 2026
Merged

0xShug0 merged 3 commits into
mainfrom
expose-yue2-perf-control

Conversation

@0xShug0

@0xShug0 0xShug0 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Expose independent YuE2 controls for packed AR QKV/gate-up projections, KV alignment, stage/graph retention, and VAE tile length.
  • Add yue2.perf_mode=off|cuda_perf using a preset table. Explicit settings override the preset, including false and alignment 1.
  • Default control values remain unchanged. Lifecycle improvements and the CUDA SnakeBeta lowering apply automatically; the default waveform is not claimed to be byte-identical to main.
  • The preset does not change weight dtype. Existing component/shared weight-type controls remain authoritative.
Control Default cuda_perf
yue2.packed_projections false true
yue2.kv_cache_alignment 1 256
yue2.mem_saver true false
yue2.vae_tile_frames Model configuration Capped at 512

Implementation

  • Prefill unequal CFG prefixes directly into persistent backend KV lanes, avoiding host KV export, packing, staging, and re-upload. Metal retains its existing host BF16 readback path.
  • With CUDA KV alignment above 1, cache decode graphs by the aligned used-context window. These session-owned graphs share persistent KV storage and are reused between requests.
  • Use the existing lazy_import_scratch option only on the new direct-prefill/windowed path; existing batched callers retain eager allocation. New external-cache arguments default to null and attention-window alignment defaults to zero.
  • Write NAR conditioning directly into persistent buffers. Reuse NAR graphs only when shapes and borrowed KV tensor/storage identities match; release consumers before backing storage.
  • Release completed refill-prefill workspaces without discarding decoder/KV state, and release old VAE graphs before allocating replacements.
  • Lower eligible single-sample CUDA SnakeBeta graphs through the existing fused kernel, retaining F32 computation and beta + 1e-9. Other backends/shapes keep their previous lowering.
  • No GGML/kernel-source changes.

Performance

Frozen main 80e66d2c versus PR 733f1b2c. Complete official tonight-awake example, full CoT, seed 12300, 8 NAR steps, original sampling settings and natural stopping. Debug/C++17, CUDA RTX 5090, 12 CPU threads, Q8 backbone with the same native F16 VAE package.

Each row used one full warmup and two measured requests in one session, run sequentially. RTF is total measured session.wall_ms divided by generated duration. Peak VRAM includes loading and warmup, sampled every 20 ms.

CFG Version / Mode Average Warm RTF Peak VRAM Audio Duration
1 Main default 0.13720 8,456 MiB 194.84 s
1 PR default 0.13938 6,854 MiB 194.84 s
1 PR cuda_perf 0.11604 11,254 MiB 220.88 s
2 Main default 0.23114 8,452 MiB 194.76 s
2 PR default 0.20325 6,850 MiB 194.76 s
2 PR cuda_perf 0.12233 12,610 MiB 219.84 s
  • PR default reduces peak VRAM by 1,602 MiB in both CFG cases. CFG 2 default reduces warm RTF by 12.1%.
  • CFG 1 default was 1.6% slower in the first pair. A reverse-order recheck gave PR 0.13890 versus main 0.14136 (1.7% faster), so no consistent slowdown was observed.
  • cuda_perf reduces warm RTF by 15.4% / 47.1% at CFG 1 / 2, at the cost of 2,798 / 4,158 MiB more peak VRAM than main default.
  • Preset outputs have different durations due to numerical/sampling differences. These are normalized end-to-end throughput comparisons, not identical generated-work comparisons.

Regression Validation

  • All six official configurations were repeat-stable: warmup and both measured WAVs matched byte-for-byte within each configuration. None reached the semantic token ceiling.
  • PR default preserved main's semantic tokens exactly at both CFG values. Waveform differences are numerical, not bit-exact:
Default vs Main Waveform Cosine SNR
CFG 1 0.999995702 50.66 dB
CFG 2 0.999994618 49.68 dB
  • Fixed-conditioning long → short → long passed in both default and retained modes, with identical WAVs when returning to the long input.
  • Actual AR decoding with mixed lengths/seeds passed medium → repeat → short → long → medium → short; repeated inputs retained identical semantic tokens and WAVs. Short, deliberately token-capped cases were used for lifecycle stress, not as natural-stop quality tests.
  • Explicit settings matched the preset byte-for-byte. Overriding all preset controls back to defaults matched the default session byte-for-byte.
  • Current CPU and Vulkan builds passed short CFG 2 default and preset runs, producing finite, non-silent stereo 48 kHz WAVs with the expected frame counts. No cross-backend sampled-output parity is claimed.
  • Rebuilt request/spec, KV-ring, packed-projection, and SnakeBeta tests passed. Local CPU/CUDA decoder checks also covered unequal prefixes, attention-window boundaries, capacity growth/shrinkage, and host-import/device-prefill switching.

Shared SnakeBeta Check

AuK-Flash Q8 (3-second generation) and SAM Audio Small Q8 (6-second separation) were checked separately against main. One warmup plus three measured requests per build, fixed input/seed; outputs were repeat-stable.

Model Main → PR Warm RTF Main → PR Peak VRAM Waveform Cosine
AuK-Flash 0.42697 → 0.39089 4,078 → 4,078 MiB 0.999999892
SAM Audio Small 0.02331 → 0.02181 3,596 → 3,728 MiB 0.999599 target / 0.999443 residual

SAM's CUDA encoder workspace increases from 641.60 to 773.44 MiB, accounting for the 132 MiB memory tradeoff. The cosine differences alone do not demonstrate an output-quality regression; both models ran faster in this recheck.

Metal was not run locally. All inference runs were logged; benchmark scripts, local assets, and validation logs are excluded from the PR.

Reuse backend KV storage and session-owned attention-window graphs. Keep lazy batched import scratch opt-in, lower CUDA SnakeBeta through existing fusion, and preserve native VAE storage in the performance preset.
@0xShug0
0xShug0 merged commit 47c2756 into main Oct 23, 2026
7 checks passed
@0xShug0
0xShug0 deleted the expose-yue2-perf-control branch October 23, 2026 17:15
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