开源项目 Hugging Face Models 2026-08-27T00:01 正文 ok 2726 words

Qwen3.8-Flash-Next:面向 Qwen4 的实验性架构预览

英文标题:🤗 Qwen/Qwen3.8-Flash-Next

Qwen 发布 Qwen3.8-Flash-Next,这是一款采用新一代混合注意力、Gated Residual 和 N-gram Embedding 架构的开放权重模型,并被定位为未来 Qwen4 的底层架构实验预览。该模型语言部分拥有 125B 参数、每次激活 6B 参数,另配备 51B N-gram Embedding 参数和 4B MTP 参数,原生支持 262,144 token 上下文,并可扩展至 100 万 token。在 DeepSWE 1.1、SWE-bench Pro、CoWorkBench、JobBench、GPQA Diamond、LiveCodeBench v6 等多项语言与 Agent 评测中,Qwen3.8-Flash-Next 给出了领先结果。对开发者而言,模型兼容 Hugging Face Transformers、vLLM、SGLang、TokenSpeed 等推理框架,并提供基于 OpenAI Chat Completions API 的文本和图像输入调用方式。
打开原文相关 1.6 · 机会 2
media4.5 KB media2.8 KB media559.1 KB media406.2 KB

中文

Qwen3.8-Flash-Next

本仓库包含采用 Hugging Face Transformers 格式的后训练模型权重与配置文件。

这些产物兼容 Hugging Face Transformers、vLLM、SGLang、TokenSpeed 等。

对于希望获得免基础设施维护、可扩展托管推理服务的用户,官方 Qwen API 服务由 Qwen Cloud 提供。

特别是,Qwen3.8-Flash 是基于 Qwen3.8-Flash-Next 的官方版本,提供更多生产级功能,例如默认支持 100 万上下文长度、官方内置工具等。更多信息请参阅 Qwen3.8-Flash 概览。

随着基础模型的前沿不断迈向更大的参数规模和更长的上下文窗口,问题已不再只是如何扩大规模,而是如何高效地扩大规模。要实现惠及所有人的通用人工智能(AGI)的可持续进步,需要架构创新。今天,我们分享朝这一方向迈出的具体一步:Qwen3.8-Flash-Next。

Qwen3.8-Flash-Next 架构

这一将为 Qwen4 奠定基础的实验性架构预览,围绕对现代大语言模型(LLM)核心组件如何在大规模下交互的根本性重新思考而构建。

亮点

这一架构下的首个开放权重发布版本为 Qwen3.8-Flash-Next,其引入了:

  • 采用 QSA 的混合注意力:Gated DeltaNet 与 Gated Attention 的组合被重构为 Gated DeltaNet 和 Qwen Sparse Attention(QSA)。QSA 不再选择单个 token 进行处理,而是在微块(micro-block)层面运作。这可显著降低长上下文延迟;随着 Agent 工作负载日益主导实际使用场景,这是一项关键提升。
  • Gated Residual:带归一化的残差流使深层 LLM 训练变得可控。Gated Residual 通过逐元素、数据依赖的读取门,以及每个分支的标量写入门,调节在扩宽残差流中传递的信息。这在保持训练稳定性和较低推理开销的同时,带来了跨层的更细粒度表达能力。
  • N-gram Embedding:Embedding 提供了一条独特的参数扩展路径:相比 Mixture-of-Experts(MoE),它所需计算更少,也更适合卸载。通过以短 n-gram 建立索引,这种方法可在不牺牲质量的前提下,为内存受限的加速器高效扩展参数规模。
  • 定制化训练方案:针对特定类别的权重使用 Muon 和 AdamW 优化器,以最大化效率。在重新拟合的缩放定律指导下,我们取消了传统的 batch size warmup,直接从目标 batch size 开始训练,在安全支持更大学习率、实现稳健收敛的同时,大幅减少优化器总步数。

更多细节请参阅我们的博客文章 Qwen3.8-Flash-Next 和 技术报告。

我们很高兴与您一同开启这一新篇章,并欢迎您在我们构建下一代产品的过程中提供反馈。

