Qwen3.8-Flash-Next-FP8-NGQ2: the FP8 Qwen3.8-Flash-Next with a 2-bit n-gram table

Status: built and CPU-verified, GPU tests PENDING. The files below are complete and every tensor was checked byte-for-byte on the CPU (see Verification), but this FP8-backbone checkpoint has not yet been loaded or evaluated on a GPU. The measured results further down come from the bf16-backbone NGQ2 checkpoint (dnotitia/Qwen3.8-Flash-Next-NGQ2); FP8-backbone numbers will be added.

A complete checkpoint of Qwen/Qwen3.8-Flash-Next-FP8 (revision 7fb48d70):

  • every backbone tensor is copied byte-for-byte from the FP8 base repo (fine-grained FP8 e4m3, 128×128 blocks, for the routed experts; bf16 elsewhere, unchanged);
  • the FP8 PLE n-gram embedding table is replaced by its NGQ2 2-bit packed form (2.10 bits per value). The table holds 51.2B parameters (320M rows × 160 dims).
  • The NGQ2 codes are the same bytes as in dnotitia/Qwen3.8-Flash-Next-NGQ2: they were encoded from the original bf16 table, of which the FP8 table is the e4m3 quantization (checked bit-exactly, see Verification). No re-encoding.

It is built to load with AutoModelForCausalLM.from_pretrained(..., trust_remote_code=True) (GPU load test pending). No other download is needed.

Derived from Qwen3.8-Flash-Next by Qwen (Copyright (c) 2026 Qwen) under the Qwen Community License 1.0; see License below.

Qwen3.8-Flash-Next-FP8 this repo
backbone (everything except the n-gram table) 134.3 GB 134.3 GB (byte-identical)
n-gram table 51.2 GB (FP8 e4m3, 8 bpp) 13.44 GB (NGQ2, 2.10 bpp)
total checkpoint 185.5 GB 147.7 GB

(The bf16 original is 360.0 GB: backbone 257.6 GB + table 102.4 GB.)

Paper: N-Gram Memories at Two Bits (in preparation).

Usage

Requirements: transformers>=5.8 (built-in qwen4_exp code and fine-grained FP8 support; the bf16-backbone NGQ2 checkpoint was tested with 5.17), torch, safetensors, huggingface_hub, accelerate, and a GPU supported by transformers' FP8 kernels.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "dnotitia/Qwen3.8-Flash-Next-FP8-NGQ2"
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16,
                                             device_map="auto", table_device="gpu")   # "gpu" | "cpu" | "disk"
tok = AutoTokenizer.from_pretrained(repo)
msgs = [{"role": "user", "content": "Name three famous works by Leo Tolstoy."}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True,
                              enable_thinking=False)["input_ids"]
out = model.generate(ids.to(model.device), max_new_tokens=64, do_sample=False)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
  • trust_remote_code=True is required. modeling_ngq2.py subclasses transformers' built-in Qwen4ExpForConditionalGeneration (unchanged). The backbone goes through transformers' own fine-grained FP8 loader (quantization_config, quant_method: "fp8"). The n-gram nn.Embedding is never allocated; it is replaced by an ngq.PackedTable that decodes rows on lookup.
  • Without trust_remote_code, transformers falls back to its built-in class. That class finds no n-gram table weights, so the table would be left uninitialized (transformers only warns about missing ngram_embedding weights). Always pass trust_remote_code=True.
  • table_device chooses where the packed bytes live: "gpu" (default, HBM), "cpu" (host DRAM; only looked-up rows go to the GPU), "disk" (page-aligned records on local NVMe read with O_DIRECT; pass disk_dir=...; uses native/rowread.c, Linux + gcc). The decode is the same code in every placement.
  • Defaults as in our evaluation: eval_compat=True (exact QSA-indexer shortcut for key lengths ≤ the indexer budget) and experts_implementation="grouped_mm". Whether grouped_mm is the best (or an available) experts implementation for the FP8 experts is part of the pending GPU tests.

Alternative without the auto-class indirection (ngq.py from this repo):

