diff --git a/nvidia/station-brev/README.md b/nvidia/station-brev/README.md new file mode 100644 index 0000000..c2569a4 --- /dev/null +++ b/nvidia/station-brev/README.md @@ -0,0 +1,104 @@ +# Station Register to Brev + +> Link your DGX Station to Brev for remote access and sharing + +## Table of Contents + +- [Overview](#overview) +- [Instructions](#instructions) +- [Troubleshooting](#troubleshooting) + +--- + +## Overview + +## Basic idea + +NVIDIA Brev is an AI development platform that makes GPU environments remotely accessible, shareable, and easy to standardize using preconfigured setups called Launchables. + +This walkthrough will help you connect your NVIDIA DGX Station to Brev so it shows up as a managed GPU environment in Brev. After a one-time registration, your Station becomes remotely accessible and shareable. + +## What you'll accomplish + +You’ll register your DGX Station with Brev and it will be visible as a healthy node in the Brev web UI and CLI, ready to share access and accept workloads whenever needed. + +## What to know before starting + +While Brev automates the complex configuration, understanding a few key concepts when establishing the initial connection will be useful: + +* **Terminal Basics**: + * Familiarity with the command line to run a few simple setup commands + +## Prerequisites + +You will also need the following: + +* NVIDIA DGX Station with GB300 GPU +* **Brev Account**: + * Have an NVIDIA Brev account. [Create an NVIDIA Brev account](https://login.brev.nvidia.com/signin) if you don’t have one. + +* **Permissions**: + * You have administrative (root or sudo) access on the DGX Station device to run the registration command. + +## Time & risk + +* **Estimated time:** 5-10 minutes +* **Risk level:** Low - Registration configures the Station for secure remote access without altering your existing workloads +* **Rollback:** The Brev configuration can be removed through the UI and CLI + +## Instructions + +## Step 1. Login to Brev + +Go to the [Brev UI](https://brev.nvidia.com), log in, and confirm you’re in the correct org (by clicking the org button on the top right hand side of the page). Once logged in, go to the [Registered Compute](https://brev.nvidia.com/org/environments?tab=registered-compute) section under the "GPU" tab in the main navigation. + +Click the “Register Compute” button and follow the instructions in the pop-up window. + +## Step 2. Complete Popup Instructions + +* Install the Brev CLI +* Configure your compute + * Add a name for compute + * To configure ssh, ensure the “Enable SSH access” toggle is on +* Run the registration command + +## Step 3. Follow Registration Flow + +In the CLI, you’ll be walked through registration. Go through the flow until registration is complete. + +## Step 4. Confirm DGX Station in Brev UI + +* Go to the [Brev UI](https://brev.nvidia.com) +* Navigate to the [Registered Compute](https://brev.nvidia.com/org/environments?tab=registered-compute) +* Confirm that the DGX Station appears as a registered node with an **Available** status + +## Step 5. Next Steps + +Your DGX Station is now integrated into Brev as a secure, remotely accessible GPU environment. + +Now that your hardware is connected, you can: + +* **Share Access Anywhere:** Access your machine from anywhere and share access with others through the Brev UI under [Registered Compute](https://brev.nvidia.com/org/environments?tab=registered-compute). + +## Step 6. Cleanup + +If you ever decide to unregister your DGX Station with Brev, you can either do so through the Brev UI or the Brev CLI. + +With the CLI simply run: + +```bash +brev deregister +``` + +In the UI: +* Go to the [Brev UI](https://brev.nvidia.com) +* Navigate to the section listing “GPU Environments” and look under “Registered Compute” +* Click the “Deregister” menu item on the device you wish to delete from Brev +* Confirm your selection + +## Troubleshooting + +| Symptom | Cause | Fix | +|---------|-------|-----| +| Your DGX Station is showing up in the wrong org | It was registered to the wrong org | Run `brev set ` and then redo the registration process | +| Unable to `brev shell ` | Need to refresh | `brev refresh` | diff --git a/nvidia/station-brev/endpoint-test.yaml b/nvidia/station-brev/endpoint-test.yaml new file mode 100644 index 0000000..73d7f57 --- /dev/null +++ b/nvidia/station-brev/endpoint-test.yaml @@ -0,0 +1,149 @@ +kind: Playbook +metadata: + name: station-brev + displayName: Station Register to Brev + shortDescription: Link your DGX Station to Brev for remote access and sharing + publisher: nvidia + description: | + # REPLACE THIS WITH YOUR MODEL CARD + https://gitlab-master.nvidia.com/api-catalog/examples/-/blob/main/modelcard-example-mixtral8x7b.md?ref_type=heads + + labelsV2: + - gpuType:playbook:gpu_type_station + - DGX + - Station + - Brev + + attributes: + - key: DURATION + value: 5 MIN + +spec: + artifactName: station-brev + nvcfFunctionId: None + attributes: + + showUnavailableBanner: false + apiDocsUrl: None + termsOfUse: | + + cta: + text: Brev Overview + url: https://docs.nvidia.com/brev/concepts/overview + + + tabs: + - + id: overview + + label: Overview + content: | + # Basic idea + + NVIDIA Brev is an AI development platform that makes GPU environments remotely accessible, shareable, and easy to standardize using preconfigured setups called Launchables. + + This walkthrough will help you connect your NVIDIA DGX Station to Brev so it shows up as a managed GPU environment in Brev. After a one-time registration, your Station becomes remotely accessible and shareable. + + # What you'll accomplish + + You’ll register your DGX Station with Brev and it will be visible as a healthy node in the Brev web UI and CLI, ready to share access and accept workloads whenever needed. + + # What to know before starting + + While Brev automates the complex configuration, understanding a few key concepts when establishing the initial connection will be useful: + + * **Terminal Basics**: + * Familiarity with the command line to run a few simple setup commands + + # Prerequisites + + You will also need the following: + + * NVIDIA DGX Station with GB300 GPU + * **Brev Account**: + * Have an NVIDIA Brev account. [Create an NVIDIA Brev account](https://login.brev.nvidia.com/signin) if you don’t have one. + + * **Permissions**: + * You have administrative (root or sudo) access on the DGX Station device to run the registration command. + + # Time & risk + + * **Estimated time:** 5-10 minutes + * **Risk level:** Low - Registration configures the Station for secure remote access without altering your existing workloads + * **Rollback:** The Brev configuration can be removed through the UI and CLI + + + + - + id: instructions + + label: Instructions + content: | + # Step 1. Login to Brev + + Go to the [Brev UI](https://brev.nvidia.com), log in, and confirm you’re in the correct org (by clicking the org button on the top right hand side of the page). Once logged in, go to the [Registered Compute](https://brev.nvidia.com/org/environments?tab=registered-compute) section under the "GPU" tab in the main navigation. + + Click the “Register Compute” button and follow the instructions in the pop-up window. + + # Step 2. Complete Popup Instructions + + * Install the Brev CLI + * Configure your compute + * Add a name for compute + * To configure ssh, ensure the “Enable SSH access” toggle is on + * Run the registration command + + # Step 3. Follow Registration Flow + + In the CLI, you’ll be walked through registration. Go through the flow until registration is complete. + + # Step 4. Confirm DGX Station in Brev UI + + * Go to the [Brev UI](https://brev.nvidia.com) + * Navigate to the [Registered Compute](https://brev.nvidia.com/org/environments?tab=registered-compute) + * Confirm that the DGX Station appears as a registered node with an **Available** status + + # Step 5. Next Steps + + Your DGX Station is now integrated into Brev as a secure, remotely accessible GPU environment. + + Now that your hardware is connected, you can: + + * **Share Access Anywhere:** Access your machine from anywhere and share access with others through the Brev UI under [Registered Compute](https://brev.nvidia.com/org/environments?tab=registered-compute). + + # Step 6. Cleanup + + If you ever decide to unregister your DGX Station with Brev, you can either do so through the Brev UI or the Brev CLI. + + With the CLI simply run: + + ```bash + brev deregister + ``` + + In the UI: + * Go to the [Brev UI](https://brev.nvidia.com) + * Navigate to the section listing “GPU Environments” and look under “Registered Compute” + * Click the “Deregister” menu item on the device you wish to delete from Brev + * Confirm your selection + + + + - + id: troubleshooting + + label: Troubleshooting + content: | + | Symptom | Cause | Fix | + |---------|-------|-----| + | Your DGX Station is showing up in the wrong org | It was registered to the wrong org | Run `brev set ` and then redo the registration process | + | Unable to `brev shell ` | Need to refresh | `brev refresh` | + + + + + resources: + - name: Brev Documentation + url: https://docs.nvidia.com/brev/latest + + diff --git a/nvidia/station-brev/overview.md b/nvidia/station-brev/overview.md new file mode 100644 index 0000000..958a829 --- /dev/null +++ b/nvidia/station-brev/overview.md @@ -0,0 +1,2 @@ +# REPLACE THIS WITH YOUR MODEL CARD +https://gitlab-master.nvidia.com/api-catalog/examples/-/blob/main/modelcard-example-mixtral8x7b.md?ref_type=heads diff --git a/nvidia/station-comfyui/endpoint-production.yaml b/nvidia/station-comfyui/endpoint-production.yaml index f4d0cb4..2af3948 100644 --- a/nvidia/station-comfyui/endpoint-production.yaml +++ b/nvidia/station-comfyui/endpoint-production.yaml @@ -82,7 +82,7 @@ spec: # Ancillary files - All required assets can be found [in the ComfyUI playbook repository](https://github.com/NVIDIA/dgx-spark-playbooks/blob/main/nvidia/station-comfyui/). + All required assets can be found in the [ComfyUI playbook repository](https://github.com/NVIDIA/dgx-spark-playbooks/blob/main/nvidia/station-comfyui/). - `assets/Dockerfile` — Builds the ComfyUI container image from NGC PyTorch base (ARM64) - `assets/scripts/download-models.sh` — Downloads all model weights from Hugging Face using the **`hf`** CLI (`huggingface-hub` package) @@ -97,9 +97,8 @@ spec: * Model downloads require HuggingFace authentication and substantial bandwidth (~150 GB total) * Port 8188 must be accessible for the ComfyUI web interface * **Rollback:** Stop and remove the Docker container. Delete the `models/` directory to reclaim disk space. - * **Last Updated:** 05/07/2026 - * Re-validated end-to-end on GB300: clean image build (`comfyui-gb300`, ~24 GB), container starts and serves on port 8188, all 8 mounted UI workflows enumerate correctly, `/object_info` returns 1092 node types, `/prompt` validation rejects on missing-model with clean errors. Documented benign startup warnings (`aimdo` CUDA-hook fallback, `urllib3` / `charset_normalizer` version skew) so users do not chase non-issues. - * 05/06/2026 — first publication; fixed walkthrough issues found on GB300: torchaudio shim for NGC PyTorch ABI mismatch, aarch64 onnxruntime swap, model-filename collisions (HiDream VAE → `ae_hidream.safetensors`, HunyuanVideo CLIP → `clip_l_hunyuan.safetensors`), `--gpus device=0` default, `df -h /` prereq, `~/.local/bin` PATH guidance, FLUX node list aligned with the actual graph, `.webp` output (not MP4), HF token via env not CLI, container output `chown` cleanup hint. + * **Last Updated:** 05/26/2026 + * First Publication @@ -368,7 +367,7 @@ spec: ## Cosmos-Predict2 Video2World - Load `cosmos-text-to-video.json`. + Load `cosmos-video2world.json`. **NVIDIA Cosmos-Predict2 14B** is NVIDIA's world foundation model for Video2World generation. It takes an input image and generates a physically plausible video extending from that scene. Place your source image in the `input/` directory before running. diff --git a/nvidia/station-gr00t/endpoint-production.yaml b/nvidia/station-gr00t/endpoint-production.yaml index 3592da4..607a0cf 100644 --- a/nvidia/station-gr00t/endpoint-production.yaml +++ b/nvidia/station-gr00t/endpoint-production.yaml @@ -45,38 +45,57 @@ spec: content: | # Basic idea - NVIDIA Isaac GR00T N1.6 is a 3-billion-parameter open vision-language-action (VLA) foundation model for generalist humanoid robot skills. It combines a Cosmos-Reason-2B vision-language backbone with a 32-layer Diffusion Transformer (DiT) action head that denoises continuous robot actions from multimodal input — language instructions and camera images. The model is pre-trained on over 10,000 hours of robot demonstration data spanning bimanual arms, semi-humanoid platforms, and full humanoids, then adapted to specific embodiments and tasks through fine-tuning. + NVIDIA Isaac GR00T N1.6 is a 3-billion-parameter open vision-language-action (VLA) foundation model for generalist humanoid robot skills. It combines a Cosmos-family vision-language backbone with a 32-layer Diffusion Transformer (DiT) action head that denoises continuous robot actions from multimodal input — language instructions and camera images. The model is pre-trained on a large mixture of robot demonstration data, then adapted to specific embodiments and tasks through fine-tuning. - In this playbook you will fine-tune GR00T N1.6 on the LIBERO Spatial benchmark — a manipulation task suite that tests spatial reasoning with a Panda robot arm. DGX Station's GB300 GPU with 284 GB of HBM3e memory enables a per-device batch size of **128**, far exceeding the typical 32–64 used on smaller GPUs, which accelerates convergence and improves training throughput. + High-level architecture (VLM + DiT action head), as in the upstream Isaac GR00T repo: + + ![GR00T N1.6 reference architecture](./assets/GR00T-reference-arch-diagram.png) + + *Source: [NVIDIA Isaac GR00T — `media/GR00T-reference-arch-diagram.png`](https://github.com/NVIDIA/Isaac-GR00T/blob/n1.6-release/media/GR00T-reference-arch-diagram.png). If the local image above is missing, the upstream copy is at `https://raw.githubusercontent.com/NVIDIA/Isaac-GR00T/n1.6-release/media/GR00T-reference-arch-diagram.png`.* + + In this playbook you will fine-tune GR00T N1.6 on the **LIBERO Spatial** benchmark on a **DGX Station** with **GB300** (large unified memory). That setup supports a high **global batch size (128)** on a single GPU, which improves training throughput compared to typical 24–80 GB consumer or datacenter GPUs. + + # LIBERO Spatial (what you are fine-tuning on) + + **LIBERO Spatial** is part of the [LIBERO](https://libero-project.github.io/main.html) suite of simulated tabletop manipulation benchmarks. The **spatial** split emphasizes **where** objects need to be placed: tasks such as putting a bowl on a **stove burner** vs a **plate**, placing utensils in a **mug** vs next to it, or moving objects to **left/right/front** targets on the table. Episodes include third-person RGB video, proprioceptive state, language instructions, and continuous end-effector actions in a consistent LeRobot v2 layout. Understanding these constraints helps when you read training logs or open-loop evaluation plots. + + # What kind of fine-tuning this playbook uses + + This playbook runs the **default Isaac GR00T fine-tuning recipe** from `launch_finetune.py`: **not** full-model weight updates of the entire 3B VLM. In the stock configuration, training focuses on the **action head (DiT)** and **projector / adapter paths** that map observations into the action model, with strong **state dropout** and **color jitter** so the policy leans on vision. Optional flags such as `--tune-llm` or `--tune-visual` (mentioned under Next steps) trade compute and memory for updating more of the backbone. **LoRA** is not the default here; if your team uses LoRA or other PEFT variants, treat that as a separate configuration branch from this playbook. + + # NVIDIA DGX Station (why this hardware) + + **DGX Station** is a deskside AI system built for **large-memory GPU** training and inference (this playbook targets **GB300** with **284 GB HBM3e**). Beyond robotics, the same class of machine supports **large-model fine-tuning**, **RAG serving**, **multi-modal training**, and **CUDA research** where single-GPU memory and bandwidth dominate. For GR00T, the headline benefit is fitting **much larger batch sizes** per GPU than on smaller cards, which stabilizes gradients and improves **samples per second** when the data pipeline keeps up. # What you'll accomplish - - Set up the Isaac GR00T environment using `uv` (fast, reproducible Python packaging) - - Verify the pre-trained base model loads and runs inference - - Fine-tune GR00T N1.6 on the LIBERO Spatial dataset with batch size 128 - - Evaluate the fine-tuned model using open-loop evaluation and measure inference latency + - Check out the **`n1.6-release`** branch of Isaac GR00T so commands, embodiment tags, and `demo_data/` match GR00T **N1.6** + - Set up the environment with `uv` (project-local `.venv`) and understand what the optional `install_deps.sh` script changes on the system + - Apply the recommended **PyAV `get_frames_by_indices` patch** when `torchcodec` is unavailable so LIBERO **AV1** video decoding does not stall on an **ffmpeg** subprocess fallback + - Verify the base model, fine-tune on LIBERO Spatial at batch size **128**, run open-loop evaluation, and measure inference latency (with **GB300 / Blackwell** TorchDynamo compilation notes) # What to know before starting - - Familiarity with Python virtual environments - - Familiarity with PyTorch training workflows (epochs, batch size, loss curves) - - General understanding of robot manipulation concepts (actions, observations, trajectories) + - Familiarity with Python virtual environments (`source .venv/bin/activate`) + - Familiarity with PyTorch training concepts (batch size, loss, checkpoints) + - Basic robot manipulation vocabulary (trajectories, observations, actions) + - Comfort running commands that may use **`sudo`** for system packages (or use the documented user-space alternative) # Prerequisites - - NVIDIA DGX Station with GB300 GPU (Blackwell SM103, 284 GB HBM3e) - - CUDA toolkit installed: `nvcc --version` should show CUDA 12.8+ - - Git installed: `git --version` - - HuggingFace account with access token (for model and dataset downloads) - - Network access to HuggingFace, GitHub, and PyPI - - At least 30 GB of free disk space (venv + model + dataset) + - NVIDIA **DGX Station** with **GB300** (Blackwell SM103, 284 GB HBM3e) + - CUDA toolkit usable by PyTorch: `nvcc --version` should show **CUDA 12.8+** (often already under `/usr/local/cuda` on DGX images) + - **Git** and **Git LFS** (`git lfs version`) — LFS is required for some demo assets and submodules; install with `sudo apt-get install -y git-lfs` then `git lfs install` if missing + - Hugging Face account and **HF_TOKEN** for model and dataset downloads + - Network access to Hugging Face, GitHub, and PyPI + - At least **~30 GB** free disk for `.venv`, checkpoints, and the LIBERO download # Time & risk - * **Duration:** ~45 minutes (5 min setup, 5 min dataset download, 25 min fine-tuning at 2000 steps, 5 min evaluation) - * **Risks:** Model download requires HuggingFace authentication; `uv sync` installs packages into a project-local `.venv` - * **Rollback:** Delete the cloned `Isaac-GR00T` directory to restore state. No system-level changes are made. - * **Last Updated:** 04/06/2026 + * **Duration:** ~45 minutes end-to-end when the video backend is healthy (setup, downloads, ~20–25 min training at 2000 steps, eval and inference) + * **Risks:** `scripts/deployment/dgpu/install_deps.sh` performs **system-level** `apt` operations and may install the **CUDA 12.8 toolkit** if `/usr/local/cuda` is absent (see Instructions). Model download requires Hugging Face authentication. + * **Rollback:** Remove the cloned `Isaac-GR00T` directory and optionally `rm -rf ~/.local/share/uv` if you want to reclaim `uv` caches. Reverting `apt`-installed packages is a separate admin task; the playbook does not uninstall them automatically. + * **Last Updated:** 05/26/2026 * First Publication @@ -88,19 +107,75 @@ spec: content: | # Step 1. Clone Isaac GR00T and install dependencies - Clone the repository and run the dGPU install script. This uses `uv` for fast, reproducible dependency management and automatically detects the aarch64 architecture: + ## 1a. Git LFS (required for a clean clone) + + If `git clone` fails with errors about **Git LFS** or missing pointer files, install and initialize LFS, then remove any partial `Isaac-GR00T` directory and clone again: + + ```bash + sudo apt-get update + sudo apt-get install -y git-lfs + git lfs install + ``` + + ## 1b. Clone and check out `n1.6-release` + + The **`main`** branch tracks ongoing development (for example newer GR00T milestones) and **does not** always match this **N1.6** playbook. Embodiment tags such as **`GR1`**, paths like **`demo_data/gr1.PickNPlace`**, and tutorial scripts are aligned with the **`n1.6-release`** branch. ```bash git clone --recurse-submodules https://github.com/NVIDIA/Isaac-GR00T cd Isaac-GR00T + git fetch origin + git checkout n1.6-release + git submodule update --init --recursive + ``` + + ## 1c. Install Python dependencies + + ### Option A — `install_deps.sh` (matches upstream docs; uses `sudo`) + + This script is the supported path. It may make **system-level** changes: + + - Runs `apt-get update` and installs **`ffmpeg`** and **`libaio-dev`** + - If **`/usr/local/cuda`** is missing, adds the NVIDIA CUDA apt repository and installs **`cuda-toolkit-12-8`** + - Installs **`uv`** into your user account if needed, then runs **`uv sync`** and **`uv pip install -e .`** into the project **`.venv`** + - On **aarch64** only: installs FFmpeg **development** packages and **builds `torchcodec` from source** into `.venv` + + ```bash I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 bash scripts/deployment/dgpu/install_deps.sh ``` - The install script: - - Installs system dependencies (`ffmpeg`, `libaio-dev`) - - Installs `uv` if not present - - Runs `uv sync` to create a `.venv` with all Python dependencies (PyTorch 2.7.1 + CUDA 12.8) - - Builds `torchcodec` from source on aarch64 (required for video decoding) + ### Option B — User-space only (no `install_deps.sh`) + + Use this only when **CUDA 12.8+** is already installed, system **`ffmpeg`** / **`libaio-dev`** are already present, and your policy forbids the script's `apt` or CUDA steps. From the **Isaac-GR00T** repo root, install **`uv`** if needed, then: + + ```bash + command -v uv >/dev/null || curl -LsSf https://astral.sh/uv/install.sh | sh + export PATH="/usr/local/cuda/bin:$HOME/.local/bin:$PATH" + export CUDA_HOME=/usr/local/cuda + uv sync + uv pip install -e . + ``` + + You still need a working **video backend** for LIBERO (see Step 2). On aarch64, building **torchcodec** inside `.venv` without the script is possible but manual; see Troubleshooting. + + > [!IMPORTANT] + > **`PATH` and `CUDA_HOME` matter on multi-toolkit hosts.** If the system has both an old Ubuntu `nvidia-cuda-toolkit` package (`/usr/bin/nvcc` ≈ 12.0) and a current NVIDIA CUDA repo install (`/usr/local/cuda-13.x/bin/nvcc`), `uv` will pick whichever appears first on `PATH`. Putting `/usr/local/cuda/bin` first (and exporting `CUDA_HOME`) is required for `flash-attn`'s source build to find the matching toolkit. Verify with `nvcc --version` after the export. + + > [!WARNING] + > **`flash-attn` build on aarch64 takes ~2 hours from source.** The upstream `pyproject.toml` only lists pre-built `flash-attn==2.7.4.post1` wheels for **`x86_64`**; on aarch64 (Grace + GB300), `uv sync` falls back to compiling ~72 CUDA kernels from source. A faster route is to pin `flash-attn==2.8.1` and reuse the GitHub release's prebuilt aarch64 wheel: + > + > ```toml + > # In pyproject.toml under [project] dependencies: + > "flash-attn==2.8.1", + > + > # In [tool.uv.sources]: + > flash-attn = [ + > { url = "https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.1/flash_attn-2.8.1+cu12torch2.10cxx11abiTRUE-cp312-cp312-linux_aarch64.whl", + > marker = "sys_platform == 'linux' and platform_machine == 'aarch64' and python_version == '3.12'" }, + > ] + > ``` + > + > With this pin, `uv sync` finishes in ~1 minute on aarch64 instead of ~2 hours. The wheel works against torch 2.10. Verified on GB300 + CUDA 13.1 in this playbook's validation run. Activate the virtual environment: @@ -111,15 +186,32 @@ spec: Verify GPU access: ```bash - CUDA_VISIBLE_DEVICES=1 python -c "import torch; print(torch.cuda.get_device_name(0))" + CUDA_VISIBLE_DEVICES=0 python -c "import torch; print(torch.cuda.get_device_name(0))" ``` Expected output: `NVIDIA GB300` > [!NOTE] - > Replace `CUDA_VISIBLE_DEVICES=1` with the index of your GB300 GPU throughout this playbook. Run `nvidia-smi --query-gpu=index,name --format=csv,noheader` to find it. + > Examples in this playbook use **`CUDA_VISIBLE_DEVICES=0`** because the GB300 is at index `0` on a single-GPU Station. On a multi-GPU Station (for example RTX PRO 6000 + GB300), the GB300 may be at a different index — run `nvidia-smi --query-gpu=index,name --format=csv,noheader`, find the GB300 row, and substitute that index everywhere `CUDA_VISIBLE_DEVICES=0` appears below. - # Step 2. Set up HuggingFace authentication + # Step 2. PyAV patch for LIBERO video (strongly recommended) + + On many stacks **`torchcodec`** fails to import or build, the resolver falls back to **`pyav`**, and stock **`n1.6-release`** can raise **`NotImplementedError`** from `get_frames_by_indices` for the **`pyav`** backend (fallback order is already `torchcodec` → `decord` → `pyav` → `ffmpeg`). Without this patch, training may **appear hung**: GPU idle, no traceback, while **ffmpeg** spawns per-frame decode work on the CPU. + + From the **Isaac-GR00T repo root** with **`n1.6-release`** checked out and **`.venv` activated**: + + ```bash + git apply /path/to/dgx-station-playbooks/nvidia/station-gr00t/assets/patches/001-pyav-get-frames-by-indices.patch + uv pip install av + ``` + + If you copied `nvidia/station-gr00t/assets/patches/` into the Isaac-GR00T root instead, use `git apply assets/patches/001-pyav-get-frames-by-indices.patch`. + + Details and re-apply rules: `nvidia/station-gr00t/assets/patches/README.md`. + + After patching, repeated log lines such as `Video backend 'torchcodec' is not available, falling back to 'pyav'` are **expected** and noisy but not fatal. + + # Step 3. Set up HuggingFace authentication ```bash export HF_TOKEN="your_huggingface_token" @@ -127,7 +219,7 @@ spec: Get a token from https://huggingface.co/settings/tokens if you don't have one. - # Step 3. Download the dataset and model + # Step 4. Download the dataset and model Download the LIBERO Spatial dataset and the GR00T N1.6 base model: @@ -145,18 +237,33 @@ spec: huggingface-cli download nvidia/GR00T-N1.6-3B ``` + > [!NOTE] + > **HF cache permission errors:** If `huggingface-cli download` fails with `Permission denied: '/home/.../.cache/huggingface/hub/...'`, the cache directory was previously created by a Docker container running as root (common on shared dev boxes). Point HF at a user-owned cache for this run: + > + > ```bash + > export HF_HOME=$HOME/hf_cache_gr00t + > ``` + > + > **Transient `xet-read-token` 500 errors:** Hugging Face's xet backend occasionally returns `500 Internal Server Error` for dataset downloads. Disable it: + > + > ```bash + > export HF_HUB_DISABLE_XET=1 + > ``` + Verify the dataset is ready: ```bash ls examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/meta/modality.json ``` - # Step 4. Verify the base model loads and runs + **Expected result:** the command prints the full path to **`modality.json`** (and `ls` exits 0). That confirms the merged modality file exists next to the downloaded LeRobot dataset metadata. - Confirm the GR00T N1.6 base model loads correctly and can produce actions. The base model ships with a GR1 demo dataset for quick verification: + # Step 5. Verify the base model loads and runs + + Confirm the GR00T N1.6 base model loads and produces actions using the **GR1** demo shipped on **`n1.6-release`**: ```bash - CUDA_VISIBLE_DEVICES=1 python scripts/deployment/standalone_inference_script.py \ + TORCHDYNAMO_DISABLE=1 CUDA_VISIBLE_DEVICES=0 python scripts/deployment/standalone_inference_script.py \ --model-path nvidia/GR00T-N1.6-3B \ --dataset-path demo_data/gr1.PickNPlace \ --embodiment-tag GR1 \ @@ -166,20 +273,19 @@ spec: --steps 32 ``` - You should see per-step timing output and no errors. This confirms the model, CUDA, and data pipeline all work before committing to a longer fine-tuning run. + **`TORCHDYNAMO_DISABLE=1`** avoids **`torch.compile`** / Triton paths that can fail on GB300 with **`ptxas-blackwell fatal: Value 'sm_103a' is not defined for option 'gpu-name'`**. Keep it on all **`standalone_inference_script.py`** invocations in this playbook unless you have a Triton build that supports SM103. + + You should see per-step timing output and no errors. This confirms the model, CUDA, and data pipeline work before a long fine-tuning run. > [!NOTE] - > If you see Triton/PTXAS errors about `sm_103a`, prepend `TORCHDYNAMO_DISABLE=1` to the command. See Troubleshooting for details. + > The base model's pretrained processor does not include the **`LIBERO_PANDA`** embodiment configuration, so you cannot run this standalone script on the LIBERO dataset with the **base** checkpoint alone. The LIBERO modality config is registered during fine-tuning. That is expected — LIBERO is a post-training benchmark. - > [!NOTE] - > The base model's pretrained processor does not include the `LIBERO_PANDA` embodiment configuration, so you cannot run evaluation directly on the LIBERO dataset with the base model. The LIBERO modality config is registered during fine-tuning. This is expected — LIBERO is a post-training benchmark. + # Step 6. Fine-tune GR00T N1.6 on LIBERO Spatial - # Step 5. Fine-tune GR00T N1.6 on LIBERO Spatial - - Fine-tune the base model on the LIBERO Spatial dataset. DGX Station's GB300 GPU with 284 GB HBM3e lets you use a batch size of **128** — roughly 4x what fits on a typical 80 GB GPU. Larger batch sizes mean more stable gradients and faster convergence per wall-clock hour. + Fine-tune the base model on LIBERO Spatial. DGX Station's GB300 GPU with 284 GB HBM3e allows a global batch size of **128** — roughly several times what fits on a typical 80 GB GPU. Larger batches stabilize gradients and improve wall-clock throughput **when the dataloader keeps the GPU fed**. ```bash - CUDA_VISIBLE_DEVICES=1 python \ + CUDA_VISIBLE_DEVICES=0 python \ gr00t/experiment/launch_finetune.py \ --base-model-path nvidia/GR00T-N1.6-3B \ --dataset-path examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/ \ @@ -198,29 +304,34 @@ spec: --dataloader-num-workers 4 ``` - Training runs for **2000 steps** at batch size 128 and takes approximately 20–25 minutes on the GB300. + If GPU utilization stays **near zero** for many minutes while the process is alive, suspect **video decoding** (see Step 2 patch and Troubleshooting). You can try **`--dataloader-num-workers 8`** if CPU cores are available. + + Training runs for **2000 steps** at batch size 128 and takes approximately **20–25 minutes** on GB300 when **`torchcodec`** is the active video backend. + + > [!IMPORTANT] + > **With the PyAV fallback (Step 2 patch + no torchcodec)**, expect ~5–6 s per step instead of <1 s — so 2000 steps is closer to **2.5–3 hours**, and GPU utilization sits in the 3–30 % range while CPU-side video decoding starves the GPU. To validate the workflow without the long wait, lower `--max-steps` (e.g. `100`) and `--save-steps` (e.g. `50`); loss should still drop visibly (validated drop **1.07 → 0.63** in 100 steps in this playbook's GB300 run). If you need full-throughput training, build `torchcodec` from source (Troubleshooting → "Video decoding errors") or run **Option A** which builds it for you. > [!NOTE] - > This playbook uses 2000 steps to keep execution time under an hour. For production-quality results matching the published 97.65% success rate on LIBERO Spatial, increase to **20,000 steps** by changing `--max-steps 20000`. Published results used batch size 640 across 8 GPUs (80 per GPU) — batch size 128 on a single GB300 exceeds the per-GPU batch size used in the published benchmarks. + > This playbook uses 2000 steps to keep execution time under an hour. For production-quality results closer to the published **97.65%** success rate on LIBERO Spatial, increase to **20,000 steps** (`--max-steps 20000`). Published settings used batch size **640** across **8** GPUs — 128 on one GB300 exceeds the per-GPU batch in that reference. **What the training flags mean:** | Flag | Value | Purpose | |------|-------|---------| - | `--global-batch-size` | 128 | Total samples per training step. GB300's 284 GB HBM3e makes this possible on a single GPU. | - | `--state-dropout-prob` | 0.8 | Drops state input 80% of the time during training, forcing the model to rely on vision. Improves generalization. | - | `--color-jitter-params` | brightness/contrast/saturation/hue | Randomly perturbs image colors during training for robustness to lighting variation. | - | `--warmup-ratio` | 0.05 | Linearly ramps learning rate from 0 to 1e-4 over the first 5% of steps (100 steps). | - | `--save-steps` | 500 | Saves a checkpoint every 500 steps. | + | `--global-batch-size` | 128 | Total samples per training step; enabled by GB300 memory. | + | `--state-dropout-prob` | 0.8 | Drops proprioceptive state 80% of the time so the model relies on vision. | + | `--color-jitter-params` | brightness/contrast/saturation/hue | Photometric augmentation for lighting robustness. | + | `--warmup-ratio` | 0.05 | Linear LR warmup over the first 5% of steps. | + | `--save-steps` | 500 | Checkpoint cadence under `output/libero_spatial_ft/`. | - Monitor the training loss in the terminal. The HuggingFace Trainer logs progress at each step — look for the `loss` field decreasing over time. Checkpoints are saved every 500 steps to `output/libero_spatial_ft/`. + Monitor the Hugging Face **Trainer** `loss` in the terminal. Checkpoints land under `output/libero_spatial_ft/`. - # Step 6. Evaluate the fine-tuned model + # Step 7. Evaluate the fine-tuned model - Run open-loop evaluation on the fine-tuned checkpoint. This compares the model's predicted actions against the ground truth from the dataset: + Open-loop evaluation compares predicted actions to dataset ground truth and writes plots to **`/tmp/open_loop_eval/`**: ```bash - CUDA_VISIBLE_DEVICES=1 python gr00t/eval/open_loop_eval.py \ + CUDA_VISIBLE_DEVICES=0 python gr00t/eval/open_loop_eval.py \ --dataset-path examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/ \ --embodiment-tag LIBERO_PANDA \ --model-path output/libero_spatial_ft/checkpoint-2000/ \ @@ -228,27 +339,17 @@ spec: --action-horizon 16 ``` - The evaluation outputs: - - - **Per-trajectory MSE and MAE** printed to the terminal - - **Average MSE** across all evaluated trajectories - - **JPEG visualizations** saved to `/tmp/open_loop_eval/` showing ground truth vs. predicted actions for each action dimension (x, y, z, roll, pitch, yaw, gripper) - - Key things to look for in the plots: - - - **Predicted trajectories** (orange line) should closely track the **ground truth** (blue line) - - **Gripper timing** — opening and closing at the correct moments - - **Lower MSE** indicates better action prediction accuracy + **How to read the run:** the terminal prints **per-trajectory MSE/MAE** and **averages**. The JPEGs under **`/tmp/open_loop_eval/`** overlay **predicted** vs **ground-truth** trajectories per action dimension (translation, rotation, gripper). Use them to confirm the policy tracks pick-and-place phases and gripper open/close timing on spatial tasks. > [!TIP] - > Even at 2000 steps, the fine-tuned model should show clearly improved action prediction compared to random. With 20,000 steps, LIBERO Spatial achieves 97.65% success rate in closed-loop simulation. + > At 2000 steps you should see clear improvement over a random policy; at 20,000 steps, published LIBERO Spatial success reaches **97.65%** in closed-loop sim. - # Step 7. Run inference timing benchmark + # Step 8. Run inference on a LIBERO sample (timing + actions) - Measure the fine-tuned model's per-step inference latency: + This step passes **LIBERO Spatial** observations through the **fine-tuned** checkpoint (the base model cannot run this embodiment). **`TORCHDYNAMO_DISABLE=1`** is included for GB300: ```bash - CUDA_VISIBLE_DEVICES=1 python scripts/deployment/standalone_inference_script.py \ + TORCHDYNAMO_DISABLE=1 CUDA_VISIBLE_DEVICES=0 python scripts/deployment/standalone_inference_script.py \ --model-path output/libero_spatial_ft/checkpoint-2000/ \ --dataset-path examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/ \ --embodiment-tag LIBERO_PANDA \ @@ -257,21 +358,9 @@ spec: --action-horizon 8 ``` - > [!NOTE] - > If you see Triton/PTXAS errors about `sm_103a`, prepend `TORCHDYNAMO_DISABLE=1` to the command. This runs inference in eager mode. See Troubleshooting for details. + **What to inspect:** the script prints a **timing breakdown** (data processing, backbone, action head, end-to-end). Compare **MSE/MAE** and latency to Step 5's base-model smoke test. In eager mode (with `TORCHDYNAMO_DISABLE=1`), per-step latency on GB300 depends heavily on the torch + CUDA stack — expect **~3–4 s/step** on torch 2.10 + cu130 in eager mode (validated in this playbook's run on a fine-tuned `checkpoint-100`); a compiled torch 2.7 + cu128 stack with Triton support for `sm_103` can be much faster. Treat the "Backbone vs Action head" split as the more stable signal across stacks. - The timing output breaks down into: - - - **Data processing** — loading and preprocessing the observation - - **Backbone** — vision-language model forward pass - - **Action head** — diffusion transformer denoising (4 steps) - - **End-to-end** — total inference time per action chunk - - In eager mode (without `torch.compile`), expect ~240 ms per step. With `torch.compile` working, expect ~38 ms per step comparable to H100. - - # Step 8. Clean up - - To remove the environment: + # Step 9. Clean up ```bash deactivate @@ -279,15 +368,15 @@ spec: rm -rf Isaac-GR00T ``` - Your fine-tuned checkpoints in `output/libero_spatial_ft/` are deleted with the repo. Copy them elsewhere first if you want to keep them. + Fine-tuned checkpoints under `output/libero_spatial_ft/` are removed with the repo. Copy them elsewhere first if you want to keep them. # Next steps - - **Increase training steps** — Change `--max-steps` to 20000 for results closer to the published 97.65% success rate on LIBERO Spatial. Training time scales linearly (~3.5 hours at 20K steps). - - **Try other LIBERO suites** — Download `libero_10_no_noops`, `libero_goal_no_noops`, or `libero_object_no_noops` datasets from the `IPEC-COMMUNITY` HuggingFace organization and repeat the workflow. Published success rates: Object 98.45%, Goal 97.5%, 10-Long 94.35%. - - **Closed-loop simulation evaluation** — Set up the LIBERO simulation environment to test the fine-tuned model in a live control loop with the Panda robot arm. See the [LIBERO evaluation guide](https://github.com/NVIDIA/Isaac-GR00T/blob/main/examples/LIBERO/README.md#evaluate-checkpoint) for server-client setup. - - **Custom embodiments** — Fine-tune GR00T on your own robot data by following the [custom embodiment guide](https://github.com/NVIDIA/Isaac-GR00T/blob/main/getting_started/finetune_new_embodiment.md). Requires converting your data to LeRobot v2 format and defining a modality config. - - **Experiment with batch size** — The GB300's 284 GB HBM3e may support even larger batch sizes depending on which model components are being tuned. The default configuration tunes the projector and diffusion model only. Enabling `--tune-llm` or `--tune-visual` increases memory usage significantly. + - **Increase training steps** — `--max-steps 20000` for stronger LIBERO Spatial alignment (~3.5 hours at the same throughput). + - **Other LIBERO suites** — `libero_10_no_noops`, `libero_goal_no_noops`, `libero_object_no_noops` from **IPEC-COMMUNITY** on Hugging Face. + - **Closed-loop sim** — LIBERO sim server/client: [LIBERO evaluation in Isaac GR00T](https://github.com/NVIDIA/Isaac-GR00T/blob/n1.6-release/examples/LIBERO/README.md#evaluate-checkpoint). + - **Custom embodiments** — [Fine-tune a new embodiment](https://github.com/NVIDIA/Isaac-GR00T/blob/n1.6-release/getting_started/finetune_new_embodiment.md) (LeRobot v2 + modality JSON). + - **Tune more of the stack** — `--tune-llm` / `--tune-visual` raise memory use; probe batch size if you enable them. @@ -298,6 +387,68 @@ spec: content: | # Common Issues + ## Issue: `git clone` fails or demo videos are tiny / missing (Git LFS) + + **Solution:** + + ```bash + sudo apt-get install -y git-lfs + git lfs install + ``` + + Remove any partial `Isaac-GR00T` directory, then clone again with `--recurse-submodules`. + + ## Issue: `GR1`, `demo_data/gr1.PickNPlace`, or scripts do not match the playbook + + **Cause:** The repository default branch (**`main`**) may track a newer GR00T line (for example N1.7) with different embodiment tags and demo layouts. + + **Solution:** + + ```bash + cd Isaac-GR00T + git fetch origin + git checkout n1.6-release + git submodule update --init --recursive + ``` + + Always run playbook commands from **`n1.6-release`** for **N1.6** + **GR00T-N1.6-3B**. + + ## Issue: `install_deps.sh` is not allowed on your machine (policy) or you need to know what it changes + + **Facts:** `scripts/deployment/dgpu/install_deps.sh` runs **`sudo apt-get`** to install **`ffmpeg`**, **`libaio-dev`**, and (on aarch64) FFmpeg **development** libraries for the **torchcodec** build. If **`/usr/local/cuda`** does not exist, it adds the NVIDIA CUDA apt repo and installs **`cuda-toolkit-12-8`**. It also installs **`uv`** into the user account if missing, then **`uv sync`** + **`uv pip install -e .`** into **`.venv`**. + + **Solution (policy-friendly):** Pre-install the same system packages and CUDA using your IT process, ensure **`nvcc`** works, then from the repo root: + + ```bash + export PATH="$HOME/.local/bin:$PATH" + uv sync + uv pip install -e . + ``` + + On **aarch64**, you still need **`torchcodec`** in `.venv` or rely on the **PyAV patch** (Instructions Step 2) plus **`uv pip install av`**. + + ## Issue: `uv sync` (Option B) appears stuck for hours building `flash-attn` on aarch64 + + **Cause:** Upstream `pyproject.toml` lists pre-built `flash-attn==2.7.4.post1` wheels only for `linux_x86_64`. On **aarch64** (Grace + GB300), `uv` falls back to a from-source build that compiles ~72 CUDA kernels — typically **~2 hours** end-to-end. + + **Solution:** Pin to `flash-attn==2.8.1` and use the GitHub release's prebuilt aarch64 wheel. Edit `pyproject.toml` in the repo root: + + ```toml + # under [project] dependencies, replace: + # "flash-attn==2.7.4.post1", + "flash-attn==2.8.1", + + # under [tool.uv.sources], add: + flash-attn = [ + { url = "https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.1/flash_attn-2.8.1+cu12torch2.10cxx11abiTRUE-cp312-cp312-linux_aarch64.whl", + marker = "sys_platform == 'linux' and platform_machine == 'aarch64' and python_version == '3.12'" }, + ] + ``` + + The `cu12torch2.10` aarch64 wheel works against torch 2.10 (cu128 or cu130 builds). Validated on GB300 + CUDA 13.1 — `uv sync` completes in ~1 minute instead of ~2 hours. Track upstream Isaac-GR00T for a future commit that bakes this in. + + If you must keep `flash-attn==2.7.4.post1` (Option A path), expect the 2-hour build on first sync; subsequent `uv sync` invocations re-use the cached wheel. + ## Issue: `install_deps.sh` fails building torchcodec **Solution:** @@ -308,19 +459,20 @@ spec: I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 bash scripts/deployment/dgpu/install_deps.sh ``` - If the build still fails, ensure FFmpeg dev libraries are installed: + If the build still fails, install FFmpeg development libraries: ```bash sudo apt-get install -y libavdevice-dev libavfilter-dev libavformat-dev \ - libavcodec-dev libavutil-dev libswresample-dev libswscale-dev + libavcodec-dev libavutil-dev libswresample-dev libswscale-dev \ + pkg-config cmake build-essential pybind11-dev ``` + Then apply **Instructions Step 2** (PyAV patch) so training does not depend on a working **torchcodec** for indexed frame reads. + ## Issue: `huggingface-cli download` fails with 401 Unauthorized **Solution:** - Verify your HuggingFace token is set and valid: - ```bash echo $HF_TOKEN huggingface-cli whoami @@ -332,119 +484,153 @@ spec: export HF_TOKEN="your_token_here" ``` - Make sure you have accepted any required model agreements on the HuggingFace model page. + Accept any required license or gated-model agreements on the Hugging Face model page. + + ## Issue: `huggingface-cli download` fails with `Permission denied: '/home/.../.cache/huggingface/hub/...'` + + **Cause:** The shared cache directory was previously created by a Docker container running as **root** (common on multi-user dev boxes that mount `~/.cache/huggingface` into containers without `--user`). The current user (`nvidia`) cannot write into it. + + **Solution:** point HF at a user-owned cache location for this run: + + ```bash + export HF_HOME=$HOME/hf_cache_gr00t + mkdir -p "$HF_HOME" + huggingface-cli download nvidia/GR00T-N1.6-3B + ``` + + Re-export `HF_HOME` for the rest of the playbook (Step 5 onward) so model loads find the right cache. To permanently un-stick the original cache, ask whoever owns the container session to chown `~/.cache/huggingface` back to your user. + + ## Issue: `huggingface-cli download` returns `500 Internal Server Error` from the `xet-read-token` endpoint + + **Cause:** Hugging Face's xet content-addressable backend occasionally returns transient `5xx`. This blocks dataset downloads even though the underlying files are reachable via the legacy backend. + + **Solution:** disable xet for the download: + + ```bash + export HF_HUB_DISABLE_XET=1 + huggingface-cli download --repo-type dataset \ + IPEC-COMMUNITY/libero_spatial_no_noops_1.0.0_lerobot \ + --local-dir examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/ + ``` + + ## Issue: `externally-managed-environment` or `pip` installs not going into `.venv` + + **Cause:** Debian/Ubuntu **PEP 668** blocks `pip install` onto the system Python. Mixing **`sudo pip`** with the project venv breaks the playbook. + + **Solution:** + + 1. **`source .venv/bin/activate`** — prompt should show `(.venv)`. + 2. Use **`uv pip install ...`** (or **`python -m pip install ...`**) **only** with the venv activated — never `sudo pip` for this project. + 3. If the venv was created with a broken `pip`, recreate: `rm -rf .venv` and run **`uv sync`** again from the repo root (after `n1.6-release` checkout). ## Issue: CUDA out of memory during fine-tuning **Solution:** - If fine-tuning fails with an OOM error at batch size 128, reduce the batch size: + Reduce batch size: ```bash --global-batch-size 64 ``` - Also check that no other processes are using GPU memory: + Check for other GPU processes: `nvidia-smi`. **`--tune-llm`** / **`--tune-visual`** increase memory use substantially. - ```bash - nvidia-smi - ``` + ## Issue: Triton / PTXAS errors about `sm_103a` (GB300 / Blackwell) - If you are tuning additional model components (`--tune-llm` or `--tune-visual`), these significantly increase memory usage. The default configuration (projector + diffusion model only) is the most memory-efficient. + **Symptom:** - ## Issue: Triton/PTXAS errors about `sm_103a` during inference - - **Solution:** - - The bundled Triton version may not yet support SM103 (GB300). This causes errors like: - - ``` + ```text ptxas-blackwell fatal: Value 'sm_103a' is not defined for option 'gpu-name' ``` - Disable `torch.compile` by prepending: + **Solution:** + + For **`scripts/deployment/standalone_inference_script.py`** (which may use **`torch.compile`**), prepend: ```bash TORCHDYNAMO_DISABLE=1 python scripts/deployment/standalone_inference_script.py ... ``` - This runs inference in eager mode (~240 ms/step instead of ~38 ms/step with compile). Training and open-loop evaluation are not affected since they use eager mode by default. + This forces eager inference (higher latency per step but stable on SM103 until Triton catches up). Fine-tuning and **`open_loop_eval.py`** typically run without this compile path; use the same prefix there **only** if you see the same crash. ## Issue: `ModuleNotFoundError: No module named 'gr00t'` **Solution:** - The virtual environment is not activated. Run: - ```bash source .venv/bin/activate + pwd # .../Isaac-GR00T ``` - Verify you are in the Isaac-GR00T directory: + ## Issue: `NotImplementedError` in `get_frames_by_indices` when backend is `pyav` + + **Cause:** On **`n1.6-release`**, **`resolve_backend`** can select **`pyav`**, but stock **`get_frames_by_indices`** did not implement the **`pyav`** branch. + + **Solution:** Apply the playbook patch and install PyAV (see **Instructions Step 2** and `assets/patches/README.md`). + + ## Issue: Training “hangs” — low GPU utilization, no traceback, very slow steps + + **Cause:** Fallback to **per-frame `ffmpeg` subprocess** decoding for **AV1** LIBERO clips; dataloaders starve the GPU. + + **Solution:** + + 1. Apply the **PyAV patch** (Step 2) and **`uv pip install av`**. + 2. Optionally increase **`--dataloader-num-workers`** (for example **8**) if CPUs are free. + + **Expected noise after patching:** logs may repeat `Video backend 'torchcodec' is not available, falling back to 'pyav'` — that is normal if **torchcodec** is absent. + + ## Issue: Video decoding errors / `torchcodec` not found (general) + + **Solution:** + + Prefer the **PyAV patch + `av`** path above for LIBERO on GB300. + + If you must build **torchcodec** into `.venv` manually (aarch64), with FFmpeg dev packages installed: ```bash - pwd - # Should show: .../Isaac-GR00T + # Run this from inside the Isaac-GR00T repo root (the directory that + # contains .venv). Capture its absolute path BEFORE changing directories + # so we can still reach the virtualenv after cd'ing into /tmp/torchcodec. + GR00T_ROOT="$(pwd)" + + # Sanity check — the virtualenv interpreter must already exist. + test -x "$GR00T_ROOT/.venv/bin/python" || { echo "Not in Isaac-GR00T root (missing .venv/bin/python)"; } + + # Clone the torchcodec source into /tmp/torchcodec (skip if already cloned). + git clone https://github.com/pytorch/torchcodec.git /tmp/torchcodec + cd /tmp/torchcodec + + # Build torchcodec into the Isaac-GR00T virtualenv using the absolute + # path captured above (do NOT use the relative ".venv/bin/python" here — + # the current directory is /tmp/torchcodec, which has no .venv). + I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 ENABLE_CUDA=1 \ + uv pip install --python "$GR00T_ROOT/.venv/bin/python" . --no-build-isolation ``` + CUDA-enabled builds can fail when system FFmpeg or CUDA does not match torchcodec expectations — in that case use the **PyAV patch** instead. + ## Issue: Training loss is not decreasing **Solution:** - At 2000 steps, the model may not have converged fully — this is expected for the shortened playbook run. If loss remains flat after 500+ steps: + At 2000 steps the model may still be early. If loss is flat after many steps: - 1. Verify the dataset was downloaded correctly and the modality config was copied: - ```bash - ls examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/meta/modality.json - ``` - - 2. Check that the correct embodiment tag is used (`LIBERO_PANDA`, not `NEW_EMBODIMENT`). - - 3. Try increasing the learning rate to `5e-4` for faster initial convergence on short runs. + 1. Verify modality file: `ls examples/LIBERO/libero_spatial_no_noops_1.0.0_lerobot/meta/modality.json` + 2. Confirm **`--embodiment-tag LIBERO_PANDA`** + 3. Try **`--learning-rate 5e-4`** for faster early movement on short runs ## Issue: `nvidia-smi` shows the wrong GPU **Solution:** - On DGX Station, the GB300 may not be device 0. Find the correct index: - ```bash nvidia-smi --query-gpu=index,name --format=csv,noheader + CUDA_VISIBLE_DEVICES= python ... ``` - Use the GB300's index with `CUDA_VISIBLE_DEVICES`: + ## Issue: OpenCV or decord cannot decode LIBERO AV1 - ```bash - CUDA_VISIBLE_DEVICES=1 python ... - ``` - - ## Issue: Slow data loading during training - - **Solution:** - - Increase the number of dataloader workers: - - ```bash - --dataloader-num-workers 8 - ``` - - ## Issue: Video decoding errors (`NotImplementedError` or torchcodec not found) - - **Solution:** - - The `install_deps.sh` script builds torchcodec from source on aarch64. If it wasn't built correctly, reinstall: - - ```bash - sudo apt-get install -y libavdevice-dev libavfilter-dev libavformat-dev \ - libavcodec-dev libavutil-dev libswresample-dev libswscale-dev \ - pkg-config cmake build-essential pybind11-dev - - git clone --depth 1 --branch release/0.4 https://github.com/meta-pytorch/torchcodec.git /tmp/torchcodec - cd /tmp/torchcodec - I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 ENABLE_CUDA=1 \ - uv pip install --python .venv/bin/python . --no-build-isolation - cd - && rm -rf /tmp/torchcodec - ``` + **Notes:** **OpenCV** often fails on **AV1** in LIBERO assets. **decord** may lack a compatible wheel for your platform. The **PyAV** patch path is the supported mitigation in this playbook. @@ -462,7 +648,7 @@ spec: url: https://research.nvidia.com/labs/gear/gr00t-n1_6/ - - name: GR00T N1.6 Paper + - name: GR00T N1 Paper url: https://arxiv.org/abs/2503.14734 diff --git a/nvidia/station-healthcare-agent/endpoint-production.yaml b/nvidia/station-healthcare-agent/endpoint-production.yaml index 2c50025..3ddcd27 100644 --- a/nvidia/station-healthcare-agent/endpoint-production.yaml +++ b/nvidia/station-healthcare-agent/endpoint-production.yaml @@ -36,7 +36,7 @@ spec: cta: text: View on GitHub - url: https://github.com/NVIDIA/dgx-station-playbooks/blob/main/nvidia/station-healthcare-agent/ + url: https://github.com/NVIDIA/dgx-spark-playbooks/blob/main/nvidia/station-healthcare-agent/ tabs: @@ -152,10 +152,8 @@ spec: * Large model downloads (~86 GB) may fail on slow or unstable connections * OpenFold3 NIM takes ~3 minutes to load — the healthcheck waits automatically * **Rollback:** `openshell sandbox delete clinical-sandbox`, `make down`, `make clean` (see Cleanup in Instructions). - * **Last Updated:** 05/06/2026 - * Refocused positioning on secure local agent workflows - * Added architecture section with agent descriptions and skill file examples - * Addressed VDR feedback: documented host-Ollama port conflict, NGC docker login, multi-GPU pinning, Node.js v22 upgrade, and other infrastructure setup gaps + * **Last Updated:** 05/12/2026 + * First Publication ## Notice and disclaimers @@ -254,9 +252,9 @@ spec: ```bash # Find the playbook directory first. Try the common locations: PLAYBOOK_DIR="" - for d in ~/dgx-station-playbooks/nvidia/station-healthcare-agent \ - /opt/dgx-station-playbooks/nvidia/station-healthcare-agent \ - /usr/local/share/dgx-station-playbooks/nvidia/station-healthcare-agent; do + for d in ~/dgx-spark-playbooks/nvidia/station-healthcare-agent \ + /opt/dgx-spark-playbooks/nvidia/station-healthcare-agent \ + /usr/local/share/dgx-spark-playbooks/nvidia/station-healthcare-agent; do if [ -d "$d/assets" ]; then PLAYBOOK_DIR="$d"; break; fi done @@ -276,8 +274,8 @@ spec: > [!IMPORTANT] > If the catalog tarball did not include `assets/` (some early distributions stripped it), pull the playbook directly from the repo: > ```bash - > git clone https://github.com/NVIDIA/dgx-station-playbooks ~/dgx-station-playbooks - > cp -r ~/dgx-station-playbooks/nvidia/station-healthcare-agent/assets ~/clinical-intelligence + > git clone https://github.com/NVIDIA/dgx-spark-playbooks ~/dgx-spark-playbooks + > cp -r ~/dgx-spark-playbooks/nvidia/station-healthcare-agent/assets ~/clinical-intelligence > ``` The NGC API key is required to **download** the OpenFold3 NIM image from `nvcr.io` and to **run** it at runtime. Get one for free at [ngc.nvidia.com](https://ngc.nvidia.com/setup/api-key). diff --git a/nvidia/station-kernel-dev-ft/endpoint-production.yaml b/nvidia/station-kernel-dev-ft/endpoint-production.yaml index 2d899f5..accfee2 100644 --- a/nvidia/station-kernel-dev-ft/endpoint-production.yaml +++ b/nvidia/station-kernel-dev-ft/endpoint-production.yaml @@ -80,6 +80,7 @@ spec: **Software:** - Docker with NVIDIA Container Toolkit: `docker run --rm --gpus all nvcr.io/nvidia/cuda:12.8.0-devel-ubuntu24.04 nvidia-smi` + - On a DGX Station, immediately confirm which device index belongs to the GB300 so later steps can target it explicitly. Run `nvidia-smi --query-gpu=index,name --format=csv,noheader` and note the index for the row showing `NVIDIA GB300`. Subsequent steps recommend `--gpus '"device=N"'` (with `N` = that index) instead of `--gpus all` so profiling and benchmark numbers stay on a single, known GPU. - Network access to pull container images from NGC and download model weights from Hugging Face. - A Hugging Face account with access to [meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B) and a [Hugging Face access token](https://huggingface.co/settings/tokens). @@ -100,14 +101,14 @@ spec: # Time & risk - * **Estimated time:** About 2 hours. Steps 1-4 (setup through baseline profiling) take about 30 minutes. Steps 5-7 (RMSNorm kernel) take about 30 minutes. Steps 8-10 (cross-entropy kernel) take about 40 minutes. Step 11 (end-to-end integration) takes about 20 minutes. + * **Estimated time:** About 2 hours. Steps 1-4 (setup through baseline profiling) take about 30 minutes. Steps 5-7 (RMSNorm kernel) take about 30 minutes. Steps 8-10 (cross-entropy kernel) take about 40 minutes. Step 11 (end-to-end integration) takes about 20 minutes. Steps 12-13 (cleanup and next steps) are a few minutes. * **Risk level:** Low * All work runs inside a Docker container — no host system modifications. * LLaMA 3.1 8B model weights (~16 GB in BF16) are downloaded from Hugging Face on first run and cached locally. * Requires a Hugging Face token with access to the LLaMA 3.1 model. * **Rollback:** Exit the container. Your source files are preserved in the mounted `assets/` directory; everything else is discarded. - * **Last Updated:** 03/30/2026 - * First Publication + * **Last Updated:** 05/26/2026 + * First publication @@ -133,12 +134,22 @@ spec: docker build -t kernel-dev-ft . ``` + Identify the GB300's device index so the container can target it explicitly. On multi-GPU DGX Station systems, pinning to a single, known GPU keeps profiling and benchmark numbers consistent across runs: + + ```bash + nvidia-smi --query-gpu=index,name --format=csv,noheader + ``` + + Look for the row showing `NVIDIA GB300` and note its index (commonly `0` or `1`). Use that value as `N` in the next command. + Start the container with GPU access. Pass your Hugging Face token so the container can download LLaMA 3.1 8B: ```bash + # Replace N with the GB300 index from the command above. + # On a single-GPU Station you may substitute --gpus all. docker run -it --rm \ --name kernel-dev-ft \ - --gpus all \ + --gpus '"device=N"' \ --ipc host \ -e HF_TOKEN=$HF_TOKEN \ -v "$(pwd):/workspace" \ @@ -150,6 +161,9 @@ spec: > [!NOTE] > The `-v "$(pwd):/workspace"` flag mounts the current directory into the container. Any files you create or modify inside `/workspace` persist on your host machine after the container exits. The `-v ~/.cache/huggingface:/root/.cache/huggingface` mount persists downloaded model weights across container restarts so you don't need to re-download the 16 GB model each time. Everything outside these mounted paths is discarded when the container stops. + > [!IMPORTANT] + > Targeting the GB300 explicitly with `--gpus '"device=N"'` (rather than `--gpus all`) ensures `torch.cuda` and `nvidia-smi` inside the container both see the **GB300** as device `0`. Profiling and benchmark numbers later in this playbook assume a single Blackwell GPU; mixing a workstation GPU in via `--gpus all` can change scheduling and skew tokens/sec and bandwidth utilization figures. + > [!NOTE] > If you haven't set `HF_TOKEN` in your shell, export it first: `export HF_TOKEN=hf_your_token_here`. You need a Hugging Face token with access to [meta-llama/Llama-3.1-8B](https://huggingface.co/meta-llama/Llama-3.1-8B). You must first accept the LLaMA 3.1 Community License Agreement on the [model page](https://huggingface.co/meta-llama/Llama-3.1-8B) before your token can download the weights. @@ -164,7 +178,7 @@ spec: Expected output should show: - Triton version 3.0 or later - PyTorch with CUDA support enabled - - Your Blackwell GPU with **compute capability 10.0** (this identifier is shared by all Blackwell GPUs — GB200, GB300, B200, B300) + - A Blackwell GPU with a `10.x` compute capability. The exact minor version depends on the SKU — for example, `nvidia-smi` reports **`10.0`** on GB200 / B200 (standard Blackwell) and **`10.3`** on GB300 / B300 (Blackwell Ultra; same GPU silicon, different host packaging). Any `10.x` value is fine for this playbook; the kernels target the Blackwell family, not a specific minor. > [!NOTE] > Unlike the CUDA C++ workflow (which requires the `nvcc` compiler and a separate compilation step), Triton is a Python library that JIT-compiles GPU code at runtime. There is no build step — you write Python, and Triton compiles it to optimized GPU machine code when you first call the kernel. @@ -202,6 +216,13 @@ spec: 2. **Large vocabularies create massive intermediate tensors.** LLaMA's 128K vocabulary means the logit tensor for a single batch is enormous. Standard cross-entropy materializes this entire tensor in memory. 3. **Memory is the binding constraint.** Unlike inference (where latency matters most), training is often limited by how much data fits in GPU memory. Kernels that reduce memory enable larger batch sizes, which improve GPU utilization across *all* operations. + **Memory-bound vs compute-bound (where to spend effort):** + + - **Memory-bound** regions are limited by how fast you can move bytes through HBM (read/write bandwidth). Symptoms: small kernels, low achieved GB/s vs peak, profiler shows many narrow ops or fusion gaps. **Optimize** by fusing passes, reducing tensor materialization, using narrower dtypes where safe, and improving coalescing so each byte does more useful math. + - **Compute-bound** regions are limited by arithmetic throughput (Tensor Cores, FP32/FP16 units). Symptoms: large `aten::mm` / matmul and attention dominating self CUDA time with high utilization. **Optimize** with better tiling, larger batch sizes (more work per launch), kernels that keep math in registers, and libraries (cuBLAS, FlashAttention) before hand-writing alternatives. + + A single training step usually mixes both: matmuls tend toward **compute-bound** on large batches, while pointwise norm/loss paths are often **memory-bound**. Profiling tells you which bucket your hotspot falls into. + # Step 3. Profile a baseline training step Now let's see where GPU time actually goes. We'll use `torch.profiler` to capture a detailed trace of a single forward + backward + optimizer step. @@ -215,6 +236,15 @@ spec: > [!NOTE] > The first run downloads LLaMA 3.1 8B weights (~16 GB in BF16) from Hugging Face. This takes several minutes depending on network speed. Subsequent runs use the cached weights and start immediately. + > [!NOTE] + > **Repeat runs:** `profile_baseline.py` removes any prior trace directory and Chrome JSON for the same flags before recording, so you can re-run baseline profiling without a "trace is already saved" error. + + > [!NOTE] + > **Ranking variance:** The exact ordering and percentages in the "Top 20 CUDA operations" table can change between runs, PyTorch / CUDA versions, and GPU generation. You should still see the same *categories* of work (matmuls, FlashAttention, RMSNorm decompositions, cross-entropy). **"Command Buffer Full"** (or similar) sometimes appears at the top of self-time tables: that reflects the GPU driver's **submission queue / scheduling**, not a user kernel to optimize. The script filters that row from the printed table; the raw trace in Perfetto still contains the underlying kernels. + + > [!TIP] + > **Optional Nsight Systems timeline:** For a visual timeline with CUDA API and GPU work (outside or alongside `torch.profiler`), install [NVIDIA Nsight Systems](https://developer.nvidia.com/nsight-systems) and run something like: `nsys profile -o llama_ft_repro --trace=cuda,nvtx python profile_baseline.py` from an environment where `nsys` is on `PATH` (often the host, or a devel image with CUDA toolkit). Open the `.nsys-rep` file in the Nsight Systems GUI. + The script loads LLaMA 3.1 8B, runs one training step under `torch.profiler`, and prints a table like this: ``` @@ -416,11 +446,22 @@ spec: 16,384 298.9 2,041.7 2,694 394 6.83x ``` - **How to read these results:** - - **Custom (GB/s)** shows effective memory bandwidth. On large inputs (16K tokens), the fused kernel reaches ~2,700 GB/s — significantly better than PyTorch's ~400 GB/s. - - **Speedup** ranges from ~1.5x on small inputs to ~6.8x on large inputs. The improvement grows with tensor size because PyTorch's unfused operations suffer more from memory round-trips as data grows, while the fused kernel's cost stays nearly flat until the data is large enough to saturate the GPU. + **How to read these results (what "better" means):** + + | Column / metric | Better when… | + |-----------------|---------------| + | **Custom (us)** | **Lower** is faster (fewer microseconds per forward+backward pass). | + | **PyTorch (us)** | Reference only; same rule (lower is faster). | + | **Custom (GB/s)** | **Higher** means you move closer to HBM peak (more useful bytes per second for this fused region). | + | **Speedup** | **Higher** means the custom kernel beats PyTorch by a larger factor on that row. | + + - **Custom (GB/s)** shows effective memory bandwidth. On large inputs (16K tokens), the fused kernel typically reaches much higher GB/s than the unfused PyTorch path. + - **Speedup** often ranges from roughly **1.5x** on small inputs to **6x+** on large inputs in internal runs. - These numbers measure **forward + backward combined**, which is what matters for training. + > [!NOTE] + > **Treat the table as illustrative, not a target.** Absolute microsecond and GB/s values **can differ by an order of magnitude** between GB300 stacks (different driver versions, NGC PyTorch builds, clock states, autograd overhead between iterations). On the validation run for this playbook the same shapes measured ~4,000–5,000 µs per fwd+bwd instead of ~300 µs, while still showing **custom faster than PyTorch and the gap widening with `num_tokens`**. The **direction of the speedup** (and the GB/s ratio between custom and PyTorch in the same run) is the stable signal — match those, and your kernel is healthy. + Now re-profile the full training step with the custom RMSNorm to confirm the bottleneck is resolved: ```bash @@ -496,7 +537,7 @@ spec: Test 2: BFloat16 (relaxed tolerance) BF16 Loss — ref: 12.250000 custom: 12.247243 diff: 2.76e-03 PASSED - BF16 Gradient — max diff: 2.98e-08 PASSED + BF16 Gradient — max diff (fp32 compare): 1.23e-01 PASSED Memory Comparison ------------------------------------------------------------ @@ -511,7 +552,10 @@ spec: The **memory comparison** shows that standard PyTorch cross-entropy allocates ~500 MB (for the softmax output and other intermediates), while the fused kernel uses ~250 MB. The 2x reduction measured here understates the real benefit: in the benchmark (Step 10), where memory is measured more precisely per-operation, the reduction is **~6x**. The larger benefit appears because the benchmark isolates just the cross-entropy overhead, while this test includes the base logit tensor allocation in both measurements. > [!NOTE] - > Cross-entropy involves `log(sum(exp(...)))`, which is numerically sensitive. The online softmax algorithm maintains stability through the running-max trick — subtracting the maximum logit before exponentiating prevents overflow. The loss values should match PyTorch within 1e-5 in FP32 or 1e-2 in BF16. + > Cross-entropy involves `log(sum(exp(...)))`, which is numerically sensitive. The online softmax algorithm maintains stability through the running-max trick — subtracting the maximum logit before exponentiating prevents overflow. FP32 checks use tight tolerances. **BF16** compares loss with relaxed `atol/rtol` and compares **gradients in float32** with wider tolerances (`atol=2e-1`, `rtol=2e-1`) so chunked reductions over 128K vocabulary do not false-fail against PyTorch's different accumulation order. + + > [!WARNING] + > BF16 tolerances are intentionally looser than FP32: they assert the custom kernel matches the reference **within training-usable error**, not bitwise. Tighten tolerances only if you change the algorithm or dtype strategy. # Step 10. Benchmark and re-profile cross-entropy @@ -538,10 +582,14 @@ spec: 1,024 315 1,277 4.06x 251 1,506 6.0x ``` - **How to read these results:** - - **Speedup** grows from slower at 128 tokens (kernel launch overhead dominates) to **4x at 1,024 tokens**. The fused kernel has a higher fixed cost per row (looping over 128K vocabulary in chunks) but scales much better because it avoids the massive intermediate softmax allocation. - - **Memory reduction** (~6x): PyTorch allocates separate tensors for the logits, softmax output, and loss gradients. The fused kernel avoids the softmax intermediary. For 1,024 tokens, this saves over 1 GB of GPU memory — room for larger batches or longer sequences. - - At very small batch sizes (128 tokens), the fused kernel is **slower**. This is expected and normal — the overhead of the online softmax loop exceeds the cost of PyTorch's bulk computation at small scales. The crossover point is around 256 tokens. + **How to read these results:** For latency columns, **lower microseconds is better**. For **Speedup**, **higher is better** (custom faster than PyTorch). For **Mem Reduction**, **higher is better** (more peak memory saved). + + - **Speedup** grows from slower at 128 tokens (kernel launch overhead dominates) to several times faster at 1,024 tokens in typical runs. + - **Memory reduction** (~6x in the table): PyTorch allocates separate tensors for the logits, softmax output, and loss gradients. The fused kernel avoids the softmax intermediary. For 1,024 tokens, this saves over 1 GB of GPU memory, room for larger batches or longer sequences. + - At very small token counts (128), the fused kernel can be **slower**. That is expected: the online softmax loop has fixed per-row overhead. The crossover is often near 256–1,024 tokens depending on stack. + + > [!NOTE] + > Same caveat as in Step 7: **absolute microseconds in the example table are illustrative**. On the validation run for this playbook the per-iteration latencies were several thousand µs rather than the ~300 µs printed above, while the **memory reduction** (~6x) and the **speedup direction** (fused becomes faster as `num_tokens` grows) remained stable. Trust the **shape** of the table and the **memory column**, not the absolute latency numbers. Now re-profile with both custom kernels active: @@ -567,24 +615,27 @@ spec: python finetune_optimized.py ``` - Example comparison: + Example comparison on **GB300** (default `--batch-size 1`, `--seq-len 512`; throughput is `batch * seq_len / step_time`; numbers below are **illustrative**, not a target): ``` ====================================================================== Baseline Results ====================================================================== - Average time per step: 1.842 s - Average throughput: 278 tokens/sec + Average time per step: 0.201 s + Average throughput: 2540 tokens/sec (illustrative) Peak GPU memory: 112.4 GB ====================================================================== - Optimized Results + Optimized Results (illustrative) ====================================================================== - Average time per step: 1.614 s - Average throughput: 317 tokens/sec + Average time per step: 0.194 s + Average throughput: 2640 tokens/sec (illustrative) Peak GPU memory: 78.6 GB ``` + > [!NOTE] + > **Treat the throughput numbers above as illustrative, not a target** — same caveat as the RMSNorm (Step 7) and cross-entropy (Step 10) benchmark notes. Absolute tok/s and step time **vary** with GPU generation, clocks, PyTorch / CUDA builds, and whether the warm-up pass included JIT; older runs near **~280 tok/s** were observed on different stacks. The **stable signals** are (1) the **relative gap** — optimized > baseline — and (2) the **peak GPU memory delta** (the cross-entropy memory reduction is what frees room for larger batch sizes). Match those, not the absolute tok/s. + **How the custom kernels are integrated:** The `finetune_optimized.py` script uses the "surgical replacement" pattern to swap in custom kernels without modifying the model source code: @@ -613,7 +664,7 @@ spec: > [!NOTE] > **Amdahl's law in action.** An 8x faster RMSNorm does not make training 8x faster. If RMSNorm was 10% of total step time, making it 8x faster saves about 8.75% of total time. The cross-entropy memory reduction has an outsized impact because it frees GPU memory that enables larger batch sizes, which improves GPU utilization across *all* operations — including the matrix multiplications and attention that dominate the compute profile. - # Step 12. Cleanup and next steps + # Step 12. Cleanup When you're finished, exit the container: @@ -638,16 +689,16 @@ spec: rm -rf ~/.cache/huggingface/hub/models--meta-llama--Llama-3.1-8B ``` - **Next steps:** + # Step 13. Next steps - You've profiled a real training workload, identified the bottlenecks, written custom Triton kernels to address them, and measured end-to-end improvements. Here's where to go next: + You profiled a real training workload, identified bottlenecks, shipped custom Triton kernels, and measured end-to-end impact. Continue from here with: - - **Fused Linear Cross-Entropy** — The kernel we wrote takes pre-computed logits as input. A more advanced variant fuses the `lm_head` linear projection with the cross-entropy, computing logits chunk-by-chunk and never materializing the full `[B*T, V]` tensor at all. See [Liger-Kernel's FusedLinearCrossEntropy](https://github.com/linkedin/Liger-Kernel) for a production implementation. - - **Fused SwiGLU with backward** — The [Custom CUDA Kernel Development](https://build.nvidia.com/nvidia/station-kernel-dev) playbook covered inference-only SwiGLU. For training, you need the backward pass too. Triton makes this straightforward with the `torch.autograd.Function` pattern used in this playbook. - - **Liger-Kernel integration** — Instead of writing every kernel yourself, use [Liger-Kernel](https://github.com/linkedin/Liger-Kernel) as a drop-in optimization: `pip install liger-kernel` and `apply_liger_kernel_to_llama()`. Compare its throughput against your hand-written kernels. - - **Larger batch sizes** — The memory freed by fused cross-entropy allows increasing batch size. Re-profile with `--batch-size 2` or `--batch-size 4` to see how GPU utilization improves when more compute work is available per step. - - **LoRA fine-tuning** — Apply the same profiling methodology to LoRA/QLoRA fine-tuning. The bottleneck profile is different (fewer optimizer states, more activation memory relative to weights), which reveals different optimization opportunities. - - **Multi-GPU training** — The custom kernels work transparently with PyTorch FSDP and DDP. Each GPU runs its own copy of the kernel independently — no changes needed. + - **Fused Linear Cross-Entropy:** The kernel in this playbook takes pre-computed logits. A more advanced variant fuses the `lm_head` linear projection with the cross-entropy so logits are produced chunk-by-chunk and the full `[B*T, V]` tensor is never stored. See [Liger-Kernel's FusedLinearCrossEntropy](https://github.com/linkedin/Liger-Kernel). + - **Fused SwiGLU with backward:** The [Custom CUDA Kernel Development](https://build.nvidia.com/nvidia/station-kernel-dev) playbook covered inference-only SwiGLU. Training needs the backward pass; use the same `torch.autograd.Function` pattern as here. + - **Liger-Kernel integration:** `pip install liger-kernel` and `apply_liger_kernel_to_llama()`, then compare throughput to your hand-written kernels. + - **Larger batch sizes:** Fused cross-entropy frees memory. Re-profile with `--batch-size 2` or `--batch-size 4` to see utilization when more matmul work sits behind each step. + - **LoRA fine-tuning:** Re-run the profiling methodology on LoRA or QLoRA. Bottlenecks shift (fewer optimizer states, different activation pressure). + - **Multi-GPU training:** These kernels compose with FSDP and DDP unchanged (each rank runs its own Triton programs). @@ -660,7 +711,8 @@ spec: |---------|-------|-----| | `ModuleNotFoundError: No module named 'triton'` | Container missing Triton | Use the `kernel-dev-ft` container built from the playbook's Dockerfile. Triton ships with PyTorch NGC containers. Verify: `python -c "import triton; print(triton.__version__)"`. | | `triton.compiler.errors.CompilationError` referencing `sm_100` | Triton version too old for Blackwell | Use PyTorch NGC container 26.01+ which includes Triton with Blackwell support. Check: `python -c "import triton; print(triton.__version__)"`. | - | Correctness test fails with large differences in BF16 | Using FP32 tolerance for BF16 comparison | BF16 has only 7 mantissa bits. Use `atol=1e-2, rtol=1e-2` for `torch.allclose`. Differences up to ~0.01 are normal. | + | Cross-entropy BF16 test fails on loss or gradient | BF16 + 128K vocab accumulate drift vs PyTorch's CE path | `cross_entropy_test.py` uses relaxed loss tolerances and compares **gradients in float32** with wider `atol/rtol`. If it still fails, check PyTorch / CUDA versions; file an issue with `torch.__version__`. | + | `RuntimeError: Trace is already saved` from profiler | Stale `traces/` directory from a previous run | Use the latest `profile_baseline.py` (it deletes the prior trace dir and Chrome JSON). Or run `rm -rf traces/trace traces/trace_*` before profiling. | | `torch.cuda.OutOfMemoryError` during baseline profiling | Batch size or sequence length too large | Reduce `--batch-size` or `--seq-len` in `profile_baseline.py`. LLaMA 3.1 8B in BF16 needs ~16 GB for weights alone, plus ~32 GB for AdamW optimizer states. | | `torch.cuda.OutOfMemoryError` during PyTorch cross-entropy but NOT during custom kernel | Standard cross-entropy materializes full `[B*T, V]` logit tensor | This demonstrates exactly why the custom kernel is needed. Reduce batch size or sequence length for the baseline comparison, or run only the custom kernel path. | | Profiler trace JSON is very large (>1 GB) | Too many training steps profiled | Reduce `wait`, `warmup`, `active` in the profiler schedule. The default script profiles only 1 active step. | @@ -693,3 +745,7 @@ spec: url: https://docs.nvidia.com/cuda/blackwell-tuning-guide/ + - name: NVIDIA Nsight Systems + url: https://developer.nvidia.com/nsight-systems + + diff --git a/nvidia/station-mig/endpoint-production.yaml b/nvidia/station-mig/endpoint-production.yaml index 60b694e..8c592db 100644 --- a/nvidia/station-mig/endpoint-production.yaml +++ b/nvidia/station-mig/endpoint-production.yaml @@ -345,7 +345,7 @@ spec: nvidia-smi -q | grep -A2 "MIG Mode" ``` - Expected output should show `Current: Disabled` for each GPU. If you still see MIG devices in `nvidia-smi -L`, destroy any remaining instances with `-dci`/`-dgi` per GPU, then run `-mig 0` again. + Expected output should show `Current: Disabled` for each GPU. If you still see MIG devices in `nvidia-smi -L`, destroy any remaining instances with `-dci`/`-dgi` per GPU, then run `-mig 0` again diff --git a/nvidia/station-nvfp4-pretraining/README.md b/nvidia/station-nvfp4-pretraining/README.md index f5a7917..5f3634e 100644 --- a/nvidia/station-nvfp4-pretraining/README.md +++ b/nvidia/station-nvfp4-pretraining/README.md @@ -66,7 +66,7 @@ NVFP4 is **1.68× faster** than BF16 (≈68% higher throughput) with ≈13.8 GB - NVIDIA DGX Station with Blackwell architecture GPU (GB300 chip) - Docker installed with GPU support - NVIDIA Container Toolkit configured -- Megatron-Bridge installed (via the the NeMo Framework NGC container) +- Megatron-Bridge installed (via the NeMo Framework NGC container) Verify your setup: @@ -113,7 +113,7 @@ docker run --rm -it \ nvcr.io/nvidia/nemo:${TAG} ``` -All subsequent `torchrun` / `python` commands in this playbook are meant to be executed **from the shell inside this container** . +All subsequent `torchrun` / `python` commands in this playbook are meant to be executed **from the shell inside this container**. ## Step 2. Review the pretraining script @@ -248,6 +248,6 @@ Then exit the container shell (`exit`) — the `--rm` flag in Step 1 deletes it | `CUDA out of memory` during model init | Insufficient GPU memory for Llama 3.1 8B + optimizer states | Reduce `micro_batch_size` or use `--nproc_per_node` for model parallelism | | `torchrun` hangs or times out | NCCL communication failure between GPUs | Check `NCCL_DEBUG=INFO torchrun ...` for details; verify all GPUs are visible | | Training loss is NaN | Precision instability | Increase `num_layers_at_end_in_bf16` (e.g., from 4 to 8) or reduce learning rate | -| `--no-fp4` works but NVFP4 crashes | Transformer Engine version mismatch | Ensure Transformer Engine supports NVFP4; update with `pip install --upgrade transformer-engine` | +| `--disable-fp4` works but NVFP4 crashes | Transformer Engine version mismatch | Ensure Transformer Engine supports NVFP4; update with `pip install --upgrade transformer-engine` | | Slow training throughput | Not using Tensor Cores efficiently | Ensure batch dimensions are multiples of 8; check that `nvidia-smi` shows high GPU utilization | | Permission denied on Docker | User not in docker group | Run `sudo usermod -aG docker $USER && newgrp docker` | diff --git a/nvidia/station-nvfp4-pretraining/endpoint-production.yaml b/nvidia/station-nvfp4-pretraining/endpoint-production.yaml index 7b38018..8f4fbc6 100644 --- a/nvidia/station-nvfp4-pretraining/endpoint-production.yaml +++ b/nvidia/station-nvfp4-pretraining/endpoint-production.yaml @@ -101,12 +101,12 @@ spec: # Time & risk - * **Estimated duration**: 20-30 minutes (quick test loop with default `--train-iters 10`); longer for real data + * **Estimated duration**: 20-30 minutes (quick test loop with default `--train-iters 50`); longer for real data * **Risks**: * NVFP4 requires Blackwell GPUs — will fail on Hopper or older * Mock data is used by default (`eval_iters=0`); real data requires a preprocessed Megatron-format dataset * **Rollback**: Stop the `torchrun` process and remove any checkpoint directories - * **Last Updated:** 04/19/2026 + * **Last Updated:** 05/26/2026 * First Publication @@ -276,7 +276,7 @@ spec: |---------|-------|-----| | `RuntimeError: NVFP4 is not supported on this GPU` or similar FP4 error | GPU is not Blackwell architecture | NVFP4 requires Blackwell GPUs (GB200, GB300). Check with `nvidia-smi` | | `ModuleNotFoundError: No module named 'megatron.bridge'` | Megatron Bridge not installed | Run `pip install megatron-bridge` or use the NGC container | - | `CUDA out of memory` during model init | Insufficient GPU memory for Llama 1B + optimizer states | Reduce `micro_batch_size` or use `--nproc_per_node` for model parallelism | + | `CUDA out of memory` during model init | Insufficient GPU memory for Llama 3.1 8B + optimizer states | Reduce `micro_batch_size` or use `--nproc_per_node` for model parallelism | | `torchrun` hangs or times out | NCCL communication failure between GPUs | Check `NCCL_DEBUG=INFO torchrun ...` for details; verify all GPUs are visible | | Training loss is NaN | Precision instability | Increase `num_layers_at_end_in_bf16` (e.g., from 4 to 8) or reduce learning rate | | `--no-fp4` works but NVFP4 crashes | Transformer Engine version mismatch | Ensure Transformer Engine supports NVFP4; update with `pip install --upgrade transformer-engine` | diff --git a/nvidia/station-nvfp4-pretraining/endpoint-test.yaml b/nvidia/station-nvfp4-pretraining/endpoint-test.yaml index 8f4fbc6..97da6e8 100644 --- a/nvidia/station-nvfp4-pretraining/endpoint-test.yaml +++ b/nvidia/station-nvfp4-pretraining/endpoint-test.yaml @@ -87,7 +87,7 @@ spec: - NVIDIA DGX Station with Blackwell architecture GPU (GB300 chip) - Docker installed with GPU support - NVIDIA Container Toolkit configured - - Megatron-Bridge installed (via the the NeMo Framework NGC container) + - Megatron-Bridge installed (via the NeMo Framework NGC container) Verify your setup: @@ -139,7 +139,7 @@ spec: nvcr.io/nvidia/nemo:${TAG} ``` - All subsequent `torchrun` / `python` commands in this playbook are meant to be executed **from the shell inside this container** . + All subsequent `torchrun` / `python` commands in this playbook are meant to be executed **from the shell inside this container**. # Step 2. Review the pretraining script @@ -279,7 +279,7 @@ spec: | `CUDA out of memory` during model init | Insufficient GPU memory for Llama 3.1 8B + optimizer states | Reduce `micro_batch_size` or use `--nproc_per_node` for model parallelism | | `torchrun` hangs or times out | NCCL communication failure between GPUs | Check `NCCL_DEBUG=INFO torchrun ...` for details; verify all GPUs are visible | | Training loss is NaN | Precision instability | Increase `num_layers_at_end_in_bf16` (e.g., from 4 to 8) or reduce learning rate | - | `--no-fp4` works but NVFP4 crashes | Transformer Engine version mismatch | Ensure Transformer Engine supports NVFP4; update with `pip install --upgrade transformer-engine` | + | `--disable-fp4` works but NVFP4 crashes | Transformer Engine version mismatch | Ensure Transformer Engine supports NVFP4; update with `pip install --upgrade transformer-engine` | | Slow training throughput | Not using Tensor Cores efficiently | Ensure batch dimensions are multiples of 8; check that `nvidia-smi` shows high GPU utilization | | Permission denied on Docker | User not in docker group | Run `sudo usermod -aG docker $USER && newgrp docker` | diff --git a/nvidia/station-sglang-inference/README.md b/nvidia/station-sglang-inference/README.md index 574413f..ee49e7e 100644 --- a/nvidia/station-sglang-inference/README.md +++ b/nvidia/station-sglang-inference/README.md @@ -298,7 +298,7 @@ This step uses `benchmark_multiturn.py` from this playbook's `assets/` directory ```bash git clone https://github.com/NVIDIA/dgx-spark-playbooks -cd dgx-station-playbooks/nvidia/station-sglang-inference +cd dgx-spark-playbooks/nvidia/station-sglang-inference ``` > [!TIP] diff --git a/nvidia/station-sglang-inference/endpoint-production.yaml b/nvidia/station-sglang-inference/endpoint-production.yaml index 4d35b66..4d5ae71 100644 --- a/nvidia/station-sglang-inference/endpoint-production.yaml +++ b/nvidia/station-sglang-inference/endpoint-production.yaml @@ -2,7 +2,7 @@ kind: Playbook metadata: name: station-sglang-inference displayName: LLM Inference with SGLang - shortDescription: Serve LLMs with SGLang on DGX Station for prefix-cached multi-turn and structured output inference + shortDescription: Serve LLMs with SGLang on DGX Station (Qwen3-8B default; Qwen3.6 MoE optional)—prefix-cached multi-turn, structured output, benchmarks, and inference-server guidance publisher: nvidia description: | @@ -21,7 +21,7 @@ metadata: attributes: - key: DURATION - value: 25 MIN + value: 30 MIN spec: artifactName: station-sglang-inference @@ -54,12 +54,13 @@ spec: # What you'll accomplish - Launch SGLang on DGX Station to serve an LLM, then exercise its two key differentiators: prefix-cached multi-turn chat and structured JSON output generation. You will also benchmark multi-turn throughput to see RadixAttention's effect. + Launch SGLang on DGX Station to serve an LLM, then exercise its two key differentiators: prefix-cached multi-turn chat and structured JSON output generation. You will also benchmark multi-turn throughput and interpret results together with server logs (wall time alone is not a reliable cache signal under parallel load). - - Serve Qwen3-8B with SGLang's Blackwell-optimized backend - - Send multi-turn conversations and observe prefix cache hits in server metrics + - Serve **Qwen3-8B** (`Qwen/Qwen3-8B` by default for fast first-run validation) or another checkpoint from the in-playbook model table — including the larger **Qwen3.6 MoE** (`Qwen/Qwen3.6-35B-A3B`) once the workflow is verified + - Send multi-turn conversations and observe prefix cache hits in **Docker logs** (`#cached-token`) - Generate structured JSON output using schema-constrained decoding - - Benchmark multi-turn throughput with and without prefix caching + - Benchmark multi-turn throughput; optional **single-conversation** run to reduce contention; full cache/metrics scrape written to a **log file** for review + - Optional next step: large MoE such as **DeepSeek-V4** on Station when your SGLang build and VRAM allow # What to know before starting @@ -76,14 +77,14 @@ spec: # Ancillary files - - `assets/benchmark_multiturn.py` — Python script that benchmarks multi-turn conversation throughput and demonstrates structured output generation + - `assets/benchmark_multiturn.py` — Benchmarks multi-turn chat under parallel load, structured JSON output, and writes full `/server_info` + `/metrics` bodies to a detail log (terminal shows a short summary only) # Time & risk - * **Duration:** 20–25 minutes (including model download) - * **Risks:** Model download requires HuggingFace authentication + * **Duration:** 20–30 minutes for the default `Qwen/Qwen3-8B`; 45–60 minutes if you switch to `Qwen/Qwen3.6-35B-A3B` (download + Blackwell CUDA-graph capture) + * **Risks:** Gated models (e.g., Llama 3.3) require HuggingFace authentication and license acceptance * **Rollback:** Stop and remove the container to restore state - * **Last Updated:** 04/06/2026 + * **Last Updated:** 05/26/2026 * First Publication @@ -105,17 +106,52 @@ spec: # Step 2. Set up environment variables ```bash - # HuggingFace token (required) - # Get a token from https://huggingface.co/settings/tokens - export HF_TOKEN="your_huggingface_token" + # HuggingFace token (only required for gated models such as Llama 3.3). + # Leave empty for public models like Qwen3-8B; for gated models get a token at + # https://huggingface.co/settings/tokens. + export HF_TOKEN="" - # Model to serve + # Model to serve (see **Example model IDs** below). + # Default uses Qwen3-8B for fast first-run validation (~10–15 min boot on Station). + # Switch to Qwen3.6-35B-A3B once the workflow is working end-to-end. export MODEL_HANDLE="Qwen/Qwen3-8B" # Maximum context length export MAX_MODEL_LEN=8192 ``` + ## Example model IDs (`MODEL_HANDLE`) + + Use any **Hugging Face text-generation or chat** checkpoint that your SGLang build supports. The table below lists common starting points on DGX Station; always check the model card for **license / gated access**, **VRAM**, and **context length**. + + | Model ID | Notes | + |----------|--------| + | `Qwen/Qwen3-8B` | **Default in this playbook.** Dense Qwen3 8B; ~16 GB download, fast warmup, ideal for validating the workflow end-to-end. | + | `Qwen/Qwen3.6-35B-A3B` | Qwen3.6 MoE (~3B active experts); strong quality per GPU hour on Blackwell. ~70 GB download; allow ~30–45 min to first request. | + | `Qwen/Qwen3.6-27B` | Dense Qwen3.6; higher VRAM than the MoE row above at equal batch settings. | + | `google/gemma-3-12b-it` | Popular Gemma 3 instruct (text + vision in full stack; chat API usage is typically text-only). | + | `google/gemma-3-27b-it` | Larger Gemma 3 instruct variant. | + | `meta-llama/Llama-3.3-70B-Instruct` | Llama 3.3 70B instruct (gated on Hugging Face; accept the license in the model card before download). | + + Heavyweight MoE (very large weights; confirm **SGLang version + GPU memory** before serving): + + | Model ID | Notes | + |----------|--------| + | `deepseek-ai/DeepSeek-V4-Flash` | DeepSeek-V4 family (MoE). Intended to showcase **large local models on Station**; expect long downloads, strict VRAM headroom, and possible extra flags per SGLang docs. | + | `deepseek-ai/DeepSeek-V4-Pro` | Larger V4 variant; only if you have sufficient GPU memory and a supported SGLang build. | + + ## Choosing an inference backend (DGX Station) + + Several OpenAI-compatible servers run well on NVIDIA hardware. None is universally “best”—pick by workload shape and operational constraints. + + | Backend | Strengths | Typical “use this when…” | + |---------|-----------|---------------------------| + | **SGLang** | RadixAttention for shared-prefix workloads; strong structured / grammar decoding; active Blackwell + CUDA 13 paths. | Highly **multi-turn**, **RAG** (repeated system + documents), **agents**, or **schema-constrained** JSON at scale. | + | **vLLM** | MaturePagedAttention, broad model coverage, common default in examples. | You want a **well-trodden** OSS server with **maximum community recipes** and straightforward PagedAttention behavior. | + | **TensorRT-LLM** | NVIDIA-optimized kernels and quantization workflows for throughput-focused deployment. | You are **productionizing** on NVIDIA GPUs and can invest in **TensorRT-LLM export / engines** for peak throughput. | + + This playbook focuses on **SGLang**; consult each project’s documentation for model support matrices and quantization modes. + # Step 3. Pull the SGLang container Pull the SGLang container image with CUDA 13.0 support (required for Blackwell SM103): @@ -126,24 +162,26 @@ spec: # Step 4. Identify the GB300 GPU - On DGX Station with multiple GPUs, identify the GB300's device index: + Identify the GB300's device index: ```bash nvidia-smi --query-gpu=index,name --format=csv,noheader ``` - Look for the row showing `NVIDIA GB300`. Note its index (e.g., `1`). + Look for the row showing `NVIDIA GB300`. Note its index — on DGX Station the GB300 may be at index `0` or `1` depending on configuration. If `nvidia-smi` shows only a single GB300, you can simply use `--gpus all` in the next step. # Step 5. Start SGLang server - Launch the SGLang server: + Launch the SGLang server. The flags below are tuned for GB300 (Blackwell SM103) — see notes after the command: ```bash - # Replace device=1 with your GB300's index from Step 4 + # Use --gpus all on a single-GPU Station, or --gpus '"device=N"' with the + # index from Step 4 if multiple GPUs are present. docker run -d \ --name sglang-server \ - --gpus '"device=1"' \ + --gpus all \ --ipc host \ + --cap-add SYS_NICE \ --ulimit memlock=-1 \ --ulimit stack=67108864 \ -p 30000:30000 \ @@ -154,9 +192,17 @@ spec: --host 0.0.0.0 \ --port 30000 \ --context-length $MAX_MODEL_LEN \ - --mem-fraction-static 0.85 + --mem-fraction-static 0.85 \ + --attention-backend flashinfer \ + --enable-cache-report ``` + > [!IMPORTANT] + > **Why these flags on GB300:** + > - `--attention-backend flashinfer` — the auto-selected `trtllm_mha` backend currently fails CUDA-graph capture on Blackwell SM103 with `buildNdTmaDescriptor` errors; `fa3` is also rejected (it requires SM ≤ 90). FlashInfer is the safe default. + > - `--cap-add SYS_NICE` — lets SGLang set NUMA affinity; otherwise the server logs a warning on every launch. + > - `--enable-cache-report` — populates `usage.prompt_tokens_details.cached_tokens` in OpenAI-style responses so the benchmark in Step 9 can report cached prefill tokens. + Check the server logs: ```bash @@ -172,7 +218,7 @@ spec: Press `Ctrl+C` to exit the log view. > [!NOTE] - > First launch downloads the model and compiles kernels. Subsequent starts are faster thanks to cached weights and compiled artifacts. + > First launch downloads the model and captures CUDA graphs. Plan for ~10–15 min for `Qwen/Qwen3-8B` and ~30–45 min for `Qwen/Qwen3.6-35B-A3B` before the server is ready. Subsequent starts are faster thanks to cached weights and compiled artifacts. # Step 6. Test basic inference @@ -224,15 +270,15 @@ spec: }' | python3 -m json.tool ``` - The second request reuses the KV cache from the shared prefix (system message + first user turn + assistant response), only computing attention for the new user message. This reduces first-token latency for follow-up turns. + The second request **reuses the KV cache for the shared prefix** (system message + first user turn + assistant response) via RadixAttention, so repeated **prefill** work on that prefix is avoided. **End-to-end HTTP latency can still go up** on later turns: the transcript is longer (more tokens to attend to even with cache hits on the prefix), each assistant reply adds decode work, and the client measures full request time—not prefill alone. - Check the cache hit rate in the server logs. SGLang logs each prefill batch with the number of cached tokens reused: + Check cache reuse in the server logs. SGLang logs each prefill batch with the number of cached tokens reused: ```bash docker logs sglang-server 2>&1 | grep "cached-token" | tail -10 ``` - Look for `#cached-token` values greater than 0 on later turns — this confirms RadixAttention is reusing the KV cache from the shared prefix. + Look for `#cached-token` values greater than 0 on later turns — this confirms RadixAttention is reusing the KV cache from the shared prefix. Treat that as the primary signal of prefix caching; wall-clock `curl` latency alone can be misleading. # Step 8. Structured JSON output @@ -280,30 +326,72 @@ spec: # Step 9. Benchmark multi-turn throughput - Run the included benchmark script to measure how prefix caching improves multi-turn latency. The script is in the `assets/` directory of this playbook. + This step uses `benchmark_multiturn.py` from this playbook's `assets/` directory. Clone (or download) the playbook repository first so the script is available locally: ```bash + git clone https://github.com/NVIDIA/dgx-spark-playbooks + cd dgx-station-playbooks/nvidia/station-sglang-inference + ``` + + > [!TIP] + > If `git` is not available, download the repository as a ZIP from the [playbook repository](https://github.com/NVIDIA/dgx-spark-playbooks/blob/main/nvidia/station-sglang-inference/) and extract it. All commands below assume your working directory is the playbook root (`dgx-station-playbooks/nvidia/station-sglang-inference/`), so `assets/benchmark_multiturn.py` resolves correctly. + + The benchmark stress-tests the server with **parallel** conversations (default: 20) and reports **per-turn wall time**, token counts, and (when the API exposes it) **cached prefill tokens**. + + Install the `requests` dependency. The **virtualenv approach below is the preferred, default installation path** — it keeps the script's dependencies isolated from the system Python interpreter so you cannot accidentally damage Ubuntu's own Python packages. Ubuntu 24.04 on DGX Station does not ship `python3-venv` by default, so install it once before creating the virtualenv: + + ```bash + sudo apt update && sudo apt install -y python3-venv python3 -m venv .venv && source .venv/bin/activate pip install requests ``` + If you cannot run `sudo apt install python3-venv` (for example, a locked-down host), the next safest option is a **per-user install** that still respects PEP 668: + + ```bash + python3 -m pip install --user requests + ``` + + > [!CAUTION] + > **Last-resort only — `--break-system-packages` can damage your system Python.** + > Ubuntu 24.04 ships an "externally managed" system Python (PEP 668). The `--break-system-packages` flag tells `pip` to ignore that guard and install into the system or per-user site-packages anyway. This can shadow or conflict with packages installed by `apt` and break system tooling that depends on them. Only use this command when both the **venv** and plain **`--user`** paths above are unavailable, and only if you are willing to take that risk on the host you are running on: + > ```bash + > python3 -m pip install --user --break-system-packages requests + > ``` + ```bash python3 assets/benchmark_multiturn.py \ --base-url http://localhost:30000 \ --model "$MODEL_HANDLE" \ --num-conversations 20 \ + --turns-per-conversation 5 \ + --cache-detail-file ./sglang_benchmark_cache_details.log + ``` + + The script prints: + - **Median / P90 wall time per turn** — often **increases** as prompts grow and under parallel load; that does **not** contradict RadixAttention. + - **Median prompt tokens per turn** — should climb as history lengthens. + - **Median cached prefill tokens** (when returned in `usage`) — populated by `--enable-cache-report` (already set in Step 5); this is the primary cache signal from the OpenAI-style `usage` payload. + - A **short summary** of cache-related `/server_info` or `/metrics` lines; the **full** responses are written to `--cache-detail-file` (default `./sglang_benchmark_cache_details.log`) so you are not flooded with an unparsed metrics blob in the terminal. + + > [!NOTE] + > The Step 5 launch enables `--enable-cache-report` (which fills `usage.prompt_tokens_details.cached_tokens`) but does **not** enable the Prometheus `/metrics` endpoint, since cached-prefill data is already exposed through `usage` and the `docker logs` `#cached-token` lines. If `/metrics` returns `404`/empty in the detail log, that is expected — the benchmark's primary cache signals (`usage.prompt_tokens_details.cached_tokens` and Docker logs) still work. To populate `/metrics` as well, add `--enable-metrics` to the `sglang serve` invocation in Step 5 and restart the container. + + To isolate prefix-cache behavior from multi-client contention, rerun with a single conversation: + + ```bash + python3 assets/benchmark_multiturn.py \ + --base-url http://localhost:30000 \ + --model "$MODEL_HANDLE" \ + --num-conversations 1 \ --turns-per-conversation 5 ``` - The script sends parallel multi-turn conversations and measures: - - **Per-turn latency** for turn 1 vs subsequent turns (shows prefix caching effect) - - **Total throughput** in tokens per second - - **Cache statistics** from server metrics + Always correlate behavior with **`docker logs`** (`#cached-token` lines) as in Step 7. - You should see latency decrease for later turns in each conversation as the shared prefix grows, demonstrating RadixAttention's cache reuse. + ## Next steps: heavier models on Station - > [!TIP] - > If you downloaded this playbook as a zip, the `assets/` directory is already present. If you cloned the full repository, navigate to `nvidia/station-sglang-inference/` first. + To stress GPU memory and throughput after completing the steps above, point `MODEL_HANDLE` at a larger checkpoint (for example `deepseek-ai/DeepSeek-V4-Flash`), **lower** `--mem-fraction-static` if you hit OOM, and reduce `--context-length` until the server starts cleanly. Confirm your SGLang image version supports the architecture (see [SGLang documentation](https://docs.sglang.io/)) and accept any **gated** model licenses on Hugging Face before pulling weights. # Step 10. Cleanup @@ -333,18 +421,24 @@ spec: |---------|-------|-----| | "permission denied" when running docker | User not in docker group | Run `sudo usermod -aG docker $USER && newgrp docker` | | Container fails to start with GPU error | NVIDIA Container Toolkit not configured | Run `nvidia-ctk runtime configure --runtime=docker` and restart Docker | - | `device >= 0 && device < num_gpus INTERNAL ASSERT FAILED` | Using `--gpus all` on a multi-GPU system | Use `--gpus '"device=N"'` to target the GB300 specifically (check index with `nvidia-smi`) | - | "Token is required" or 401 error | Missing HuggingFace token | Ensure `HF_TOKEN` is exported before running the docker command | + | `device >= 0 && device < num_gpus INTERNAL ASSERT FAILED` | `--gpus '"device=N"'` index does not exist on this Station | Re-run `nvidia-smi --query-gpu=index,name --format=csv,noheader` and use the actual GB300 index, or `--gpus all` if there is only one GPU | + | `RuntimeError: ... buildNdTmaDescriptor ... Check failed: false` during CUDA-graph capture | Default `trtllm_mha` attention backend is incompatible with Blackwell SM103 | Pass `--attention-backend flashinfer` to `sglang serve` | + | `AssertionError: FlashAttention v3 Backend requires SM>=80 and SM<=90` | `--attention-backend fa3` selected on Blackwell (SM103) | Use `--attention-backend flashinfer` instead | + | `User lacks permission to set NUMA affinity ... try adding --cap-add SYS_NICE` warning | Docker dropped the `SYS_NICE` capability | Add `--cap-add SYS_NICE` to the `docker run` command | + | `python3 -m venv .venv` fails with `apt install python3.12-venv` hint | Ubuntu 24.04 ships without `python3-venv` | Run `sudo apt update && sudo apt install -y python3-venv` (or use `python3 -m pip install --user --break-system-packages requests`) | + | "Token is required" or 401 error | Missing HuggingFace token for a gated model | Export `HF_TOKEN` before running the docker command and accept the model license on huggingface.co | | Server exits with OOM error | Model too large for available GPU memory | Lower `--mem-fraction-static` (e.g., 0.7) or reduce `--context-length`. Check GPU memory with `nvidia-smi` | | `json_schema` response_format returns error | SGLang version too old | Ensure you are using `lmsysorg/sglang:latest-cu130`. Older versions may not support `json_schema` format | | Server starts but CUDA errors on inference | Wrong CUDA version for Blackwell | Use the `latest-cu130` image tag. SM103 requires CUDA 13.0+ | - | Model runs on wrong GPU | Default GPU selection | Use `--gpus '"device=N"'` to select the GB300 specifically | - | Slow first request after server start | Kernel JIT compilation | First request triggers kernel compilation. Subsequent requests are fast. Wait ~30 seconds | - | Connection refused on port 30000 | Server still loading model | Check `docker logs sglang-server` — wait for the Uvicorn startup message | - | `/server_info` shows no cache stats | Endpoint may differ across versions | Try `curl http://localhost:30000/v1/models` to verify the server is responsive. Cache metrics may be under `/metrics` (requires `--enable-metrics` server flag) | + | Slow first request after server start | Kernel JIT + CUDA-graph capture | First launch can take 10–15 min for `Qwen/Qwen3-8B` and 30–45 min for `Qwen/Qwen3.6-35B-A3B` before the server prints "fired up and ready to roll!". Subsequent requests are fast. | + | Connection refused on port 30000 | Server still loading model or capturing CUDA graphs | Check `docker logs sglang-server` — wait for the Uvicorn startup message and "The server is fired up and ready to roll!" | + | `Med cached prefill` column is `n/a` in the benchmark | OpenAI-style `cached_tokens` not enabled on the server | Add `--enable-cache-report` to `sglang serve` so `usage.prompt_tokens_details.cached_tokens` is populated | + | `/server_info` body floods the benchmark "cache highlights" output | Older `benchmark_multiturn.py` matched any line containing "cache" — including the single-line `/server_info` JSON | Use the version of `benchmark_multiturn.py` shipped with this playbook (it skips JSON blobs and lines longer than 200 chars); the full body is still saved to `--cache-detail-file` | + | Benchmark shows **higher** median latency on later turns | Expected under parallel load + longer transcripts | RadixAttention reduces repeated **prefill** on shared prefixes—use `docker logs` (`#cached-token`) and optionally `--num-conversations 1`. See Step 9 and `sglang_benchmark_cache_details.log` | + | `deepseek-ai/DeepSeek-V4-*` fails to load | Unsupported in this SGLang build or insufficient VRAM | Check [SGLang docs](https://docs.sglang.io/) for model support; try `DeepSeek-V4-Flash` before Pro; lower `--mem-fraction-static` and `--context-length` | > [!NOTE] - > On DGX Station, the GB300 is typically device 1 (device 0 is the RTX Pro 6000 workstation GPU). Always verify with `nvidia-smi --query-gpu=index,name --format=csv,noheader`. + > On DGX Station the GB300 may be at device `0` or `1` depending on configuration (some Stations also expose a workstation GPU at `0`). Always verify with `nvidia-smi --query-gpu=index,name --format=csv,noheader` before launching the container. diff --git a/nvidia/station-sglang-inference/endpoint-test.yaml b/nvidia/station-sglang-inference/endpoint-test.yaml index 4d5ae71..06507ab 100644 --- a/nvidia/station-sglang-inference/endpoint-test.yaml +++ b/nvidia/station-sglang-inference/endpoint-test.yaml @@ -330,7 +330,7 @@ spec: ```bash git clone https://github.com/NVIDIA/dgx-spark-playbooks - cd dgx-station-playbooks/nvidia/station-sglang-inference + cd dgx-spark-playbooks/nvidia/station-sglang-inference ``` > [!TIP] diff --git a/nvidia/station-topic-modeling/endpoint-production.yaml b/nvidia/station-topic-modeling/endpoint-production.yaml index 884d04e..6262f5c 100644 --- a/nvidia/station-topic-modeling/endpoint-production.yaml +++ b/nvidia/station-topic-modeling/endpoint-production.yaml @@ -33,7 +33,6 @@ spec: cta: text: View on GitHub url: https://github.com/NVIDIA/dgx-spark-playbooks/blob/main/nvidia/station-topic-modeling/ - tabs: diff --git a/nvidia/station-vllm/README.md b/nvidia/station-vllm/README.md index 965960a..92127db 100644 --- a/nvidia/station-vllm/README.md +++ b/nvidia/station-vllm/README.md @@ -1,11 +1,11 @@ -# Serve Qwen3-235B with vLLM +# vLLM for Inference -> Set up vLLM server with Qwen3-235B on DGX Station +> Install and use vLLM on DGX Station ## Table of Contents - [Overview](#overview) -- [Serve Qwen3-235B](#serve-qwen3-235b) +- [Instructions](#instructions) - [Troubleshooting](#troubleshooting) --- @@ -22,7 +22,9 @@ vLLM is an inference engine designed to run large language models efficiently. T ## What you'll accomplish -Serve the **Qwen3-235B-A22B-NVFP4** model using vLLM on NVIDIA DGX Station. This 235B parameter model uses NVFP4 quantization and fits entirely in VRAM on the GB300 GPU. +Serve a **supported model** using vLLM on NVIDIA DGX Station. Refer to the table below to see the supported models. + +You'll set up vLLM high-throughput LLM serving on NVIDIA DGX Station with Blackwell architecture. ## What to know before starting @@ -37,16 +39,25 @@ Serve the **Qwen3-235B-A22B-NVFP4** model using vLLM on NVIDIA DGX Station. This - HuggingFace account with access token - Network access to NGC and HuggingFace +## Model Support Matrix + +The following models are supported with vLLM on DGX Station. All listed models are available and ready to use: + +| Model | Quantization | Support Status | HF Handle | +|-------|-------------|----------------|-----------| +| **Step-3.7-Flash-FP8** | FP8 | ✅ | [`stepfun-ai/Step-3.7-Flash-FP8`](https://huggingface.co/stepfun-ai/Step-3.7-Flash-FP8) | +| **Step-3.7-Flash-NVFP4** | NVFP4 | ✅ | [`stepfun-ai/Step-3.7-Flash-NVFP4`](https://huggingface.co/stepfun-ai/Step-3.7-Flash-NVFP4) | +| **Qwen3-235B-A22B-NVFP4** | NVFP4 | ✅ | [`nvidia/Qwen3-235B-A22B-NVFP4`](https://huggingface.co/nvidia/Qwen3-235B-A22B-NVFP4) | ## Time & risk -* **Duration:** 15-20 minutes (longer on first run due to model download) +* **Duration:** 30 minutes (longer on first run due to model download) * **Risks:** Model download requires HuggingFace authentication * **Rollback:** Stop and remove the container to restore state -* **Last Updated:** 03/02/2026 - * First Publication +* **Last Updated:** 05/28/2026 + * Update models -## Serve Qwen3-235B +## Instructions ## Step 1. Set up Docker permissions @@ -67,7 +78,7 @@ Set the following so the vLLM container can download the model and use your chos export HF_TOKEN="your_huggingface_token" ## Model to serve -export MODEL_HANDLE="nvidia/Qwen3-235B-A22B-NVFP4" +export MODEL_HANDLE="" ## Maximum context length export MAX_MODEL_LEN=8192 @@ -81,9 +92,16 @@ Pull the vLLM container from NGC. Use the **26.01** image on DGX Station; the 25 docker pull nvcr.io/nvidia/vllm:26.01-py3 ``` +For Step-3.7-Flash models, pull the custom VLLM container +```bash +docker pull vllm/vllm-openai:stepfun37 +``` + ## Step 4. Start vLLM server -Start the vLLM server with the Qwen3-235B model. This model fits entirely in VRAM on the GB300. On a single-GPU DGX Station, `--gpus all` uses the GB300; if you have multiple GPUs and want to use only the GB300, replace with `--gpus '"device=N"'` where N is the GB300 device ID from `nvidia-smi`. +Start the vLLM server with the model. On a single-GPU DGX Station, `--gpus all` uses the GB300; if you have multiple GPUs and want to use only the GB300, replace with `--gpus '"device=N"'` where N is the GB300 device ID from `nvidia-smi`. + +For Qwen3-235B NVFP4 model, run with the NGC container. This model fits entirely in VRAM on the GB300. ```bash docker run -d \ @@ -101,6 +119,28 @@ docker run -d \ --gpu-memory-utilization 0.9 ``` +For Step-3.7-Flash models, run with the custom VLLM container. The FP8 and the NVFP4 versions fit entirely in VRAM on the GB300. + +```bash +docker run -d \ + --name vllm-server \ + --gpus all \ + --ipc host \ + --ulimit memlock=-1 \ + --ulimit stack=67108864 \ + -p 8000:8000 \ + -e HF_TOKEN="$HF_TOKEN" \ + -v "$HOME/.cache/huggingface/hub:/root/.cache/huggingface/hub" \ + vllm/vllm-openai:stepfun37 \ + "$MODEL_HANDLE" \ + --gpu-memory-utilization 0.95 \ + --trust-remote-code \ + --reasoning-parser step3p5 \ + --enable-auto-tool-choice \ + --tool-call-parser step3p5 \ + --kv-cache-dtype fp8 +``` + Check the server logs for startup progress: ```bash @@ -110,7 +150,7 @@ docker logs -f vllm-server Expected output includes: - Model download progress (first run only) - Model loading into GPU memory -- `Uvicorn running on http://0.0.0.0:8000` +- `Application startup complete.` Press `Ctrl+C` to exit log view once the server is ready. @@ -141,9 +181,10 @@ docker rm vllm-server Optionally, remove the image and cached model: +Eg. ```bash -docker rmi nvcr.io/nvidia/vllm:26.01-py3 -rm -rf $HOME/.cache/huggingface/hub/models--nvidia--Qwen3-235B-A22B-NVFP4 +docker rmi "" +rm -rf $HOME/.cache/huggingface/hub/"" ``` ## Troubleshooting diff --git a/nvidia/station-vllm/endpoint-test.yaml b/nvidia/station-vllm/endpoint-test.yaml index c003724..42a2056 100644 --- a/nvidia/station-vllm/endpoint-test.yaml +++ b/nvidia/station-vllm/endpoint-test.yaml @@ -1,8 +1,8 @@ kind: Playbook metadata: name: station-vllm - displayName: Serve Qwen3-235B with vLLM - shortDescription: Set up vLLM server with Qwen3-235B on DGX Station + displayName: vLLM for Inference + shortDescription: Install and use vLLM on DGX Station publisher: nvidia description: | # REPLACE THIS WITH YOUR MODEL CARD @@ -15,7 +15,7 @@ metadata: attributes: - key: DURATION - value: 20 MIN + value: 30 MIN spec: artifactName: station-vllm @@ -42,7 +42,9 @@ spec: # What you'll accomplish - Serve the **Qwen3-235B-A22B-NVFP4** model using vLLM on NVIDIA DGX Station. This 235B parameter model uses NVFP4 quantization and fits entirely in VRAM on the GB300 GPU. + Serve a **supported model** using vLLM on NVIDIA DGX Station. Refer to the table below to see the supported models. + + You'll set up vLLM high-throughput LLM serving on NVIDIA DGX Station with Blackwell architecture. # What to know before starting @@ -57,21 +59,30 @@ spec: - HuggingFace account with access token - Network access to NGC and HuggingFace + # Model Support Matrix + + The following models are supported with vLLM on Spark. All listed models are available and ready to use: + + | Model | Quantization | Support Status | HF Handle | + |-------|-------------|----------------|-----------| + | **Step-3.7-Flash-FP8** | FP8 | ✅ | [`stepfun-ai/Step-3.7-Flash-FP8`](https://huggingface.co/stepfun-ai/Step-3.7-Flash-FP8) | + | **Step-3.7-Flash-NVFP4** | NVFP4 | ✅ | [`stepfun-ai/Step-3.7-Flash-NVFP4`](https://huggingface.co/stepfun-ai/Step-3.7-Flash-NVFP4) | + | **Qwen3-235B-A22B-NVFP4** | NVFP4 | ✅ | [`nvidia/Qwen3-235B-A22B-NVFP4`](https://huggingface.co/nvidia/Qwen3-235B-A22B-NVFP4) | # Time & risk - * **Duration:** 15-20 minutes (longer on first run due to model download) + * **Duration:** 30 minutes (longer on first run due to model download) * **Risks:** Model download requires HuggingFace authentication * **Rollback:** Stop and remove the container to restore state - * **Last Updated:** 03/02/2026 - * First Publication + * **Last Updated:** 05/28/2026 + * Update models - id: instructions - label: Serve Qwen3-235B + label: Instructions content: | # Step 1. Set up Docker permissions @@ -92,7 +103,7 @@ spec: export HF_TOKEN="your_huggingface_token" # Model to serve - export MODEL_HANDLE="nvidia/Qwen3-235B-A22B-NVFP4" + export MODEL_HANDLE="" # Maximum context length export MAX_MODEL_LEN=8192 @@ -106,9 +117,16 @@ spec: docker pull nvcr.io/nvidia/vllm:26.01-py3 ``` + For Step-3.7-Flash models, pull the custom VLLM container + ```bash + docker pull vllm/vllm-openai:stepfun37 + ``` + # Step 4. Start vLLM server - Start the vLLM server with the Qwen3-235B model. This model fits entirely in VRAM on the GB300. On a single-GPU DGX Station, `--gpus all` uses the GB300; if you have multiple GPUs and want to use only the GB300, replace with `--gpus '"device=N"'` where N is the GB300 device ID from `nvidia-smi`. + Start the vLLM server with the model. On a single-GPU DGX Station, `--gpus all` uses the GB300; if you have multiple GPUs and want to use only the GB300, replace with `--gpus '"device=N"'` where N is the GB300 device ID from `nvidia-smi`. + + For Qwen3-235B NVFP4 model, run with the NGC container. This model fits entirely in VRAM on the GB300. ```bash docker run -d \ @@ -126,6 +144,28 @@ spec: --gpu-memory-utilization 0.9 ``` + For Step-3.7-Flash models, run with the custom VLLM container. The FP8 and the NVFP4 versions fit entirely in VRAM on the GB300. + + ```bash + docker run -d \ + --name vllm-server \ + --gpus all \ + --ipc host \ + --ulimit memlock=-1 \ + --ulimit stack=67108864 \ + -p 8000:8000 \ + -e HF_TOKEN="$HF_TOKEN" \ + -v "$HOME/.cache/huggingface/hub:/root/.cache/huggingface/hub" \ + vllm/vllm-openai:stepfun37 \ + "$MODEL_HANDLE" \ + --gpu-memory-utilization 0.95 \ + --trust-remote-code \ + --reasoning-parser step3p5 \ + --enable-auto-tool-choice \ + --tool-call-parser step3p5 \ + --kv-cache-dtype fp8 + ``` + Check the server logs for startup progress: ```bash @@ -135,7 +175,7 @@ spec: Expected output includes: - Model download progress (first run only) - Model loading into GPU memory - - `Uvicorn running on http://0.0.0.0:8000` + - `Application startup complete.` Press `Ctrl+C` to exit log view once the server is ready. @@ -166,9 +206,10 @@ spec: Optionally, remove the image and cached model: + Eg. ```bash - docker rmi nvcr.io/nvidia/vllm:26.01-py3 - rm -rf $HOME/.cache/huggingface/hub/models--nvidia--Qwen3-235B-A22B-NVFP4 + docker rmi "" + rm -rf $HOME/.cache/huggingface/hub/"" ```