
QSA Paper | GitHub | Engine + Build | Runtime Guide | Indexer training | GGUF Model Series | Unsloth GGUF | X | License
Qwen3.8-27B QSA - BF16 source weights (indexer v2)
The original 18 backbone, vision, and MTP shards are byte-for-byte unchanged from Qwen/Qwen3.8-27B. This release adds 52,434,944 FP32 indexer parameters to the 16 full-attention layers. The other 48 decoder layers retain their original Gated DeltaNet architecture. Training left the backbone, vision encoder, projector, and MTP weights unchanged.
Indexer v2 (2026-11-19).
indexers/qsa_indexers.ptandqsa-indexers.safetensorsnow hold the v2 indexer. No other weight file changed. On a held-out 240-question structured-recall test at 128k context, v2 answered 215 questions correctly with thinking off, 27.2% more than v1 (169); dense attention answered 227. All three used the Q8_0 GGUF. The v1 files remain available as the revisionv1.
Indexer files
| File | Format | SHA256 (v2) |
|---|---|---|
indexers/qsa_indexers.pt | Trainer format: {layer_index: state_dict} | 6a6bb0decc88f3a8d411e423069f6634f2a5a69d832853ddf9b6504535d136bc |
qsa-indexers.safetensors | model.language_model.layers.{L}.self_attn._qsa_indexer.{q_proj.weight,k_proj.weight,q_norm,k_norm,k_block_norm}, F32 | 985345467f60a2c0ae6cf9d8c875ce36d6a6da4aef4aa7428e04e457e4aad6d4 |
Both files hold the same weights, with the same keys, shapes, dtype, and key order as v1. Norm weights are zero-centred (the GGUF format stores 1 + weight). The GGUF model series carries the same 80 tensors.
To load v1 instead, pass revision="v1" to from_pretrained, or download indexers/qsa_indexers.pt at revision v1 (SHA256 e44193e5…).
What changed in v2
v1 was trained only at length 16,384: text distillation first, then 300 steps with a 50% multimodal mix and synthetic OCR, table, and shape tasks. Its training source snapshot is under research/. v2 continues from v1 in two text-only stages aimed at long-context recall:
- Stage 1: 300 steps at 16,384 tokens, adding two terms to the dense-attention distillation: one rewards attention mass on the records a question needs, and one asks those records to outscore look-alike decoys.
- Stage 2: 300 steps at 65,536 tokens, labelling every token of the needed and decoy records, with more weight on the decoy margin and on question types where look-alike records are common.
Training details are in How v2 was trained.
Long-context recall: v1 vs v2
With K=2,048 tokens at 128k context, the indexer can show the attention layers only about 1.6% of the context. Most v1 errors on structured recall came from that narrow budget: the model answered with a look-alike record (a key differing by one character, or a neighbouring record) or assembled the wrong set of records.
| Indexer | Thinking off | Thinking low |
|---|---|---|
| v1 | 169/240 (70.4%) | 185/240 (77.1%) |
| v2 stage 1 only (not released) | 191/240 (79.6%) | 211/240 (87.9%) |
| v2 | 215/240 (89.6%) | 218/240 (90.8%) |
| Dense attention (upper reference) | 227/240 (94.6%) | 232/240 (96.7%) |
Improvement of v2 over v1:
| Measure | Thinking off | Thinking low |
|---|---|---|
| Correct answers | +46 (+27.2%) | +33 (+17.8%) |
| Accuracy | +19.2 points | +13.8 points |
| Wrong answers | 71 to 25 (64.8% fewer) | 55 to 22 (60.0% fewer) |
| Share of the v1-to-dense gap closed | 79.3% | 70.2% |
| Comparison (paired exact McNemar, questions only one side answered correctly) | Thinking off | Thinking low |
|---|---|---|
| v2 vs v1 | 55 vs 9, p = 3.5e-9 | 39 vs 6, p = 5.4e-7 |
| v2 vs dense | 7 vs 19, p = 0.029 | 6 vs 20, p = 0.009 |
With thinking off, look-alike-record errors fell from 26 (v1) to 9 (dense: 5), and wrong-record-set errors from 25 to 9 (dense: 2). Dense attention remains significantly better.
How this was measured:
- Test set: an internal recall-grid set of 240 questions (8 question types × 10 depths × 3), planted in about 127k tokens of PG-19 validation and test books that were not used in training. It was used only for validation and is not published.
- Setup: the Q8_0 GGUF of this release with pentaCoxian/Qwen-QSA-llama.cpp at
70b4e14, built for sm_80, one A100 80GB, context 262,144, FP16 KV, MTP draft 2, K=2,048, greedy decoding, maximum output 65,536 tokens. Only the indexer differed between runs. This is not a result of the Transformers reference wrapper. - Thinking off disables the reasoning block. Thinking low uses the chat template's
reasoning_effort: "low". - Each model was run once. For the same weights, about 6 of 240 answers changed between repeated runs.
Not yet verified for v2
- Images and video. v2's two stages used text only. Multimodal quality with v2 has not been measured. In the Transformers reference, image and video conversations use dense attention, so they do not use the indexer.
- Other lengths and general text. Recall at 16k–64k and beyond 128k, general-text perplexity, and standard benchmarks have not been measured for v2.
- Quantized variants. UD-Q4_K_M was measured on the same 240 questions with the recommended engine on two V100s: 217 correct with thinking off and 209 with thinking low (v2 Q8_0 above: 215 and 218; paired p = 0.80 and 0.064). Quantization, GPU type and engine all differed between those runs. Details are in the GGUF repository. UD-Q5_K_M and UD-Q6_K were checked at the tensor level and with a short run, not with the 240-question test.
- Q8_0 on the recommended engine. The Q8_0 scores above used pentaCoxian/Qwen-QSA-llama.cpp at
70b4e14, which has the same llama.cpp base (6209237) as Qwen3.8-27B QSA for llama.cpp but differs in 15 code files. With the recommended engine, v2 UD-Q4_K_M was measured on the 240-question test. On 2026-11-20 it was also started on one V100 (GPU guide example) and as a source build for sm_80 on an A100; both used the sparse route for text and images and gave consistent answers to short Japanese, English, code and image prompts. v2 Q8_0 has not been run on the 240-question test with the recommended engine. - The "Limited quality checks" and throughput sections below were measured with v1.
QSA in brief
Qwen Sparse Attention (QSA) uses a learned, compressed indexer to select context in four-token blocks. The 16 full-attention layers in this 27B adaptation use fixed K=2,048 plus the current block. All original KV entries are retained, so this is not KV-cache compression. The 12.5% figure describes K at 16k, not a constant ratio at every context length; at 128k, K covers about 1.6% of the context. The architecture reference is On the Design of Qwen3.8-Next Architecture: Evaluation, Efficiency, and Training Stability.

