Instructions to use GadflyII/GLM-4.7-Flash-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GadflyII/GLM-4.7-Flash-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GadflyII/GLM-4.7-Flash-NVFP4") 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-NVFP4") model = AutoModelForCausalLM.from_pretrained("GadflyII/GLM-4.7-Flash-NVFP4") 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-NVFP4 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-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": "GadflyII/GLM-4.7-Flash-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/GadflyII/GLM-4.7-Flash-NVFP4
- SGLang
How to use GadflyII/GLM-4.7-Flash-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 "GadflyII/GLM-4.7-Flash-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": "GadflyII/GLM-4.7-Flash-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 "GadflyII/GLM-4.7-Flash-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": "GadflyII/GLM-4.7-Flash-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use GadflyII/GLM-4.7-Flash-NVFP4 with Docker Model Runner:
docker model run hf.co/GadflyII/GLM-4.7-Flash-NVFP4
MTP quality, 47 layer
Thank you so much for your contribution to open-source.
Did you check the MTP quality after this quantization?
Maybe leaving original precision for this last layer would be beneficial, what do you think?
No, I didn't. MTP in vLLM does not work at all if the MTP layer is NVFP4; so I did not test it at all.
I made a new version of this model with MTP, and will upload it as soon as testing is complete. I also changed the calibration scripts a bit and left the MTP layer in BF16 which increased the model size by 446MB, MTP works, and initial testing resulted in 63% acceptance rate (vs. 60% original BF16).
I will reply again as soon as it is uploaded.
Thanks! I am waiting for it so much! :-)
What could you say about throughput FP16/8 vs. NVP4 on Blackwell,
- will we notice the speedup and it is about no optimised kernels availability issue in vLLM or something other?
(according to this PR https://github.com/vllm-project/vllm/pull/32520 the speedup is huge for FP4, but only in case of dense models)
GadflyII/GLM-4.7-Flash-MTP-NVFP4 is up.
Blackwell has native hardware acceleration for FP4, which makes it considerably faster than FP8/BF16.
This morning that merged a PR in my vllm fork that should radically improve performance at larger context windows , give it a shot.