--- library_name: transformers license: apache-2.0 license_link: https://huggingface.co/Qwen/Qwen3.6-27B/blob/main/LICENSE pipeline_tag: image-text-to-text base_model: - Qwen/Qwen3.6-27B tags: - unsloth - qwen - qwen3_5 --- > [!IMPORTANT] > ### MTP Layers Grafted on Unsloth UD XL Quantizations > > The GGUF files in this repo are **Unsloth Dynamic 2.0 XL (UD XL) quantizations** of Qwen3.6-27B > with **Multi-Token Prediction (MTP) layers grafted on top**. > > - **Base quantization:** Unsloth UD XL — see > [Unsloth Dynamic 2.0 GGUFs](https://unsloth.ai/docs/basics/unsloth-dynamic-v2.0-gguf) for benchmarks. > - **MTP layers:** Taken from > [Radamanthys11/Qwen3.6-27B-MTP-Q8_0-GGUF](https://huggingface.co/Radamanthys11/Qwen3.6-27B-MTP-Q8_0-GGUF) > and stored in **Q8_0** precision, then merged into the UD XL GGUFs. > - **Why Q8 for MTP?** The draft heads are small relative to the base model, so Q8_0 keeps them > near-lossless while avoiding the overhead of full-requantizing the entire stack. > - **`convert.py`:** The script used to graft MTP layers into the UD XL GGUFs. Adapted from > [this gist](https://gist.github.com/buzz/1c439684d5e3f36492ae9f64ef7e3f67). > - **`27B_MTP.gguf`:** The raw Q8_0 MTP layer source file used as input to `convert.py`. > > To run these files with MTP you need a custom build of **llama.cpp** that includes the MTP/speculative > decoding support from [PR #22673](https://github.com/ggml-org/llama.cpp/pull/22673). Follow the steps below. > > --- > > ### 🐳 Or Use Pre-built Docker Images (Recommended) > > Don't want to build from source? Ready-to-use Docker images with MTP support are available for multiple backends: > > > | Image | Backend | > |---|---| > | `havenoammo/llama:cuda13-server` | CUDA 13 | > | `havenoammo/llama:cuda12-server` | CUDA 12 | > | `havenoammo/llama:vulkan-server` | Vulkan | > | `havenoammo/llama:intel-server` | Intel (CPU/Xe) | > | `havenoammo/llama:rocm-server` | ROCm (AMD) | > > Quick start — running this model via Docker: > ```bash > docker run --gpus all --rm \ > -p 8080:8080 \ > -v ./models:/models \ > havenoammo/llama:cuda13-server \ > -m /models/Qwen3.6-27B-MTP-UD-Q8_K_XL.gguf \ > --port 8080 --host 0.0.0.0 \ > -n -1 --parallel 1 \ > --ctx-size 262144 --fit-target 844 \ > --mmap -ngl -1 --flash-attn on \ > --temp 1.0 --min-p 0.0 --top-p 0.95 --top-k 20 \ > --jinja \ > --chat-template-kwargs '{"preserve_thinking":true}' \ > --ubatch-size 512 --batch-size 2048 \ > --cache-type-k q8_0 --cache-type-v q8_0 \ > --spec-type mtp \ > --spec-draft-n-max 3 > ``` > The two flags that matter most for MTP are `--spec-type mtp` and `--spec-draft-n-max 3`. > See the [Reddit post](https://www.reddit.com/r/LocalLLaMA/comments/1tc132c/) for more details and discussion. > > --- > > ### Building llama.cpp with MTP Support — Step by Step > > #### 1. Clone and enter the repo > ```bash > git clone https://github.com/ggml-org/llama.cpp.git > cd llama.cpp > ``` > > #### 2. Fetch the latest remote changes > ```bash > git fetch origin > ``` > This pulls all new refs from the upstream repository so you're working off the current tip of master. > > #### 3. Fetch [PR #22673](https://github.com/ggml-org/llama.cpp/pull/22673) as a local branch > ```bash > git fetch origin pull/22673/head:pr-22673 > ``` > [PR #22673](https://github.com/ggml-org/llama.cpp/pull/22673) ("llama + spec: MTP Support") adds the speculative-decoding / MTP infrastructure that > lets `llama-server` consume multi-token prediction heads. We pull it directly without waiting for > it to be merged upstream. > > #### 4. Checkout master and reset to latest remote > ```bash > git checkout master > git reset --hard 856c3adac > ``` > Ensures a clean starting point at the current upstream master, discarding any local drift. > > #### 5. Merge the PR on top (non-fast-forward) > ```bash > git merge --no-ff pr-22673 -m "Merge [PR #22673](https://github.com/ggml-org/llama.cpp/pull/22673): llama + spec: MTP Support" > ``` > The `--no-ff` flag preserves a merge commit so you can cleanly cherry-pick or revert later if > the PR lands officially and changes. > > #### 6. Build `llama-server` > ```bash > cmake -B build -DGGML_CUDA=ON > cmake --build build --config Release --target llama-server > ``` > This produces `build/bin/llama-server`. > > #### 7. Run the server with MTP enabled > ```bash > ./build/bin/llama-server \ > -m path/to/qwen3.6-27b-ud-xl-mtp.gguf \ > --spec-type mtp \ > --spec-draft-n-max 3 > ``` > `--spec-type mtp` tells llama.cpp to use the MTP heads baked into the GGUF. > `--spec-draft-n-max 3` sets the max number of draft tokens per step (matching the model's 3 MTP layers). > --- --- # Read our How to [Run Qwen3.6 Guide!](https://unsloth.ai/docs/models/qwen3.6)
See Unsloth Dynamic 2.0 GGUFs for our quantization benchmarks.
---
# Qwen3.6-27B
[](https://chat.qwen.ai)
> [!Note]
> 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, KTransformers, etc.
Following the February release of the Qwen3.5 series, we're pleased to share the first open-weight variant of Qwen3.6. Built on direct feedback from the community, Qwen3.6 prioritizes stability and real-world utility, offering developers a more intuitive, responsive, and genuinely productive coding experience.
## Qwen3.6 Highlights
This release delivers substantial upgrades, particularly in
- **Agentic Coding:** the model now handles frontend workflows and repository-level reasoning with greater fluency and precision.
- **Thinking Preservation:** we've introduced a new option to retain reasoning context from historical messages, streamlining iterative development and reducing overhead.

For more details, please refer to our blog post [Qwen3.6-27B](https://qwen.ai/blog?id=qwen3.6-27b).
## 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: 248320 (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: 17408
- LM Output: 248320 (Padded)
- MTP: trained with multi-steps
- Context Length: 262,144 natively and extensible up to 1,010,000 tokens.
## Benchmark Results
### Language
### Vision Language
## Quickstart
For streamlined integration, we recommend using Qwen3.6 via APIs. Below is a guide to use Qwen3.6 via OpenAI-compatible API.
### Serving Qwen3.6
Qwen3.6 can be served via APIs with popular inference frameworks.
In the following, we show example commands to launch OpenAI-Compatible API servers for Qwen3.6 models.
> [!Important]
> 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.
> [!Important]
> The model has a default context length of 262,144 tokens.
> If you encounter out-of-memory (OOM) errors, consider reducing the context window.
> However, because Qwen3.6 leverages extended context for complex tasks, we advise maintaining a context length of at least 128K tokens to preserve thinking capabilities.
#### SGLang
[SGLang](https://github.com/sgl-project/sglang) is a fast serving framework for large language models and vision language models.
`sglang>=0.5.10` is recommended for Qwen3.6, which can be installed using the following command in a fresh environment:
```shell
uv pip install sglang[all]
```
See [its documentation](https://docs.sglang.ai/get_started/install.html) for more details.
The following will create API endpoints at `http://localhost:8000/v1`:
- **Standard Version**: The following command can be used to create an API endpoint with maximum context length 262,144 tokens using tensor parallel on 8 GPUs.
```shell
python -m sglang.launch_server --model-path Qwen/Qwen3.6-27B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --reasoning-parser qwen3
```
- **Tool Use**: To support tool use, you can use the following command.
```shell
python -m sglang.launch_server --model-path Qwen/Qwen3.6-27B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --reasoning-parser qwen3 --tool-call-parser qwen3_coder
```
- **Multi-Token Prediction (MTP)**: The following command is recommended for MTP:
```shell
python -m sglang.launch_server --model-path Qwen/Qwen3.6-27B --port 8000 --tp-size 8 --mem-fraction-static 0.8 --context-length 262144 --reasoning-parser qwen3 --speculative-algo NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
```
For detailed deployment guide, see the [SGLang Qwen3.5 Cookbook](https://lmsysorg.mintlify.app/cookbook/llm/Qwen/Qwen3.5).
#### vLLM
[vLLM](https://github.com/vllm-project/vllm) is a high-throughput and memory-efficient inference and serving engine for LLMs.
`vllm>=0.19.0` is recommended for Qwen3.6, which can be installed using the following command in a fresh environment:
```shell
uv pip install vllm --torch-backend=auto
```
See [its documentation](https://docs.vllm.ai/en/stable/getting_started/installation/index.html) for more details.
The following will create API endpoints at `http://localhost:8000/v1`:
- **Standard Version**: The following command can be used to create an API endpoint with maximum context length 262,144 tokens using tensor parallel on 8 GPUs.
```shell
vllm serve Qwen/Qwen3.6-27B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3
```
- **Tool Call**: To support tool use, you can use the following command.
```shell
vllm serve Qwen/Qwen3.6-27B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3 --enable-auto-tool-choice --tool-call-parser qwen3_coder
```
- **Multi-Token Prediction (MTP)**: The following command is recommended for MTP:
```shell
vllm serve Qwen/Qwen3.6-27B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3 --speculative-config '{"method":"qwen3_next_mtp","num_speculative_tokens":2}'
```
- **Text-Only**: The following command skips the vision encoder and multimodal profiling to free up memory for additional KV cache:
```shell
vllm serve Qwen/Qwen3.6-27B --port 8000 --tensor-parallel-size 8 --max-model-len 262144 --reasoning-parser qwen3 --language-model-only
```
For detailed deployment guide, see the [vLLM Qwen3.5 Recipe](https://docs.vllm.ai/projects/recipes/en/latest/Qwen/Qwen3.5.html).
#### KTransformers
[KTransformers](https://github.com/kvcache-ai/ktransformers) is a flexible framework for experiencing cutting-edge LLM inference optimizations with CPU-GPU heterogeneous computing.
For running Qwen3.6 with KTransformers, see the [KTransformers Deployment Guide](https://github.com/kvcache-ai/ktransformers/blob/main/doc/en/Qwen3.5.md).
#### Hugging Face Transformers
Hugging Face Transformers contains a _lightweight_ server which can be used for quick testing and moderate load deployment.
The latest `transformers` is required for Qwen3.6:
```shell
pip install "transformers[serving]"
```
See [its documentation](https://huggingface.co/docs/transformers/main/serving) for more details. Please also make sure torchvision and pillow are installed.
Then, run `transformers serve` to launch a server with API endpoints at `http://localhost:8000/v1`; it will place the model on accelerators if available:
```shell
transformers serve Qwen/Qwen3.6-27B --port 8000 --continuous-batching
```
### Using Qwen3.6 via the Chat Completions API
The chat completions API is accessible via standard HTTP requests or OpenAI SDKs.
Here, we show examples using the OpenAI Python SDK.
Before starting, make sure it is installed and the API key and the API base URL is configured, e.g.:
```shell
pip install -U openai
# Set the following accordingly
export OPENAI_BASE_URL="http://localhost:8000/v1"
export OPENAI_API_KEY="EMPTY"
```
> [!Tip]
> We recommend using the following set of sampling parameters for generation
> - Thinking mode for general tasks: `temperature=1.0, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0`
> - Thinking mode for precise coding tasks (e.g. WebDev): `temperature=0.6, 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.
> [!Important]
> Qwen3.6 models operate in thinking mode by default, generating thinking content signified by `