@draht/pods 2026.3.2-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +511 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +346 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/models.d.ts +39 -0
  7. package/dist/commands/models.d.ts.map +1 -0
  8. package/dist/commands/models.js +658 -0
  9. package/dist/commands/models.js.map +1 -0
  10. package/dist/commands/pods.d.ts +21 -0
  11. package/dist/commands/pods.d.ts.map +1 -0
  12. package/dist/commands/pods.js +175 -0
  13. package/dist/commands/pods.js.map +1 -0
  14. package/dist/commands/prompt.d.ts +7 -0
  15. package/dist/commands/prompt.d.ts.map +1 -0
  16. package/dist/commands/prompt.js +54 -0
  17. package/dist/commands/prompt.js.map +1 -0
  18. package/dist/config.d.ts +11 -0
  19. package/dist/config.d.ts.map +1 -0
  20. package/dist/config.js +74 -0
  21. package/dist/config.js.map +1 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +3 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/model-configs.d.ts +22 -0
  27. package/dist/model-configs.d.ts.map +1 -0
  28. package/dist/model-configs.js +75 -0
  29. package/dist/model-configs.js.map +1 -0
  30. package/dist/models.json +295 -0
  31. package/dist/scripts/model_run.sh +83 -0
  32. package/dist/scripts/pod_setup.sh +336 -0
  33. package/dist/ssh.d.ts +24 -0
  34. package/dist/ssh.d.ts.map +1 -0
  35. package/dist/ssh.js +115 -0
  36. package/dist/ssh.js.map +1 -0
  37. package/dist/types.d.ts +23 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/types.js +3 -0
  40. package/dist/types.js.map +1 -0
  41. package/package.json +40 -0
  42. package/scripts/model_run.sh +83 -0
  43. package/scripts/pod_setup.sh +336 -0