import ngq                                   # from this repo
model, tok = ngq.load("dnotitia/Qwen3.8-Flash-Next-FP8-NGQ2", table_device="gpu")

Example script: python examples/generate.py [--table_device cpu|disk --disk_dir /nvme/ngq] [--loader ngq] (logits sanity check + short greedy generation; to be run as part of the pending GPU tests).

What NGQ2 is

The method applies a uniform-rate 2-bit trellis code to each table row, then restores each row's norm.

  • Code. The QTIP bitshift trellis (Tseng et al., 2024): L = 16 state bits, 4 bits per pair of values, QTIP's "HYB" (quantlut_sym) codebook with a 512×2 base table, tail-biting. Each 160-dim row is one trellis sequence of 80 steps (40 bytes), so every row decodes independently (row-granular).
  • Norm restoration. One bf16 gain per row makes the decoded row's L2 norm equal the original row's norm (16 bits per 160-dim row = +0.10 bpp).
  • What the method leaves out:
    • no rotation;
    • no Hessian, calibration data or fine-tuning (data-free);
    • uniform rate.
  • Unchanged: the hashing and addressing. Packed row r replaces row r of ple.ple_embedding.ngram_embedding.

Same codes as evaluated. The stored codes are the ones behind the numbers below (config qtip2ncc_norht).

  • All 320,001,536 rows decode bit-identically to the evaluated table; see Verification.
  • The last 90 rows are padding rows the hash never addresses.

Checkpoint layout

The repo follows the layout of Qwen/Qwen3.8-Flash-Next-FP8: config.json, generation_config.json, chat_template.jinja, the tokenizer and processor files and LICENSE are the FP8 repo's files (only config.json is edited, see below). The weights sit in 30 safetensors shards of ≤ 5 GB, listed in model.safetensors.index.json.

  • Backbone. 151,960 tensors, byte-identical to the FP8 base shards, with the same names, dtypes and shapes: F8_E4M3 routed-expert weights with their BF16 weight_scale_inv (128×128 blocks), bf16 everything else (attention, shared experts, PLE projections, ngram_heads_offsets / ngram_heads_vocab_sizes / layer_multipliers, MTP, vision, embeddings, LM head).
  • Removed. The 129 FP8 table tensors: model.language_model.layers.1.ple.ple_embedding.ngram_embedding.shard_{0..127}.weight (F8_E4M3 [2,500,012, 160]) and the table's single per-tensor scale ...ngram_embedding.weight_scale (BF16 [1]).
  • Packed table (shards 00028–00030), byte-identical to dnotitia/Qwen3.8-Flash-Next-NGQ2:
tensor dtype shape content
model.language_model.layers.1.ple.ple_embedding.ngram_embedding.shard_{j}.ngq2_symbols uint8 [2,500,012, 40] rows j·2,500,012 …: 80 4-bit trellis symbols per row (2 per byte, high nibble first)
….ngram_embedding.shard_{j}.ngq2_gain bf16 [2,500,012] per-row gain
ngq2.codebook fp32 [512, 2] HYB base table (full codebook = 65536 × 2, see ngq.hyb_lut)

config.json

config.json is the FP8 base config (model_type / architectures / text_config unchanged) with:

  1. quantization_config kept as the base FP8 block (quant_method: "fp8", activation_scheme: "dynamic", weight_block_size: [128, 128], the 943 modules_to_not_convert entries) with two edits, because the n-gram table is no longer FP8:
    • modules_to_convert: ["ple.ple_embedding.ngram_embedding"] → [] (no FP8 embedding is built for the table);
    • modules_to_not_convert: model.language_model.layers.1.ple.ple_embedding.ngram_embedding appended. So FP8 loaders (transformers, and later vLLM / SGLang) neither build an FP8 table nor look for its weight / weight_scale.
  2. ngq2_config: the NGQ2 block, field-for-field identical to the quantization_config of dnotitia/Qwen3.8-Flash-Next-NGQ2, plus base_quantization_config_edits recording the two edits above. It is a separate top-level key (not nested in, and not replacing, quantization_config), so that the FP8 semantics are untouched and the NGQ2 block is found under one clearly named key. ngq.py (v2.1) reads ngq2_config when present, else quantization_config.
  3. auto_map: AutoModelForCausalLM / AutoModelForImageTextToText → modeling_ngq2.NGQ2Qwen4ExpForConditionalGeneration.
