Text Generation
Transformers
Safetensors
minimax_m2
mxfp4_16
Mixture of Experts
mixture-of-experts
custom_code
8-bit precision
fp8
quantization
compressed-tensors
iq4_nl
sparse-moe
256-experts
top-8
rdna4
amd
rocm
rx9700
gfx12xx
vllm22
tclaviger
r9700
minimax
200k-context
long-context
function-calling
tool-use
agent
llm
large-language-model
open-source
chat
conversational
reasoning
8-bit precision
Instructions to use djdeniro/MiniMax-M2.7-MXFP416 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use djdeniro/MiniMax-M2.7-MXFP416 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="djdeniro/MiniMax-M2.7-MXFP416", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("djdeniro/MiniMax-M2.7-MXFP416", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("djdeniro/MiniMax-M2.7-MXFP416", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use djdeniro/MiniMax-M2.7-MXFP416 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "djdeniro/MiniMax-M2.7-MXFP416" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "djdeniro/MiniMax-M2.7-MXFP416", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/djdeniro/MiniMax-M2.7-MXFP416
- SGLang
How to use djdeniro/MiniMax-M2.7-MXFP416 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 "djdeniro/MiniMax-M2.7-MXFP416" \ --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": "djdeniro/MiniMax-M2.7-MXFP416", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "djdeniro/MiniMax-M2.7-MXFP416" \ --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": "djdeniro/MiniMax-M2.7-MXFP416", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use djdeniro/MiniMax-M2.7-MXFP416 with Docker Model Runner:
docker model run hf.co/djdeniro/MiniMax-M2.7-MXFP416
File size: 6,418 Bytes
dc6f8a4 a31cf7c dc6f8a4 92d90e3 aa3df05 92d90e3 dc6f8a4 92d90e3 dc6f8a4 aa3df05 92d90e3 dc6f8a4 92d90e3 dc6f8a4 e3ca50a 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 1a7f400 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 b85fae7 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 dc6f8a4 92d90e3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | ---
pipeline_tag: text-generation
license: other
license_name: other
license_link: https://github.com/MiniMax-AI/MiniMax-M2.7/blob/main/LICENSE
library_name: transformers
base_model: MiniMaxAI/MiniMax-M2.7
tags:
- minimax_m2
- mxfp4_16
- text-generation
- moe
- mixture-of-experts
- custom_code
- 8-bit precision
- fp8
- quantization
- compressed-tensors
- iq4_nl
- sparse-moe
- 256-experts
- top-8
- rdna4
- amd
- rocm
- rx9700
- gfx12xx
- vllm22
- tclaviger
- r9700
- minimax
- 200k-context
- long-context
- function-calling
- tool-use
- agent
- llm
- large-language-model
- open-source
- chat
- conversational
- reasoning
---
## `mxfp4_16` Quantization of [MiniMaxAI/MiniMax-M2.7](https://huggingface.co/MiniMaxAI/MiniMax-M2.7)
**Runtime:** Requires [`tcclaviger/vllm22:latest`](https://hub.docker.com/r/tcclaviger/vllm22) — a **RDNA 4 (gfx12xx)** vLLM image with `mxfp4_16` kernel support. No other vLLM build currently loads these weights.
---
## 1. Introduction
This is an **MXFP4-16** (Mixed-precision 4-bit with 16-element group size) quantized variant of [MiniMaxAI/MiniMax-M2.7](https://huggingface.co/MiniMaxAI/MiniMax-M2.7), produced using compressed-tensors with an **IQ4_NL** codebook.
The quantization:
- **4-bit** weights with 16-element group size, IQ4_NL codebook
- All `Linear` layers quantized (MoE experts, FFN, attention projections)
- Attention `k/v_proj` scales, router gate, norms, embeddings kept BF16
- KV cache: FP8 (e4m3), calibrated scales baked into checkpoint
The result fits in ~17.5 GiB per GPU (TP8) while retaining near-BF16 quality.
---
## 2. Model Architecture
- **229B total params** (BF16), **~12B activated** per token (top-8)
- **256 experts** per MoE layer, top-8 routing, 62 transformer layers
- **200k context window**
- Native tool-calling support
---
## 3. Runtime Requirements
- **GPU:** 8× RX 9700 (RDNA 4 / gfx12xx)
- **Memory:** 128GB+ system RAM
- **Docker:** `tcclaviger/vllm22:latest` — only validated runtime
The Docker image includes:
- Custom Triton attention kernels tuned for RDNA4
- Fixed FP8 KV-cache quantization path
- Pre-tuned GEMM configs for RX 9700
- MXFP4-16 kernels for gfx12xx
---
## 4. Deployment
**Full deployment guide (RDNA4 / RX 9700):** [docs/vllm_deploy_guide.md](./docs/vllm_deploy_guide.md)
Quick-start:
```bash
docker run --name minimax-mxfp416 \
--rm --tty --ipc=host --shm-size=128g \
--device /dev/kfd:/dev/kfd \
--device /dev/dri/renderD128:/dev/dri/renderD128 \
--device /dev/dri/renderD129:/dev/dri/renderD129 \
--device /dev/dri/renderD130:/dev/dri/renderD130 \
--device /dev/dri/renderD132:/dev/dri/renderD132 \
--device /dev/dri/renderD137:/dev/dri/renderD137 \
--device /dev/dri/renderD138:/dev/dri/renderD138 \
--device /dev/dri/renderD139:/dev/dri/renderD139 \
--device /dev/dri/renderD140:/dev/dri/renderD140 \
-e HIP_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
-e ROCR_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
-e TRUST_REMOTE_CODE=1 \
-v /path/to/models:/app/models:ro \
-p 8000:8000 \
tcclaviger/vllm22:latest \
bash -c "cp /app/models/vllm22_minimax_m2.py /app/vllm/vllm/model_executor/models/minimax_m2.py && \
pip install -q sentencepiece && \
exec vllm serve /app/models/MiniMax-M2.7-MXFP416 \
--served-model-name minimax-m2.7-mxfp416 \
--host 0.0.0.0 --port 8000 --trust-remote-code \
--tensor-parallel-size 8 --enable-expert-parallel \
--disable-cascade-attn \
--reasoning-parser minimax_m2 \
--enable-auto-tool-choice --tool-call-parser minimax_m2 \
--enable-prefix-caching --gpu-memory-utilization 0.93 \
--max-model-len 180000 --max-num-seqs 48 --max-num-batched-tokens 2048 \
--kv-cache-dtype fp8_e4m3 --attention-backend TRITON_ATTN \
--override-generation-config '{\"max_tokens\": 16384}'"
```
### Performance (8× RX 9700, 210W power limit)
| Metric | Value |
|--------|-------|
| Generation throughput | ~30–35 tokens/s |
| Prefill throughput | up to 2,190 tokens/s (w/ prefix cache) |
| Prefix cache hit rate | ~93% |
| KV cache memory | 11.35 GiB |
| KV cache capacity | 767,856 tokens |
| Max context per request | 180,000 tokens |
| Max concurrent (180k) | 4 requests |
| Model weight memory (TP8) | ~17.5 GiB/GPU |
> **Power tip:** Set `rocm-smi --setpowerlimit <i> 210` per GPU. At 210W sustained throughput is higher than at full 300W due to reduced thermal throttling.
---
## 5. API Usage
```python
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
completion = client.chat.completions.create(
model="minimax-m2.7-mxfp416",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
temperature=1.0,
max_tokens=1024,
)
print(completion.choices[0].message.content)
```
---
## 6. Chat Template
The model uses a Jinja chat template supporting system messages, tool calls (`<minimax:tool_call>`/`</minimax:tool_call>`), reasoning content (`<think>`/`</think>`), and tool responses (`<response>`).
```python
from transformers import AutoProcessor, AutoModelForCausalLM
processor = AutoProcessor.from_pretrained(
"djdeniro/MiniMax-M2.7-MXFP416", trust_remote_code=True
)
model = AutoModelForCausalLM.from_pretrained(
"djdeniro/MiniMax-M2.7-MXFP416",
device_map="auto", dtype="auto", trust_remote_code=True
)
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, how are you?"}
]
inputs = processor.apply_chat_template(
messages, tokenize=True, add_generation_prompt=True,
return_dict=True, return_tensors="pt"
).to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(processor.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
```
---
## 7. Inference Parameters
- `temperature`: 1.0
- `top_p`: 0.95
- `top_k`: 40
- `max_tokens`: 16384 (default)
---
## 8. Acknowledgments
- Base model: [MiniMaxAI/MiniMax-M2.7](https://huggingface.co/MiniMaxAI/MiniMax-M2.7)
- Quantization inspiration: [tcclaviger/Step-3.7-Flash-240REAP-MXFP416](https://huggingface.co/tcclaviger/Step-3.7-Flash-240REAP-MXFP416)
- Runtime: [tcclaviger/vllm22](https://hub.docker.com/r/tcclaviger/vllm22)
---
## 9. License
Apache 2.0 — inherits from [base model](https://github.com/MiniMax-AI/MiniMax-M2.7/blob/main/LICENSE). |