From 57a010b3209a2b59b10f6c1c834ac073acaf66d8 Mon Sep 17 00:00:00 2001 From: benITo47 Date: Thu, 19 Nov 2026 12:47:16 +0100 Subject: [PATCH] Drop the int8a8 variant from the package int8a8 ran each projection's input through per-token int8 rounding, and has crashed on CUDA. The package now offers fp32, fp16, int8 and int4, and a checkpoint with quantized activations fails to load with a clear error instead. --- README.md | 2 +- docs/reference.md | 5 ++--- docs/usage.md | 2 +- reverb_tts/model.py | 19 +++---------------- reverb_tts/tts.py | 4 ++-- tests/test_model.py | 7 +++---- 6 files changed, 12 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 0e5646e..2b0e4c1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ that runs it. - **0.96% word error rate** on the Open TTS Leaderboard's MiniMax test set, lower than every model on the leaderboard. - **297M parameters**, plus a 22M-parameter codec decoder. - **232.3× real time** on an NVIDIA H200 and **164.9×** on an RTX 5090 at batch 32, **over 20×** on an Apple M4 Pro and an iPhone 17 at batch 1. -- **Weights:** fp32, fp16, int8, int8a8, and int4 safetensors, and ExecuTorch programs for MLX, Vulkan, and QNN. +- **Weights:** fp32, fp16, int8, and int4 safetensors, and ExecuTorch programs for MLX, Vulkan, and QNN. ## Install diff --git a/docs/reference.md b/docs/reference.md index 3bafc38..650b1a2 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,14 +4,13 @@ ### safetensors -PyTorch weights for the `reverb-tts` package, in five variants (`TTS.from_pretrained(variant=...)`): +PyTorch weights for the `reverb-tts` package, in four variants (`TTS.from_pretrained(variant=...)`): | Variant | Weights | Activations | Download | |---|---|---|---| | `fp32` | fp32 | full precision | 1.19 GB | | `fp16` | fp16 | full precision | 594 MB | | `int8` (default) | int8, one scale per output channel | full precision | 307 MB | -| `int8a8` | int8, one scale per output channel | int8, one scale per token | 307 MB | | `int4` | int4, one scale per group of 32 inputs | full precision | 191 MB | In the quantized variants the decoder's linear layers hold the quantized weights, with fp16 scales. On an internal test @@ -55,7 +54,7 @@ The weights on Hugging Face, [software-mansion/Reverb-TTS](https://huggingface.c ``` model/ tokenizer.json, tokenizer_config.json, chat_template.jinja - safetensors// config.json, model.safetensors: fp32, fp16, int8, int8a8, int4 + safetensors// config.json, model.safetensors: fp32, fp16, int8, int4 executorch/mlx// reverb_mlx_.pte: fp16, int8, int4 executorch/vulkan/int4/ reverb_vulkan_int4.pte executorch/qnn/int4/ reverb_qnn_int4_.pte: v69, v73, v75, v79, v81 diff --git a/docs/usage.md b/docs/usage.md index 13d40a0..dd9a857 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -103,7 +103,7 @@ for text that is already written out, in `generate` or in `voice`. ```python import torch -tts = TTS.from_pretrained(variant="int4") # fp32, fp16, int8 (default), int8a8 or int4 +tts = TTS.from_pretrained(variant="int4") # fp32, fp16, int8 (default) or int4 tts = TTS.from_pretrained(device="cpu", dtype=torch.float32) tts = TTS.from_pretrained("path/to/weights") # a local folder ``` diff --git a/reverb_tts/model.py b/reverb_tts/model.py index 7858921..64cb2fa 100644 --- a/reverb_tts/model.py +++ b/reverb_tts/model.py @@ -5,7 +5,7 @@ import json from pathlib import Path -from typing import Dict, Optional, Tuple +from typing import Dict, Optional import torch from safetensors.torch import load_file @@ -63,12 +63,6 @@ def load(cls, folder: Path) -> "Network": heads = weights["audio_heads.weight"].view(CODEBOOKS, CODES, -1) weights["audio_heads.weight"] = (heads - heads.mean(1, keepdim=True)).flatten(0, 1) network.load_state_dict(weights) - - # An int8a8 checkpoint was made to run with each token's projection inputs rounded to int8. - if quantization and quantization.get("activations"): - for module in network.llm.layers.modules(): - if isinstance(module, torch.nn.Linear): - module.register_forward_pre_hook(round_per_token) return network.eval() @@ -80,6 +74,8 @@ def dequantize(weights: Dict[str, torch.Tensor], quantization: Dict) -> Dict[str if quantization.get("rotation"): raise NotImplementedError("checkpoints with rotated projections are not supported") + if quantization.get("activations"): + raise NotImplementedError("checkpoints with quantized activations, such as int8a8, are not supported") bits, group = quantization["bits"], quantization.get("group_size") for key in [key for key in weights if key.endswith(SCALE)]: name, scale = key[: -len(SCALE)], weights.pop(key).float() @@ -95,12 +91,3 @@ def dequantize(weights: Dict[str, torch.Tensor], quantization: Dict) -> Dict[str weights[name] = codes * scale return weights - -def round_per_token(module: torch.nn.Module, args: Tuple[torch.Tensor, ...]) -> Tuple[torch.Tensor, ...]: - """ - Rounds each token's input to symmetric int8, with a scale of its own. - """ - - x = args[0] - scale = x.abs().amax(-1, keepdim=True).clamp(min=1e-12) / 127 - return ((x / scale).round().clamp(-127, 127) * scale,) + args[1:] diff --git a/reverb_tts/tts.py b/reverb_tts/tts.py index 8ee19a3..ac9adce 100644 --- a/reverb_tts/tts.py +++ b/reverb_tts/tts.py @@ -28,7 +28,7 @@ REPOSITORY, REVISION = "software-mansion/Reverb-TTS", "v1.0.0" # the released weights PRESETS = REPOSITORY # preset voices, as voices/.json CODEC, CODEC_REVISION = "eustlb/higgs-audio-v2-tokenizer", "0e3a9177c2991016b8e5e17d23aa474ee665bef2" -VARIANTS = ("fp32", "fp16", "int8", "int8a8", "int4") +VARIANTS = ("fp32", "fp16", "int8", "int4") FRAME_RATE = 25 # codec frames per second LONGEST, PIECE = 30.0, 15.0 # seconds: a text estimated longer than LONGEST is spoken in pieces of about PIECE END_CUT = 0.2 # seconds cut from every take's end, where the codec can leave a short burst of noise @@ -134,7 +134,7 @@ def from_pretrained( model/safetensors//) or one checkpoint (config.json and model.safetensors, with the tokenizer beside or above it). - - variant: fp32, fp16, int8 (the default), int8a8 or int4. Every variant is converted to `dtype` on load, so the + - variant: fp32, fp16, int8 (the default) or int4. Every variant is converted to `dtype` on load, so the smaller ones download faster but run at the same speed. - device: cuda, mps or cpu; by default the first one available. - dtype: by default bfloat16 on CUDA (float16 without bf16 support), float16 on MPS and float32 on the CPU. diff --git a/tests/test_model.py b/tests/test_model.py index bd2c588..22e06a1 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -38,11 +38,10 @@ def test_quantized_checkpoints_are_expanded_on_load(network: Network, tmp_path: assert (table - loaded.state_dict()["llm.embed_tokens.table.weight"]).abs().max() <= table.abs().amax() / 254 + 1e-3 -def test_int8a8_checkpoint_rounds_projection_inputs(network: Network, tmp_path: Path) -> None: +def test_checkpoints_with_quantized_activations_are_rejected(network: Network, tmp_path: Path) -> None: quantization = {"bits": 8, "group_size": None, "activations": "per_token", "rotation": None} - loaded = Network.load(write_checkpoint(tmp_path, network, quantization)) - hooked = [m for m in loaded.llm.layers.modules() if isinstance(m, torch.nn.Linear) and m._forward_pre_hooks] - assert len(hooked) == 7 * 2 # q, k, v, o, gate, up, down in each of 2 layers + with pytest.raises(NotImplementedError, match="int8a8"): + Network.load(write_checkpoint(tmp_path, network, quantization)) def test_rotated_checkpoints_are_rejected(network: Network, tmp_path: Path) -> None: