This repository manages a distributed vLLM inference cluster across two physical GPU nodes ("spark1" and "spark2"). The cluster runs inside Docker containers and is controlled via SSH from a local management machine.
Tech Stack: Bash scripts, SSH, tmux, Docker, nvidia-smi, vLLM
High-Level Architecture:
spark1(cat .env | grep SPARK1 | cut -d= -f2): Primary node - runs therun-recipe.pycontroller inside a tmux sessionspark2(cat .env | grep SPARK2 | cut -d= -f2): Secondary node - participates in the distributed cluster- Local machine: Issues commands via SSH to both nodes
. # Root: shell scripts for cluster control
├── .env # Cluster configuration (IPs, thresholds, etc.)
├── spark-start.sh # Launch vLLM cluster in tmux, tail logs
├── spark-stop.sh # Stop containers and kill tmux session
├── spark-shutdown.sh # Stop cluster then hard-shutdown both nodes
├── spark-tune.sh # Tune GPU clocks and benchmark both nodes
This is a shell script project—no build system. Validation is manual:
- Review script logic for correctness before editing
- Test changes with
./script.sh(or equivalent) on actual hardware
- Shebang:
#!/bin/bashon all scripts - Variable naming: Uppercase for constants (e.g.,
SPARK1,SESSION,RECIPE), lowercase for locals - Paths: Use
$(dirname "$0")for script-relative paths - SSH: Always quote commands passed to remote hosts to avoid local expansion issues
- Parallelism: Use
&+waitto parallelize SSH calls to multiple nodes - Error handling: Use
2>/dev/nullfor expected failures (e.g.,tmux kill-sessionwhen no session exists); propagate errors via exit codes - Logging: Use
/tmp/vllm.logfor cluster logs;mktemp+trap cleanup EXITfor temporary files
| Concept | Implementation |
|---|---|
| Cluster lifecycle | spark-start.sh → spark-stop.sh / spark-shutdown.sh |
| Node tuning | spark-tune.sh — drops caches, sets GPU clocks via nvidia-smi -lgc |
| Benchmarking | Remote ./benchmark.sh script on each node; parses TFLOPS output |
| Container management | docker stop vllm_node on each node |
| Session management | tmux session named vllm on spark1 |
-
Unquoted SSH commands:
ssh $HOST "echo $VAR"expands$VARlocally. Usessh $HOST 'echo $VAR'or escape:"echo \$VAR". -
Parallel SSH without wait: Forked SSH processes (
&) won't be reaped. Alwayswaitbefore reading results or exiting. -
Timing-sensitive cluster startup:
spark-start.shtails logs immediately. vLLM may need time to initialize containers. -
Hard shutdown during operation:
spark-shutdown.shsendssudo shutdown -h now. Only use afterspark-stop.shto cleanly terminate containers. -
GPU clock persistence:
nvidia-smi -lgcsets clocks temporarily. They reset on reboot—spark-tune.shmust be re-run after each boot. -
TFLOPS threshold: Defined in
.env(THRESHOLD=58), used byspark-tune.sh. GPUs below this threshold likely have thermal/power issues.