Skip to content

feat(irodori_tts): support Irodori-TTS v4 Large (T5Gemma 2 text encoder) - #1163

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
KKTTSPJ:pr/irodori-v4-large
Nov 2, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
KKTTSPJ:pr/irodori-v4-large

Conversation

@KKTTSPJ

@KKTTSPJ KKTTSPJ commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Irodori-TTS-v4-Large to irodori_tts.

v4 Large is the v4 architecture at 3.29B parameters (24-layer, 2048-wide DiT) with one structural change: the ModernBERT text encoder is replaced by the encoder half of T5Gemma 2 (26 Gemma 3 layers, 1152 wide, vocabulary 262144), shared by the text and caption paths. Every other part (duration predictor, caption conditioning, residual_mlp projectors, speaker patching) uses the same configuration values as v4 Small, so the change stays inside the text encoder and tokenizer.

The checkpoint already carries everything needed: the T5Gemma 2 weights (pretrained_text_backbone.backbone.*), its config (text_encoder_config_json metadata) and the Gemma tokenizer (tokenizer/). tools/models/convert_irodori_gguf.py packages it as before, and the gated T5Gemma 2 repository is not needed. The existing spec already declares text_encoder_config.json and tokenizer/tokenizer.json, so model_specs/irodori_tts.json is unchanged.

No package is added to the catalog: the weights are under the Gemma Terms of Use. The docs describe local conversion.

Changes

  • assets.cpp / assets.h
    • When text_encoder_config.json has model_type: "t5gemma2", read encoder.text_config (heads, KV heads, head dim, RMS eps, query_pre_attn_scalar, per-layer-type RoPE theta and linear factor) and check the T5Gemma 2 tensor shapes.
    • Every layer uses the full bidirectional mask. That equals Hugging Face's sliding-window mask while no sequence is longer than sliding_window (512); loading fails if max_text_len or max_caption_len is longer.
    • MLP ratios are read as double. Python sizes MLPs as int(dim * ratio) with a double product; in float, 1280 * 2.6 truncates to 3327 instead of 3328, which is v4 Large's speaker-encoder width. Existing checkpoints get the same widths as before.
  • condition_encoder.cpp: the backbone is built with the shared T5GemmaEncoderModule, configured the way BreezeTTS 2 does. No sliding-window mask input is created for this encoder. Hugging Face's eoi_embedding (the end-of-image token) is not applied; TTS text has no image tokens.
  • tokenizer_text.cpp: the Gemma BPE tokenizer.json through LlamaBpeTokenizer (Gemma4 pre-tokenizer, U+2581 spaces), BOS first and PAD on the right like Python's PretrainedTextTokenizer.
  • convert_irodori_gguf.py: --type q4_k / q5_k / q6_k. A k-quant needs input widths that are multiples of 256, so T5Gemma 2's 1152-wide projections would otherwise stay F32. The script stores those weights as Q8_0 with --keep-type. Embeddings keep the converter's F16 rule.
  • docs/models/irodori_tts.md: variant row and a v4 Large section.

Validation

RTX 5060 Ti (CUDA 12.8) and CPU (AVX2), Windows. Python reference: Aratako/Irodori-TTS 89f9d8f (v4-Large support), fp32, CUDA.

Existing checkpoints are unchanged. Upstream main (dcec826b) and this branch give byte-identical WAVs on CUDA for v4 Small, v4.1 Small, 500M v3 and 600M v3 VoiceDesign (no reference, reference audio, and caption where supported; 11 cases, seed 42, 16 steps).

Tokens and condition encoders (Q8_0, CUDA) against Python (12 sentences: plain text, emoji, numbers, mixed English, rare kanji, surrogate-pair kanji, spaces, 3 captions):

Result
Text token ids identical in 10 of 12
Caption token ids identical in 3 of 3
Text-encoder output (after text_norm) per-token cosine ≥ 0.99990
Caption-encoder output per-token cosine ≥ 0.99981

The two token differences come from text normalization, not the tokenizer: Python's normalize_text applies NFKC and maps 〜 to ー, and audio.cpp's Irodori normalize_text does neither (half-width katakana, full-width Latin, 〜). This gap exists for all Irodori checkpoints; it shows here because the Gemma tokenizer has no normalizer of its own. I would send it as a separate PR.

Audio against Python fp32 (seed 42, 40 steps; log-mel frame cosine):

Type No reference Caption Reference audio (34.7 s)
Q8_0, CUDA 0.9999 0.9980 0.9667
Q8_0, CPU 0.9999 0.9996 –
Q6_K, CUDA 0.9970 0.9968 0.9740
Q5_K, CUDA 0.9666 0.8863 0.9863
Q4_K, CUDA 0.9842 0.8844 0.9771

Reference-audio cosines against Python vary between 0.92 and 0.97 for v4 Small as well, so that column is not evidence of a v4 Large difference. Q5_K and Q4_K change the delivery of the caption line (same length, different prosody).

Listening: Q5_K and Q4_K give a different performance of the caption line, with no audible loss of audio quality; Q6_K and Q8_0 sound the same. With reference audio, Q4_K to Q8_0 could not be told apart from Python.

Size, memory and time (CUDA, 40 steps, about 6 s of speech, CLI run including model load):

Type File Peak GPU (no reference) Peak GPU (reference) Time
Q8_0 4.24 GB 5.4 GB 7.8 GB 12 s
Q6_K 3.63 GB 4.9 GB 7.3 GB 21 s
Q5_K 3.30 GB 4.6 GB 6.9 GB 25 s
Q4_K 2.98 GB 4.3 GB 6.7 GB 28 s

Python fp32 on the same GPU took 46–54 s per line.

🤖 Generated with Claude Code

v4 Large keeps the v4 architecture at 3.29B parameters but replaces the
ModernBERT text encoder with the encoder half of T5Gemma 2, shared by the
text and caption paths.

- assets: read the embedded T5Gemma 2 config (encoder.text_config), check
  its tensor shapes, and require max_text_len / max_caption_len to fit the
  sliding window so every layer can use the full bidirectional mask.
- condition encoder: build the backbone with the shared
  T5GemmaEncoderModule (as BreezeTTS 2 does); no sliding-window mask input
  for this encoder.
- tokenizer: the checkpoint's Gemma BPE tokenizer.json through
  LlamaBpeTokenizer, BOS first and PAD on the right like Python.
- config: MLP ratios are read as double. Python sizes MLPs as
  int(dim * ratio); in float, 1280 * 2.6 truncates to 3327 instead of 3328
  (v4 Large's speaker encoder). Existing checkpoints get the same widths.
- converter: q4_k / q5_k / q6_k; 2-D weights whose input width is not a
  multiple of 256 are stored as Q8_0 instead of F32.
- docs: v4 Large section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@0xShug0
0xShug0 merged commit 9af9719 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-v4-large branch November 2, 2026 03:51
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