Views
No views yet
| Configuration | Throughput | VRAM | Model Size | Hardware |
|---|---|---|---|---|
| NF4 (bitsandbytes) | 39.8 tok/s | 3.5 GB | ~2.5 GB | DGX Spark GB10 |
| bf16 (full precision) | 20.5 tok/s | 8.6 GB | ~8 GB | DGX Spark GB10 |
| Q4_K_M GGUF (CPU) | 12.3 tok/s | ~4 GB RAM | 2.4 GB | Azure D4as_v5 (4-core EPYC) |
max_new_tokens=200, temperature=0.3, do_sample=Truetorch.cuda.synchronize() before/after, wall-clock for CPU"The symptoms of malaria can vary depending on the type of malaria parasite, the severity of the infection, and the individual's immune response. Common symptoms include fever, chills, headache..."
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3
4quantization_config = BitsAndBytesConfig(
5 load_in_4bit=True,
6 bnb_4bit_compute_dtype=torch.bfloat16
7)
8
9tokenizer = AutoTokenizer.from_pretrained("google/medgemma-4b-it")
10model = AutoModelForCausalLM.from_pretrained(
11 "google/medgemma-4b-it",
12 quantization_config=quantization_config,
13 device_map="auto"
14)
15
16messages = [{"role": "user", "content": "What are the symptoms of malaria?"}]
17inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
18
19with torch.no_grad():
20 outputs = model.generate(inputs, max_new_tokens=200, temperature=0.3, do_sample=True)
21
22print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))1model = AutoModelForCausalLM.from_pretrained(
2 "google/medgemma-4b-it",
3 torch_dtype=torch.bfloat16,
4 device_map="auto"
5)1# Install llama.cpp
2git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
3cmake -B build && cmake --build build -j$(nproc) --target llama-server
4
5# Download model
6pip install huggingface_hub
7python3 -c "from huggingface_hub import hf_hub_download; hf_hub_download('unsloth/medgemma-4b-it-GGUF', 'medgemma-4b-it-Q4_K_M.gguf', local_dir='models')"
8
9# Serve
10./build/bin/llama-server -m models/medgemma-4b-it-Q4_K_M.gguf -c 2048 -t 4 --port 8080
11
12# Query
13curl http://localhost:8080/v1/chat/completions \
14 -d '{"messages":[{"role":"user","content":"What is malaria?"}],"max_tokens":200}'@misc{craneailabs2026medgemma,
title={MedGemma 4B Blackwell Inference Benchmark},
author={Crane AI Labs},
year={2026},
url={https://huggingface.co/CraneAILabs/medgemma-blackwell-benchmark}
}