Initial commit: router front-door vLLM stack
Three always-running vLLM services (text TP=2 GPU0+1, ocr + embed on GPU2, sleep mode) behind a FastAPI router that auto-wakes models on request. Tiered idle (sleep 15 min / offload 3 h), depth-aware 503s with Retry-After, persisted wake-intent recovery, admin API on 127.0.0.1:8010. Routine control via vllmctl is pure HTTP — no docker on the request path. Verified: 91 router unit tests + 15-test E2E on real hardware (measurements in CALIBRATION.md; design record in .claude/memory/router-front-door-plan.md). Old nginx stack files removed before git init; design survives in .claude/memory/sleep-mode-implementation-plan.md. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
33
diag/gpu_integrity.py
Normal file
33
diag/gpu_integrity.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Per-GPU basic integrity: H2D/D2H copy fidelity, matmul correctness,
|
||||
repeated-copy stress. Does NOT test P2P — use p2p_check.py for that.
|
||||
|
||||
Run: docker exec vllm python3 /path/to/gpu_integrity.py
|
||||
"""
|
||||
import torch
|
||||
|
||||
print("torch", torch.__version__, "cuda", torch.version.cuda, "devs", torch.cuda.device_count())
|
||||
for dev in range(torch.cuda.device_count()):
|
||||
try:
|
||||
torch.cuda.set_device(dev)
|
||||
x = torch.randint(0, 2**31 - 1, (128 * 1024 * 1024,), dtype=torch.int32)
|
||||
y = x.to(f"cuda:{dev}")
|
||||
z = y.cpu()
|
||||
copy_ok = torch.equal(x, z)
|
||||
a = torch.randn(2048, 2048, dtype=torch.float32)
|
||||
b = torch.randn(2048, 2048, dtype=torch.float32)
|
||||
ref = (a.double() @ b.double()).float()
|
||||
c = (a.to(f"cuda:{dev}") @ b.to(f"cuda:{dev}")).cpu()
|
||||
err = (c - ref).abs().max().item()
|
||||
stress_ok = True
|
||||
for _ in range(20):
|
||||
s = torch.randint(0, 2**31 - 1, (16 * 1024 * 1024,), dtype=torch.int32)
|
||||
if not torch.equal(s, s.to(f"cuda:{dev}").cpu()):
|
||||
stress_ok = False
|
||||
break
|
||||
print(f"GPU{dev}: copy_ok={copy_ok} matmul_max_err={err:.3e} "
|
||||
f"stress_ok={stress_ok} name={torch.cuda.get_device_name(dev)}")
|
||||
del x, y, z, a, b, c
|
||||
torch.cuda.empty_cache()
|
||||
except Exception as e:
|
||||
print(f"GPU{dev}: ERROR {type(e).__name__}: {e}")
|
||||
58
diag/p2p_check.py
Normal file
58
diag/p2p_check.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""GPU P2P transfer integrity check.
|
||||
|
||||
Tests every ordered GPU pair: host -> src GPU -> dst GPU -> host, and
|
||||
compares against the host copy. ANY mismatch means the P2P DMA path is
|
||||
corrupting data and tensor-parallel inference MUST run with P2P disabled
|
||||
(NCCL_P2P_DISABLE=1 and, for vLLM, --disable-custom-all-reduce).
|
||||
|
||||
Run somewhere with torch + all GPUs visible, e.g.:
|
||||
docker exec vllm python3 /models/../diag/p2p_check.py
|
||||
or docker run --rm --gpus all -v $PWD/diag:/diag vllm/vllm-openai:v0.27.1 \
|
||||
python3 /diag/p2p_check.py
|
||||
"""
|
||||
import sys
|
||||
import torch
|
||||
|
||||
|
||||
def main():
|
||||
n = torch.cuda.device_count()
|
||||
print(f"torch={torch.__version__} gpus={n}")
|
||||
if n < 2:
|
||||
print("need >= 2 GPUs"); return 2
|
||||
for i in range(n):
|
||||
for j in range(n):
|
||||
if i != j:
|
||||
print(f"p2p {i}->{j} supported: {torch.cuda.can_device_access_peer(i, j)}")
|
||||
x = torch.arange(16 * 1024 * 1024, dtype=torch.float32, device="cpu")
|
||||
ref = x.clone()
|
||||
bad_pairs = []
|
||||
for src in range(n):
|
||||
for dst in range(n):
|
||||
if src == dst:
|
||||
continue
|
||||
try:
|
||||
a = x.to(f"cuda:{src}")
|
||||
b = a.to(f"cuda:{dst}")
|
||||
c = b.cpu()
|
||||
torch.cuda.synchronize()
|
||||
n_bad = int((c != ref).sum().item())
|
||||
status = "OK" if n_bad == 0 else f"CORRUPT ({n_bad}/{ref.numel()} elements wrong)"
|
||||
print(f"{src}->{dst}: {status}")
|
||||
if n_bad:
|
||||
bad_pairs.append((src, dst))
|
||||
del a, b, c
|
||||
torch.cuda.empty_cache()
|
||||
except Exception as e:
|
||||
print(f"{src}->{dst}: FAILED {type(e).__name__} {str(e)[:160]}")
|
||||
bad_pairs.append((src, dst))
|
||||
if bad_pairs:
|
||||
print(f"\nRESULT: {len(bad_pairs)} corrupt/failing P2P paths: {bad_pairs}")
|
||||
print("Keep NCCL_P2P_DISABLE=1 (+ --disable-custom-all-reduce for vLLM).")
|
||||
return 1
|
||||
print("\nRESULT: all P2P paths clean.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
43
diag/weight_check.py
Normal file
43
diag/weight_check.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify every tensor of a safetensors model is finite (no NaN/Inf) and
|
||||
sane. Usage: python3 weight_check.py /models/<MODEL_DIR>
|
||||
|
||||
Run inside the vllm container (it has torch + safetensors):
|
||||
docker cp diag/weight_check.py vllm:/tmp/ && \
|
||||
docker exec vllm python3 /tmp/weight_check.py /models/Qwen3.6-35B-A3B
|
||||
"""
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
import torch
|
||||
from safetensors import safe_open
|
||||
|
||||
|
||||
def main():
|
||||
model_dir = sys.argv[1] if len(sys.argv) > 1 else "/models"
|
||||
files = sorted(glob.glob(os.path.join(model_dir, "*.safetensors")))
|
||||
if not files:
|
||||
print(f"no safetensors found in {model_dir}")
|
||||
return 2
|
||||
total = bad = 0
|
||||
for f in files:
|
||||
with safe_open(f, framework="pt", device="cpu") as st:
|
||||
for k in st.keys():
|
||||
t = st.get_tensor(k)
|
||||
total += 1
|
||||
if torch.is_floating_point(t):
|
||||
if not torch.isfinite(t).all():
|
||||
print(f"BAD {os.path.basename(f)}::{k} "
|
||||
f"nan={int(torch.isnan(t).sum())} inf={int(torch.isinf(t).sum())}",
|
||||
flush=True)
|
||||
bad += 1
|
||||
elif t.dtype != torch.bool and (t.abs() > 1e6).any():
|
||||
print(f"ODD {os.path.basename(f)}::{k} max={t.abs().max().item()}",
|
||||
flush=True)
|
||||
print(f"DONE shards={len(files)} tensors={total} bad={bad}")
|
||||
return 1 if bad else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user