Instructions to use amd/DeepSeek-V4.1-Flash-Quark-MXFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amd/DeepSeek-V4.1-Flash-Quark-MXFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="amd/DeepSeek-V4.1-Flash-Quark-MXFP4")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("amd/DeepSeek-V4.1-Flash-Quark-MXFP4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use amd/DeepSeek-V4.1-Flash-Quark-MXFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amd/DeepSeek-V4.1-Flash-Quark-MXFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-V4.1-Flash-Quark-MXFP4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/amd/DeepSeek-V4.1-Flash-Quark-MXFP4
- SGLang
How to use amd/DeepSeek-V4.1-Flash-Quark-MXFP4 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 "amd/DeepSeek-V4.1-Flash-Quark-MXFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-V4.1-Flash-Quark-MXFP4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "amd/DeepSeek-V4.1-Flash-Quark-MXFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amd/DeepSeek-V4.1-Flash-Quark-MXFP4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use amd/DeepSeek-V4.1-Flash-Quark-MXFP4 with Docker Model Runner:
docker model run hf.co/amd/DeepSeek-V4.1-Flash-Quark-MXFP4
DeepSeek-V4.1-Flash-Quark-MXFP4
Model Overview
- Model Architecture: DeepseekV41ForCausalLM
- Input: Text, Image
- Output: Text
- Supported Hardware Microarchitecture: AMD MI355 / MI350 (gfx950). The native MXFP4 MoE kernel targets gfx950; MI300X / MI325X (gfx942) have not been validated.
- Quantization environment: ROCm 7.2.0, PyTorch 2.12.0, Transformers 5.17.0, AMD Quark 0.13.0. The serving environment is listed separately under Environment.
- Operating System(s): Linux
- Inference Engine: vLLM
- Model Optimizer: AMD-Quark (v0.13.0)
- Quantized layers:
expertsandshared_expertsin the language model - experts and shared_experts: OCP MXFP4 for both weights and activations
- Not quantized by Quark: attention (
self_attn) is kept in the source model's FP8: e4m3 weights with 32×32 blocks and UE8M0 scales, and dynamic per-group-32 FP8 activations. The vision tower is not quantized.
- Quantized layers:
Model Quantization
Quantized from deepseek-ai/DeepSeek-V4.1-Flash
with AMD Quark. The MoE expert
projections (experts, shared_experts) are quantized to OCP MXFP4, weights and
activations. All other modules are excluded from Quark quantization and, with
keep_excluded_layers_as_original_model_state=True, carried over unchanged from the
source checkpoint:
- attention (
self_attn), in the source model's FP8 (quant_methodfp8,weight_block_size[32, 32],scale_fmtue8m0), not quantized by Quark; - the vision tower, router gate, embeddings, output head, engram and MTP blocks.
Quantization script
from quark.torch import LLMTemplate, ModelQuantizer
MODEL_DIR = "deepseek-ai/DeepSeek-V4.1-Flash"
OUTPUT_DIR = "amd/DeepSeek-V4.1-Flash-Quark-MXFP4"
template = LLMTemplate(
model_type="deepseek_v41",
kv_layers_name=["*wkv"],
q_layer_name=["*wq_a", "*wq_b"],
exclude_layers_name=[
"*attn*",
"embed",
"*head*",
"*ffn.gate*",
"hc_*",
"*engram*",
"*vision*",
"*aligner*",
"*main_proj*",
],
)
LLMTemplate.register_template(template)
quant_config = template.get_config(scheme="mxfp4")
quantizer = ModelQuantizer(quant_config)
quantizer.direct_quantize_checkpoint(
pretrained_model_path=MODEL_DIR,
save_path=OUTPUT_DIR,
keep_excluded_layers_as_original_model_state=True,
)
Deployment
Use with vLLM
This model is served with the vLLM backend using the
Docker image vllm/vllm-openai-rocm:v0.33.0 with AITER rebuilt at commit f1965cd (tag v0.1.28) and FlyDSL 0.4.1,
TP=2, and VLLM_ROCM_USE_AITER_MOE=1, which runs the native MXFP4 MoE kernel (AITER_MXFP4_MXFP4).
All results and instructions on this card use this setup.
- The AITER rebuild is required. The image ships AITER 0.1.26, whose MXFP4 MoE fails during CUDA-graph capture with
Memory access fault. See Container and AITER and Launching server. - Newer image, no rebuild needed:
vllm/vllm-openai-rocm:deepseek-v41-flash-8a13616(vLLM 0.34.0rc1, AITER 0.1.29.post1, FlyDSL 0.5.0) also runs this model as shipped, with the same serve command. GSM8K on it: 92.72 for the base model, 91.28 for this model.
Evaluation
The model was evaluated with vLLM on GSM8K, GPQA Diamond, AIME26, MMMU-Pro, AA-LCR and IFBench, and on the agentic coding benchmarks DeepSWE v1.1 and Terminal-Bench 4.0.
Accuracy
| Benchmark | deepseek-ai/DeepSeek-V4.1-Flash | amd/DeepSeek-V4.1-Flash-Quark-MXFP4 (this model) | Recovery |
|---|---|---|---|
| GSM8K (8-shot, flexible-extract) | 92.49 | 92.04 | 99.5% |
| GPQA Diamond (0-shot, thinking, mean@8) | 90.15 | 88.64 | 98.3% |
| AIME26 (mean@16) | 97.50 | 97.71 | 100.2% |
| MMMU-Pro, standard (10 options, mean@1) | 76.47 | 76.36 | 99.9% |
| MMMU-Pro, vision (mean@1) | 72.95 | 72.02 | 98.7% |
| AA-LCR (LLM judge, mean@8) | 78.25 | 77.88 | 99.5% |
| IFBench (prompt-level loose, mean@5) | 78.93 | 78.13 | 99.0% |
GSM8K is measured with lm-eval, GPQA Diamond with sgl-eval, and AIME26, MMMU-Pro, AA-LCR and IFBench with EvalScope 1.14.1. For each benchmark the base and quantized models are run with the same framework, settings, and host. The serving setup used for each result is listed in Notes.
GPQA Diamond uses stochastic sampling (temperature=1.0, top_p=0.95), so each of the 8 runs over the 198 questions varies:
| Per-run range | Mean@8 | |
|---|---|---|
| Base | 87.88–91.41 | 90.15 |
| This model | 86.87–89.90 | 88.64 |
Paired by question, the difference is −1.52 ± 0.85 points (sign-flip p = 0.09), which is not significant.
Agentic coding
| Benchmark | deepseek-ai/DeepSeek-V4.1-Flash | amd/DeepSeek-V4.1-Flash-Quark-MXFP4 (this model) | Recovery |
|---|---|---|---|
| DeepSWE v1.1 (resolved, 113 tasks, mean@3) | 71.4 | 72.0 | 100.8% |
| Terminal-Bench 4.0 (pass rate, 63 tasks, mean@3) | 24.9 | 22.2 | 89.4% |
Both use mini-swe-agent 2.4.6 at DeepSeek's evaluation settings: reasoning_effort=max, temperature=1.0, top_p=0.95, 1M-token context, at most 500 agent steps.
DeepSWE v1.1:
- Harness: DeepSeek's
evaluation/README.mdsetup, i.e. Pier0c802fcwithdsh-minimal.patchand deep-swe0b9fabb. - Per-run solved counts: baseline 78 / 88 / 76, this model 79 / 82 / 83.
- Comparison: paired by task over the 3 runs, the difference is +0.6 ± 2.7 points (sign-flip p = 0.91), which is not significant.
Terminal-Bench 4.0:
- Harness: v4.0.0 on Harbor 0.25.
- Tasks: the 3 tasks that need NVIDIA H100 GPUs are excluded.
- Comparison: paired by task, the difference is −2.6 ± 4.0 points (sign-flip p = 0.60), which is not significant.
- Not directly comparable to DeepSeek's 31.2. DeepSeek used the DeepSeek Harness on all 66 tasks.
- One task fails for both models:
vllm-deepseek-streamingcannot be solved with vLLM'sdeepseek_v41tokenizer mode, which rejects message text containing the image token.
Grader timeouts count as unsolved for both models. Single runs vary by several points on both benchmarks, so only the means over 3 runs should be compared.
Serving for agentic use: the command under Launching server, with three changes:
--enable-auto-tool-choice --tool-call-parser deepseek_v41added (tool calling);--max-model-len 1048576;--gpu-memory-utilization 0.85.
Reproduction
All benchmarks use the environment, container and server below; the agentic benchmarks add the
serving flags listed under Agentic coding. The base model uses
deepseek-ai/DeepSeek-V4.1-Flash with the same flags, on its own TP=2 server.
Environment
| Component | Version |
|---|---|
| GPUs | AMD Instinct MI355X × 2 per model (TP=2) |
| Container | vllm/vllm-openai-rocm:v0.33.0 (vLLM 0.33.0, PyTorch 2.13.0+rocm10.0.0) |
| AITER | rebuilt at commit f1965cd26021c43436ae2bd614846a5977c2636e (tag v0.1.28, amd-aiter 0.1.28) with flydsl 0.4.1; the image ships AITER 0.1.26 and FlyDSL 0.4.0 |
| Evaluators | lm-eval 0.4.13 (GSM8K), sgl-eval 0.1.3 (GPQA Diamond), EvalScope 1.14.1 (AIME26, MMMU-Pro, AA-LCR, IFBench) |
| Checkpoint | this repository; the weights are unchanged since the initial upload |
Container and AITER
VGID=$(getent group video | cut -d: -f3); RGID=$(getent group render | cut -d: -f3)
docker run -d --name dsv41 \
--entrypoint /bin/bash --network=host --ipc=host --shm-size 64G \
--device=/dev/kfd --device=/dev/dri --group-add $VGID --group-add $RGID \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
-e VLLM_ROCM_USE_AITER=1 -e VLLM_ROCM_USE_AITER_MHA=1 -e VLLM_ROCM_USE_AITER_MOE=1 \
-e SAFETENSORS_FAST_GPU=1 -v /data/models:/data/models \
vllm/vllm-openai-rocm:v0.33.0 \
-c 'sleep infinity'
# Inside the container: AITER commit f1965cd (tag v0.1.28), which has the native MXFP4 MoE fixes
git clone https://github.com/ROCm/aiter.git /opt/aiter
cd /opt/aiter
git checkout f1965cd26021c43436ae2bd614846a5977c2636e
git submodule update --init --recursive
pip install flydsl==0.4.1
AITER_USE_SYSTEM_TRITON=1 python3 -m pip install -e . --no-build-isolation
python3 -c "import aiter, importlib.metadata as m; print(aiter.__file__, m.version('amd-aiter'))"
# expect: /opt/aiter/aiter/__init__.py 0.1.28
- The image has no
rendergroup name, so numeric group IDs are passed to--group-add. - Rebuild AITER before starting any server in the container. A server started on the image's AITER 0.1.26 compiles kernels into
/usr/local/lib/python3.12/dist-packages/aiter/jit; that directory survives the upgrade and hides the new install (ImportError: cannot import name 'ActivationType'). If that happens, move the directory away.
Launching server
VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_MHA=1 VLLM_ROCM_USE_AITER_MOE=1 \
vllm serve amd/DeepSeek-V4.1-Flash-Quark-MXFP4 \
--tensor-parallel-size 2 --trust-remote-code \
--tokenizer-mode deepseek_v41 --reasoning-parser deepseek_v41 \
--max-model-len 262144 --max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.90 --port 8000
--max-num-batched-tokens 8192is required: larger prefill chunks hit an untuned MoE kernel path.- The server log should show
Using 'AITER_MXFP4_MXFP4' Mxfp4 MoE backend. --max-model-len:- It must cover input plus output (
max_tokens). - 262144 was used for GSM8K, GPQA Diamond, AA-LCR and IFBench. AA-LCR needs it: ~95K-token inputs plus
max_tokens98,304. - AIME26 and MMMU-Pro were run with 131072.
- It must cover input plus output (
GSM8K
8-shot, greedy, all 1,319 questions:
python3 -m venv ~/lmeval-venv
~/lmeval-venv/bin/pip install 'lm-eval[api]==0.4.13' transformers # the tokenizer needs transformers
~/lmeval-venv/bin/lm_eval --model local-completions \
--model_args model=amd/DeepSeek-V4.1-Flash-Quark-MXFP4,base_url=http://localhost:8000/v1/completions,tokenized_requests=False,num_concurrent=8,tokenizer=amd/DeepSeek-V4.1-Flash-Quark-MXFP4,tokenizer_backend=huggingface,trust_remote_code=True \
--tasks gsm8k --batch_size auto --num_fewshot 8 --seed 42 \
--gen_kwargs "temperature=0,max_gen_toks=4096"
GPQA Diamond
Mean@8, thinking mode, default reasoning_effort:
python3 -m venv ~/sgleval-venv
~/sgleval-venv/bin/pip install 'sgl-eval==0.1.3'
~/sgleval-venv/bin/sgl-eval run gpqa \
--model amd/DeepSeek-V4.1-Flash-Quark-MXFP4 --api-key EMPTY \
--base-url http://localhost:8000/v1 \
--num-threads 64 --n-repeats 8 \
--max-tokens 65536 --temperature 1.0 --top-p 0.95 --thinking
AIME26, MMMU-Pro, AA-LCR and IFBench
Settings
- Thinking mode is on (the DeepSeek-V4.1 default).
reasoning_effortis not set, so the chat template's default (high= 75) applies. - Sampling:
temperature1.0,top_p0.95,max_tokens98,304. - Repeats are separate samples with no per-request seed; mean@k is the mean accuracy over all k samples.
Evaluation client
python3 -m venv ~/es-venv
~/es-venv/bin/pip install 'evalscope==1.14.1' langdetect
~/es-venv/bin/pip install -r ~/es-venv/lib/python3*/site-packages/evalscope/benchmarks/ifbench/requirements.txt
~/es-venv/bin/python -c "import nltk; [nltk.download(p) for p in ('punkt_tab','stopwords','averaged_perceptron_tagger_eng')]"
Commands
Common arguments:
MODEL=amd/DeepSeek-V4.1-Flash-Quark-MXFP4 # must match the served model name
URL=http://127.0.0.1:8000/v1/chat/completions
GEN='{"temperature":1.0,"top_p":0.95,"max_tokens":98304,"timeout":43200}'
AIME26 (mean@16; 16 runs of this command in separate work dirs):
evalscope eval --model $MODEL --api-url $URL --datasets aime26 \
--eval-batch-size 32 --generation-config "$GEN" --work-dir runs/aime26_run1
Do not name a work dir after the dataset (e.g. aime26): it shadows the dataset and the run fails with DataFilesNotFoundError.
MMMU-Pro (standard and vision):
evalscope eval --model $MODEL --api-url $URL --datasets mmmu_pro \
--dataset-args '{"mmmu_pro":{"extra_params":{"dataset_format":"standard (10 options)"}}}' \
--eval-batch-size 32 --generation-config "$GEN" --work-dir runs/mmmu_pro_standard
# vision: "dataset_format":"vision"
AA-LCR (mean@8, LLM judge):
evalscope eval --model $MODEL --api-url $URL --datasets aa_lcr --dataset-hub huggingface \
--dataset-args '{"aa_lcr":{"hf_dataset_revision":"bdae010bbce259820c0e34c1d7cce210d966fb75"}}' \
--eval-batch-size 32 --repeats 8 --generation-config "$GEN" \
--judge "$(cat judge.json)" --work-dir runs/aa_lcr_r8
Judge: gpt-5.6-luna through the OpenAI Responses API, reasoning_effort medium, max_tokens 4096. judge.json (fill in your own endpoint and key):
{"strategy": "auto",
"models": [{"model_id": "gpt-5.6-luna", "api_url": "<endpoint>/responses", "api_key": "<key>",
"eval_type": "openai_responses_api",
"generation_config": {"reasoning_effort": "medium", "max_tokens": 4096, "timeout": 600}}]}
- EvalScope masks only fields named
api_key; credentials in other fields (e.g.extra_headers) are written to the run log and config in plain text. - Start the first run alone until it has downloaded the AA-LCR documents. Two runs starting on an empty cache race and both fail.
IFBench (mean@5):
evalscope eval --model $MODEL --api-url $URL --datasets ifbench --dataset-hub huggingface \
--dataset-args '{"ifbench":{"primary_metric":"prompt_level_loose"}}' \
--eval-batch-size 32 --repeats 5 --generation-config "$GEN" --work-dir runs/ifbench_r5
Notes
Serving setup per result. All instructions on this card use vllm/vllm-openai-rocm:v0.33.0
with AITER f1965cd (tag v0.1.28) and FlyDSL 0.4.1.
- GSM8K and GPQA Diamond were measured on this setup.
- AIME26, MMMU-Pro, AA-LCR, IFBench, DeepSWE and Terminal-Bench were measured earlier on a vLLM nightly (0.32.1rc1, 2026-10-27) with AITER
59fae2078(14 commits beforef1965cd, with the same MXFP4 MoE fixes). That setup is listed for provenance only. - AA-LCR re-run on the v0.33.0 setup scored 78.88 for this model, within run-to-run variation of the 77.88 in the table.
License
This model is a quantized derivative of deepseek-ai/DeepSeek-V4.1-Flash and is distributed under the same license as the source model: the MIT License. A copy of the upstream LICENSE is included in this repository.
Modifications Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. AMD has modified the model weights of the MoE expert layers by quantizing them to MXFP4 with AMD Quark; the modifications are provided under the same MIT License and are not subject to any separate or different license.
- Downloads last month
- 1,134
Model tree for amd/DeepSeek-V4.1-Flash-Quark-MXFP4
Base model
deepseek-ai/DeepSeek-V4.1-Flash