Repository navigation
v0.2.0: Flash-Next long context (QSA), offload in ninfer-serve
New
- Long contexts for Qwen3.8-Flash-Next. Contexts above 2051 tokens now use the model's QSA token selection (each query attends to its 512 highest-scoring 4-token blocks plus the recent tail); previously
--max-contextwas capped at 2051. Requires the default--kv-dtype bf16and text-only input. Up to 2051 tokens attention is dense and unchanged. ninfer-serveaccepts--moe-offload(--moe-gpu-experts,--moe-threads,--moe-expert-stats,--moe-record-stats), so Flash-Next can run behind the OpenAI/Anthropic-compatible API. Recommended:--host-kv-mib 1024.ninfer-perplexity --token-nll FILEwrites per-token NLL.- Source tree: streaming conversion now downloads only the byte ranges the next jobs need and deletes them after use; the default cache is 20 GB (was effectively the whole checkpoint).
Measured (RTX 4060 Ti 16 GB, Xeon E5-2673 v3, ninfer-serve, 64 GPU experts, greedy):
- QSA selections equal an independent CPU oracle exactly in the operator test; a passkey placed at the start of a 3,352-token prompt is answered correctly; 24 greedy tokens after a 3,300-token prompt match the FP32 reference.
- 3,327-token prompt: 11.7 tok/s decode, 36 tok/s prefill. 1,777-token prompt: 11.7-11.9 tok/s with
--max-context 4096vs 11.8-12.0 with--max-context 2048(~1.2% cost); short prompts are 0.9-2.0% slower with--max-contextabove 2051, so keep 2048 if you do not need longer contexts. - Streaming conversion of Qwen3.6-35B-A3B with a 20 GB cache: 69.3 GB downloaded, peak cache 8.3 GB, result identical to the published artifact.
Download ninfer-offload-v0.2.0-linux-x86_64-sm89.tar.zst, then:
tar --zstd -xf ninfer-offload-v0.2.0-linux-x86_64-sm89.tar.zst
cd ninfer-offload-v0.2.0-linux-x86_64-sm89
./ninfer --helpRequirements unchanged (RTX 40-series sm_89, driver ≥ 570, glibc ≥ 2.38, AVX2; see README.md inside). Built from commit 4e54bfc with CUDA 12.8.90 and GCC 13.3 on Ubuntu 24.04. Tested only on the machine above. The prebuilt Flash-Next model on ModelScope works unchanged: https://modelscope.cn/models/mymodel3861/Qwen3.8-Flash-Next-NInfer-Offload
新增
- Qwen3.8-Flash-Next 支持长上下文。 超过 2051 个 token 时使用模型自带的 QSA token 选择(每个查询只看得分最高的 512 个 4-token 块和最近的尾部 token);之前
--max-context最多 2051。需要默认的--kv-dtype bf16,且只支持纯文本输入;2051 以内仍是原来的稠密注意力。 ninfer-serve支持--moe-offload(以及--moe-gpu-experts、--moe-threads、--moe-expert-stats、--moe-record-stats),Flash-Next 可以通过 OpenAI / Anthropic 兼容接口提供服务。建议加--host-kv-mib 1024。ninfer-perplexity --token-nll FILE可输出逐 token 的 NLL。- 源码:流式转换现在只下载接下来要用的字节范围,用完即删;默认缓存 20 GB(以前实际上会缓存几乎整个原版模型)。
实测(RTX 4060 Ti 16 GB,Xeon E5-2673 v3,ninfer-serve,64 个 GPU 专家,贪心解码):
- 算子测试中 QSA 选块结果与独立的 CPU 参考完全一致;放在 3352 token 提示词开头的密码能被正确答出;3300 token 后贪心生成的 24 个 token 与 FP32 参考一致。
- 3327 token 提示词:解码 11.7 tok/s,prefill 36 tok/s。1777 token 提示词:
--max-context 4096为 11.7~11.9 tok/s,--max-context 2048为 11.8~12.0(约 1.2% 代价);短提示词在上限超过 2051 时慢 0.9~2.0%,不需要长上下文时可继续用 2048。 - Qwen3.6-35B-A3B 流式转换(缓存上限 20 GB):下载 69.3 GB,缓存峰值 8.3 GB,结果与官方发布的模型一致。
下载 ninfer-offload-v0.2.0-linux-x86_64-sm89.tar.zst 后:
tar --zstd -xf ninfer-offload-v0.2.0-linux-x86_64-sm89.tar.zst
cd ninfer-offload-v0.2.0-linux-x86_64-sm89
./ninfer --help运行要求不变。只在上述机器上测试过。ModelScope 上的 Flash-Next 预转换模型无需更新即可使用。