gasschina commited on
Commit
e06e376
·
verified ·
1 Parent(s): b1194a9

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +31 -27
README.md CHANGED
@@ -20,19 +20,19 @@ tags:
20
 
21
  Everything needed to run **iFlytek Spark-X2.5-4B** on an NVIDIA T4 (16GB) with llama.cpp:
22
  a prebuilt CUDA binary (XHToken fork — the `spark2_5` architecture is **not** supported by mainline llama.cpp),
23
- Q8_0 / Q4_K_M model weights, a **1.7B draft model for speculative decoding** (+41% throughput, 0.89 acceptance rate),
24
  and battle-tested one-click scripts (256k-context OpenAI-compatible API + public tunnel).
25
 
26
- > Verified end-to-end on 2026-09-06: streaming, native tool calling (`--jinja`), thinking mode,
27
- > and a real agent workload (84-tool zagent, 12 consecutive tool calls, 240k prompt tokens, zero failures).
28
 
29
  ## What's in this repo
30
 
31
  | File | Size | Description |
32
  |------|------|-------------|
33
  | `llama.cpp-spark-build-t4-cuda.tar.gz` | 242MB | Prebuilt llama.cpp (XHToken fork) for CUDA / SM 7.5: `llama-server` + all runtime libs |
34
- | `Spark-X2.5-4B-Q8_0.gguf` | 4.37GB | 8-bit quant (near-F16 quality) — **default** |
35
- | `Spark-X2.5-4B-Q4_K_M.gguf` | 2.60GB | 4-bit quant for extreme long context |
36
  | `Spark-X2.5-1.7B-Q8_0.gguf` | 1.82GB | Draft model (same tokenizer, same `spark2_5` arch) for speculative decoding |
37
  | `scripts/oneclick_start.sh` | – | One-click: checks → serve → tunnel → self-test |
38
  | `scripts/spark_api.sh` | – | OpenAI-compatible API manager (start / stop / status / test) |
@@ -64,29 +64,31 @@ The launcher prints the local endpoint, public tunnel URL, and API key when done
64
  Model weights live on Colab local disk (`/content/spark-t4-models`), never eating into the
65
  15GB Drive quota; the build and scripts persist on Drive across sessions.
66
 
67
- ## Default config (v3): Q8_0 + 1.7B speculative decoding @ 256k
68
 
69
  | Item | Value | Notes |
70
  |------|-------|-------|
71
- | Weights | Q8_0 (4.37GB) | near-F16 quality |
72
- | Speculative decoding | 1.7B-Q8_0 draft, `draft-simple` | **acceptance 0.891, 52.3 tok/s (+41%)** |
73
- | Context | **262,144 (256k)** | draft KV/compute buffers inherit main ctx; >300k OOMs |
74
- | KV quant | q4_0 (main + draft) | via `-ctk/-ctv` |
75
- | VRAM | **11.8GB / 15.36GB** | ~3.5GB headroom |
76
- | Throughput | **52.3 tok/s** | vs 37.1 tok/s without draft (same weights) |
77
- | Attention | `-fa on` + `-b 512 -ub 512` | Turing requires flash attention for KV quant |
78
  | Auth | auto-generated key → Drive `.api_key` | `API_KEY=off` to disable |
79
- | Thinking mode | on by default | see API section to disable |
80
 
81
- Speculative decoding is **on by default** in the scripts; the draft model is auto-downloaded
82
- from this repo if missing. Turn it off for long-context mode:
83
 
84
  ```bash
85
- DRAFT_MODEL= CTX=500000 bash oneclick_start.sh # 500k long-context: 37 tok/s, 11.8GB
86
- DRAFT_MODEL= QUANT=Q4_K_M CTX=786432 bash oneclick_start.sh # 768k extreme: 14.3GB, 52 tok/s
 
87
  ```
88
 
89
  > 1M context physically does not fit on a T4: 1M KV@q4_0 alone needs ~13GB before weights.
 
 
90
 
91
  ## Benchmarks (T4, greedy, 384-token generations, /completion timings)
92
 
@@ -94,14 +96,16 @@ DRAFT_MODEL= QUANT=Q4_K_M CTX=786432 bash oneclick_start.sh # 768k extreme:
94
  |--------|---------|------|-----------|
95
  | Q8_0, no draft (baseline) | 500k | 11.8GB | 37.1 tok/s |
96
  | **Q8_0 + 1.7B-Q8_0 draft** | **256k** | **11.8GB** | **52.3 tok/s (+41%)** |
97
- | Q8_0 + draft, n_max=16 | 256k | 11.8GB | 52.6 tok/s (no gain over 8) |
98
  | Q4_K_M, no draft | 500k | 10.1GB | 51.7 tok/s |
 
99
  | Q4_K_M + draft | 500k | OOM | draft compute buffer ~1.5GB |
100
  | ngram-simple (self-speculation) | 500k | +0GB | 37.5 tok/s (no gain on prose) |
101
 