模型概览

  • 类型:带视觉编码器的因果语言模型
  • 训练阶段:预训练与后训练
  • 语言模型
    • 参数量:125B,激活参数为 6B,另有 51B N-gram Embedding 和 4B MTP
    • 隐藏层维度:2560
    • Token Embedding:248320(Padded)
    • N-gram Embedding:20,000,000(第 2 层使用二元组/三元组)
    • 层数:48
    • 隐藏层布局:12 × (3 × (Gated DeltaNet → MoE) → 1 × (Qwen Sparse Attention → MoE))
    • Gated DeltaNet:
      • 线性注意力头数量:V 为 48,QK 为 16
      • 头维度:128
    • Qwen Sparse Attention:
      • 注意力头数量:Q 为 24,KV 为 2
      • 头维度:256
      • 旋转位置编码维度:64
      • Indexer 结构:采用 4 个 Query Head 和 1 个共享 Key Head 的 MQA
      • Indexer 头维度:128
      • 预算:512 个块或 2048 个 token
    • Mixture Of Experts
      • 专家数量:512
      • 激活专家数量:10 个路由专家 + 1 个共享专家
      • 专家中间层维度:640
    • Gated Residual:
      • 分支数量:4
      • 瓶颈秩:320
    • LM 输出:248320(Padded)
    • MTP:1 层,采用多步训练
  • 上下文长度:原生支持 262,144,可扩展至 1,000,000 个 token。

基准测试结果

语言

| Qwen3.8-Flash-Next | Qwen3.8-27B | Qwen3.7-Plus | DeepSeek-V4-Flash-0731 | Claude-Opus-4.6 (Max) | |---|---|---|---|---|---| | 参数量 | 125B | 27B | 397B | 284B | -- | | 激活参数量 | 6B | 27B | 17B | 13B | -- | | N-gram Embedding 参数量 | 51B | -- | -- | -- | -- | | 编程 | | | | | | | Agent 编程:DeepSWE 1.1 | 58.7 | 42.2 | 16.5 | 54.4 | -- | | Agent 编程:SWE-bench Pro | 62.5 | 61.7 | 55.8 | 56.0 | 53.4 | | 多语言软件工程:SWE-bench Multilingual | 81.0 | 73.8 | 75.8 | -- | 77.5 | | 仓库级代码生成:NL2Repo-Bench | 48.1 | 42.3 | 41.1 | 54.2 | 47.6 | | Agent | | | | | | | 长周期办公工作:CoWorkBench | 73.9 | 70.7 | 65.1 | 45.1 | 68.2 | | 专业岗位任务:JobBench | 55.7 | 33.4 | 27.6 | 41.3 | 36.6 | | 前沿 Agent 任务:Agents' Last Exam | | | | | -- | | 真实世界工具使用:Toolathlon Verified (Pass@1) | 73.5 | 67.1 | 50.6 | 70.3 | -- | | 通用 | | | | | | | 指令遵循:IFBench | 81.3 | 79.5 | 79.1 | 79.2 | 62.5 | | 科学推理:GPQA Diamond | 91.7 | 89.2 | 90.3 | 90.8 | 91.3 | | 多学科推理:HLE | 35.9 | 30.8 | 34.7 | 33.8 | 40.0 | | 竞赛编程:LiveCodeBench v6 | 91.9 | 90.3 | 89.6 | 90.6 | 88.8 |

  1. DeepSWE 1.1:使用 Claude Code 和 mini-SWE-agent harness 评估,temp=1.0、top_p=0.95、256K 上下文窗口。我们报告两个 harness 中的最高分;值得注意的是,Qwen3.8-Flash-Next 在 mini-SWE-agent 上表现最佳。
  2. SWE-bench Pro:除 Claude-Opus-4.6 (Max) 报告官方公开分数外,所有模型均使用 Claude Code harness 评估,参数为 temp=1.0、top_p=0.95、256K 上下文窗口。我们修正了存在问题的任务,并在优化后的基准测试上重新评估了所有基线模型。
  3. SWE-bench Multilingual:使用 mini-SWE-agent harness 评估,参数为 temp=1.0、top_p=0.95、256K 上下文窗口。
  4. NL2Repo-Bench:使用 Claude Code harness 评估。为防止奖励黑客(reward hacking),我们禁用了尝试访问特定仓库的 Bash 命令,例如 pip download、pip install 和 git clone。
  5. CoWorkBench:内部协同办公基准,用于评估跨计算机科学、金融、法律、医疗及其他生产力领域的长周期办公和生产力 Agent 任务。
  6. HLE:由 GPT-4o 评判。
  7. 每行最佳结果以粗体显示。
  8. 空单元格(--)表示分数尚不可用或不适用。