"ngq2_config": {
  "quant_method": "ngq2", "version": 1, "bits": 2, "bpp": 2.1,
  "code": "qtip_hyb_trellis", "L": 16, "K": 2, "V": 2,
  "codebook": {"tensor": "ngq2.codebook", "type": "hyb", "base_entries": 512},
  "gain": "ncc_bf16", "granularity": "row",
  "modules_to_quantize": ["model.language_model.layers.1.ple.ple_embedding.ngram_embedding"],
  "packed_tensor_suffixes": {"symbols": "ngq2_symbols", "row_gain": "ngq2_gain"},
  "checkpoint_parts": "shard_{j}",
  "base_quantization_config_edits": {...}
}

The meaning of every NGQ2 field and the exact decode are in VLLM_NOTES.md.

Hardware

Not measured yet (GPU tests pending). Sizes for planning: the FP8 backbone is 134.3 GB (125.1 GiB), the packed table 13.44 GB (12.5 GiB). With table_device="gpu" the weights alone are 137.6 GiB, more than one H200 (141 GB) holds with activations, so 2 GPUs are expected; whether one H200 suffices with table_device="cpu" / "disk" is to be measured. The bf16-backbone checkpoint needed 2 × H200.

Results (bf16-backbone evaluation)

These numbers were measured with the bf16 backbone (dnotitia/Qwen3.8-Flash-Next-NGQ2) and the same NGQ2 table bytes. They are not measurements of this FP8-backbone checkpoint. FP8-backbone numbers (KL vs the bf16 original and vs Qwen3.8-Flash-Next-FP8, task scores) are to be added after the GPU tests.

Numbers are taken from our benchmark result files.

  • Format: chat format (thinking off) for generative tasks; raw text for log-likelihood / KL.
  • CIs: 95%, item bootstrap (tasks) or chunk bootstrap (KL).
  • KL: KL(original ‖ config) per token on 6 text domains.
  • Benefit retained: (q − removed) / (original − removed), where removed = table zeroed. On this model the table matters much less for many tasks than on DeepSeek / LongCat, so several benefit CIs are wide.
  • RTN: asymmetric g80 (d = 160) with bf16 scale and min.

Fidelity

config bpp table GB gm KL worst KL ben gm KL top-1 agree mean / min (6 dom) WT2 PPL
original (bf16, 16 bpp) 16.00 102.40 .000 [.000,.000] .000 [.000,.000] 1.000 [1.000,1.000] 1.0000 / 1.0000 4.671 [4.336,5.000]
table removed (zeroed) 0.00 0.00 .308 [.296,.320] .481 [.470,.491] .000 [.000,.000] 0.8151 / 0.7450 6.476 [6.182,6.764]
RTN 2-bit g80 (2.40 bpp) 2.40 15.36 .059 [.057,.061] .099 [.090,.109] .809 [.803,.816] 0.9230 / 0.9092 5.089 [4.791,5.384]
QTIP 2.0, published recipe (2.00 bpp) 2.00 12.80 .035 [.033,.036] .048 [.043,.052] .887 [.883,.892] 0.9392 / 0.9276 4.827 [4.515,5.141]
NGQ2 (this repo, 2.10 bpp) 2.10 13.44 .033 [.032,.034] .044 [.040,.048] .894 [.890,.898] 0.9404 / 0.9279 4.830 [4.515,5.145]

Knowledge (absolute / benefit retained)

