Instructions to use lesj0610/Qwen3.8-Flash-Next-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lesj0610/Qwen3.8-Flash-Next-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lesj0610/Qwen3.8-Flash-Next-NVFP4") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("lesj0610/Qwen3.8-Flash-Next-NVFP4") model = AutoModelForMultimodalLM.from_pretrained("lesj0610/Qwen3.8-Flash-Next-NVFP4", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lesj0610/Qwen3.8-Flash-Next-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lesj0610/Qwen3.8-Flash-Next-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lesj0610/Qwen3.8-Flash-Next-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/lesj0610/Qwen3.8-Flash-Next-NVFP4
- SGLang
How to use lesj0610/Qwen3.8-Flash-Next-NVFP4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lesj0610/Qwen3.8-Flash-Next-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lesj0610/Qwen3.8-Flash-Next-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "lesj0610/Qwen3.8-Flash-Next-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lesj0610/Qwen3.8-Flash-Next-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use lesj0610/Qwen3.8-Flash-Next-NVFP4 with Docker Model Runner:
docker model run hf.co/lesj0610/Qwen3.8-Flash-Next-NVFP4
Qwen3.8-Flash-Next — NVFP4
NVFP4 post-training quantization of Qwen/Qwen3.8-Flash-Next,
produced with NVIDIA TensorRT Model Optimizer
using NVIDIA's official general-purpose NVFP4 recipe, applied as published — see
Quantization recipe for the exact provenance and the four lines that were added.
Routed MoE experts are quantized to NVFP4 (E2M1 weights with E4M3 per-block scales, block size 16). The KV cache is declared FP8. Everything else — attention, Gated DeltaNet, the QSA indexer, shared experts, routers, hyper-connections and the n-gram embedding tables — is kept in BF16.
| Tensors | Size | |
|---|---|---|
Qwen/Qwen3.8-Flash-Next (BF16) |
1,658 | 360.0 GB |
| this repository (NVFP4) | 296,347 | 186.4 GB |
The reduction is smaller than 4× because the n-gram embedding table alone is 102.4 GB and stays in BF16 — it is an embedding lookup, not a matmul, so quantizing it buys accuracy risk rather than throughput.
Quantization recipe
This is NVIDIA's official NVFP4 recipe, applied as published — not a hand-tuned configuration.
NVIDIA has not released an NVFP4 recipe or checkpoint for Qwen3.8-Flash-Next specifically. What is
official here is the recipe itself: nvfp4_experts_only_input_scale1-kv_fp8_cast.yaml, shipped
in TensorRT Model Optimizer under modelopt_recipes/general/ptq/. It sits under general/
precisely because it is architecture-agnostic — NVIDIA's standard NVFP4 configuration for
expert-quantized MoE models, not something derived per model.
It was used as-is. The quantize.algorithm block is identical, and all seven quant_cfg entries
are reproduced in their original order and content. No threshold, block size, scale bound or
calibration setting was changed — constant_amax: 2688.0 is NVIDIA's value, not a tuned one.
The only addition is four enable: false lines, for four submodules that exist in this
architecture and have no counterpart in the base recipe. Each falls into a category the base recipe
already excludes via default_disabled_quantizers (embeddings, gates/routers, conv mixers, output
heads), so these extend NVIDIA's own exclusion policy to new module names rather than introducing
a different one.
Everything above the # Qwen3.8-Flash-Next specific exclusions comment is the shipped file:
imports:
base_disable_all: configs/ptq/units/base_disable_all
default_disabled_quantizers: configs/ptq/units/default_disabled_quantizers
nvfp4: configs/numerics/nvfp4
kv_fp8_cast: configs/ptq/units/kv_fp8_cast
quantize:
algorithm:
method: max
layerwise: false # decoder layers nest under model.language_model.layers
skip_forward_without_activation_calib: true # every activation quantizer is constant-amax
quant_cfg:
- $import: base_disable_all
- quantizer_name: '*.experts.*weight_quantizer'
cfg: {$import: nvfp4}
- quantizer_name: '*.experts.*input_quantizer'
cfg: {$import: nvfp4, constant_amax: 2688.0}
- quantizer_name: '*block_sparse_moe*weight_quantizer'
cfg: {$import: nvfp4}
- quantizer_name: '*block_sparse_moe*input_quantizer'
cfg: {$import: nvfp4, constant_amax: 2688.0}
- $import: kv_fp8_cast
- $import: default_disabled_quantizers
# Qwen3.8-Flash-Next specific exclusions:
- {quantizer_name: '*ple.ple_embedding*', enable: false}
- {quantizer_name: '*ple.conv1d*', enable: false}
- {quantizer_name: '*hyper_connection*', enable: false}
- {quantizer_name: '*self_attn.indexer*', enable: false}
Why these four:
| Excluded | Reason |
|---|---|
ple.ple_embedding.* |
Per-layer n-gram embedding tables. Embeddings, the same category as embed_tokens, which the base recipe already excludes. |
ple.conv1d |
Depthwise conv mixer. Mirrors the existing *linear_attn.conv1d* / *mixer.conv1d* exclusions. |
*hyper_connection* |
Gated-Residual mixing coefficients. Same role as the gate/router weights the base recipe disables; ~0.6 B params, so quantizing perturbs residual mixing for little memory gain. |
self_attn.indexer.* |
The QSA indexer selects which KV blocks are attended. Quantizing it changes selection, not just precision. ~0.02 B params. |
constant_amax: 2688.0 is E2M1_MAX * E4M3_MAX (6 × 448). It pins the exported expert
input_scale to exactly 1.0, which is what makes the calibration forward unnecessary: every
activation quantizer is either constant-amax (experts) or use-constant-amax (KV cast), so
skip_forward_without_activation_calib elides the forward pass and only weight calibration runs.
No calibration dataset was used, and none is needed for this recipe — the exported weights are
data-independent.
What is and is not quantized
| Component | Precision |
|---|---|
Routed MoE experts — gate_proj, up_proj, down_proj (48 layers × 512 experts × 3) |
NVFP4, block 16 |
| KV cache | FP8 (E4M3, cast mode) |
| Self-attention, Gated DeltaNet | BF16 |
| QSA indexer | BF16 |
| Shared experts, MoE routers | BF16 |
| Hyper-connections (Gated Residual) | BF16 |
| N-gram embedding tables, PLE conv/proj/norms | BF16 |
embed_tokens, lm_head |
BF16 |
| MTP block, vision tower | BF16 |
quantization_config in config.json:
{
"quant_method": "modelopt",
"quant_algo": "NVFP4",
"config_groups": {
"group_0": {
"weights": {"num_bits": 4, "type": "float", "group_size": 16, "dynamic": false},
"input_activations": {"num_bits": 4, "type": "float"}
}
},
"kv_cache_scheme": {"num_bits": 8, "type": "float", "dynamic": false}
}
kv_fp8_cast declares the FP8 KV cache without emitting k_scale/v_scale tensors — the cast
mode uses an implicit unit scale. This matches NVIDIA's own published NVFP4 checkpoints built
with the same unit.
Verification
Every check below was run against this repository's files. Numbers are measured, not estimated.
Structural integrity
- 296,347 tensors across 10 shards. Zero tensors present in the index but missing from a shard, zero present in a shard but missing from the index.
- Every shard's byte length equals its header offset plus its last tensor's end offset — no truncated or padded shard.
metadata.total_size(186.4 GB) equals the sum of the actual shard file sizes.- No zero-dimension tensors.
- dtype census: 73,728
U8(packed NVFP4 weights) · 73,728F8_E4M3(weight_scale) · 147,456F32(weight_scale_2+input_scale) · 1,432BF16· 3I64.
Numerical fidelity
Packed NVFP4 weights were unpacked, rescaled by weight_scale × weight_scale_2, and compared
against the corresponding slices of the original BF16 checkpoint:
| Layer 0 expert | gate_proj |
up_proj |
down_proj |
|---|---|---|---|
| 0 | cos 0.99543 / rel 0.094 | cos 0.99540 / rel 0.094 | cos 0.99551 / rel 0.095 |
| 7 | cos 0.99545 / rel 0.094 | cos 0.99543 / rel 0.094 | cos 0.99530 / rel 0.095 |
| 255 | cos 0.99546 / rel 0.094 | cos 0.99544 / rel 0.094 | cos 0.99532 / rel 0.095 |
| 511 | cos 0.99545 / rel 0.094 | cos 0.99546 / rel 0.094 | cos 0.99539 / rel 0.095 |
Cosine similarity ≈ 0.9954 and relative Frobenius error ≈ 0.094 across the full expert range and all three projections — the expected error profile for E2M1 with 16-element blocks, and uniform, which rules out a mis-mapped or partially written expert.
Expert input_scale: 200 sampled tensors, all exactly 1.0, as the constant_amax design requires.
BF16 passthrough is bit-exact
The n-gram embedding table is stored in the source checkpoint as 128 shards of (2,500,012 × 160)
and as a single (320,001,536 × 160) tensor here. Head and tail rows of shards 0, 1, 63 and 127
are bit-identical to the corresponding row ranges of the merged tensor, confirming both the values
and the concatenation order. ple.conv1d, ple.value_proj, attn_hyper_connection.block_inject_weight
and mlp.gate are likewise bit-identical to the source.
Coverage
All 48 MoE layers are quantized, each with exactly 1,536 expert weight tensors (512 × 3), totalling
73,728 — no layer silently skipped. The 31 MTP tensors are preserved in BF16. The QSA indexer,
shared experts and Gated DeltaNet carry no scale tensors, confirming the exclusions took effect.
The only keys present in the source but not here are the 128 n-gram shards and the 96 fused
gate_up_proj/down_proj tensors, all accounted for by unsharding and expert unfusing.
Quantizer state
quantizer_summary.txt in this repository is Model Optimizer's own dump of all 52,142 inserted
quantizers — 49,272 active, 2,870 disabled — so the recipe's effect can be audited per module
without rerunning anything. Active expert quantizers read:
...experts.gate_up_proj_weight_quantizers.0 TensorQuantizer((2, 1) bit fake
block_sizes={-1: 16, 'type': 'dynamic', 'scale_bits': (4, 3)}, amax=1.78e-01 ...)
...experts.gate_up_proj_input_quantizer TensorQuantizer((2, 1) bit fake
block_sizes={-1: 16, 'type': 'dynamic', 'scale_bits': (4, 3)}, amax=2.69e+03 ...)
(2, 1) bit is E2M1, block_sizes={-1: 16} the 16-element blocks, scale_bits: (4, 3) the E4M3
per-block scale, and the input quantizer's amax=2.69e+03 is the recipe's constant_amax of 2688.
Not verified
No inference was run against these weights, and no benchmarks were reproduced. The checks above establish that the tensors are complete, correctly scaled and numerically faithful to the source — they do not establish end-to-end generation quality, nor that any particular serving stack loads this checkpoint. Treat downstream task quality as unmeasured. If you evaluate it, please report what you find.
Environment
nvidia-modelopt 0.47.0.dev74+g58ad6edc5
transformers 5.16.1
torch 2.13.0+cu130
accelerate 1.14.0
transformers must be recent enough to provide the qwen4_exp architecture.
Quantization ran on two 64 GB GPUs with the n-gram embedding table held on disk through
accelerate offload, since that single tensor is 102.4 GB and cannot be split across devices.
Wall-clock: 44 minutes.
python examples/hf_ptq/hf_ptq.py \
--pyt_ckpt_path Qwen/Qwen3.8-Flash-Next \
--recipe <recipe above> \
--batch_size 1 --skip_generate \
--export_fmt hf --export_path <out>
Everything below is the original model card from Qwen/Qwen3.8-Flash-Next, reproduced unchanged.
Qwen3.8-Flash-Next
This repository contains model weights and configuration files for the post-trained model in the Hugging Face Transformers format.
These artifacts are compatible with Hugging Face Transformers, vLLM, SGLang, TokenSpeed, etc.
For users seeking managed, scalable inference without infrastructure maintenance, the official Qwen API service is provided by Qwen Cloud.
In particular, Qwen3.8-Flash is the official version based on Qwen3.8-Flash-Next with more production features, e.g., 1M context length by default, official built-in tools. For more information, please refer to the Qwen3.8-Flash Overview.
As the frontier of foundation models pushes toward ever-larger parameter counts and ever-longer context windows, the question is no longer just how much we can scale, but how efficiently we can do so. Sustainable progress toward artificial general intelligence (AGI) that benefits everyone demands architectural innovation. Today, we are sharing a concrete step in that direction: Qwen3.8-Flash-Next.
This experimental preview of the architecture that will underpin Qwen4 is built around a fundamental rethinking of how the core components of modern large language models (LLMs) interact at scale.
Highlights
The first open-weight release under this architecture is Qwen3.8-Flash-Next, which introduces:
- Hybrid Attention with QSA: The Gated DeltaNet and Gated Attention pairing has been reworked into Gated DeltaNet and Qwen Sparse Attention (QSA). Rather than selecting individual tokens for processing, QSA operates at the micro-block level. This cuts long-context latency significantly, a critical gain as agentic workloads increasingly dominate real-world usage.
- Gated Residual: Residual streams with normalization are what make deep LLM training manageable. Gated Residual modulates information flowing through widened residual streams via an element-wise, data-dependent read gate and a per-branch scalar write gate. This brings finer-grained expressiveness across layers while preserving training stability and keeping inference overhead low.
- N-gram Embedding: Embeddings provide a unique axis for parameter scaling that requires less computation and is more amenable to offloading than Mixture-of-Experts (MoE). By indexing with short n-grams, this approach makes parameter scaling highly efficient for memory-constrained accelerators without sacrificing quality.
- Tailored Training Recipe: The Muon and AdamW optimizers are applied to specific weight categories to maximize efficiency. Guided by refitted scaling laws, we eliminate traditional batch-size warmups and start directly at the target batch size, substantially reducing total optimizer steps while safely supporting larger learning rates for robust convergence.
For more details, please refer to our blog post Qwen3.8-Flash-Next and the technical report.
We are excited to embark on this next chapter with you and welcome your feedback as we build what comes next.
Model Overview
- Type: Causal Language Model with Vision Encoder
- Training Stage: Pre-training & Post-training
- Language Model
- Number of Parameters: 125B with 6B activated, plus 51B n-gram embedding and 4B MTP
- Hidden Dimension: 2560
- Token Embedding: 248320 (Padded)
- N-gram Embedding: 20,000,000 (bigrams/trigrams at layer 2)
- Number of Layers: 48
- Hidden Layout: 12 × (3 × (Gated DeltaNet → MoE) → 1 × (Qwen Sparse Attention → MoE))
- Gated DeltaNet:
- Number of Linear Attention Heads: 48 for V and 16 for QK
- Head Dimension: 128
- Qwen Sparse Attention:
- Number of Attention Heads: 24 for Q and 2 for KV
- Head Dimension: 256
- Rotary Position Embedding Dimension: 64
- Indexer Structure: MQA with 4 Query Heads and 1 Shared Key Head
- Indexer Head Dimension: 128
- Budget: 512 blocks or 2048 tokens
- Mixture Of Experts
- Number of Experts: 512
- Number of Activated Experts: 10 Routed + 1 Shared
- Expert Intermediate Dimension: 640
- Gated Residual:
- Number of Branches: 4
- Bottleneck Rank: 320
- LM Output: 248320 (Padded)
- MTP: 1 layer, trained with multi-steps
- Context Length: 262,144 natively and extensible up to 1,000,000 tokens.
Benchmark Results
Language
| Qwen3.8-Flash-Next | Qwen3.8-27B | Qwen3.7-Plus | DeepSeek-V4-Flash-0731 | Claude-Opus-4.6 (Max) | |
|---|---|---|---|---|---|
# Params |
125B | 27B | 397B | 284B | -- |
# Activated params |
6B | 27B | 17B | 13B | -- |
# N-gram embedding params |
51B | -- | -- | -- | -- |
| Coding | |||||
Agentic coding DeepSWE 1.1 |
58.7 | 42.2 | 16.5 | 54.4 | -- |
Agentic coding SWE-bench Pro |
62.5 | 61.7 | 55.8 | 56.0 | 53.4 |
Multilingual software engineering SWE-bench Multilingual |
81.0 | 73.8 | 75.8 | -- | 77.5 |
Repo-level code generation NL2Repo-Bench |
48.1 | 42.3 | 41.1 | 54.2 | 47.6 |
| Agent | |||||
Long-horizon office work CoWorkBench |
73.9 | 70.7 | 65.1 | 45.1 | 68.2 |
Professional job tasks JobBench |
55.7 | 33.4 | 27.6 | 41.3 | 36.6 |
Frontier agentic tasks Agents' Last Exam |
Pass@1 24.3 Score 51.2 |
Pass@1 20.4 Score 42.9 |
Pass@1 13.2 Score 33.6 |
Pass@1 25.2 Score -- |
-- |
Real-world tool use Toolathlon Verified (Pass@1) |
73.5 | 67.1 | 50.6 | 70.3 | -- |
| General | |||||
Instruction following IFBench |
81.3 | 79.5 | 79.1 | 79.2 | 62.5 |
Scientific reasoning GPQA Diamond |
91.7 | 89.2 | 90.3 | 90.8 | 91.3 |
Multidisciplinary reasoning HLE |
35.9 | 30.8 | 34.7 | 33.8 | 40.0 |
Competitive coding LiveCodeBench v6 |
91.9 | 90.3 | 89.6 | 90.6 | 88.8 |
1. DeepSWE 1.1: evaluated with the Claude Code and mini-SWE-agent harnesses, temp=1.0, top_p=0.95, 256K context window. We report the highest score across the two harnesses; notably, Qwen3.8-Flash-Next performs best on mini-SWE-agent.
2. SWE-bench Pro: except for Claude-Opus-4.6 (Max), for which we report the officially published score, all models are evaluated with the Claude Code harness, temp=1.0, top_p=0.95, 256K context window. Problematic tasks were corrected and all baseline models were re-evaluated on the refined benchmark.
3. SWE-bench Multilingual: evaluated with the mini-SWE-agent harness, temp=1.0, top_p=0.95, 256K context window.
4. NL2Repo-Bench: evaluated with the Claude Code harness. To prevent reward hacking, we disable Bash commands that attempt to access the specific repository, such as pip download, pip install and git clone.
5. CoWorkBench: an in-house cowork benchmark for evaluating long-horizon office and productivity agent tasks across computer science, finance, law, medical and other productivity domains.
6. HLE: judged by GPT-4o.
7. The best result in each row is shown in bold.
8. Empty cells (--): scores are not yet available or are not applicable.
Vision Language
| Qwen3.8-Flash-Next | Qwen3.8-27B | Qwen3.7-Plus | Claude-Opus-4.6 (Max) | |
|---|---|---|---|---|
| Agentic Multimodal Intelligence | ||||
Multimodal tool use ClawEval-MM |
Pass@3 64.4 Average 60.4 |
Pass@3 57.4 Average 56.9 |
Pass@3 57.4 Average 60.1 |
Pass@3 52.5 Average 54.7 |
Application recreation RecreationBench |
49.9 | 47.1 | 30.2 | -- |
Mobile use AndroidWorld |
84.5 | 81.9 | 81.0 | 62.0 |
Computer use OSWorld 2.0 |
Binary 19.4 Partial 52.3 |
Binary 19.4 Partial 48.0 |
Binary 2.8 Partial 21.5 |
-- |
Visual web development Vision2Web |
64.0 | 62.9 | 42.1 | -- |
| General Multimodal Intelligence | ||||
Embodied intelligence ERQA |
72.3 | 65.5 | 69.8 | 40.8 |
Long video understanding LVBench |
76.6 | 72.4 | 76.2 | 63.0 |
Real-world perception RealWorldQA |
88.5 | 85.9 | 86.9 | 73.9 |
Visual math problem solving MathVision |
Without CI 90.6 With CI 95.7 |
Without CI 90.0 With CI 94.6 |
Without CI 90.3 With CI 88.7 |
Without CI 65.5 |
Scientific chart analysis CharXiv (RQ) |
Without CI 84.6 With CI 90.6 |
Without CI 83.7 With CI 90.2 |
Without CI 85.8 With CI 85.9 |
Without CI 66.0 |
1. ClawEval-MM: scores are reported as "pass@3 / average score". Pass@3 measures the percentage passed in at least one of three trials, and the average score is the mean score across the three trials.
2. RecreationBench: an in-house long-horizon application-recreation benchmark for evaluating hybrid-agent abilities spanning five platforms — desktop (Ubuntu, macOS, Windows), mobile (Android) and web.
3. OSWorld 2.0: scores are reported as "binary / partial". The binary score is the percentage of tasks that receive the full task reward, while the partial score aggregates the partial rewards obtained across all tasks.
4. Vision2Web: scores are reported as the average over the frontend, webpage and website categories, using the Claude Code harness and judged by gpt-5.4-2026-03-05.
5. MathVision, CharXiv (RQ): scores are reported as "without CI / with CI". A small number of incorrect ground-truth annotations in MathVision were corrected after manual verification. Our model's score is evaluated using a fixed prompt, e.g. "Please reason step by step, and put your final answer within \boxed{}." For other models, we report the higher score between runs with and without the \boxed{} formatting.
6. The best result in each row is shown in bold.
7. Empty cells (--) indicate scores not yet available or not applicable.
Quickstart
For streamlined integration, we recommend using Qwen3.8-Flash-Next via APIs.
Serving Qwen3.8-Flash-Next
Inference efficiency and throughput vary significantly across frameworks. We recommend using the latest framework versions to ensure optimal performance and compatibility. For production workloads or high-throughput scenarios, dedicated serving engines such as SGLang, KTransformers or vLLM are strongly recommended.
Qwen3.8-Flash-Next can be deployed with popular inference frameworks, e.g.:
- SGLang: Qwen3.8-Flash-Next Cookbook
- vLLM: Qwen3.8-Flash-Next Recipe
- TokenSpeed: Qwen3.8-Flash-Next Recipe
API Usage
Qwen3.8-Flash-Next models operate in thinking mode by default, generating thinking content signified by
<think>\n...</think>\n\nbefore producing the final responses. To disable thinking content and obtain direct response, refer to the examples here.
We recommend using the following sets of sampling parameters for generation:
- Thinking Mode:
temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=0.0,repetition_penalty=1.0- Instruct (or non-thinking) mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0Please note that the support for sampling parameters varies according to inference frameworks.
In multi-turn agentic tasks, lower reasoning effort does not always reduce overall task completion time. Although it may produce faster per-turn responses, it can also lead to insufficient analysis, more failures, and repeated retries, which may increase total latency and token consumption.
Qwen3.8-Flash-Next supports controlling thinking behavior via enable_thinking, preserve_thinking, and reasoning_effort.
Chat Completions API
The Chat Completions API can be used with most inference frameworks, as well as Qwen Cloud. Before starting, make sure it is installed and the API key and the API base URL is configured, e.g.:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="EMPTY"
Text-Only Input
from openai import OpenAI
# Configured by environment variables
client = OpenAI()
messages = [
{"role": "user", "content": "Write a Python function to merge two sorted linked lists."},
]
completion = client.chat.completions.create(
model="Qwen/Qwen3.8-Flash-Next",
messages=messages,
extra_body={
"chat_template_kwargs": {
"enable_thinking": True, # on by default
"preserve_thinking": True, # on by default
},
},
reasoning_effort="xhigh", # xhigh by default; supported levels are xhigh, medium, and low
stream=True,
stream_options={"include_usage": True},
)
reasoning_content = ""
answer_content = ""
is_answering = False
print("\n" + "=" * 20 + "Reasoning" + "=" * 20 + "\n")
for chunk in completion:
if not chunk.choices:
print("\nUsage:")
print(chunk.usage)
continue
delta = chunk.choices[0].delta
if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
if not is_answering:
print(delta.reasoning_content, end="", flush=True)
reasoning_content += delta.reasoning_content
elif hasattr(delta, "reasoning") and delta.reasoning is not None:
if not is_answering:
print(delta.reasoning, end="", flush=True)
reasoning_content += delta.reasoning
if hasattr(delta, "content") and delta.content:
if not is_answering:
print("\n" + "=" * 20 + "Answer" + "=" * 20 + "\n")
is_answering = True
print(delta.content, end="", flush=True)
answer_content += delta.content
messages.append({
"role": "assistant",
"content": answer_content,
"reasoning_content": reasoning_content,
"reasoning": reasoning_content,
})
Image Input
from openai import OpenAI
# Configured by environment variables
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/CI_Demo/mathv-1327.jpg"
}
},
{
"type": "text",
"text": "The centres of the four illustrated circles are in the corners of the square. The two big circles touch each other and also the two little circles. With which factor do you have to multiply the radii of the little circles to obtain the radius of the big circles?\nChoices:\n(A) $\\frac{2}{9}$\n(B) $\\sqrt{5}$\n(C) $0.8 \\cdot \\pi$\n(D) 2.5\n(E) $1+\\sqrt{2}$"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-Flash-Next",
messages=messages,
)
print("Chat response:", chat_response)
Video Input
from openai import OpenAI
# Configured by environment variables
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "video_url",
"video_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/video/N1cdUjctpG8.mp4"
}
},
{
"type": "text",
"text": "How many porcelain jars were discovered in the niches located in the primary chamber of the tomb?"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-Flash-Next",
messages=messages,
)
# When vLLM is launched with `--media-io-kwargs '{"video": {"num_frames": -1}}'`,
# video frame sampling can be configured via `extra_body` (e.g., by setting `fps`).
# This feature is currently supported only in vLLM.
#
# By default, `fps=2` and `do_sample_frames=True`.
# With `do_sample_frames=True`, you can customize the `fps` value to set your desired video sampling rate.
# chat_response = client.chat.completions.create(
# model="Qwen/Qwen3.8-Flash-Next",
# messages=messages,
# extra_body={
# "mm_processor_kwargs": {"fps": 2, "do_sample_frames": True},
# },
# )
print("Chat response:", chat_response)
Instruct (or Non-Thinking) Mode
Qwen3.8-Flash-Next will think by default before responding. You can obtain a direct response from the model without thinking by configuring the API parameters. For example,
from openai import OpenAI
# Configured by environment variables
client = OpenAI()
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://qianwen-res.oss-accelerate.aliyuncs.com/Qwen3.5/demo/RealWorld/RealWorld-04.png"
}
},
{
"type": "text",
"text": "Where is this?"
}
]
}
]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-Flash-Next",
messages=messages,
temperature=0.7,
top_p=0.8,
presence_penalty=1.5,
extra_body={
"top_k": 20,
"chat_template_kwargs": {"enable_thinking": False},
},
)
print("Chat response:", chat_response)
If you are using APIs from Qwen Cloud, in addition to changing
model, please use"enable_thinking": Falseinstead of"chat_template_kwargs": {"enable_thinking": False}.
Disable Preserved Thinking
By default, Qwen3.8-Flash-Next retains thinking blocks from all historical messages, maintaining a complete reasoning trace across the conversation. This behavior, known as preserved thinking, ensures full context continuity and is especially beneficial for agent scenarios where decision consistency and reduced redundant reasoning are critical. It also improves KV cache utilization, optimizing inference efficiency in both thinking and non-thinking modes.
If you prefer to retain only the thinking blocks from the latest user message, you can disable this behavior by setting preserve_thinking to False:
from openai import OpenAI
# Configured by environment variables
client = OpenAI()
messages = [...]
chat_response = client.chat.completions.create(
model="Qwen/Qwen3.8-Flash-Next",
messages=messages,
extra_body={
"chat_template_kwargs": {"preserve_thinking": False},
},
)
print("Chat response:", chat_response)
If you are using APIs from Qwen Cloud, in addition to changing
model, please use"preserve_thinking": Falsedirectly instead of wrapping it inchat_template_kwargs.
Best Practices
To achieve optimal performance, we recommend the following settings:
Sampling Parameters: We suggest using the following sets of sampling parameters:
- Thinking Mode:
temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=0.0,repetition_penalty=1.0 - Instruct (or non-thinking) mode:
temperature=0.7,top_p=0.80,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0
For supported frameworks, you can adjust the
presence_penaltyparameter between 0 and 2 to reduce endless repetition. However, using a higher value may occasionally result in language mixing and a slight decrease in model performance.- Thinking Mode:
Adequate Output Length: To optimize performance on agentic tasks, we recommend allocating sufficient output length to allow the model to generate detailed and comprehensive responses. For frameworks that support separate token limits for internal reasoning and final outputs, we suggest the following configuration within the 1M context length:
- Reasoning Content: Set the maximum output length to 262,144 tokens.
- Final Response: Set the maximum output length to 131,072 tokens.
These settings provide the necessary capacity for complex reasoning while ensuring ample space for high-quality final deliverables.
Processing Ultra-Long Texts: Qwen3.8-Flash-Next natively supports context lengths of up to 262,144 tokens. For long-horizon tasks where the total length (including both input and output) exceeds this limit, we recommend using RoPE scaling techniques to handle long texts effectively, e.g., YaRN.
YaRN is currently supported by several inference frameworks, e.g., vLLM, SGLang, and TokenSpeed. In general, there are two approaches to enabling YaRN for supported frameworks:
Modifying the model configuration file:
In the
config.jsonfile, change therope_parametersfields intext_configto:{ "mrope_interleaved": true, "mrope_section": [ 11, 11, 10 ], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144 }Passing command line arguments:
For vLLM, you can use
VLLM_ALLOW_LONG_MAX_MODEL_LEN=1 vllm serve ... --hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' --max-model-len 1000000For SGLang, you can use
SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 python -m sglang.launch_server ... --json-model-override-args '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' --context-length 1000000For TokenSpeed, you can use
TOKENSPEED_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1 tokenspeed serve ... --hf-overrides '{"text_config": {"rope_parameters": {"mrope_interleaved": true, "mrope_section": [11, 11, 10], "rope_type": "yarn", "rope_theta": 10000000, "partial_rotary_factor": 0.25, "factor": 4.0, "original_max_position_embeddings": 262144}}}' --max-model-len 1000000
All the notable open-source frameworks implement static YaRN, which means the scaling factor remains constant regardless of input length, potentially impacting performance on shorter texts. We advise modifying the
rope_parametersconfiguration only when processing long contexts is required. It is also recommended to modify thefactoras needed. For example, if the typical context length for your application is 524,288 tokens, it would be better to setfactoras 2.0.Long Video Understanding: To optimize inference efficiency for plain text and images, the
sizeparameter in the releasedvideo_preprocessor_config.jsonis conservatively configured. It is recommended to set thelongest_edgeparameter in the video_preprocessor_config file to 469,762,048 (corresponding to 224k video tokens) to enable higher frame-rate sampling for hour-scale videos and thereby achieve superior performance. For example,{"longest_edge": 469762048, "shortest_edge": 4096}Alternatively, override the default values via engine startup parameters. For implementation details, refer to: vLLM / SGLang.
Citation
If you find our work helpful, feel free to give us a cite.
@techreport{qwen2026design,
title = {On the Design of {Qwen3.8-Next} Architecture: Evaluation, Efficiency, and Training Stability},
author = {{Qwen Team}},
institution = {Alibaba Group},
month = {August},
year = {2026}
}
@misc{qwen3.8flashnext,
title = {{Qwen3.8-Flash-Next}: A New Architecture, Towards Ultimate Cost-Efficiency},
author = {{Qwen Team}},
month = {August},
year = {2026},
url = {https://qwen.ai/blog?id=qwen3.8-flash-next}
}
- Downloads last month
- 50
Model tree for lesj0610/Qwen3.8-Flash-Next-NVFP4
Base model
Qwen/Qwen3.8-Flash-Next