Instructions to use GadflyII/GLM-4.7-Flash-MXFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GadflyII/GLM-4.7-Flash-MXFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GadflyII/GLM-4.7-Flash-MXFP4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("GadflyII/GLM-4.7-Flash-MXFP4") model = AutoModelForCausalLM.from_pretrained("GadflyII/GLM-4.7-Flash-MXFP4") 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 GadflyII/GLM-4.7-Flash-MXFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GadflyII/GLM-4.7-Flash-MXFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GadflyII/GLM-4.7-Flash-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/GadflyII/GLM-4.7-Flash-MXFP4
- SGLang
How to use GadflyII/GLM-4.7-Flash-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 "GadflyII/GLM-4.7-Flash-MXFP4" \ --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": "GadflyII/GLM-4.7-Flash-MXFP4", "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 "GadflyII/GLM-4.7-Flash-MXFP4" \ --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": "GadflyII/GLM-4.7-Flash-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use GadflyII/GLM-4.7-Flash-MXFP4 with Docker Model Runner:
docker model run hf.co/GadflyII/GLM-4.7-Flash-MXFP4
can not run
Dockerfile
FROM vllm/vllm-openai:nightly-4753f3bf69a2b975361afa7c49e8d948047613f6
RUN apt-get update && apt-get install -y git && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN pip install git+https://github.com/huggingface/transformers.git@76732b4e7120808ff989edbd16401f61fa6a0afa
EXPOSE 8000
ENTRYPOINT ["vllm", "serve", "GadflyII/GLM-4.7-Flash-NVFP4", \
"--tensor-parallel-size", "1", \
"--max-model-len", "65536", \
"--trust-remote-code", \
"--gpu-memory-utilization", "0.90", \
"--host", "0.0.0.0"]
Log
(EngineCore_DP0 pid=137) File "/usr/local/lib/python3.12/dist-packages/vllm/model_executor/models/glm4_moe_lite.py", line 508, in load_weights
(EngineCore_DP0 pid=137) weight_loader(param, loaded_weight)
(EngineCore_DP0 pid=137) TypeError: FusedMoE.weight_loader() missing 3 required positional arguments: 'weight_name', 'shard_id', and 'expert_id'
Is this for the NVFP4 or MXFP4? (your docker file says NVFP4, but you opened this in the MXFP4 page).
Edit:
If you are trying to run this MXFP4 model on blackwell GPU's. You will need to pull my fork listed in the model card. You will also need to make sure you have the release version of transformers 5.0.0 installed.
sorry, I pasted a wrong dockerfile.
I both tried MXFP4 and NVFP4. NVFP4 works fine.
so it's necessary to use your vllm fork to run MXFP4, right?
I'll try again. my machine stucked when compiling vllm yesterday.
I see your new comment in model card.
I choose to keep using NVFP4 for speed.
thanks!
Pull and build my fork, make sure you have 5.0.0
release transformers installed, NV4FP model got a lot faster ;)