102
- Takeaway: the T4 is memory-bandwidth-bound. Q8_0 + draft reaches bare-Q4_K_M speed while keeping
103
- the exact Q8_0 output distribution (drafting never changes the target distribution). If you need
104
- 500k context, drop the draft; if you want raw speed without drafting, use Q4_K_M.
 
105
 
106
  ## MTP status (why classic drafting)
107
 
@@ -109,8 +113,8 @@ llama.cpp already ships `draft-mtp` / `draft-eagle3` / `draft-dspark` speculativ
109
  require matching trained heads. Spark-X2.5-4B publishes no MTP/nextn/EAGLE weights
110
  (`num_nextn_predict_layers` is absent from its config), and the fork's `spark2_5` backend has no
111
  nextn implementation. Classic draft-model speculation with the official same-vocabulary (131,072)
112
- 1.7B sibling is the best available option — and it works well: **0.891 acceptance, mean accepted
113
- length 8.13 tokens**.
114
 
115
  ## API usage (OpenAI-compatible)
116
 
@@ -127,8 +131,8 @@ r = requests.post(f"{BASE}/v1/chat/completions",
127
  print(r.json()["choices"][0]["message"]["content"])
128
  ```
129
 
130
- - **Streaming**: add `"stream": true` (SSE)
131
- - **Disable thinking** (faster, no reasoning block): add `"chat_template_kwargs": {"enable_thinking": false}`
132
  - **Tool calling**: pass a standard OpenAI `tools` array (`--jinja` enables native function calling)
133
 
134
  ## Why this build exists
@@ -140,4 +144,4 @@ community i1 quant; the 1.7B draft quantized in-house (Q8_0) from the official F
140
 
141
  ## 中文速览
142
 
143
- 讯飞星火 Spark-X2.5-4B 在 Colab T4 上的完整 llama.cpp 运行包:CUDA 编译产物 + Q8_0/Q4_K_M 权重 + 1.7B 草稿模型 + 一键脚本。默认配置 = Q8_0 + 1.7B 草稿投机解码 @256k 上下文实测 52.3 tok/s,+41%,接受率 0.891,显存 11.8GB;需要 500k 长上下文时用 `DRAFT_MODEL= CTX=500000` 关闭草稿三分钟起步见上方 Quick start;API 为 OpenAI 兼容格式(/v1/chat/completions),模型名 `spark-x2.5-4b`。
 
20
 
21
  Everything needed to run **iFlytek Spark-X2.5-4B** on an NVIDIA T4 (16GB) with llama.cpp:
22
  a prebuilt CUDA binary (XHToken fork — the `spark2_5` architecture is **not** supported by mainline llama.cpp),
23
+ Q8_0 / Q4_K_M model weights, a **1.7B draft model** (boosts the Q8_0 config by +41%, 0.89 acceptance),
24
  and battle-tested one-click scripts (256k-context OpenAI-compatible API + public tunnel).
25
 
26
+ > Verified end-to-end on 2026-09-06: streaming, native tool calling (`--jinja`), and a real agent
27
+ > workload (84-tool zagent, 12 consecutive tool calls, 240k prompt tokens, zero failures).
28
 
29
  ## What's in this repo
30
 
31
  | File | Size | Description |
32
  |------|------|-------------|
33
  | `llama.cpp-spark-build-t4-cuda.tar.gz` | 242MB | Prebuilt llama.cpp (XHToken fork) for CUDA / SM 7.5: `llama-server` + all runtime libs |
34
+ | `Spark-X2.5-4B-Q8_0.gguf` | 4.37GB | 8-bit quant (near-F16 quality) — pairs best with the draft model |
35
+ | `Spark-X2.5-4B-Q4_K_M.gguf` | 2.60GB | 4-bit quant **default**: fastest, most VRAM headroom |
36
  | `Spark-X2.5-1.7B-Q8_0.gguf` | 1.82GB | Draft model (same tokenizer, same `spark2_5` arch) for speculative decoding |
37
  | `scripts/oneclick_start.sh` | – | One-click: checks → serve → tunnel → self-test |
38
  | `scripts/spark_api.sh` | – | OpenAI-compatible API manager (start / stop / status / test) |
 
64
  Model weights live on Colab local disk (`/content/spark-t4-models`), never eating into the
65
  15GB Drive quota; the build and scripts persist on Drive across sessions.
66
 
67
+ ## Default config (v5): Q4_K_M bare @ 256k, tuned for agent platforms
68
 
69
  | Item | Value | Notes |
70
  |------|-------|-------|
71
+ | Weights | Q4_K_M (2.60GB) | 4-bit fastest, most headroom |
72
+ | Speculative decoding | **off** | ⚠️ 4-bit quantization noise drops draft acceptance 0.89 → 0.37-0.61; measured **27 tok/s (slower than bare!)**. Drafting only pays off on Q8_0 |
73
+ | Context | **262,144 (256k)** | 500k available at the same speed (51.7 tok/s / 10.1GB) |
74
+ | KV quant | q4_0 | via `-ctk/-ctv` |
75
+ | VRAM | **6.6GB / 15.36GB** | 8.8GB headroom |
76
+ | Throughput | **48.75 tok/s** | prefill 790 tok/s; Q8_0+draft does 52.3 tok/s |
77
+ | Thinking mode | **server-side off by default** | ⚠️ the aitun tunnel hard-kills silent non-streaming requests at **120s 504**; thinking adds 30–90s of silence. Re-enable per request with `"chat_template_kwargs": {"enable_thinking": true}` |
78
  | Auth | auto-generated key → Drive `.api_key` | `API_KEY=off` to disable |
 
79
 
80
+ Draft policy is automatic by quant tier: `QUANT=Q8_0` attaches the 1.7B draft (acceptance 0.89,
81
+ **52.3 tok/s, 11.8GB**); 4-bit runs bare. Override with `SPEC_TYPE=draft-simple` / `SPEC_TYPE=none`.
82
 
83
  ```bash
84
+ QUANT=Q8_0 bash oneclick_start.sh # quality + draft: 52.3 tok/s, 11.8GB
85
+ CTX=500000 bash oneclick_start.sh # 500k long-context, same speed, 10.1GB
86
+ QUANT=Q4_K_M CTX=786432 bash oneclick_start.sh # 768k extreme, 14.3GB
87
  ```
88
 
89
  > 1M context physically does not fit on a T4: 1M KV@q4_0 alone needs ~13GB before weights.
90
+ > Single slot (`-np 1`): concurrent requests queue behind long agent replies. On agent platforms
91
+ > (aicq.me etc.) prefer streaming and keep `max_tokens` ≤ 2000.
92
 
93
  ## Benchmarks (T4, greedy, 384-token generations, /completion timings)
94
 
 
96
  |--------|---------|------|-----------|
97
  | Q8_0, no draft (baseline) | 500k | 11.8GB | 37.1 tok/s |
98
  | **Q8_0 + 1.7B-Q8_0 draft** | **256k** | **11.8GB** | **52.3 tok/s (+41%)** |
99
+ | Q4_K_M, no draft (v5 default) | 256k | 6.6GB | 48.75 tok/s |
100
  | Q4_K_M, no draft | 500k | 10.1GB | 51.7 tok/s |
101
+ | Q4_K_M + draft | 256k | ~10.1GB | **27.2 tok/s (anti-optimization! acceptance 0.37-0.61)** |
102
  | Q4_K_M + draft | 500k | OOM | draft compute buffer ~1.5GB |
103
  | ngram-simple (self-speculation) | 500k | +0GB | 37.5 tok/s (no gain on prose) |
104
 
105
+ Takeaway: the T4 is memory-bandwidth-bound. Drafting is a *distribution-matching* game with a
106
+ near-lossless Q8_0 target the 1.7B sibling hits 0.89 acceptance (+41%), but a 4-bit target's
107
+ argmax flips too often and drafting goes net-negative. Gateway note: the free aitun tunnel
108
+ terminates non-streaming requests at exactly **120s** (reproduced); streaming is immune.
109
 
110
  ## MTP status (why classic drafting)
111
 
 
113
  require matching trained heads. Spark-X2.5-4B publishes no MTP/nextn/EAGLE weights
114
  (`num_nextn_predict_layers` is absent from its config), and the fork's `spark2_5` backend has no
115
  nextn implementation. Classic draft-model speculation with the official same-vocabulary (131,072)
116
+ 1.7B sibling is the best available option: **0.891 acceptance, mean accepted length 8.13 tokens**
117
+ on the Q8_0 target.
118
 
119
  ## API usage (OpenAI-compatible)
120
 
 
131
  print(r.json()["choices"][0]["message"]["content"])
132
  ```
133
 
134
+ - **Streaming**: add `"stream": true` (SSE) — strongly recommended behind tunnels/gateways
135
+ - **Thinking mode** (server-side off by default): add `"chat_template_kwargs": {"enable_thinking": true}`
136
  - **Tool calling**: pass a standard OpenAI `tools` array (`--jinja` enables native function calling)
137
 
138
  ## Why this build exists
 
144
 
145
  ## 中文速览
146
 
147
+ 讯飞星火 Spark-X2.5-4B 在 Colab T4 上的完整 llama.cpp 运行包。**默认配置 v5 = Q4_K_M 裸跑 @256k 上下文 + 思考默认关**(实测 48.75 tok/s,显存仅 6.6GB)——为 aicq.me 等智能体平台调优:aitun 隧道对非流式请求有 120s 硬超时(开思考必 504),故思考默认关闭、单请求可传 `enable_thinking:true` 恢复;草稿投机解码只对 Q8_0 有正收益(+41%,接受率 0.89`QUANT=Q8_0` 时自动挂载,4bit 档实测反而慢一半已自动关闭。API 为 OpenAI 兼容格式,模型名 `spark-x2.5-4b`,智能体平台建议开流式、max_tokens ≤2000