Instructions to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP # Run inference directly in the terminal: llama cli -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP # Run inference directly in the terminal: llama cli -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP # Run inference directly in the terminal: ./llama-cli -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP # Run inference directly in the terminal: ./build/bin/llama-cli -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Use Docker
docker model run hf.co/bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
- LM Studio
- Jan
- vLLM
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF", "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/bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
- Ollama
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with Ollama:
ollama run hf.co/bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
- Unsloth Studio
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF to start chatting
- Pi
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with Docker Model Runner:
docker model run hf.co/bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
- Lemonade
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Run and chat with the model
lemonade run user.Qwen3.8-27B-ROCmFP4-STRIX-GGUF-Q4_0_ROCMFP
List all available models
lemonade list
- Hermes Agent
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF:Q4_0_ROCMFP" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Qwen3.8-27B — ROCmFP4 (STRIX recipe) GGUF
An imatrix-calibrated Q4_0_ROCMFP4_STRIX build of
Qwen/Qwen3.8-27B, with the LM head kept at Q6_K.
ROCmFP4 is a Strix Halo–specific 4-bit format from the ROCmFPX llama.cpp fork. It is not a general-purpose quant: it only loads on a ROCmFPX-capable build. This file exists because almost nobody publishes this format, and because we measured it rather than assuming it.
The trade is ~10% faster decode and 0.6 GB smaller, for roughly 2x the quantization error. Both sides of that are measured below.
What it is
| file | Qwen3.8-27B-Q4_0_ROCMFP4_STRIX-q6Khead.gguf |
| size | 15.38 GB (+ 0.93 GB vision projector) |
| vision | yes — mmproj-F16.gguf included, verified working |
| base type | Q4_0_ROCMFP4_STRIX (~4.49 bpw, Strix Halo attn-K/V recipe) |
| LM head | Q6_K (see below — this is the important part) |
| token embeddings | Q6_K (from the STRIX recipe) |
| calibration | imatrix, 400 chunks × 512 tok (~205k tokens), DE + EN + code + tool-calls |
| context | 262144 |
Quality — measured, not claimed
KL-divergence against our own F16 conversion of the same weights, 200 chunks,
wikitext-2 (EN) and a held-out German Wikipedia slice (DE) disjoint from the calibration corpus.
Lower is better; same-top is how often the quant picks the same token as F16.
| build | size | KLD (EN) | KLD (DE) | same-top (EN) |
|---|---|---|---|---|
| this file | 15.38 GB | 0.034788 | 0.033229 | 91.43% |
| stock STRIX, no head fix | 15.01 GB | 0.046211 | 0.042837 | 88.91% |
| stock STRIX, no imatrix | 15.01 GB | 0.052341 | 0.048451 | 88.58% |
| reference: Q4_K_M, same weights | 16.0 GB | 0.017582 | 0.015666 | 93.18% |
Be clear about the trade-off: a standard Q4_K_M is roughly 2× closer to F16 for ~0.6 GB more. If you are not memory-constrained on a Strix Halo box, a K-quant is the better choice.
Speed — measured on identical runtime
Same rocmfpx build, same flags (-fa 1 -c 262144 -ctk q8_0 -ctv q8_0), cache-defeated 4096-token
prompts, concurrency 1. Only the quantization format differs between the first two rows.
| build | size | decode | prefill | warm TTFT |
|---|---|---|---|---|
| this file (ROCmFP4, HIP) | 15.38 GB | 13.0 tok/s | 377 tok/s | 0.672 s |
| Q4_K_M, same HIP runtime | 16.00 GB | 11.8 tok/s | 352 tok/s | 0.768 s |
| Q4_K_M, Vulkan-RADV | 16.00 GB | 12.9 tok/s | 288 tok/s | 1.303 s |
Against a K-quant on the same runtime: +10.2% decode, +7.1% prefill, +12.5% warm TTFT. That is the point of the format — native FP4 execution on Strix Halo, not just a smaller file.
Long-context retrieval verified on all three: needle-in-haystack at 42,850 tokens, correct.
Measured on a Ryzen AI MAX+ 395 / Radeon 8060S (gfx1151), 128 GB unified, llama.cpp b10400, ROCm 7.14.
Which should you use?
- Want the best quality? Use a K-quant — roughly 2x closer to F16 than this file.
- On Strix Halo, want the throughput and the smaller footprint? This file, and accept the higher divergence.
There is no version of this where ROCmFP4 is simply better. It is a deliberate trade.
Why the LM head is at Q6_K
The stock Q4_0_ROCMFP4_STRIX recipe protects token_embd.weight at Q6_K but leaves
output.weight at 4-bit. On this model the vocabulary is 248,320 tokens, so that head is
1.27B parameters feeding the logits directly.
Overriding just that one tensor:
- −24.7% KLD (EN), −22.4% (DE) — 19σ and 14σ
- +2.5 points top-token agreement
- costs 0.37 GB (one tensor out of 866)
q8_0 on the head was also tested and is not worth it (0.4σ better than q6_K, double the
size cost). Upgrading ffn_down helps more (−42% vs stock) but adds 1.68 GB, which makes the
file larger than a Q4_K_M while still being worse — strictly dominated, so it is not shipped.
Reproduce
# needs a ROCmFPX-capable llama.cpp (e.g. kyuz0/amd-strix-halo-toolboxes:*-rocmfpx)
llama-quantize \
--imatrix imatrix_a.gguf \
--output-tensor-type q6_K \
Qwen3.8-27B-F16.gguf \
Qwen3.8-27B-Q4_0_ROCMFP4_STRIX-q6Khead.gguf \
Q4_0_ROCMFP4_STRIX
Run
llama-server -m Qwen3.8-27B-Q4_0_ROCMFP4_STRIX-q6Khead.gguf \
--mmproj Qwen3.8-27B-mmproj-F16.gguf \
-dev ROCm0 -ngl 999 -fa 1 -c 262144 -ctk q8_0 -ctv q8_0 --jinja \
--chat-template-kwargs '{"enable_thinking":false}'
Drop --mmproj for text-only. The projector is kept at F16 deliberately — the imatrix never
touches the vision tower, and quantizing a projector costs image quality for very little size.
Requires a ROCmFPX build. It will not load on stock llama.cpp.
Notes
- Image input verified on this exact FP4 build (not just on the F16).
- Measured on a Ryzen AI MAX+ 395 / Radeon 8060S (gfx1151), 128 GB unified memory.
- KLD is measured against our own F16 conversion, so it reflects quantization loss only.
Upstream model card
Everything below is reproduced from the official Qwen/Qwen3.8-27B model card, unchanged. It describes the base model, not this quantization.
Qwen3.8-27B
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-27B will be available as a hosted version with more production features, e.g., 1M context length by default, official built-in tools. For more information, please refer to the Qwen3.8-27B Overview. The service is coming soon. Stay tuned for updates.
Following the widespread community adoption of the Qwen3.5 and Qwen3.6 series, we are pleased to introduce Qwen3.8, the most capable generation in the Qwen open-model family to date.
Built on the architectural foundation of Qwen3.5, Qwen3.8 delivers substantial gains across coding, professional work, research, and long-horizon agentic tasks. Qwen3.8-27B brings these advances to a compact, deployment-friendly dense model: a native vision-language model that understands images and videos, with flexible thinking control, designed to carry complex, multi-step tasks through to completion with greater reliability.
Qwen3.8 Highlights
Qwen3.8-27B features the following enhancements:
- Core Capabilities: Comprehensive improvements across coding, professional work, research, and long-horizon agentic tasks.
- Agent Execution: Stronger autonomous planning and better handling of environment feedback, leading to more reliable end-to-end task completion.
- Downstream Compatibility: Broader support for popular harnesses and development tools, making it easier to integrate into your existing stack.
- Flexible Thinking Control: Thinking mode is on by default and can be disabled per request; reasoning depth can be tuned with
reasoning_effort, and reasoning context from historical messages is retained viapreserve_thinking. - Vision-Language Understanding: Native support for image and video understanding, from STEM diagrams and documents to hour-scale videos.
Model Overview
- Type: Causal Language Model with Vision Encoder
- Training Stage: Pre-training & Post-training
- Language Model
- Number of Parameters: 27B
- Hidden Dimension: 5120
- Token Embedding: 248,320 (Padded)
- Number of Layers: 64
- Hidden Layout: 16 × (3 × (Gated DeltaNet → FFN) → 1 × (Gated Attention → FFN))
- Gated DeltaNet:
- Number of Linear Attention Heads: 48 for V and 16 for QK
- Head Dimension: 128
- Gated Attention:
- Number of Attention Heads: 24 for Q and 4 for KV
- Head Dimension: 256
- Rotary Position Embedding Dimension: 64
- Feed Forward Network:
- Intermediate Dimension: 17,408
- LM Output: 248,320 (Padded)
- MTP (Multi-Token Prediction): trained with multiple steps
- Context Length: 262,144 natively and extensible up to 1,000,000 tokens.
Benchmark Results
Text Performance
| Qwen3.8-27B | Qwen3.6-27B | Qwen3.7-Plus | Muse Glimmer-30B | Opus4.6 Max | |
|---|---|---|---|---|---|
| Coding | |||||
Agentic terminal coding Terminal Bench 2.1 (Terminus) |
73.0 | 63.4 | 64.0 | 51.7 | 78.2 |
Agentic coding SWE-bench Pro |
61.7 | 53.5 | 57.6 | 51.2 | 53.4 |
Repo-level code generation NL2Repo-Bench |
42.3 | 36.2 | 41.1 | -- | 47.6 |
Agentic coding DeepSWE 1.1 |
42.2 | 13.3 | 14.2 | -- | -- |
Software engineering QwenSWEBench |
79.0 | 49.3 | 59.2 | -- | 63.8 |
| Agent | |||||
Long-horizon office work CoWorkBench |
70.7 | 61.0 | 65.1 | -- | 68.2 |
Professional job tasks JobBench |
33.4 | 21.8 | 27.6 | -- | -- |
Frontier agentic tasks Agents' Last Exam |
Pass@1 20.4 Score 42.9 |
Pass@1 10.6 Score 27.3 |
Pass@1 13.2 Score 33.6 |
-- | -- |
| General | |||||
Instruction following IFBench |
79.5 | 69.1 | 79.1 | 77.0 | 62.5 |
Scientific reasoning GPQA Diamond |
89.2 | 87.8 | 90.3 | 83.5 | 91.3 |
Multidisciplinary reasoning HLE |
30.8 | 24.0 | 34.7 | 22.0 | 40.0 |
Competitive coding LiveCodeBench v6 |
90.3 | 83.9 | 89.6 | -- | 88.8 |
- SWE-bench Pro: Except for Opus4.6 Max, which uses the officially reported score, all models are evaluated with the Claude Code harness at temp=1.0, top_p=0.95, and a 256K context window. Problematic tasks were corrected, and all baseline models were re-evaluated on the refined benchmark.
- 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.
- DeepSWE 1.1: Evaluated with the Claude Code harness at temp=1.0, top_p=0.95, and a 256K context window.
- QwenSWEBench: In-house coding benchmark for evaluating models' software engineering capabilities. Evaluated with the Claude Code harness. Reporting avg@3 with an 8-hour timeout, max_tokens=32,768, temperature=1.0, and a 256K context window.
- CoWorkBench: In-house cowork benchmark for evaluating long-horizon tasks across computer science, finance, law, medical, and other productivity domains.
- HLE: Judged by GPT-4o.
- The best result in each row is shown in bold.
- Empty cells (--) indicate that results are not yet available or not applicable.
VL Performance
| Qwen3.8-27B | Qwen3.6-27B | Qwen3.7-Plus | Muse Glimmer-30B | Opus4.6 Max | |
|---|---|---|---|---|---|
| Agentic Multimodal Intelligence | |||||
Computer use OSWorld-Verified | 84.3 | 63.9 | 73.3 | 65.9 | 72.7 |
Browser use WebArena-Verified | 64.8 | 48.8 | 55.3 | -- | -- |
Mobile use AndroidWorld | 81.9 | 70.3 | 81.0 | -- | 62.0 |
Application recreation RecreationBench | 47.1 | 29.8 | 30.2 | -- | -- |
Multimodal tool use ClawEval-MM | Pass@3 57.4 Average 56.9 | Pass@3 42.6 Average 50.4 | Pass@3 57.4 Average 60.1 | -- | Pass@3 52.5 Average 54.7 |
Multimodal software engineering SWE-MM | 38.6 | 25.7 | 30.0 | -- | 27.1 |
Visual web development Vision2Web | 62.9 | 45.0 | 42.1 | -- | -- |
| General Multimodal Intelligence | |||||
Visual math problem solving MathVision | Without CI 90.0 With CI 94.6 | Without CI 85.1 | Without CI 90.3 | -- | Without CI 65.5 |
General visual reasoning BabyVision | Without CI 65.7 With CI 85.6 | Without CI 28.9 | Without CI 64.7 With CI 70.4 | -- | Without CI 12.6 |
Scientific chart analysis CharXiv (RQ) | Without CI 83.7 With CI 90.2 | Without CI 78.4 | Without CI 85.8 With CI 85.9 | 78.8 | Without CI 66.0 |
Document intelligence OmniDocBench 1.5 | 91.1 | 89.4 | 91.4 | 75.8 | 86.6 |
Real-world perception RealWorldQA | 85.9 | 84.1 | 86.9 | -- | 73.9 |
Embodied intelligence ERQA | 65.5 | 62.5 | 69.8 | -- | 40.8 |
- MathVision, BabyVision, and CharXiv (RQ): Where both settings are available, cells report “Without CI” and “With CI” separately; otherwise, only the available setting is shown. A small number of incorrect ground-truth annotations in MathVision and CharXiv (RQ) were corrected following manual verification, and all reported scores on those benchmarks were computed using the corrected annotations.
- MathVision: Qwen3.8-27B is evaluated using the fixed prompt: “Please reason step by step, and put your final answer within
\boxed{}.” For the remaining models, we report the higher score from two prompt variants—one with and one without the\boxed{}formatting requirement. - WebArena-Verified: Scores are computed with the official WebArena-Verified grader under the OSWorld scaffold.
- RecreationBench: An in-house, long-horizon application-recreation benchmark designed to evaluate hybrid-agent capabilities across five platforms: desktop (Ubuntu, macOS, and Windows), mobile (Android), and the web.
- ClawEval-MM: Scores are reported as “Pass@3 / average score.” Pass@3 is the percentage of tasks passed in at least one of three trials; the average score is the mean benchmark score across the three trials.
- Vision2Web: Scores are averaged across the frontend, webpage, and website categories. Evaluations use the Claude Code harness and are judged by
gpt-5.4-2026-03-05. - SWE-MM: Scores are evaluated on the Claude Code harness using the public dev split of SWE-bench Multimodal, with the modifications described in Appendix 8.3 of the Claude Opus 4.7 system card.
- Empty cells (--) indicate that results are not yet available or not applicable.
Quickstart
For streamlined integration, we recommend using Qwen3.8 via APIs.
Serving Qwen3.8
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, vLLM, or TokenSpeed are recommended.
Qwen3.8 can be deployed with popular inference frameworks, e.g.:
API Usage
Qwen3.8 models operate in thinking mode by default, generating thinking content signified by
<think>\n...</think>\n\nbefore producing the final response. To disable thinking content and obtain a 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.
Qwen3.8 comes with official support for reasoning_effort, which can be used to adjust reasoning depth and control cost:
xhigh(default): for complex tasks demanding thorough analysismedium: balancing accuracy and speedlow: efficient reasoning optimizing for speed and cost
In addition, preserve_thinking is enabled by default for all workloads for the best out-of-the-box experience. To disable preserved thinking, refer to the examples here.
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.
Chat Completions API
The Chat Completions API can be used with most inference frameworks, as well as Qwen Cloud. Before starting, make sure the OpenAI Python SDK is installed and the API key and the API base URL are configured, e.g.:
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL='your-base-url'
export OPENAI_API_KEY='your-api-key'
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-27B",
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-27B",
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-27B",
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-27B",
# 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-27B 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-27B",
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 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-27B",
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-27B 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.
@misc{qwen38,
title = {{Qwen3.8-Max}: A New Bar for Coding and Cowork},
url = {https://qwen.ai/blog?id=qwen3.8},
author = {{Qwen Team}},
month = {August},
year = {2026}
}
- Downloads last month
- 716
4-bit
Model tree for bg-digitalservices/Qwen3.8-27B-ROCmFP4-STRIX-GGUF
Base model
Qwen/Qwen3.8-27B