config mmlu popqa tqa nq entityq simpleqa
original (bf16, 16 bpp) .868 [.848,.889] .363 [.350,.377] .823 [.810,.837] .424 [.409,.440] .372 [.355,.390] .137 [.115,.158]
table removed (zeroed) .859 [.838,.881] .266 [.253,.278] .734 [.718,.750] .376 [.360,.391] .205 [.191,.220] .077 [.061,.094]
RTN 2-bit g80 (2.40 bpp) .863 [.842,.885] / .444 [-4.000,4.000] .351 [.338,.364] / .874 [.817,.935] .820 [.806,.833] / .963 [.896,1.032] .417 [.402,.432] / .845 [.726,.969] .354 [.337,.371] / .892 [.839,.947] .127 [.107,.147] / .833 [.644,1.061]
QTIP 2.0, published recipe (2.00 bpp) .873 [.853,.894] / 1.556 [-3.792,7.000] .361 [.348,.374] / .979 [.930,1.026] .824 [.810,.837] / 1.007 [.947,1.074] .421 [.405,.436] / .937 [.824,1.052] .372 [.355,.390] / .998 [.954,1.042] .132 [.111,.152] / .917 [.750,1.103]
NGQ2 (this repo, 2.10 bpp) .868 [.848,.889] / 1.000 [-2.075,5.000] .364 [.351,.378] / 1.014 [.967,1.067] .822 [.808,.835] / .985 [.932,1.043] .421 [.406,.436] / .937 [.829,1.046] .366 [.349,.384] / .964 [.919,1.011] .139 [.118,.160] / 1.033 [.859,1.255]

Multilingual / generation / task groups

config belebele8 mkqa8 mgsm6
original (bf16, 16 bpp) .939 .268 .711
table removed (zeroed) .919 .206 .688
RTN 2-bit g80 (2.40 bpp) .939 / .975 [.798,1.190] .269 / 1.008 [.925,1.101] .707 / .829 [-.086,2.216]
QTIP 2.0, published recipe (2.00 bpp) .939 / 1.000 [.844,1.182] .266 / .964 [.892,1.041] .705 / .714 [-.215,1.667]
NGQ2 (this repo, 2.10 bpp) .940 / 1.012 [.864,1.200] .268 / .988 [.914,1.063] .719 / 1.314 [.658,3.953]
config gsm8k humaneval
original (bf16, 16 bpp) .876 [.846,.904] .957 [.927,.982]
table removed (zeroed) .830 [.796,.862] .945 [.909,.976]
RTN 2-bit g80 (2.40 bpp) .864 [.836,.892] / .739 [.316,1.188] .957 [.927,.982] / 1.000 [1.000,1.000]
QTIP 2.0, published recipe (2.00 bpp) .866 [.836,.894] / .783 [.357,1.222] .951 [.915,.982] / .500 [-2.000,3.000]
NGQ2 (this repo, 2.10 bpp) .868 [.838,.896] / .826 [.478,1.167] .957 [.927,.982] / 1.000 [1.000,1.000]
config commonsense knowledge rc multilingual generation
original (bf16, 16 bpp) .769 .496 .965 .633 .917
table removed (zeroed) .757 .420 .961 .597 .888
RTN 2-bit g80 (2.40 bpp) .773 / 1.370 [.908,2.563] .489 / .906 [.856,.958] .963 / .597 [-3.437,3.360] .632 / .970 [.833,1.125] .911 / .794 [.369,1.148]
QTIP 2.0, published recipe (2.00 bpp) .770 / 1.100 [.693,1.889] .495 / .991 [.951,1.036] .965 / 1.031 [-2.490,4.168] .631 / .928 [.809,1.062] .909 / .723 [.062,1.230]
NGQ2 (this repo, 2.10 bpp) .770 / 1.047 [.626,1.818] .496 / .994 [.953,1.041] .963 / .541 [-1.862,2.791] .635 / 1.050 [.925,1.196] .913 / .863 [.498,1.133]

Answer flips vs the original over 35,213 0/1 items:

  • NGQ2: 3.03% right→wrong, 4.27% wrong→right, net −0.05 pp.

Reading:

  • NGQ2 keeps 89.4% of the table's KL benefit (gm).
  • Its KL is 0.56× that of RTN 2-bit (paired, 95% CI 0.55–0.57) and 0.94× that of the published QTIP recipe (CI 0.92–0.97), which uses rotation and a global scale at 2.00 bpp.
  • Knowledge-group benefit is 99.4%. GSM8K and HumanEval stay within noise of the original.

