Text Generation
Transformers
Safetensors
minimax_m2
neuralmagic
redhat
llmcompressor
quantized
FP4
conversational
custom_code
8-bit precision
compressed-tensors
Instructions to use RedHatAI/MiniMax-M2.5-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/MiniMax-M2.5-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHatAI/MiniMax-M2.5-NVFP4", 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("RedHatAI/MiniMax-M2.5-NVFP4", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("RedHatAI/MiniMax-M2.5-NVFP4", trust_remote_code=True) 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
- vLLM
How to use RedHatAI/MiniMax-M2.5-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/MiniMax-M2.5-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/MiniMax-M2.5-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RedHatAI/MiniMax-M2.5-NVFP4
- SGLang
How to use RedHatAI/MiniMax-M2.5-NVFP4 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 "RedHatAI/MiniMax-M2.5-NVFP4" \ --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": "RedHatAI/MiniMax-M2.5-NVFP4", "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 "RedHatAI/MiniMax-M2.5-NVFP4" \ --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": "RedHatAI/MiniMax-M2.5-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RedHatAI/MiniMax-M2.5-NVFP4 with Docker Model Runner:
docker model run hf.co/RedHatAI/MiniMax-M2.5-NVFP4
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
base_model:
|
| 6 |
+
- MiniMaxAI/MiniMax-M2.5
|
| 7 |
+
tags:
|
| 8 |
+
- neuralmagic
|
| 9 |
+
- redhat
|
| 10 |
+
- llmcompressor
|
| 11 |
+
- quantized
|
| 12 |
+
- FP4
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# MiniMax-M2.5-NVFP4
|
| 16 |
+
|
| 17 |
+
## Model Overview
|
| 18 |
+
- **Model Architecture:** MiniMaxM2ForCausalLM
|
| 19 |
+
- **Input:** Text
|
| 20 |
+
- **Output:** Text
|
| 21 |
+
- **Model Optimizations:**
|
| 22 |
+
- **Weight quantization:** FP4
|
| 23 |
+
- **Intended Use Cases:**
|
| 24 |
+
- Reasoning.
|
| 25 |
+
- Function calling.
|
| 26 |
+
- Subject matter experts via fine-tuning.
|
| 27 |
+
- Multilingual instruction following.
|
| 28 |
+
- Translation.
|
| 29 |
+
- **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws).
|
| 30 |
+
- **Release Date:** 02/12/2026
|
| 31 |
+
- **Version:** 1.0
|
| 32 |
+
- **Model Developers:** RedHat (Neural Magic)
|
| 33 |
+
|
| 34 |
+
### Model Optimizations
|
| 35 |
+
|
| 36 |
+
This model was obtained by quantizing the weights and activations of [MiniMax-M2.5](https://huggingface.co/MiniMaxAI/MiniMax-M2.5) to FP4 data type.
|
| 37 |
+
This optimization reduces the number of bits per parameter from 16 to 4, reducing the disk size and GPU memory requirements by approximately 75%.
|
| 38 |
+
Only the weights and activations of the linear operators within transformers blocks of the language model are quantized.
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
## Deployment
|
| 42 |
+
|
| 43 |
+
This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
+
from vllm import LLM, SamplingParams
|
| 47 |
+
from transformers import AutoTokenizer
|
| 48 |
+
|
| 49 |
+
model_id = "RedHatAI/MiniMax-M2.5-NVFP4"
|
| 50 |
+
number_gpus = 1
|
| 51 |
+
sampling_params = SamplingParams(temperature=1.0, top_p=0.95, top_k=40, min_p=0, max_tokens=256)
|
| 52 |
+
|
| 53 |
+
messages = [
|
| 54 |
+
{"role": "user", "content": prompt}
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 58 |
+
|
| 59 |
+
messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
|
| 60 |
+
|
| 61 |
+
prompts = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
| 62 |
+
|
| 63 |
+
llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
|
| 64 |
+
|
| 65 |
+
outputs = llm.generate(prompts, sampling_params)
|
| 66 |
+
|
| 67 |
+
generated_text = outputs[0].outputs[0].text
|
| 68 |
+
print(generated_text)
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
|
| 72 |
+
|
| 73 |
+
## Creation
|
| 74 |
+
|
| 75 |
+
<details>
|
| 76 |
+
<summary>Creation details</summary>
|
| 77 |
+
This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below.
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
import torch
|
| 82 |
+
from datasets import load_dataset
|
| 83 |
+
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
|
| 84 |
+
|
| 85 |
+
from llmcompressor import oneshot
|
| 86 |
+
from llmcompressor.modeling.minimax_m2 import ( # noqa: F401
|
| 87 |
+
CalibrationMiniMaxM2SparseMoeBlock,
|
| 88 |
+
)
|
| 89 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 90 |
+
|
| 91 |
+
# Load the model
|
| 92 |
+
model_id = "inference-optimization/MiniMax-M2.5-BF16"
|
| 93 |
+
config = AutoConfig.from_pretrained(model_id, trust_remote_code=True)
|
| 94 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 95 |
+
model_id, dtype=torch.bfloat16, config=config,trust_remote_code=True
|
| 96 |
+
)
|
| 97 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 98 |
+
# MoE calibration is handled automatically by the pipeline.
|
| 99 |
+
# The `CalibrationMiniMaxM2SparseMoeBlock` modules (from
|
| 100 |
+
# `llmcompressor.modeling.minimax_m2`) will be applied during calibration to enable
|
| 101 |
+
# proper expert calibration. These replace the original
|
| 102 |
+
# `MiniMaxM2SparseMoeBlock` class from
|
| 103 |
+
# `transformers.models.minimax_m2.modeling_minimax_m2`.
|
| 104 |
+
|
| 105 |
+
# Select calibration dataset.
|
| 106 |
+
DATASET_ID = "HuggingFaceH4/ultrachat_200k"
|
| 107 |
+
DATASET_SPLIT = "train_sft"
|
| 108 |
+
|
| 109 |
+
# Select number of samples. 512 samples is a good place to start.
|
| 110 |
+
# Increasing the number of samples can improve accuracy.
|
| 111 |
+
NUM_CALIBRATION_SAMPLES = 512
|
| 112 |
+
MAX_SEQUENCE_LENGTH = 2048
|
| 113 |
+
|
| 114 |
+
# Load dataset and preprocess.
|
| 115 |
+
ds = load_dataset(DATASET_ID, split=f"{DATASET_SPLIT}[:{NUM_CALIBRATION_SAMPLES}]")
|
| 116 |
+
ds = ds.shuffle(seed=42)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def preprocess(example):
|
| 120 |
+
return {
|
| 121 |
+
"text": tokenizer.apply_chat_template(
|
| 122 |
+
example["messages"],
|
| 123 |
+
tokenize=False,
|
| 124 |
+
)
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
ds = ds.map(preprocess)
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
# Tokenize inputs.
|
| 132 |
+
def tokenize(sample):
|
| 133 |
+
return tokenizer(
|
| 134 |
+
sample["text"],
|
| 135 |
+
padding=False,
|
| 136 |
+
max_length=MAX_SEQUENCE_LENGTH,
|
| 137 |
+
truncation=True,
|
| 138 |
+
add_special_tokens=False,
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
ds = ds.map(tokenize, remove_columns=ds.column_names)
|
| 143 |
+
|
| 144 |
+
moe_ignores = [
|
| 145 |
+
"lm_head",
|
| 146 |
+
"re:.*block_sparse_moe.gate$",
|
| 147 |
+
]
|
| 148 |
+
|
| 149 |
+
# Experts live under `model.layers.*.block_sparse_moe.experts.<idx>.(w1|w2|w3)`.
|
| 150 |
+
EXPERT_TARGET_REGEX = [
|
| 151 |
+
"re:.*block_sparse_moe\\.experts\\.\\d+\\.w1$",
|
| 152 |
+
"re:.*block_sparse_moe\\.experts\\.\\d+\\.w2$",
|
| 153 |
+
"re:.*block_sparse_moe\\.experts\\.\\d+\\.w3$",
|
| 154 |
+
]
|
| 155 |
+
|
| 156 |
+
recipe = QuantizationModifier(
|
| 157 |
+
targets=EXPERT_TARGET_REGEX,
|
| 158 |
+
scheme="NVFP4",
|
| 159 |
+
weight_observer="mse",
|
| 160 |
+
ignore= moe_ignores
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
# Apply algorithms.
|
| 165 |
+
oneshot(
|
| 166 |
+
model=model,
|
| 167 |
+
dataset=ds,
|
| 168 |
+
processor=tokenizer,
|
| 169 |
+
recipe=recipe,
|
| 170 |
+
num_calibration_samples=NUM_CALIBRATION_SAMPLES,
|
| 171 |
+
max_seq_length=MAX_SEQUENCE_LENGTH,
|
| 172 |
+
sequential_targets=["MiniMaxM2DecoderLayer"],
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
# Save to disk compressed.
|
| 176 |
+
SAVE_DIR = model_id.rstrip("/").split("/")[-1] + "-NVFP4"
|
| 177 |
+
model.save_pretrained(SAVE_DIR, save_compressed=True)
|
| 178 |
+
tokenizer.save_pretrained(SAVE_DIR)
|
| 179 |
+
|
| 180 |
+
</details>
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
## Evaluation
|
| 186 |
+
|
| 187 |
+
The model was evaluated on the ifeval, mmlu_pro and gsm8k_platinum using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness), on reasoning tasks using [lighteval](https://github.com/neuralmagic/lighteval/tree/reasoning).
|
| 188 |
+
[vLLM](https://docs.vllm.ai/en/stable/) was used for all evaluations.
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
<details>
|
| 192 |
+
<summary>Evaluation details</summary>
|
| 193 |
+
|
| 194 |
+
Deploy using vllm to create an OpenAI-compatible API endpoint:
|
| 195 |
+
|
| 196 |
+
- vLLM:
|
| 197 |
+
```shell
|
| 198 |
+
vllm serve RedHatAI/MiniMax-M2.5-NVFP4 --max-model-len 262144 --reasoning-parser deepseek_r1
|
| 199 |
+
```
|
| 200 |
+
|
| 201 |
+
**lm-evaluation-harness**
|
| 202 |
+
```
|
| 203 |
+
lm_eval --model local-chat-completions \
|
| 204 |
+
--tasks mmlu_pro_chat \
|
| 205 |
+
--model_args "model=RedHatAI/MiniMax-M2.5-NVFP4,max_length=262144,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=64,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
|
| 206 |
+
--num_fewshot 0 \
|
| 207 |
+
--apply_chat_template \
|
| 208 |
+
--gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,top_k=40,min_p=0.0,max_gen_toks=64000
|
| 209 |
+
```
|
| 210 |
+
|
| 211 |
+
```
|
| 212 |
+
lm_eval --model local-chat-completions \
|
| 213 |
+
--tasks ifeval \
|
| 214 |
+
--model_args "model=RedHatAI/MiniMax-M2.5-NVFP4,max_length=262144,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=64,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
|
| 215 |
+
--num_fewshot 0 \
|
| 216 |
+
--apply_chat_template \
|
| 217 |
+
--gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,top_k=40,min_p=0.0,max_gen_toks=64000
|
| 218 |
+
```
|
| 219 |
+
|
| 220 |
+
```
|
| 221 |
+
lm_eval --model local-chat-completions \
|
| 222 |
+
--tasks gsm8k_platinum_cot_llama \
|
| 223 |
+
--model_args "model=RedHatAI/MiniMax-M2.5-NVFP4,max_length=262144,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=64,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=1200" \
|
| 224 |
+
--num_fewshot 0 \
|
| 225 |
+
--apply_chat_template \
|
| 226 |
+
--gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,top_k=40,min_p=0.0,max_gen_toks=64000
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
**lighteval**
|
| 230 |
+
|
| 231 |
+
lighteval_model_arguments.yaml
|
| 232 |
+
```yaml
|
| 233 |
+
model_parameters:
|
| 234 |
+
model_name: RedHatAI/MiniMax-M2.5-NVFP4
|
| 235 |
+
dtype: auto
|
| 236 |
+
gpu_memory_utilization: 0.9
|
| 237 |
+
max_model_length: 40960
|
| 238 |
+
generation_parameters:
|
| 239 |
+
temperature: 1.0
|
| 240 |
+
top_k: 40
|
| 241 |
+
min_p: 0.0
|
| 242 |
+
top_p: 0.95
|
| 243 |
+
max_new_tokens: 64000
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
```
|
| 247 |
+
lighteval endpoint litellm lighteval_model_arguments.yaml \
|
| 248 |
+
"aime25|0,math_500|0,gpqa:diamond|0"
|
| 249 |
+
```
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
</details>
|
| 253 |
+
|
| 254 |
+
### Accuracy
|
| 255 |
+
|
| 256 |
+
| Benchmark | inference-optimization/MiniMax-M2.5-BF16 | inference-optimization/MiniMax-M2.5-NVFP4 | Recovery (%) |
|
| 257 |
+
|-----------|------------------------------------------|-------------------------------------------|--------------|
|
| 258 |
+
| GSM8k Platinum (0-shot) | 95.15 | 93.91 | 98.70 |
|
| 259 |
+
| IfEval (0-shot) | 88.17 | 85.40 | 96.86 |
|
| 260 |
+
| AIME 2025 | 87.50 | 77.08 | 88.10 |
|
| 261 |
+
| GPQA diamond | 83.67 | 80.30 | 95.98 |
|
| 262 |
+
| Math 500 | 87.33 | 87.73 | 100.46 |
|
| 263 |
+
| MMLU Pro Chat | 80.83 | 80.08 | 99.07 |
|