Instructions to use MiniMaxAI/MiniMax-M2.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MiniMaxAI/MiniMax-M2.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MiniMaxAI/MiniMax-M2.1", 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("MiniMaxAI/MiniMax-M2.1", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("MiniMaxAI/MiniMax-M2.1", 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]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use MiniMaxAI/MiniMax-M2.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MiniMaxAI/MiniMax-M2.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MiniMaxAI/MiniMax-M2.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MiniMaxAI/MiniMax-M2.1
- SGLang
How to use MiniMaxAI/MiniMax-M2.1 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 "MiniMaxAI/MiniMax-M2.1" \ --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": "MiniMaxAI/MiniMax-M2.1", "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 "MiniMaxAI/MiniMax-M2.1" \ --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": "MiniMaxAI/MiniMax-M2.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MiniMaxAI/MiniMax-M2.1 with Docker Model Runner:
docker model run hf.co/MiniMaxAI/MiniMax-M2.1
Loading weigts error when running MiniMax-2.1 with sglang using pipeline parallelism
When I`m running MiniMax-2.1 on H200 with sglang command:python3 -m sglang.launch_server --model /volume/models/MiniMaxAI/MiniMax-M2.1/snapshots/17f852dfda7d63c61b1107d47552bb30488ffbee --trust-remote-code --tp-size 2 --pp-size 2 --mem-fraction-static 0.85 --chunked-prefill-size 20480 --page-size 64 --cuda-graph-max-bs 64 --enable-metrics
the error occurs:
[2026-01-12 02:39:23 PP3 TP1] Scheduler hit an exception: Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/managers/scheduler.py", line 2653, in run_scheduler_process
scheduler = Scheduler(
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/managers/scheduler.py", line 316, in __init__
self.tp_worker = TpModelWorker(
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/managers/tp_worker.py", line 245, in __init__
self._model_runner = ModelRunner(
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/model_executor/model_runner.py", line 361, in __init__
self.initialize(min_per_gpu_memory)
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/model_executor/model_runner.py", line 436, in initialize
self.load_model()
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/model_executor/model_runner.py", line 804, in load_model
self.model = get_model(
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/model_loader/__init__.py", line 28, in get_model
return loader.load_model(
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/model_loader/loader.py", line 600, in load_model
self.load_weights_and_postprocess(
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/model_loader/loader.py", line 608, in load_weights_and_postprocess
model.load_weights(weights)
File "/usr/local/lib/python3.10/dist-packages/sglang/srt/models/minimax_m2.py", line 882, in load_weights
param = params_dict[name]
KeyError: 'model.layers.37.block_sparse_moe.e_score_correction_bias'
[2026-01-12 02:39:23] Received sigquit from a child process. It usually means the child failed.
PP is not supported for M2 in vLLM and SGLang currently. We recommend using TP or EP instead, as they have been fully implemented and verified.
PP is not supported for M2 in vLLM and SGLang currently. We recommend using TP or EP instead, as they have been fully implemented and verified.
Do you deploy M2 on RTX-5090 ? Do you have any recommended parameter configurations?
PP is not supported for M2 in vLLM and SGLang currently. We recommend using TP or EP instead, as they have been fully implemented and verified.
Are there any version requirements for vllm and sglang? I hope there are more parameters to refer to.
Are there any version requirements for vllm and sglang? I hope there are more parameters to refer to.
@DarrenChen We recommend using the latest release of vLLM/SGLang, as our optimizations and verification for M2.1/M2 are primarily focused on the most recent official versions.
Do you deploy M2 on RTX-5090 ? Do you have any recommended parameter configurations?
@tuo02 For detailed deployment parameters and recommended configurations (e.g., 4-GPU or 8-GPU setups), please refer to our documentation here: vllm, sglang.