Verification of this checkpoint (CPU only, before upload)

All checks were run on the CPU on the exact files in this repo. Scripts: scripts/release/full_fp8/ in our research repo.

check result
base snapshot == Hub Qwen/Qwen3.8-Flash-Next-FP8 @ 7fb48d708ca6cd8eeed8f4db0433be18af96984f: all 144 files, sha256 (LFS) / git blob sha1 and sizes match the Hub metadata (185.56 GB)
FP8 table derives from the table we encoded 100,000 sampled rows (16 of the 128 shards): FP8 = e4m3(bf16(x_bf16 / scale)) of the original bf16 rows bit-exactly (16,000,000 / 16,000,000 values; scale = BF16 per-tensor 0.000199318). Dequantized vs bf16: rel. error mean 0.0266 (max 0.0346), cosine min 0.99940; mismatched-row control cosine 0.026
backbone vs bf16 original the 1,432 tensors present in both repos with the same dtype are byte-identical; the only same-name dtype changes are the 128 table shards; the 98 fused bf16 expert tensors correspond to the FP8 repo's 150,528 per-expert tensors (shapes all match; sampled experts dequantize with cosine ≥ 0.9996)
backbone tensors 151,960 / 151,960 byte-identical to the FP8 base shards (same names, dtypes, shapes); key set = FP8 base keys minus the 129 table tensors
packed tensors 257 / 257 byte-identical to dnotitia/Qwen3.8-Flash-Next-NGQ2 (whose 320,001,536 rows decode bit-identically to the evaluated table)
index every tensor listed exactly once; every shard opens with safetensors; total_size matches
CPU decode 8,432 rows (start, tail incl. the 90 padding rows, ±8 rows around every shard boundary, 4,096 random) decoded from this checkpoint on the CPU with this repo's ngq.py (read_layout via ngq2_config → load_packed → PackedTable.decode_rows): 8,432 / 8,432 bit-identical to the evaluated table qtip2ncc_norht
config parses with transformers 5.17 (AutoConfig, remote code); FineGrainedFP8Config builds; on a meta-device skeleton the FP8 quantizer converts the experts (FP8Experts), builds no FP8Embedding, and the table is the NGQ2 placeholder (no weight expected)
GPU: from_pretrained, KL, placements, generation PENDING

vLLM

There is no vLLM support yet. A vLLM port needs the base FP8 method for the backbone plus an ngq2 embedding method for the n-gram table; see VLLM_NOTES.md.

Limitations

  • Untested on GPU (see Status). Results above are from the bf16 backbone.
  • Not lossless. With the bf16 backbone: gm KL .033, worst .044; WikiText-2 PPL 4.67 → 4.83. The FP8 backbone adds its own (small, per Qwen) quantization error on top.
  • Decode on every lookup. Pure-PyTorch decode, no fused kernel shipped.
  • Disk placement. Experimental for Qwen; Linux-only.
  • transformers path. modeling_ngq2.py overrides from_pretrained and builds the built-in Qwen4ExpTextNGramEmbedding without its table. save_pretrained of the loaded model is not supported: it would not write the packed table.

License

This repo is distributed under the Qwen Community License 1.0, the license of the base model. The full text is in LICENSE (Copyright (c) 2026 Qwen).

It contains Qwen3.8-Flash-Next's weights (byte-identical) and a compressed derivative of its n-gram table. Note the license's conditions, including:

  • the attribution / model-name display requirement above 100M monthly active users or US$20M monthly revenue;
  • that Model-as-a-Service or AI Work Assistant businesses need a separate license from Qwen for commercial use.

Built with Qwen. The trellis code follows QTIP (Tseng et al., 2024). Paper: N-Gram Memories at Two Bits (in preparation).

Downloads last month
62
Safetensors
Model size
142B params
Tensor type
BF16
·
F8_E4M3
·
I64
·
F32
·
U8
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for dnotitia/Qwen3.8-Flash-Next-FP8-NGQ2

Quantized
(19)
this model