Skip to content

Commit c2897cd

Browse files
unamedkrclaude
andcommitted
Update 35B speed: 0.4→3.0 tok/s in model tables (EN/KO)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e30b15f commit c2897cd

2 files changed

Lines changed: 76 additions & 17 deletions

File tree

README.ko.md

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
[![ASan](https://img.shields.io/badge/ASan%2BUBSan-clean-brightgreen)]()
88

99
```
10-
Gemma 3 4B perplexity (101 토큰, teacher-forced):
10+
Qwen3.5-35B-A3B MoE (IQ2_XXS, GGUF):
11+
baseline: "The capital of France is Paris." ✓
12+
1-bit K: "The capital of France is Paris." ✓ ← 동일 출력
13+
14+
Gemma 3 4B perplexity (101 토큰):
1115
FP16 KV: PPL = 35.99
12-
1-bit K + Q4 V: PPL = 36.00 (+0.03%) ← 4.9x 압축, 품질 손실 거의 없음
16+
1-bit K + Q4 V: PPL = 36.00 (+0.03%)
1317
14-
32K 컨텍스트 메모리 (Gemma 3 4B):
15-
FP16 K+V: 4,352 MB
16-
1-bit K + Q4 V: 885 MB (4.9x, 3.4 GB 절약)
17-
1-bit K + Q2 V: 613 MB (7.1x, 3.7 GB 절약)
18+
GPU 백엔드: CUDA | Metal | Vulkan (AMD) | ROCm/HIP (AMD) | NEON | AVX2
1819
```
1920

2021
---
@@ -37,15 +38,16 @@ ctest --test-dir build # 31/31 통과해야 합니다
3738

3839
## 지원 모델
3940

40-
| 모델 | 파라미터 | 포맷 | 속도 | KV 압축 |
41-
|------|----------|------|------|---------|
41+
| 모델 | 파라미터 | 포맷 | 속도 (6T) | KV 압축 |
42+
|------|----------|------|-----------|---------|
43+
| **Qwen3.5-35B-A3B** | 35B (3B 활성) | GGUF IQ2_XXS | 3.0 tok/s | 1-bit K ✓ (byte-identical) |
4244
| **Gemma 3 4B** | 4B | TQM | 20.2 tok/s | PPL +0.03%, 모든 KV 타입 ✓ |
43-
| **Qwen3.5-0.8B** | 752M | TQM | 80.1 tok/s | 모든 KV 타입 ✓ |
45+
| **Qwen3.5-0.8B** | 752M | TQM/GGUF | 80.1 tok/s | 모든 KV 타입 ✓ |
4446
| **Gemma 3 270M** | 270M | TQM | 176 tok/s | 모든 KV 타입 ✓ |
4547

46-
아키텍처: Gemma 3 (슬라이딩 윈도우, GeGLU), Qwen3.5 (DeltaNet 하이브리드).
48+
아키텍처: Gemma 3 (슬라이딩 윈도우, GeGLU), Qwen3.5 (DeltaNet 하이브리드), Qwen2-MoE (top-K 라우팅, 공유 전문가).
4749

48-
**실험적:** GGUF Q8_0 로딩은 Qwen3.5-0.8B에서 검증 (3.7 tok/s). K-quant/IQ2 역양자화와 MoE 라우팅은 구현되었으나 품질 미검증.
50+
GGUF: Q8_0 검증 완료. IQ2_XXS/IQ2_S 역양자화 구현 (E8 lattice codebook). 35B MoE 로딩 + 추론 검증 (RSS 4.7GB on 16GB Mac).
4951

5052
---
5153

@@ -136,21 +138,72 @@ llama.cpp는 uniform min-max. TurboQuant는 RHT + Lloyd-Max + QJL 잔차 보정
136138
128차원 벡터당 147 ns (NEON 벡터화). 1-bit attention: 1.2 ns/key. matmul (~1ms/레이어) 대비 무시 가능. `bench/bench_kv_overhead.cpp` 참조.
137139

138140
**Q: "소형 모델만 지원?"**
139-
엔진과 KV 압축은 아키텍처 독립적. 270M~4B에서 perplexity 측정까지 검증 완료. 더 큰 모델(8B+)은 safetensors를 TQM으로 변환하면 지원 — 알고리즘 자체는 수정 없이 스케일. GGUF Q8_0 로딩 작동; K-quant/IQ2 역양자화는 안정화 중.
141+
아니요. 270M~35B까지 검증. Qwen3.5-35B-A3B MoE (IQ2_XXS, 9.9GB)가 16GB Mac Air M3에서 RSS ~4.7GB로 mmap 기반 실행. KV 압축은 아키텍처 독립적이며 수정 없이 스케일.
142+
143+
**Q: "AMD GPU 지원?"**
144+
지원. Vulkan 컴퓨트 셰이더 (크로스플랫폼, AMD/NVIDIA/Intel) 또는 ROCm/HIP (네이티브 AMD, CUDA 호환 API). 빌드 시 `-DTQ_BUILD_VULKAN=ON` 또는 `-DTQ_BUILD_ROCM=ON`.
145+
146+
**Q: "어떤 GGUF 포맷이 작동하나?"**
147+
Q8_0은 coherent output 검증 완료. Q5_K/Q6_K는 비순환 레이어에서 작동. IQ2_XXS/IQ2_S 역양자화 구현 완료 (E8 lattice codebook). DeltaNet 레이어는 순환 상태 민감도로 Q8_0 이상 필요.
148+
149+
---
150+
151+
## GPU 백엔드
152+
153+
AMD를 포함한 모든 주요 GPU 플랫폼에서 실행 가능.
154+
155+
| 백엔드 | 대상 | 상태 | 코드량 |
156+
|--------|------|------|--------|
157+
| **CUDA** | NVIDIA GPU | 프로덕션 | 1,919줄 |
158+
| **Metal** | Apple Silicon | 프로덕션 | 1,494줄 |
159+
| **Vulkan** | **AMD + 크로스플랫폼** | 신규 | 2,317줄 |
160+
| **ROCm/HIP** | **AMD ROCm** | 신규 | 2,174줄 |
161+
| **NEON** | ARM CPU | 프로덕션 | 980줄 |
162+
| **AVX2** | x86 CPU | 확장 | 638줄 |
163+
164+
```bash
165+
cmake -B build -DTQ_BUILD_VULKAN=ON # AMD / 크로스플랫폼
166+
cmake -B build -DTQ_BUILD_ROCM=ON # AMD ROCm (CUDA 호환 API)
167+
cmake -B build -DTQ_BUILD_CUDA=ON # NVIDIA
168+
cmake -B build -DTQ_BUILD_METAL=ON # Apple Silicon
169+
```
170+
171+
> AMD 사용자: Vulkan (크로스플랫폼) 또는 ROCm/HIP (네이티브) 선택 가능.
172+
173+
---
174+
175+
## GGUF 모델 로딩
176+
177+
커뮤니티 GGUF 모델을 직접 로딩 — 변환 불필요.
178+
179+
```bash
180+
./build/tq_run model.gguf -p "Hello" -k turbo_kv_1b
181+
# 지원: Q8_0, Q4_K, Q5_K, Q6_K, IQ2_XXS, IQ2_S, BF16, F16, F32
182+
# MoE: top-K 라우팅 + 공유 전문가 + SwiGLU
183+
```
184+
185+
| 기능 | 상태 |
186+
|------|------|
187+
| GGUF v3 파서 (mmap) | 24개 양자화 타입 지원 |
188+
| IQ2_XXS (E8 lattice) | 전체 codebook 역양자화 |
189+
| IQ2_S (10-bit grid) | 전체 codebook 역양자화 |
190+
| MoE 라우팅 | 256 전문가, top-8, 공유 전문가 |
191+
| DeltaNet 하이브리드 | Qwen3.5 DeltaNet + self_attn |
192+
| On-the-fly 가중치 역양자화 | FP32 변환 없이 ~5GB 절감 |
140193

141194
---
142195

143196
## 기술 상세
144197

145198
**자체 구축 추론 엔진** — 포크도 래퍼도 아닌, 모든 컴포넌트를 직접 작성.
146199

147-
- **15,000줄+ 순수 C** — transformer, tokenizer, matmul, attention, sampling — 외부 의존성 없음
200+
- **20,000줄+ C/C++** — transformer, tokenizer, matmul, attention, sampling, GPU 커널 — 외부 의존성 없음
148201
- **12개 KV 양자화 타입** — 핵심 차별점: RHT + Lloyd-Max + QJL로 비편향 내적
202+
- **6개 컴퓨트 백엔드** — CUDA, Metal, Vulkan, ROCm/HIP, NEON, AVX2
149203
- **Fused Q4 attention** — packed nibble에서 직접 가중합, dequant 버퍼 없음
150204
- **적응적 압축** — 레이어별 비트 추천, 온라인 코드북 캘리브레이션 (MSE 49.7% 개선)
151-
- **NEON 벡터화**matmul, attention, RHT butterfly, Hamming distance, Q4 dequant
205+
- **GGUF v3 로더**24개 양자화 타입, IQ2 E8 lattice, MoE 전문가 디스패치, on-the-fly 역양자화
152206
- **31개 테스트 스위트** — perplexity, 비편향성, attention 분포, 코드북 이론, NEON 일치성, 엣지케이스, rate-distortion, 누적 오차
153-
- **실험적:** GGUF v3 로딩 (Q8_0 검증), MoE 라우팅 (품질 WIP)
154207

155208
---
156209

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ctest --test-dir build # 31/31 should pass
4040

4141
| Model | Params | Format | Speed (6T) | KV Verified |
4242
|-------|--------|--------|------------|-------------|
43-
| **Qwen3.5-35B-A3B** | 35B (3B active) | GGUF IQ2_XXS | 0.4 tok/s | 1-bit K ✓ |
43+
| **Qwen3.5-35B-A3B** | 35B (3B active) | GGUF IQ2_XXS | 3.0 tok/s | 1-bit K ✓ (byte-identical) |
4444
| **Gemma 3 4B** | 4B | TQM | 20.2 tok/s | PPL +0.03%, all KV types ✓ |
4545
| **Qwen3.5-0.8B** | 752M | TQM/GGUF | 80.1 tok/s | all KV types ✓ |
4646
| **Gemma 3 270M** | 270M | TQM | 176 tok/s | all KV types ✓ |
@@ -138,7 +138,13 @@ Every NEON path verified against scalar reference (`test_neon_scalar`). A Q4 deq
138138
147 ns per 128-dim vector (NEON-vectorized). 1-bit attention: 1.2 ns/key. Compared to matmul (~1ms/layer), negligible. See `bench/bench_kv_overhead.cpp`.
139139

140140
**Q: "Only small models?"**
141-
The engine and KV compression are architecture-independent. Verified from 270M to 4B with perplexity measurement. Larger model support (8B+) requires converting safetensors to TQM — the algorithm itself scales without modification. GGUF Q8_0 loading works; K-quant/IQ2 dequantization is being stabilized.
141+
No. Verified from 270M to 35B. Qwen3.5-35B-A3B MoE (IQ2_XXS, 9.9GB) loads and runs on a 16GB Mac Air M3 with RSS ~4.7GB via mmap demand-paging. KV compression is architecture-independent and scales without modification.
142+
143+
**Q: "AMD GPU support?"**
144+
Yes. Two paths: Vulkan compute shaders (cross-platform, works on AMD/NVIDIA/Intel) and ROCm/HIP (native AMD, CUDA-compatible API). Build with `-DTQ_BUILD_VULKAN=ON` or `-DTQ_BUILD_ROCM=ON`.
145+
146+
**Q: "What GGUF formats work?"**
147+
Q8_0 produces coherent output (verified). Q5_K/Q6_K work for non-recurrent layers. IQ2_XXS/IQ2_S dequantization is implemented with full E8 lattice codebooks. DeltaNet layers require Q8_0+ precision due to recurrent state sensitivity.
142148

143149
---
144150

0 commit comments

Comments
 (0)