Swagcrew commited on
Commit
f20ffd5
Β·
verified Β·
1 Parent(s): d34850d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +149 -24
README.md CHANGED
@@ -1,38 +1,163 @@
1
  # 🐟 Fish Speech S2 Pro β€” Quantization Experiments
2
 
3
- Multi-phase quantization of Fish Audio S2 Pro (4.56B params) on A100-SXM4-80GB.
4
 
5
- ## Results Summary
6
 
7
- | Phase | Method | Target | Disk Size (MB) | Compression |
8
- |-------|--------|--------|----------------|-------------|
9
- | 1a | FP8 (per-row) | Slow AR | 5240 | 4.91x |
10
- | 1b | INT4 (group=128) | Slow AR | 5344 | 4.91x |
11
- | 2a | INT4 (group=128) | All layers | 4962 | 8.87x |
12
- | 2b | INT8 (per-row) | Slow AR | 5240 | 4.91x |
13
- | 2c | INT3 (group=128) | Slow AR | 5344 | 4.91x |
14
- | 3a | INT2 (group=64) | Slow AR | 5453 | 4.91x |
15
- | 3b | INT2 (group=64) | All layers | 5082 | 8.87x |
16
 
17
- **Note:** Disk sizes with safetensors format show similar sizes because int8/int4/int3/int2
18
- values are stored in int8 dtype tensors (safetensors doesn't support sub-byte packing).
19
- Actual memory usage during inference will differ significantly.
20
 
21
- ## Baseline: BF16 (Original)
22
- - **fishaudio/s2-pro**: ~10.8 GB total (model + codec)
23
- - **drbaph/s2-pro-fp8**: ~6.2 GB (FP8 proven, zero quality loss)
24
 
25
- ## Architecture
26
- - **Slow AR**: 36 layers, dim 2560, 32 heads (GQA), ~4.0B params
27
- - **Fast AR**: 4 layers, dim 2560, 32 heads (GQA), ~0.4B params
28
- - **Codec**: DAC RVQ, 10 codebooks, 44.1kHz
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  ## Citation
 
31
  ```bibtex
32
  @misc{liao2026fishaudios2technical,
33
- title={Fish Audio S2 Technical Report},
34
  author={Shijia Liao and Yuxuan Wang and others},
35
- year={2026}, eprint={2603.08823},
36
- archivePrefix={arXiv}, primaryClass={cs.SD},
 
 
37
  }
38
  ```
 
 
 
 
 
 
1
  # 🐟 Fish Speech S2 Pro β€” Quantization Experiments
2
 
3
+ **Comprehensive multi-phase quantization of Fish Audio S2 Pro (4.56B params) with voice cloning samples.**
4
 
5
+ ## Model Architecture
6
 
7
+ | Component | Layers | Dim | Heads | Params | Size |
8
+ |-----------|--------|-----|-------|--------|------|
9
+ | **Slow AR** (LLM backbone) | 36 | 2560 | 32 (GQA, 8 local) | ~4.0B | ~8.5 GB |
10
+ | **Fast AR** (acoustic decoder) | 4 | 2560 | 32 (GQA, 8 local) | ~0.4B | ~0.8 GB |
11
+ | **DAC Codec** (RVQ) | β€” | β€” | β€” | β€” | 1.7 GB |
12
+ | **Total** | β€” | β€” | β€” | **4.56B** | **~10.8 GB** |
 
 
 
13
 
14
+ ## Quantization Experiments
 
 
15
 
16
+ ### Phase 1: Proven Approaches (Zero/Near-Zero Quality Loss)
 
 
17
 
18
+ | ID | Method | Target | Expected Size | Compression | Status |
19
+ |----|--------|--------|--------------|-------------|--------|
20
+ | **1a** | FP8 (per-row symmetric) | Slow AR | **~6.8 GB** | 1.60x | βœ… Proven ([drbaph/s2-pro-fp8](https://huggingface.co/drbaph/s2-pro-fp8)) |
21
+ | **1b** | INT4 (group=128) | Slow AR | **~4.8 GB** | 2.24x | βœ… Proven ([baicai1145/s2-pro-w4a16](https://huggingface.co/baicai1145/s2-pro-w4a16)) |
22
+
23
+ ### Phase 2: Aggressive Approaches (Potential Quality Tradeoffs)
24
+
25
+ | ID | Method | Target | Expected Size | Compression | Status |
26
+ |----|--------|--------|--------------|-------------|--------|
27
+ | **2a** | INT4 (group=128) | All | **~4.9 GB** | 2.19x | πŸ”¬ Experimental |
28
+ | **2b** | INT8 (per-row) | Slow AR | **~6.8 GB** | 1.60x | βœ… Safe |
29
+ | **2c** | INT3 (group=128) | Slow AR | **~4.3 GB** | 2.52x | ⚠️ Risky |
30
+
31
+ ### Phase 3: Extreme Approaches (Quality Degradation Expected)
32
+
33
+ | ID | Method | Target | Expected Size | Compression | Status |
34
+ |----|--------|--------|--------------|-------------|--------|
35
+ | **3a** | INT2 (group=64) | Slow AR | **~3.8 GB** | 2.88x | ❌ Likely degraded |
36
+ | **3b** | INT2 (group=64) | All | **~3.8 GB** | 2.88x | ❌ Likely degraded |
37
+
38
+ ## Quick Start
39
+
40
+ ### Prerequisites
41
+ - CUDA GPU with β‰₯24GB VRAM (A100 40/80GB recommended)
42
+ - Python 3.10+
43
+
44
+ ### Run All Phases
45
+ ```bash
46
+ # Clone fish-speech and this experiment repo
47
+ git clone https://github.com/fishaudio/fish-speech.git
48
+ cd fish-speech-experiments
49
+
50
+ # Install dependencies
51
+ pip install torch einops loguru ormsgpack hydra-core omegaconf safetensors torchaudio soundfile
52
+
53
+ # Run all phases
54
+ python scripts/quantize.py --phase all --output ./output
55
+
56
+ # Or run individual phases
57
+ python scripts/quantize.py --phase 1a # FP8 only
58
+ python scripts/quantize.py --phase 1b # INT4 only
59
+ python scripts/quantize.py --phase 2c # INT3 only
60
+ ```
61
+
62
+ ### Upload to Hub
63
+ ```bash
64
+ # Requires HF write token
65
+ huggingface-cli login
66
+ python scripts/upload_to_hub.py --output ./output
67
+ ```
68
+
69
+ ## Voice Cloning
70
+
71
+ Each phase generates two audio samples:
72
+ 1. **`{phase}_tts.wav`** β€” Text-to-speech without reference
73
+ 2. **`{phase}_clone.wav`** β€” Voice cloning from celebrity reference
74
+
75
+ The reference audio is generated from the base model using a Morgan Freeman-style deep narration:
76
+ > *"Good morning. I want to tell you something about the universe. Every atom in your body came from a star that exploded. We are all made of star stuff."`
77
+
78
+ ## Existing Quantized Models on HuggingFace
79
+
80
+ | Model | Method | Size | Link |
81
+ |-------|--------|------|------|
82
+ | fishaudio/s2-pro | BF16 (original) | 10.8 GB | [Link](https://huggingface.co/fishaudio/s2-pro) |
83
+ | drbaph/s2-pro-fp8 | FP8 | 6.2 GB | [Link](https://huggingface.co/drbaph/s2-pro-fp8) |
84
+ | baicai1145/s2-pro-w4a16 | GPTQ INT4 | ~5.5 GB | [Link](https://huggingface.co/baicai1145/s2-pro-w4a16) |
85
+ | rodrigomt/s2-pro-gguf | GGUF (q2-q8) | 2.4-9.2 GB | [Link](https://huggingface.co/rodrigomt/s2-pro-gguf) |
86
+
87
+ ### GGUF Sizes (from rodrigomt/s2-pro-gguf)
88
+ | Quant | Size | Notes |
89
+ |-------|------|-------|
90
+ | f16 | 9.2 GB | Lossless |
91
+ | q8_0 | 5.2 GB | Near-lossless |
92
+ | q6_k | 4.2 GB | Minimal loss |
93
+ | q5_k_m | 3.8 GB | Slight loss |
94
+ | q4_k_m | 3.3 GB | Good tradeoff |
95
+ | q3_k | 2.8 GB | Noticeable loss |
96
+ | q2_k | 2.4 GB | Significant loss |
97
+
98
+ ## Quantization Details
99
+
100
+ ### FP8 (Phase 1a)
101
+ - **Method**: Per-row symmetric FP8 (float8_e4m3fn)
102
+ - **What's quantized**: All `nn.Linear` weights in Slow AR
103
+ - **What's kept in bf16**: Embeddings, layer norms, Fast AR, codec
104
+ - **Scale**: Per-row float32 (captures per-channel variation)
105
+ - **Dequant**: `W_bf16 = W_fp8.to(bfloat16) * scale`
106
+ - **Quality**: Zero perceptible loss
107
+
108
+ ### INT4 (Phase 1b)
109
+ - **Method**: Group-wise symmetric INT4 (group_size=128)
110
+ - **Range**: [-7, 7] per weight
111
+ - **Scale**: Per-group float32
112
+ - **Target**: Slow AR only (Fast AR + codec in bf16)
113
+ - **Quality**: Near-zero loss with group_size=128
114
+
115
+ ### INT3 (Phase 2c)
116
+ - **Method**: Group-wise symmetric INT3 (group_size=128)
117
+ - **Range**: [-3, 3] per weight
118
+ - **Expected**: Some quality loss, especially on prosody
119
+
120
+ ### INT2 (Phase 3)
121
+ - **Method**: Group-wise symmetric INT2 (group_size=64)
122
+ - **Range**: [-1, 0, 1] per weight (ternary!)
123
+ - **Expected**: Significant quality degradation
124
+
125
+ ## Files
126
+
127
+ ```
128
+ fish-speech-experiments/
129
+ β”œβ”€β”€ scripts/
130
+ β”‚ β”œβ”€β”€ quantize.py # Main quantization + sample generation script
131
+ β”‚ β”œβ”€β”€ run_all_phases.py # Alternative all-in-one script (for HF Jobs)
132
+ β”‚ └── upload_to_hub.py # Upload results to HuggingFace Hub
133
+ β”œβ”€β”€ output/ # Generated quantized models + samples
134
+ β”‚ β”œβ”€β”€ samples/ # Audio samples from each phase
135
+ β”‚ β”œβ”€β”€ phase1a/ # FP8 quantized model
136
+ β”‚ β”œβ”€β”€ phase1b/ # INT4 quantized model
137
+ β”‚ β”œβ”€β”€ phase2a/ # INT4 all layers
138
+ β”‚ β”œβ”€β”€ phase2b/ # INT8 quantized model
139
+ β”‚ β”œβ”€β”€ phase2c/ # INT3 quantized model
140
+ β”‚ β”œβ”€β”€ phase3a/ # INT2 quantized model
141
+ β”‚ β”œβ”€β”€ phase3b/ # INT2 all layers
142
+ β”‚ └── all_results.json # Combined results
143
+ β”œβ”€β”€ size_analysis.json # Theoretical size analysis
144
+ └── README.md # This file
145
+ ```
146
 
147
  ## Citation
148
+
149
  ```bibtex
150
  @misc{liao2026fishaudios2technical,
151
+ title={Fish Audio S2 Technical Report},
152
  author={Shijia Liao and Yuxuan Wang and others},
153
+ year={2026},
154
+ eprint={2603.08823},
155
+ archivePrefix={arXiv},
156
+ primaryClass={cs.SD},
157
  }
158
  ```
159
+
160
+ ## License
161
+
162
+ Quantized models inherit the [Fish Audio Research License](https://huggingface.co/fishaudio/s2-pro/blob/main/LICENSE.md).
163
+ Research and non-commercial use only.