How to Deploy Molmo2-4B with vLLM
Younes El Hjouji
Detailed Deployment Instructions
1. Environment Setup
# Create a working directory
# Create virtual environment with Python 3.12
python3.12 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Verify Python version
python --version
# Upgrade pip
pip install --upgrade pip
# Install vLLM
pip install vllm
2. Launch Deployment
source venv/bin/activate
# Recommended public-facing configuration
vllm serve allenai/Molmo2-4B \
--trust-remote-code \
--dtype bfloat16 \
--max-model-len 8192 \
--max-num-batched-tokens 8192 \
--gpu-memory-utilization 0.60 \
--port 8000
3. Verification
3.1. Check server is running:
curl http://localhost:8000/v1/models
3.2. Test text inference:
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "allenai/Molmo2-4B",
"prompt": "Hello, how are you?",
"max_tokens": 50
}'
3.3. Test video inference:
VIDEO_BASE64=$(base64 -w 0 /path/to/video.mp4)
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d "{
\"model\": \"allenai/Molmo2-4B\",
\"messages\": [{
\"role\": \"user\",
\"content\": [
{
\"type\": \"video_url\",
\"video_url\": {
\"url\": \"data:video/mp4;base64,\$VIDEO_BASE64\"
}
},
{
\"type\": \"text\",
\"text\": \"Describe this video in detail.\"
}
]
}],
\"max_tokens\": 100
}"
Verified Results:
- Deployment succeeded with the 8K / 60% GPU configuration.
- Short text inference returned in about 0.5 seconds.
- A short video inference request completed in about 6.8 seconds and produced a detailed description.
4. Troubleshooting
Issue 1: trust_remote_code required
- Solution: Always include
--trust-remote-codewhen launching Molmo2 models.
Issue 2: Not enough free GPU memory
- Solution: Lower
--gpu-memory-utilizationor reduce--max-model-len.
Issue 3: Slow first load
- Solution: This is expected on the first run while the model weights are downloaded and the model is compiled.
5. Notes
- Molmo2-4B supports text, image, and video inputs through vLLM.
- The tested deployment used an 8K context window.
- This model requires
--trust-remote-code.
6. References
- Model Card: https://huggingface.co/allenai/Molmo2-4B
- GitHub: https://github.com/allenai/molmo2
- vLLM Documentation: https://docs.vllm.ai/