Instructions to use cyankiwi/MiniMax-M3-AWQ-INT4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cyankiwi/MiniMax-M3-AWQ-INT4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="cyankiwi/MiniMax-M3-AWQ-INT4", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("cyankiwi/MiniMax-M3-AWQ-INT4", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("cyankiwi/MiniMax-M3-AWQ-INT4", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cyankiwi/MiniMax-M3-AWQ-INT4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cyankiwi/MiniMax-M3-AWQ-INT4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cyankiwi/MiniMax-M3-AWQ-INT4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/cyankiwi/MiniMax-M3-AWQ-INT4
- SGLang
How to use cyankiwi/MiniMax-M3-AWQ-INT4 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 "cyankiwi/MiniMax-M3-AWQ-INT4" \ --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": "cyankiwi/MiniMax-M3-AWQ-INT4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "cyankiwi/MiniMax-M3-AWQ-INT4" \ --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": "cyankiwi/MiniMax-M3-AWQ-INT4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use cyankiwi/MiniMax-M3-AWQ-INT4 with Docker Model Runner:
docker model run hf.co/cyankiwi/MiniMax-M3-AWQ-INT4
Can this model run on the A100/sm80 architecture?
Anyone tried this yet?
I successfully ran the program on 8*a100 40g. However, after installing VLLM using the code provided by the author, it is necessary to modify the “vllm/_custom_ops.py” file to enable support for kv_cache_dtype.
I successfully ran the program on 8*a100 40g. However, after installing VLLM using the code provided by the author, it is necessary to modify the “vllm/_custom_ops.py” file to enable support for kv_cache_dtype.
Thanks for your reply. Could you share your patch code? I would really appreciate it.
I successfully ran the program on 8*a100 40g. However, after installing VLLM using the code provided by the author, it is necessary to modify the “vllm/_custom_ops.py” file to enable support for kv_cache_dtype.
Hi, thanks for sharing! I'm trying to reproduce your setup. Could you share the specific changes you made to for support?
Find /usr/local/lib/python3.12/dist-packages/vllm/_custom_ops.py
And edit the file
import torch
# ... Find the reshape_and_cache_flash function in the file and replace it with the following content...
def reshape_and_cache_flash(
key: torch.Tensor,
value: torch.Tensor,
key_cache: torch.Tensor,
value_cache: torch.Tensor,
slot_mapping: torch.Tensor,
kv_cache_dtype: str,
k_scale: torch.Tensor,
v_scale: torch.Tensor,
) -> None:
# ==========================================
# Patch for A100 (sm80) FP8 KV cache support
# ==========================================
if kv_cache_dtype in ("fp8", "fp8_e4m3"):
# Convert the input to a safe allocated type (such as bf16) and set to "auto" to bypass the check
key = key.to(key_cache.dtype)
value = value.to(value_cache.dtype)
kv_cache_dtype = "auto"
torch.ops._C_cache_ops.reshape_and_cache_flash(
key,
value,
key_cache,
value_cache,
slot_mapping,
kv_cache_dtype,
k_scale,
v_scale,
)
# ... Similarly, locate the reshape_and_cache function (non-Flash version) and make the same modifications ...
def reshape_and_cache(
key: torch.Tensor,
value: torch.Tensor,
key_cache: torch.Tensor,
value_cache: torch.Tensor,
slot_mapping: torch.Tensor,
kv_cache_dtype: str,
k_scale: torch.Tensor,
v_scale: torch.Tensor,
) -> None:
if kv_cache_dtype in ("fp8", "fp8_e4m3"):
key = key.to(key_cache.dtype)
value = value.to(value_cache.dtype)
kv_cache_dtype = "auto"
torch.ops._C_cache_ops.reshape_and_cache(
key,
value,
key_cache,
value_cache,
slot_mapping,
kv_cache_dtype,
k_scale,
v_scale,
)
But I haven't tried it yet, so I don't know if it works
I successfully ran the program on 8*a100 40g. However, after installing VLLM using the code provided by the author, it is necessary to modify the “vllm/_custom_ops.py” file to enable support for kv_cache_dtype.
Thanks for your reply. Could you share your patch code? I would really appreciate it.
Find /usr/local/lib/python3.12/dist-packages/vllm/_custom_ops.py and modify “kv_cache_dtype” into “auto”,just like the answer above, finally "FP8" does not support. The LLM will work but it use huge GPU memory