Instructions to use joerunde/gemma-4-moe-nano with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use joerunde/gemma-4-moe-nano with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="joerunde/gemma-4-moe-nano") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("joerunde/gemma-4-moe-nano") model = AutoModelForMultimodalLM.from_pretrained("joerunde/gemma-4-moe-nano", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use joerunde/gemma-4-moe-nano with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "joerunde/gemma-4-moe-nano" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "joerunde/gemma-4-moe-nano", "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/joerunde/gemma-4-moe-nano
- SGLang
How to use joerunde/gemma-4-moe-nano 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 "joerunde/gemma-4-moe-nano" \ --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": "joerunde/gemma-4-moe-nano", "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 "joerunde/gemma-4-moe-nano" \ --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": "joerunde/gemma-4-moe-nano", "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 joerunde/gemma-4-moe-nano with Docker Model Runner:
docker model run hf.co/joerunde/gemma-4-moe-nano
gemma-4-moe-nano
A tiny, randomly-initialized stand-in for the gemma-4 MoE architecture
(google/gemma-4-26B-A4B-it), built for per-architecture correctness testing of
the spyre-inference backend on
IBM Spyre accelerators. It is not a usable language model β the weights are
random with only a brief conditioning pass, so its outputs are gibberish.
Why this exists
spyre-inference validates its Spyre lowering per model architecture. The real
gemma-4 MoE checkpoints are 26B+ parameters and dominate CI wall-clock, yet no small
public gemma-4 MoE checkpoint satisfies Spyre's head-size-multiple-of-64 rule (every
public tiny-random one uses head_dim 16/32). This model fills that gap: it carries
the exact gemma-4 architecture at a few-hundred-MB size, so the architecture can
be exercised on every PR while the full product models run in an opt-in suite.
What is preserved from the real architecture
Gemma4ForConditionalGeneration/model_type: gemma4, text + vision tower- Dual local/global head dim (256 / 512, both multiples of 64) and the 2-KV-head global-attention layers
- The 128-expert, top-8 MoE block
- The sliding/full
layer_typesmix (with afull_attentionlayer retained) - The full 262144-token vocabulary and the real tokenizer
Shrunk (size only): hidden size, FFN / MoE intermediate sizes, text layer count (β 6, keeping one full-attention layer), and vision layer count.
How it was generated
Reproducibly, by tests/data/generate_micro_gemma4_moe.py in spyre-inference:
it loads the real config, overrides only the size fields, applies controlled init
plus a short language-modeling conditioning pass (so the output distribution is
non-flat and numerically well-behaved), and verifies a finite fp16 forward.
Validation
Loaded and run compiled on a Spyre card via the text-backbone path
(hf_overrides={"architectures": ["Gemma4ForCausalLM"]}), with no CPU fallback β
the shrunk config lowers through the same SpyreGemma4ForCausalLM per-block compile
as the full model.
- Downloads last month
- 21