Instructions to use Demondiablo/medgemma-4b-it-mxfp8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Demondiablo/medgemma-4b-it-mxfp8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Demondiablo/medgemma-4b-it-mxfp8") 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("Demondiablo/medgemma-4b-it-mxfp8") model = AutoModelForMultimodalLM.from_pretrained("Demondiablo/medgemma-4b-it-mxfp8", device_map="auto") 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 Demondiablo/medgemma-4b-it-mxfp8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Demondiablo/medgemma-4b-it-mxfp8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Demondiablo/medgemma-4b-it-mxfp8", "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/Demondiablo/medgemma-4b-it-mxfp8
- SGLang
How to use Demondiablo/medgemma-4b-it-mxfp8 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 "Demondiablo/medgemma-4b-it-mxfp8" \ --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": "Demondiablo/medgemma-4b-it-mxfp8", "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 "Demondiablo/medgemma-4b-it-mxfp8" \ --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": "Demondiablo/medgemma-4b-it-mxfp8", "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 Demondiablo/medgemma-4b-it-mxfp8 with Docker Model Runner:
docker model run hf.co/Demondiablo/medgemma-4b-it-mxfp8
MedGemma 4B-IT (MXFP8 Microscaling)
This is an MXFP8 (Microscaling 8-bit Float) quantized version of google/medgemma-4b-it created using llm-compressor and formatted in compressed-tensors.
MXFP8 conforms to the OCP Microscaling Formats (MX) Specification, utilizing microscopic block-wise scaling (group_size=32) with E8M0 scale exponents. This architecture delivers superior numerical fidelity compared to standard per-tensor FP8 while achieving native tensor core acceleration on NVIDIA Blackwell (SM 10.0+) architecture.
Quantization Specifications
- Base Model: google/medgemma-4b-it
- Quantization Framework: llm-compressor
- Quantization Scheme:
MXFP8- Weights: Float8 (E4M3), group-wise scaling (
group_size=32), E8M0 scale factors - Input Activations: Dynamic group-wise microscaling (
group_size=32)
- Weights: Float8 (E4M3), group-wise scaling (
- Preserved Precision (BF16):
lm_head,embed_tokens,multi_modal_projector, and vision tower components are kept unquantized to guarantee full clinical and diagnostic fidelity. - Hardware Platform: Quantized and validated on NVIDIA RTX PRO 6000 Blackwell Server Edition (98 GB VRAM).
High-Performance Deployment with vLLM
vLLM natively parses compressed-tensors MXFP8 checkpoints:
from vllm import LLM, SamplingParams
model_name = "Demondiablo/medgemma-4b-it-mxfp8"
# Initialize vLLM engine
llm = LLM(
model=model_name,
trust_remote_code=True,
max_model_len=4096,
)
prompt = "Analyze the clinical implications of an acute ST-elevation myocardial infarction (STEMI)."
messages = [{"role": "user", "content": prompt}]
sampling_params = SamplingParams(
temperature=0.2,
max_tokens=512,
top_p=0.95,
)
outputs = llm.chat(messages=messages, sampling_params=sampling_params)
print(outputs[0].outputs[0].text)
Checkpoint Files
model.safetensors: MXFP8 compressed weights with per-group E8M0 scale factorsconfig.json: Model architecture withquantization_configmetadatarecipe.yaml: Reproducible LLM Compressor recipe- Tokenizer, processor, and chat template files for complete offline compatibility
- Downloads last month
- 18