视觉语言

| Qwen3.8-Flash-Next | Qwen3.8-27B | Qwen3.7-Plus | Claude-Opus-4.6 (Max) | |---|---|---|---|---| | Agent 多模态智能 | | | | | | 多模态工具使用:ClawEval-MM | | | | | | 应用复现:RecreationBench | 49.9 | 47.1 | 30.2 | -- | | 移动端使用:AndroidWorld | 84.5 | 81.9 | 81.0 | 62.0 | | 计算机使用:OSWorld 2.0 | | | | -- | | 视觉 Web 开发:Vision2Web | 64.0 | 62.9 | 42.1 | -- | | 通用多模态智能 | | | | | | 具身智能:ERQA | 72.3 | 65.5 | 69.8 | 40.8 | | 长视频理解:LVBench | 76.6 | 72.4 | 76.2 | 63.0 | | 真实世界感知:RealWorldQA | 88.5 | 85.9 | 86.9 | 73.9 | | 视觉数学问题求解:MathVision | | | | | | 科学图表分析:CharXiv (RQ) | | | | |

  1. ClawEval-MM:分数以“pass@3 / 平均分”形式报告。Pass@3 衡量三次试验中至少一次通过的百分比,平均分为三次试验分数的平均值。
  2. RecreationBench:内部长期应用复现基准,用于评估横跨五个平台的混合 Agent 能力,包括桌面端(Ubuntu、macOS、Windows)、移动端(Android)和 Web。
  3. OSWorld 2.0:分数以“二元分数 / 部分分数”形式报告。二元分数为获得完整任务奖励的任务百分比,部分分数汇总了所有任务中获得的部分奖励。
  4. Vision2Web:使用 Claude Code harness,并由 gpt-5.4-2026-03-05 评判;分数为前端、网页和网站三个类别的平均值。
  5. MathVision、CharXiv (RQ):分数以“不含 CI / 含 CI”形式报告。MathVision 中少量不正确的真实标签在人工验证后得到修正。我们模型的分数使用固定提示词评估,例如“Please reason step by step, and put your final answer within \boxed{}.”。对于其他模型,我们报告使用和不使用 \boxed{} 格式的运行结果中较高的分数。
  6. 每行最佳结果以粗体显示。
  7. 空单元格(--)表示分数尚不可用或不适用。

快速开始

为实现更简化的集成,我们建议通过 API 使用 Qwen3.8-Flash-Next。

部署 Qwen3.8-Flash-Next

不同框架的推理效率和吞吐量存在显著差异。我们建议使用最新版本的框架,以确保最佳性能和兼容性。对于生产工作负载或高吞吐场景,强烈建议使用 SGLang、KTransformers 或 vLLM 等专用服务引擎。

Qwen3.8-Flash-Next 可通过主流推理框架部署,例如:

API 使用

Qwen3.8-Flash-Next 模型默认以思考模式运行,在生成最终回答前会生成以 <think>\n...</think>\n\n 标识的思考内容。若要禁用思考内容并直接获取回答,请参阅此处示例。

我们建议生成时使用以下采样参数组合:

  • 思考模式:temperature=1.0、top_p=0.95、top_k=20、min_p=0.0、presence_penalty=0.0、repetition_penalty=1.0
  • Instruct(或非思考)模式:temperature=0.7、top_p=0.80、top_k=20、min_p=0.0、presence_penalty=1.5、repetition_penalty=1.0