@@ -0,0 +1,336 @@
1
+ #!/usr/bin/env bash
2
+ # GPU pod bootstrap for vLLM deployment
3
+ set -euo pipefail
4
+
5
+ # Parse arguments passed from pi CLI
6
+ MOUNT_COMMAND=""
7
+ MODELS_PATH=""
8
+ HF_TOKEN=""
9
+ PI_API_KEY=""
10
+ VLLM_VERSION="release" # Default to release
11
+
12
+ while [[ $# -gt 0 ]]; do
13
+ case $1 in
14
+ --mount)
15
+ MOUNT_COMMAND="$2"
16
+ shift 2
17
+ ;;
18
+ --models-path)
19
+ MODELS_PATH="$2"
20
+ shift 2
21
+ ;;
22
+ --hf-token)
23
+ HF_TOKEN="$2"
24
+ shift 2
25
+ ;;
26
+ --vllm-api-key)
27
+ PI_API_KEY="$2"
28
+ shift 2
29
+ ;;
30
+ --vllm)
31
+ VLLM_VERSION="$2"
32
+ shift 2
33
+ ;;
34
+ *)
35
+ echo "ERROR: Unknown option: $1" >&2
36
+ exit 1
37
+ ;;
38
+ esac
39
+ done
40
+
41
+ # Validate required parameters
42
+ if [ -z "$HF_TOKEN" ]; then
43
+ echo "ERROR: HF_TOKEN is required" >&2
44
+ exit 1
45
+ fi
46
+
47
+ if [ -z "$PI_API_KEY" ]; then
48
+ echo "ERROR: PI_API_KEY is required" >&2
49
+ exit 1
50
+ fi
51
+
52
+ if [ -z "$MODELS_PATH" ]; then
53
+ echo "ERROR: MODELS_PATH is required" >&2
54
+ exit 1
55
+ fi
56
+
57
+ echo "=== Starting pod setup ==="
58
+
59
+ # Install system dependencies
60
+ apt update -y
61
+ apt install -y python3-pip python3-venv git build-essential cmake ninja-build curl wget lsb-release htop pkg-config
62
+
63
+ # --- Install matching CUDA toolkit -------------------------------------------
64
+ echo "Checking CUDA driver version..."
65
+ DRIVER_CUDA_VERSION=$(nvidia-smi | grep "CUDA Version" | awk '{print $9}')
66
+ echo "Driver supports CUDA: $DRIVER_CUDA_VERSION"
67
+
68
+ # Check if nvcc exists and its version
69
+ if command -v nvcc &> /dev/null; then
70
+ NVCC_VERSION=$(nvcc --version | grep "release" | awk '{print $6}' | cut -d, -f1)
71
+ echo "Current nvcc version: $NVCC_VERSION"
72
+ else
73
+ NVCC_VERSION="none"
74
+ echo "nvcc not found"
75
+ fi
76
+
77
+ # Install CUDA toolkit matching driver version if needed
78
+ if [[ "$NVCC_VERSION" != "$DRIVER_CUDA_VERSION" ]]; then
79
+ echo "Installing CUDA Toolkit $DRIVER_CUDA_VERSION to match driver..."
80
+
81
+ # Detect Ubuntu version
82
+ UBUNTU_VERSION=$(lsb_release -rs)
83
+ UBUNTU_CODENAME=$(lsb_release -cs)
84
+
85
+ echo "Detected Ubuntu $UBUNTU_VERSION ($UBUNTU_CODENAME)"
86
+
87
+ # Map Ubuntu version to NVIDIA repo path
88
+ if [[ "$UBUNTU_VERSION" == "24.04" ]]; then
89
+ REPO_PATH="ubuntu2404"
90
+ elif [[ "$UBUNTU_VERSION" == "22.04" ]]; then
91
+ REPO_PATH="ubuntu2204"
92
+ elif [[ "$UBUNTU_VERSION" == "20.04" ]]; then
93
+ REPO_PATH="ubuntu2004"
94
+ else
95
+ echo "Warning: Unsupported Ubuntu version $UBUNTU_VERSION, trying ubuntu2204"
96
+ REPO_PATH="ubuntu2204"
97
+ fi
98
+
99
+ # Add NVIDIA package repositories
100
+ wget https://developer.download.nvidia.com/compute/cuda/repos/${REPO_PATH}/x86_64/cuda-keyring_1.1-1_all.deb
101
+ dpkg -i cuda-keyring_1.1-1_all.deb
102
+ rm cuda-keyring_1.1-1_all.deb
103
+ apt-get update
104
+
105
+ # Install specific CUDA toolkit version
106
+ # Convert version format (12.9 -> 12-9)
107
+ CUDA_VERSION_APT=$(echo $DRIVER_CUDA_VERSION | sed 's/\./-/')
108
+ echo "Installing cuda-toolkit-${CUDA_VERSION_APT}..."
109
+ apt-get install -y cuda-toolkit-${CUDA_VERSION_APT}
110
+
111
+ # Add CUDA to PATH
112
+ export PATH=/usr/local/cuda-${DRIVER_CUDA_VERSION}/bin:$PATH
113
+ export LD_LIBRARY_PATH=/usr/local/cuda-${DRIVER_CUDA_VERSION}/lib64:${LD_LIBRARY_PATH:-}
114
+
115
+ # Verify installation
116
+ nvcc --version
117
+ else
118
+ echo "CUDA toolkit $NVCC_VERSION matches driver version"
119
+ export PATH=/usr/local/cuda-${DRIVER_CUDA_VERSION}/bin:$PATH
120
+ export LD_LIBRARY_PATH=/usr/local/cuda-${DRIVER_CUDA_VERSION}/lib64:${LD_LIBRARY_PATH:-}
121
+ fi
122
+
123
+ # --- Install uv (fast Python package manager) --------------------------------
124
+ curl -LsSf https://astral.sh/uv/install.sh | sh
125
+ export PATH="$HOME/.local/bin:$PATH"
126
+
127
+ # --- Install Python 3.12 if not available ------------------------------------
128
+ if ! command -v python3.12 &> /dev/null; then
129
+ echo "Python 3.12 not found. Installing via uv..."
130
+ uv python install 3.12
131
+ fi
132
+
133
+ # --- Clean up existing environments and caches -------------------------------
134
+ echo "Cleaning up existing environments and caches..."
135
+
136
+ # Remove existing venv for a clean installation
137
+ VENV="$HOME/venv"
138
+ if [ -d "$VENV" ]; then
139
+ echo "Removing existing virtual environment..."
140
+ rm -rf "$VENV"
141
+ fi
142
+
143
+ # Remove uv cache to ensure fresh installs
144
+ if [ -d "$HOME/.cache/uv" ]; then
145
+ echo "Clearing uv cache..."
146
+ rm -rf "$HOME/.cache/uv"
147
+ fi
148
+
149
+ # Remove vLLM cache to avoid conflicts
150
+ if [ -d "$HOME/.cache/vllm" ]; then
151
+ echo "Clearing vLLM cache..."
152
+ rm -rf "$HOME/.cache/vllm"
153
+ fi
154
+
155
+ # --- Create and activate venv ------------------------------------------------
156
+ echo "Creating fresh virtual environment..."
157
+ uv venv --python 3.12 --seed "$VENV"
158
+ source "$VENV/bin/activate"
159
+
160
+ # --- Install PyTorch and vLLM ------------------------------------------------
161
+ echo "Installing vLLM and dependencies (version: $VLLM_VERSION)..."
162
+ case "$VLLM_VERSION" in
163
+ release)
164
+ echo "Installing vLLM release with PyTorch..."
165
+ # Install vLLM with automatic PyTorch backend selection
166
+ # vLLM will automatically install the correct PyTorch version
167
+ uv pip install vllm>=0.10.0 --torch-backend=auto || {
168
+ echo "ERROR: Failed to install vLLM"
169
+ exit 1
170
+ }
171
+ ;;
172
+ nightly)
173
+ echo "Installing vLLM nightly with PyTorch..."
174
+ echo "This will install the latest nightly build of vLLM..."
175
+
176
+ # Install vLLM nightly with PyTorch
177
+ uv pip install -U vllm \
178
+ --torch-backend=auto \
179
+ --extra-index-url https://wheels.vllm.ai/nightly || {
180
+ echo "ERROR: Failed to install vLLM nightly"
181
+ exit 1
182
+ }
183
+
184
+ echo "vLLM nightly successfully installed!"
185
+ ;;
186
+ gpt-oss)
187
+ echo "Installing GPT-OSS special build with PyTorch nightly..."
188
+ echo "WARNING: This build is ONLY for GPT-OSS models!"
189
+ echo "Installing PyTorch nightly and cutting-edge dependencies..."
190
+
191
+ # Convert CUDA version format for PyTorch (12.4 -> cu124)
192
+ PYTORCH_CUDA="cu$(echo $DRIVER_CUDA_VERSION | sed 's/\.//')"
193
+ echo "Using PyTorch nightly with ${PYTORCH_CUDA} (driver supports ${DRIVER_CUDA_VERSION})"
194
+
195
+ # The GPT-OSS build will pull PyTorch nightly and other dependencies
196
+ # via the extra index URLs. We don't pre-install torch here to avoid conflicts.
197
+ uv pip install --pre vllm==0.10.1+gptoss \
198
+ --extra-index-url https://wheels.vllm.ai/gpt-oss/ \
199
+ --extra-index-url https://download.pytorch.org/whl/nightly/${PYTORCH_CUDA} \
200
+ --index-strategy unsafe-best-match || {
201
+ echo "ERROR: Failed to install GPT-OSS vLLM build"
202
+ echo "This automatically installs PyTorch nightly with ${PYTORCH_CUDA}, Triton nightly, and other dependencies"
203
+ exit 1
204
+ }
205
+
206
+ # Install gpt-oss library for tool support
207
+ uv pip install gpt-oss || {
208
+ echo "WARNING: Failed to install gpt-oss library (needed for tool use)"
209
+ }
210
+ ;;
211
+ *)
212
+ echo "ERROR: Unknown vLLM version: $VLLM_VERSION"
213
+ exit 1
214
+ ;;
215
+ esac
216
+
217
+ # --- Install additional packages ---------------------------------------------
218
+ echo "Installing additional packages..."
219
+ # Note: tensorrt removed temporarily due to CUDA 13.0 compatibility issues
220
+ # TensorRT still depends on deprecated nvidia-cuda-runtime-cu13 package
221
+ uv pip install huggingface-hub psutil hf_transfer
222
+
223
+ # --- FlashInfer installation (optional, improves performance) ----------------
224
+ echo "Attempting FlashInfer installation (optional)..."
225
+ if uv pip install flashinfer-python; then
226
+ echo "FlashInfer installed successfully"
227
+ else
228
+ echo "FlashInfer not available, using Flash Attention instead"
229
+ fi
230
+
231
+ # --- Mount storage if provided -----------------------------------------------
232
+ if [ -n "$MOUNT_COMMAND" ]; then
233
+ echo "Setting up mount..."
234
+
235
+ # Create mount point directory if it doesn't exist
236
+ mkdir -p "$MODELS_PATH"
237
+
238
+ # Execute the mount command
239
+ eval "$MOUNT_COMMAND" || {
240
+ echo "WARNING: Mount command failed, continuing without mount"
241
+ }
242
+
243
+ # Verify mount succeeded (optional, may not always be a mount point)
244
+ if mountpoint -q "$MODELS_PATH" 2>/dev/null; then
245
+ echo "Storage successfully mounted at $MODELS_PATH"
246
+ else
247
+ echo "Note: $MODELS_PATH is not a mount point (might be local storage)"
248
+ fi
249
+ fi
250
+
251
+ # --- Model storage setup ------------------------------------------------------
252
+ echo ""
253
+ echo "=== Setting up model storage ==="
254
+ echo "Storage path: $MODELS_PATH"
255
+
256
+ # Check if the path exists and is writable
257
+ if [ ! -d "$MODELS_PATH" ]; then
258
+ echo "Creating model storage directory: $MODELS_PATH"
259
+ mkdir -p "$MODELS_PATH"
260
+ fi
261
+
262
+ if [ ! -w "$MODELS_PATH" ]; then
263
+ echo "ERROR: Model storage path is not writable: $MODELS_PATH"
264
+ echo "Please check permissions"
265
+ exit 1
266
+ fi
267
+
268
+ # Create the huggingface cache directory structure in the models path
269
+ mkdir -p "${MODELS_PATH}/huggingface/hub"
270
+
271
+ # Remove any existing cache directory or symlink
272
+ if [ -e ~/.cache/huggingface ] || [ -L ~/.cache/huggingface ]; then
273
+ echo "Removing existing ~/.cache/huggingface..."
274
+ rm -rf ~/.cache/huggingface 2>/dev/null || true
275
+ fi
276
+
277
+ # Create parent directory if needed
278
+ mkdir -p ~/.cache
279
+
280
+ # Create symlink from ~/.cache/huggingface to the models path
281
+ ln -s "${MODELS_PATH}/huggingface" ~/.cache/huggingface
282
+ echo "Created symlink: ~/.cache/huggingface -> ${MODELS_PATH}/huggingface"
283
+
284
+ # Verify the symlink works
285
+ if [ -d ~/.cache/huggingface/hub ]; then
286
+ echo "✓ Model storage configured successfully"
287
+
288
+ # Check available space
289
+ AVAILABLE_SPACE=$(df -h "$MODELS_PATH" | awk 'NR==2 {print $4}')
290
+ echo "Available space: $AVAILABLE_SPACE"
291
+ else
292
+ echo "ERROR: Could not verify model storage setup"
293
+ echo "The symlink was created but the target directory is not accessible"
294
+ exit 1
295
+ fi
296
+
297
+ # --- Configure environment ----------------------------------------------------
298
+ mkdir -p ~/.config/vllm
299
+ touch ~/.config/vllm/do_not_track
300
+
301
+ # Write environment to .bashrc for persistence
302
+ cat >> ~/.bashrc << EOF
303
+
304
+ # Pi vLLM environment
305
+ [ -d "\$HOME/venv" ] && source "\$HOME/venv/bin/activate"
306
+ export PATH="/usr/local/cuda-${DRIVER_CUDA_VERSION}/bin:\$HOME/.local/bin:\$PATH"
307
+ export LD_LIBRARY_PATH="/usr/local/cuda-${DRIVER_CUDA_VERSION}/lib64:\${LD_LIBRARY_PATH:-}"
308
+ export HF_TOKEN="${HF_TOKEN}"
309
+ export PI_API_KEY="${PI_API_KEY}"
310
+ export HUGGING_FACE_HUB_TOKEN="${HF_TOKEN}"
311
+ export HF_HUB_ENABLE_HF_TRANSFER=1
312
+ export VLLM_NO_USAGE_STATS=1
313
+ export VLLM_DO_NOT_TRACK=1
314
+ export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
315
+ export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
316
+ EOF
317
+
318
+ # Create log directory for vLLM
319
+ mkdir -p ~/.vllm_logs
320
+
321
+ # --- Output GPU info for pi CLI to parse -------------------------------------
322
+ echo ""
323
+ echo "===GPU_INFO_START==="
324
+ nvidia-smi --query-gpu=index,name,memory.total --format=csv,noheader | while IFS=, read -r id name memory; do
325
+ # Trim whitespace
326
+ id=$(echo "$id" | xargs)
327
+ name=$(echo "$name" | xargs)
328
+ memory=$(echo "$memory" | xargs)
329
+ echo "{\"id\": $id, \"name\": \"$name\", \"memory\": \"$memory\"}"
330
+ done
331
+ echo "===GPU_INFO_END==="
332
+
333
+ echo ""
334
+ echo "=== Setup complete ==="
335
+ echo "Pod is ready for vLLM deployments"
336
+ echo "Models will be cached at: $MODELS_PATH"