Skip to content

perf(irodori_tts): leave caption tokens out of the RF context without a caption - #1170

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
KKTTSPJ:pr/irodori-rf-skip-empty-caption
Nov 2, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
KKTTSPJ:pr/irodori-rf-skip-empty-caption

Conversation

@KKTTSPJ

@KKTTSPJ KKTTSPJ commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

On caption-conditioned checkpoints (v3 VoiceDesign, v4 Small, v4.1 Small, v4 Large), the RF context always holds max_caption_len (512) caption tokens, also for requests without a caption, where every one of them is masked out. They take K/V memory in every DiT layer (512 of the 770 context tokens without a reference) and attention work at every sampling step, and contribute nothing.

With this PR, requests without a caption pass no caption state to the RF and MeanFlow samplers, so the context holds only the text and speaker tokens. Requests with a caption, and checkpoints without caption conditioning, are unchanged. src/models/irodori_tts/rf_dit.cpp only.

Python Irodori-TTS also pads to 512 masked tokens. Masked keys add nothing to attention, so the result is the same up to floating-point order. The output is not byte-identical: the attention reduces over a different number of keys.

This is independent of #1168 (the K/V copy in the step graphs) and merges cleanly with it. The 40-step measurements below have #1168 applied on both sides.

Validation

RTX 5060 Ti, CUDA 12.8, 40 steps, codec chunking on (codec_decode_chunk_steps=100, codec_encode_chunk_steps=100), with and without this PR.

With a caption: byte-identical (v4 Small Q8_0, v4 Large Q8_0 and Q4_K).

Without a caption (log-mel frame cosine against the output without this PR):

Short (6 s) Long (18 s) Reference audio (34.7 s)
v4 Small Q8_0 0.9999 0.9999 0.9904
v4 Large Q8_0 1.0000 0.9993 1.0000
v4 Large Q4_K 0.9999 0.9981 1.0000

Existing checkpoints against main (Q8_0, 16 steps, seed 42): v3 500M (no caption conditioning) and every request with a caption are byte-identical; without a caption, v4 Small 0.9997 / 0.9962, v4.1 Small 0.9773 / 0.9999, v3 VoiceDesign 0.9999 / 0.9991 (no reference / reference audio).

Lengths are unchanged in every case. The changes are of the size other numerical changes cause after many steps, not a shift in one direction. Against Python fp32:

Without this PR With this PR
v4 Large Q8_0, no reference (40 steps) 0.9999 0.9998
v4 Large Q8_0, reference audio (40 steps) 0.9755 0.9755
v4.1 Small Q8_0, no reference (16 steps) 0.9811 0.9618

The v4.1 Small case is the largest change we saw. It comes from Q8_0, not from this PR: the same line with the F16 package, or with Q8_0 at 40 steps, is unchanged by it (main binary vs this PR on top of #1168, which does not change output; both against Python fp32):

v4.1 Small, no reference Without ↔ with this PR Python ↔ without Python ↔ with
Q8_0, 16 steps 0.9773 0.9811 0.9618
F16, 16 steps 1.0000 0.9997 0.9997
Q8_0, 40 steps 1.0000 0.9615 0.9616
F16, 40 steps 0.9992 0.9982 0.9974

At Q8_0 this line's sampling trajectory is sensitive to small numerical differences: at 40 steps it is already 0.96 from Python without this PR. Any change in floating-point order can tip it, as this one does at 16 steps.

Listening check: only the Q8_0 16-step v4.1 Small line could be told apart, as roughly one breath's worth of timing difference, with no effect on audio quality. The v4 Small reference-audio case (0.9904 above) could not be told apart.

Peak GPU memory (increase over idle, sampled every 50 ms):

Short Long Reference audio
v4 Large Q8_0 5,121 → 5,116 MiB 5,150 → 5,149 MiB 5,498 → 5,124 MiB
v4 Large Q4_K 3,944 → 3,934 MiB 3,963 → 3,916 MiB 4,292 → 3,974 MiB
v4 Small Q8_0 2,390 → 2,405 MiB 2,407 → 2,398 MiB 2,374 → 2,363 MiB

The saving shows where sampling sets the peak, here v4 Large with reference audio (about 0.3–0.4 GB). Elsewhere the weights and the codec set the peak. Run times did not change measurably.

🤖 Generated with Claude Code

… a caption

On caption-conditioned checkpoints (v3 VoiceDesign, v4) every request
carried max_caption_len (512) caption tokens through the RF context, even
without a caption, where all of them are masked out. They still took K/V
memory in every DiT layer and attention work at every step.

Requests without a caption now pass no caption state to the RF and
MeanFlow samplers, so the context holds only text and speaker tokens.
Masked keys add nothing to attention, so the result is the same up to
floating-point order: outputs with a caption are byte-identical, outputs
without one differ at the level of other numerical changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@0xShug0
0xShug0 merged commit 5434ea3 into 0xShug0:main Nov 2, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

@KKTTSPJ Thanks! PR merged.

@KKTTSPJ
KKTTSPJ deleted the pr/irodori-rf-skip-empty-caption branch November 2, 2026 07:31
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.

2 participants