请注意,不同推理框架对采样参数的支持情况有所不同。

在多轮 Agent 任务中,较低的推理强度并不总能减少整体任务完成时间。尽管它可能带来更快的单轮响应,但也可能导致分析不足、更多失败和重复重试,进而增加总延迟和 token 消耗。

Qwen3.8-Flash-Next 支持通过 enable_thinking、preserve_thinking 和 reasoning_effort 控制思考行为。

Chat Completions API

Chat Completions API 可与大多数推理框架以及 Qwen Cloud 一起使用。开始前,请确保已安装相关依赖,并已配置 API key 和 API base URL,例如:

pip install -U openai

Set the following accordingly

export OPENAI_BASE_URL="http://localhost:8000/v1" export OPENAI_API_KEY="EMPTY"

纯文本输入

from openai import OpenAI

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,
"preserve_thinking": True, }, }, reasoning_effort="xhigh",
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, })

图像输入

from openai import OpenAI

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

English / 原文

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.

Qwen3.8-Flash-Next Architecture

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 codingDeepSWE 1.1 | 58.7 | 42.2 | 16.5 | 54.4 | --
Agentic codingSWE-bench Pro | 62.5 | 61.7 | 55.8 | 56.0 | 53.4
Multilingual software engineeringSWE-bench Multilingual | 81.0 | 73.8 | 75.8 | -- | 77.5
Repo-level code generationNL2Repo-Bench | 48.1 | 42.3 | 41.1 | 54.2 | 47.6
Agent
Long-horizon office workCoWorkBench | 73.9 | 70.7 | 65.1 | 45.1 | 68.2
Professional job tasksJobBench | 55.7 | 33.4 | 27.6 | 41.3 | 36.6
Frontier agentic tasksAgents' Last Exam | | | | | --
Real-world tool useToolathlon Verified (Pass@1) | 73.5 | 67.1 | 50.6 | 70.3 | --
General
Instruction followingIFBench | 81.3 | 79.5 | 79.1 | 79.2 | 62.5
Scientific reasoningGPQA Diamond | 91.7 | 89.2 | 90.3 | 90.8 | 91.3
Multidisciplinary reasoningHLE | 35.9 | 30.8 | 34.7 | 33.8 | 40.0
Competitive codingLiveCodeBench 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 useClawEval-MM | | | |
Application recreationRecreationBench | 49.9 | 47.1 | 30.2 | --
Mobile useAndroidWorld | 84.5 | 81.9 | 81.0 | 62.0
Computer useOSWorld 2.0 | | | | --
Visual web developmentVision2Web | 64.0 | 62.9 | 42.1 | --
General Multimodal Intelligence
Embodied intelligenceERQA | 72.3 | 65.5 | 69.8 | 40.8
Long video understandingLVBench | 76.6 | 72.4 | 76.2 | 63.0
Real-world perceptionRealWorldQA | 88.5 | 85.9 | 86.9 | 73.9
Visual math problem solvingMathVision | | | |
Scientific chart analysisCharXiv (RQ) | | | |

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.:

API Usage

Qwen3.8-Flash-Next models operate in thinking mode by default, generating thinking content signified by <think>\n...</think>\n\n before 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.0

Please 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

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,  
            "preserve_thinking": True, 
        },
    },
    reasoning_effort="xhigh",  
    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

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

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,
)















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

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": False instead 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


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": False directly instead of wrapping it in chat_template_kwargs.

Best Practices

To achieve optimal performance, we recommend the following settings:

  1. 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_penalty parameter 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.

  1. 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.

  1. 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.json file, change the rope_parameters fields in text_config to:

       {
           "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 1000000  

For 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 1000000

For 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_parameters configuration only when processing long contexts is required. It is also recommended to modify the factor as needed. For example, if the typical context length for your application is 524,288 tokens, it would be better to set factor as 2.0.

  1. Long Video Understanding : To optimize inference efficiency for plain text and images, the size parameter in the released video_preprocessor_config.json is conservatively configured. It is recommended to set the longest_edge parameter 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}
}