vllm-container / README.md
RickyDeSkywalker's picture
Upload folder using huggingface_hub
ccd8135 verified
# vLLM Container for DeltaAI (aarch64 / GH200)
Self-contained Apptainer SIF for running vLLM on NVIDIA GH200 (Grace-Hopper, aarch64) nodes.
Baked with vLLM bleeding-edge, Transformers 5.x (for new models like gemma-4),
and all runtime deps. No build-time setup needed on the target machine.
---
## 1. Contents
| Component | Version |
| --- | --- |
| Base image | NGC `nvcr.io/nvidia/pytorch:26.03-py3` |
| CUDA runtime | 13.2 (with `cuda-compat` 595.45.04 baked in for older drivers) |
| PyTorch | 2.11.0a0 (NGC build) |
| Triton | 3.6.0 (NGC build) |
| flash_attn | 2.7.4.post1 (NGC build) |
| vLLM | 0.19.1rc1.dev285+g19ec9a0a6 |
| Transformers | **5.5.4** (installed into `/opt/extra_pkgs`, auto-loaded via `PYTHONPATH`) |
| huggingface_hub | 0.36.2 |
| Tool parsers registered | 34 (includes `qwen3_coder`, `gemma4`, `deepseek_v3`, ...) |
Note: vLLM's internal metadata says it wants `transformers<5`. We bypass that at
runtime by shadowing the system Transformers 4.57 with 5.5.4 from `/opt/extra_pkgs`
via `PYTHONPATH` (set up automatically by `/.singularity.d/env/92-extra-packages.sh`).
---
## 2. Hardware / software requirements
| Requirement | Value |
| --- | --- |
| CPU arch | **aarch64** (ARM64 — Grace, Ampere Altra, Neoverse) |
| GPU | NVIDIA Hopper-class (GH200, H100, H200). Compute capability ≥ 9.0 assumed. |
| NVIDIA driver | **R535 or newer** (compat layer in SIF handles up to CUDA 13.2). DeltaAI's 570.172.08 is compatible. |
| Apptainer | 1.3+ (tested on 1.4.2). Singularity CE 4.x should also work. |
| Disk for SIF | ~40 GB |
| GPU memory | 80 GB+ per GPU recommended for TP=1 on 27-30B models |
---
## 3. Quick start
```bash
SIF=/path/to/vllm.sif
apptainer run --nv $SIF python -c "import vllm; print(vllm.__version__)"
```
If that prints a version, you're done with setup. Proceed to section 4 for a
real serve command.
---
## 4. Required bind mounts and env vars
The SIF is read-only. To let vLLM write caches and find your model checkpoints,
you must provide writable host paths via `--bind` and point env vars at them.
### 4.1 Minimal set
```bash
# HuggingFace model cache (the model weights live here)
--bind /path/on/host/.cache/huggingface:/hf_cache
--env HF_HOME=/hf_cache
--env HF_HUB_CACHE=/hf_cache/hub
--env HF_HUB_DISABLE_IMPLICIT_TOKEN=1
# Runtime caches (torch.compile, triton JIT, vLLM model info, etc.)
--bind /path/on/host/cache_dir:/app_cache
--env XDG_CACHE_HOME=/app_cache
--env VLLM_CACHE_ROOT=/app_cache/vllm
--env TRITON_CACHE_DIR=/app_cache/triton
--env TORCHINDUCTOR_CACHE_DIR=/app_cache/inductor
```
Create the cache dirs once: `mkdir -p $HOME/vllm_cache/{vllm,triton,inductor}`.
### 4.2 Why this is needed
- Apptainer's auto-home mount breaks on directories protected by POSIX ACLs
(common on HPC cluster home dirs), so we bind our own paths explicitly.
- vLLM writes: `~/.cache/vllm/modelinfos`, torch.compile cache, triton JIT cache.
All of these need a writable persistent path.
- `HF_HUB_DISABLE_IMPLICIT_TOKEN=1` avoids the container trying to read a
non-existent token file when home has no HF credentials.
---
## 5. Example: Serve Qwen3.5-27B with tool-calling
```bash
SIF=/work/nvme/bdjz/rwang18/vllm_container/vllm.sif
HF_CACHE=$HOME/.cache/huggingface
APP_CACHE=$HOME/vllm_cache
mkdir -p $APP_CACHE
apptainer run --nv \
--bind $HF_CACHE:/hf_cache \
--bind $APP_CACHE:/app_cache \
--env HF_HOME=/hf_cache \
--env HF_HUB_CACHE=/hf_cache/hub \
--env HF_HUB_DISABLE_IMPLICIT_TOKEN=1 \
--env XDG_CACHE_HOME=/app_cache \
--env VLLM_CACHE_ROOT=/app_cache/vllm \
--env TRITON_CACHE_DIR=/app_cache/triton \
--env TORCHINDUCTOR_CACHE_DIR=/app_cache/inductor \
$SIF \
python -m vllm.entrypoints.openai.api_server \
--model Qwen/Qwen3.5-27B \
--port 8000 \
--data-parallel-size 4 \
--max-model-len 163840 \
--quantization fp8 \
--gdn-prefill-backend triton \
--reasoning-parser qwen3 \
--enable-auto-tool-choice \
--tool-call-parser qwen3_coder
```
### Flag reference
| Flag | Why |
| --- | --- |
| `--nv` | Inject host NVIDIA driver libs |
| `--data-parallel-size 4` | One vLLM engine per GPU (4x GH200) |
| `--quantization fp8` | GH200 native FP8; halves weight memory, frees mamba cache blocks |
| `--gdn-prefill-backend triton` | Avoid missing `flashinfer` dependency for Qwen3.5 linear attention |
| `--reasoning-parser qwen3` | Parses `<thinking>...</thinking>` from Qwen3 output |
| `--tool-call-parser qwen3_coder` | Required for tool/function calling with Qwen3.5-Coder |
---
## 6. Example: Serve a model that needs Transformers 5.x (e.g. gemma-4)
Exactly the same command as above — Transformers 5.5.4 is preloaded into the
container. Just swap the model name and parser:
```bash
apptainer run --nv \
[... same bind/env flags as above ...] \
$SIF \
python -m vllm.entrypoints.openai.api_server \
--model google/gemma-4-31B-it \
--port 8000 \
--data-parallel-size 4 \
--max-model-len 262144 \
--quantization fp8 \
--enable-auto-tool-choice \
--tool-call-parser gemma4
```
---
## 7. Querying the served endpoint
vLLM defaults to `0.0.0.0:8000`, so any machine that can reach the compute node
can hit it.
```bash
# From the same node:
curl http://localhost:8000/v1/models
# From another node on the cluster:
curl http://<node_hostname>:8000/v1/models
# From outside the cluster (e.g. your laptop):
ssh -L 8000:<node_hostname>:8000 user@login_host
# then in your laptop browser: http://localhost:8000
```
OpenAI-compatible chat completion:
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3.5-27B",
"messages": [{"role": "user", "content": "hello"}]
}'
```
---
## 8. Tunable knobs for resource-constrained setups
| Symptom | Fix |
| --- | --- |
| `max_num_seqs (1024) exceeds available Mamba cache blocks (N)` | Add `--quantization fp8` (frees memory), OR `--max-num-seqs <N>`, OR `--gpu-memory-utilization 0.95` |
| Model too large to fit one GPU | Use `--tensor-parallel-size 4` (shards weights across 4 GPUs) instead of `--data-parallel-size 4` |
| Context length too short | Increase `--max-model-len`; you may need to lower `--max-num-seqs` to compensate |
| First run very slow | JIT compiling kernels; cache is persisted in `$APP_CACHE/triton` + `$APP_CACHE/inductor`, so second run is fast |
---
## 9. Troubleshooting
### `cuDriverGetVersion = 12080` instead of 13020
The cuda-compat layer isn't active. Sanity-check:
```bash
apptainer exec --nv $SIF bash -c 'echo $LD_LIBRARY_PATH; python -c "import ctypes; l=ctypes.CDLL(\"libcuda.so.1\"); v=ctypes.c_int(); l.cuDriverGetVersion(ctypes.byref(v)); print(v.value)"'
```
Expected: `/usr/local/cuda/compat` as the first entry in LD_LIBRARY_PATH, and `cuDriverGetVersion = 13020`.
If missing, the env-script `/.singularity.d/env/91-cuda-compat.sh` didn't fire — check `apptainer --version` is ≥ 1.3.
### `Permission denied` on `~/.cache/huggingface/...`
Your cluster's home dir probably uses POSIX ACLs that don't survive user
namespace. Use `--bind /explicit/path/to/cache:/hf_cache` (section 4) rather than
relying on auto-home.
### `ModuleNotFoundError: No module named 'flashinfer'`
Some models (linear-attention Qwen3.5) try to use `flashinfer` for prefill.
It's not installed in this SIF. Pass `--gdn-prefill-backend triton` to fall back
to the Triton kernel (~5-10% slower but works).
### `NVIDIA Driver Release 595.45 or later ... compatibility mode is UNAVAILABLE`
This NGC entrypoint warning is a false positive — it doesn't detect our baked-in
cuda-compat. The actual runtime verifies with `cuDriverGetVersion = 13020` (see above).
Safe to ignore.
### Model weights not found / re-downloading
vLLM looks in `$HF_HUB_CACHE` (which you set to `/hf_cache/hub` via `--env`).
Make sure the model is already in `<host>/.cache/huggingface/hub/models--<org>--<name>/`
and that you bind-mounted the correct parent directory.
### Container crashes silently right after launch
Check `nvidia-smi --query-compute-apps=pid --format=csv` — a previous vLLM run
may have orphaned workers holding the GPU. Clean up:
```bash
pkill -9 -u $USER -f "VLLM::Worker\|vllm\|api_server"
```
---
## 10. What's baked in vs. what's bound
At runtime the container sees a merged view:
- **Read-only squashfs** (ID 3 in `apptainer sif list`): the NGC 26.03 base.
- **Read-only ext3 overlay** (ID 4): cuda-compat, vLLM, tool parsers, `/opt/extra_pkgs/` with Transformers 5.x.
- **Your bind mounts**: `/hf_cache`, `/app_cache`.
- **Auto-injected by `--nv`**: host NVIDIA driver libs (`libcuda.so`, `libnvidia-ml.so`, `nvidia-smi`).
Nothing inside the SIF can be modified at runtime. To upgrade any baked-in
package, you'd need to rebuild the SIF (see repo-root install script).
---
## 11. Moving the SIF between machines
The SIF is a single file, portable across aarch64 Linux boxes. Copy:
```bash
scp vllm.sif user@other_host:/path/
# or
rsync -avh --progress vllm.sif user@other_host:/path/
```
Target machine just needs:
- `apptainer` installed
- aarch64 + NVIDIA driver ≥ R535
- Enough disk for the SIF (~40 GB) and model checkpoints
No python, no conda, no vllm install on the target.
---
## 12. Files in this directory
| File | Purpose |
| --- | --- |
| `vllm.sif` | The actual container image |
| `README.md` | This file |
For the build recipe (how `vllm.sif` was produced) see
`/taiga/illinois/eng/cs/tozhang/ricky/vllm_container/install_container.sh`.