Original Qwen3.8-27B (left) and the QSA adaptation with 16 learned indexers (right).
Quantized model series
The GGUF model series contains the Q8_0 conversion and three Unsloth mixed-precision variants. These are separate artifacts from this BF16 repository. All four carry the v2 indexer.
| Variant | Source | Size |
|---|---|---|
| Q8_0 | Conversion from this QSA BF16 release | 29.26 GB |
| Unsloth UD-Q4_K_M | Unsloth mixed-precision tensors plus the same FP32 indexers | 16.67 GB |
| Unsloth UD-Q5_K_M | Unsloth mixed-precision tensors plus the same FP32 indexers | 19.98 GB |
| Unsloth UD-Q6_K | Unsloth mixed-precision tensors plus the same FP32 indexers | 22.19 GB |
The Unsloth variants reuse 866 original tensors from unsloth/Qwen3.8-27B-GGUF byte-for-byte and add the same 80 FP32 QSA indexer tensors. No retraining or requantization was performed after adding the indexers. UD denotes mixed precision, not a uniform bit depth for every tensor.
Two execution paths
The Transformers wrapper in this repository is a correctness reference. Text uses an SDPA mask, image and video conversations use dense attention, and MTP execution is not implemented. This wrapper does not provide native sparse-kernel speed.
For deployment, select a GGUF variant and use Qwen3.8-27B QSA for llama.cpp. The engine supports native text, image, and video QSA with M-RoPE, MTP with up to two draft tokens, and prefix-cache reuse. Stock llama.cpp does not support these QSA files. See the runtime guide for model selection, build, and launch instructions.
When launching, set QSA_MODEL to the selected GGUF filename, for example:
QSA_MODEL=Qwen3.8-27B-QSA-Unsloth-UD-Q5_K_M.gguf QSA_MODEL_DIR=/path/to/gguf ./qsa27b-runtime/launch.sh
Reference loading
Install requirements.txt. The captured Python environment used torch 2.14.1+cu126 and torchvision 0.29.1+cu126; the native runtime separately uses CUDA 12.9. Inspect the packaged custom code before enabling it.
from transformers import AutoModelForImageTextToText, AutoProcessor
path = "higa2515/Qwen3.8-27B-QSA-BF16"
processor = AutoProcessor.from_pretrained(path, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
path, trust_remote_code=True, dtype="auto", device_map="auto",
attn_implementation="sdpa",
)
Add revision="v1" to both calls to load the v1 indexer.
Restore the original model
original/ contains the pinned official metadata, including the original config, weight index, processor, tokenizer, license, and model card. The additional QSA shard is excluded by the original index. After downloading this complete repository:
python restore_original.py --source . --output ../Qwen3.8-27B-original
The tool verifies all original LFS hashes and then creates a separate, dense, standard HF snapshot, hard-linking large unchanged weights where possible. It refuses to overwrite an existing output directory.
How v2 was trained
The backbone, vision encoder, projector, and MTP weights were frozen. Only the indexer (16 layers × 5 tensors, 52,434,944 FP32 parameters) was trained, in two stages starting from v1.
| Stage 1 | Stage 2 | |
|---|---|---|
| Start | v1 | Stage 1 |
| Steps × sequence length | 300 × 16,384 tokens | 300 × 65,536 tokens |
| Data | About 240 synthetic recall questions, one 16,384-token record document per step (8 question types, Python standard-library source as background text), and 60 FineWeb-Edu sequences | 300 synthetic questions in 100 documents of about 63k tokens, with PG-19 training-split books as background text |
| Question mix | Roughly even across the 8 types (23–36 each) | Weighted toward look-alike cases: pointer 86, revision 71, code 41, guid 31, ingredients 20, binding 19, join 16, quantities 16 |
| Labels | First token of each record needed for the answer, and of decoy records | Every token of the answer records and of the one-character decoy records |
| Teacher loss | KL to the dense block-attention teacher over all blocks and positions | KL within the 512 selected blocks with the teacher renormalised (QSA paper, Eq. 20), at all question tokens and 4,096 random document positions per step |
| Answer-mass weight λ | 0.3 | 0.3 |
| Decoy-margin weight μ, margin | 0.1, 2.0 | 0.3, 2.0 |
| Optimizer | AdamW (β 0.9, 0.95), lr 5e-5, gradient clip 1.0, K=2,048 | Same |
| Compute | One A100 80GB, about 75 minutes | One A100 80GB, 5.26 hours (63 s per step, 78.7 GB peak memory) |
- Each stage-2 question was used once. None of the evaluation questions or evaluation books appear in either stage.
- Stage 2 changed the stage-1 weights by about 6% (relative Frobenius norm of
q_projandk_proj). - A write-up of stage 2 (in Japanese) is in qsa-indexer-forge. The training code, configurations, and data generators for both stages are also in that repository (reproduction guide, in Japanese). The
research/snapshot here is the v1 training source.
Limited quality checks (v1 indexer)
The checks in this section were measured with the v1 indexer and have not been repeated with v2.
BF16 reference
These BF16 research-reference checks compare QSA with the original dense path. They are not Q8_0 native quality results.
| Check | Original dense | QSA (v1) | Observed comparison |
|---|---|---|---|
| Text PPL on 32,766 tokens, lower is better | 7.072960 | 7.071384 | QSA/dense ratio 0.99978 |
| Constructed 50-item four-choice DocVQA | 50/50 | 50/50 | 100% of the dense score on this probe |
The DocVQA probe is not standard open-ended DocVQA scoring. DocVQA was used for evaluation, not as the synthetic indexer training set. These small checks do not establish a general performance-retention percentage or broad quality equivalence.
Native image/video and cache probes passed with v1, with limited multimodal checks through 64k. General multimodal quality at 128k/262k remains unverified.
Unsloth Q4/Q5/Q6 text checks
A teacher-forced evaluation used six fixed windows, up to 65,024 input tokens, FP16 KV, and MTP disabled. PPL differences are QSA relative to dense within each quantized model.
| Variant (v1 indexer) | Overall PPL difference | 64k capture | Same-budget oracle | 64k prose PPL difference |
|---|---|---|---|---|
| UD-Q4_K_M | -1.41% | 73.82% | 82.93% | +2.44% |
| UD-Q5_K_M | -0.47% | 73.76% | 82.91% | +1.97% |
| UD-Q6_K | -0.35% | 73.89% | 83.04% | +1.76% |
Capture measures attention mass, not task accuracy. These text-only checks do not establish general quality equivalence, free-generation quality, or a comparison with this BF16 model. See the complete evaluation.
Q8_0 throughput: QSA vs dense
The following results were measured with the v1 indexer and apply only to Q8_0, not to the Unsloth variants. v2 changes only indexer weights: tensor shapes, K, and the amount of attention work are the same, so throughput was not re-measured. The GGUF engine was measured against its dense Q8_0 control with the same weights, FP16 KV, MTP draft2, engine, and two sm70 32GB GPUs.
| Input tokens | QSA cold prefill | Dense cold prefill | QSA decode | Dense decode |
|---|---|---|---|---|
| 0 | 660.75 | 658.87 | 49.28 | 49.87 |
| 261,120 | 1071.53 | 366.84 | 41.07 | 22.91 |
All values are token/s. At 261,120 input tokens, QSA was 1.793x faster in decode and 2.921x faster in cold prefill. From each path's re-measured 0k point, mixed decode declined 16.66% for QSA and 54.06% for dense.

These are text-speed results, not long-context reasoning accuracy. QSA's nonzero-depth samples were retained from the earlier matched run, and the two paths were measured in separate sessions. See the full comparison data and methodology.
Credits and licenses
- Qwen: original model and the QSA architecture paper.
- Unsloth and the Unsloth Qwen3.8-27B GGUF repository: UD mixed-precision recipes and the source tensors reused in the Q4/Q5/Q6 variants.
- pentaCoxian: V100-oriented engine base.
- Warabii1248 and ggml-org contributors: V100 patches and upstream llama.cpp.
- kuraneko1: QSA 27B integration, multimodal runtime, release engineering, and the v2 indexer training.
- Indexer training data: PG-19 (Apache-2.0), FineWeb-Edu (ODC-By 1.0), and Python standard-library source text (PSF License) as synthetic background text.
Original model weights and notices retain the upstream Apache-2.0 license. QSA additions in this release are provided under Apache-2.0. Native llama.cpp code retains MIT and its included third-party notices.