Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4a841b0
Restore uma-fix mod on develop
eugr May 26, 2026
ca4d700
Merge branch 'main' into develop
eugr May 29, 2026
491ad21
Merge branch 'main' into develop
eugr May 29, 2026
64d6a99
Merge branch 'main' into develop
eugr May 31, 2026
6e28d78
uma mod fixes
eugr Jun 3, 2026
2916b18
Merge branch 'main' into develop
eugr Jun 3, 2026
6392204
memory handling changes
eugr Jun 3, 2026
403edb3
get free memory directly from cuda
eugr Jun 4, 2026
0cafde9
Get memory info directly from CUDA
eugr Jun 4, 2026
88a08a4
Merge branch 'main' into develop
eugr Jun 7, 2026
04aff65
Added cuda-compat library
eugr Jun 7, 2026
55e60eb
Merge branch 'main' into develop
eugr Jun 8, 2026
349ada7
Merge branch 'main' into develop
eugr Jun 10, 2026
7aa310b
Merge branch 'main' into develop
eugr Jun 10, 2026
68ad707
Fixed memory mod
eugr Jun 10, 2026
0cf1a7b
Merge branch 'main' into develop
eugr Jun 11, 2026
f685340
CUDA graphs fix for DiffusionGemma on V1 model runner
eugr Jun 11, 2026
13bcd72
V2 model runner support under WSL
eugr Jun 11, 2026
484d429
Merge branch 'main' into develop
eugr Jun 12, 2026
029c107
Merge branch 'main' into develop
eugr Jun 14, 2026
da91353
Updated memory mod
eugr Jun 14, 2026
e4035ec
Merge branch 'main' into develop
eugr Jun 16, 2026
e6fd0a7
Merge branch 'main' into develop
eugr Jun 16, 2026
e8b4365
Merge branch 'main' into develop
eugr Jun 17, 2026
00175fe
Merge branch 'main' into develop
eugr Jun 18, 2026
61b22d8
Merge branch 'main' into develop
eugr Jun 19, 2026
74b0b61
Sync for uma-fix mod
eugr Jun 19, 2026
0425607
Merge branch 'main' into develop
eugr Jun 23, 2026
eea65b2
Merge branch 'main' into develop
eugr Jun 25, 2026
bbdb939
Merge branch 'main' into develop
eugr Jun 25, 2026
3266a77
Sync for uma-fix
eugr Jun 25, 2026
7c0a6cb
Merge branch 'main' into develop
eugr Jul 1, 2026
ce4a76c
Merge branch 'main' into develop
eugr Jul 2, 2026
07f3787
Merge branch 'main' into develop
eugr Jul 2, 2026
9557699
Merge branch 'main' into develop
eugr Jul 3, 2026
2e27f6f
Merge branch 'main' into develop
eugr Jul 4, 2026
3d9e4e1
uma-fix sync
eugr Jul 4, 2026
48df784
Merge branch 'main' into develop
eugr Jul 6, 2026
c91ba3f
Merge branch 'main' into develop
eugr Jul 12, 2026
db74d50
Merge branch 'main' into develop
eugr Jul 13, 2026
26990b5
Merge branch 'main' into develop
eugr Jul 16, 2026
2bace5e
Merge branch 'b12x' into develop
eugr Jul 22, 2026
32fcbee
Experimental mod for DGX Station to speed up trtllm with UVA offloade…
eugr Jul 22, 2026
2846a48
Merge branch 'b12x' into develop
eugr Jul 23, 2026
5572342
Merge branch 'b12x' into develop
eugr Jul 24, 2026
93ef0c4
Merge branch 'b12x' into develop
eugr Jul 24, 2026
83fdc74
Merge branch 'b12x' into develop
eugr Jul 31, 2026
9b3fb4c
Merge branch 'b12x' into develop
eugr Aug 4, 2026
4e39090
Merge branch 'main' into develop
eugr Aug 17, 2026
a264cc6
uma-fix changes
eugr Aug 17, 2026
c6a323a
Merge branch 'main' into develop
eugr Aug 17, 2026
6f97b3b
Merge branch 'main' into develop
eugr Aug 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test-recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'run-recipe.py'
- 'run-recipe.sh'
- 'launch-cluster.sh'
- 'mods/uma-fix/**'
- 'recipes/**'
- 'tests/**'
- '.github/workflows/test-recipes.yml'
Expand All @@ -15,6 +16,7 @@ on:
- 'run-recipe.py'
- 'run-recipe.sh'
- 'launch-cluster.sh'
- 'mods/uma-fix/**'
- 'recipes/**'
- 'tests/**'
- '.github/workflows/test-recipes.yml'
Expand Down Expand Up @@ -52,6 +54,9 @@ jobs:
./tests/test_recipes.sh -v
./tests/test_launch_cluster_image_sync.sh
./tests/test_launch_cluster_vllm_pr.sh

- name: Run uma-fix compatibility test
run: python tests/test_uma_fix_mod.py -v

- name: Verify all recipes with dry-run
run: |
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ RUN apt update && \
python3-dev python3-pip git wget \
libibverbs1 libibverbs-dev rdma-core \
ccache devscripts debhelper fakeroot \
cuda-compat-13-3 \
&& rm -rf /var/lib/apt/lists/* \
&& pip install uv

Expand Down Expand Up @@ -90,6 +91,8 @@ ENV CCACHE_COMPRESS=1
# Tell CMake to use ccache for compilation
ENV CMAKE_CXX_COMPILER_LAUNCHER=ccache
ENV CMAKE_CUDA_COMPILER_LAUNCHER=ccache
# Use CUDA 13.3 user-mode driver/JIT libraries on older host drivers.
ENV LD_LIBRARY_PATH=/usr/local/cuda-13.3/compat:${LD_LIBRARY_PATH}

# 2. Set Environment Variables
ARG TORCH_CUDA_ARCH_LIST="12.1a"
Expand Down Expand Up @@ -718,6 +721,7 @@ ENV TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}
ARG FLASHINFER_CUDA_ARCH_LIST="12.1a"
ENV FLASHINFER_CUDA_ARCH_LIST=${FLASHINFER_CUDA_ARCH_LIST}
ENV TRITON_PTXAS_PATH=/usr/local/cuda/bin/ptxas
ENV LD_LIBRARY_PATH=/usr/local/cuda-13.3/compat:${LD_LIBRARY_PATH}
ENV TIKTOKEN_ENCODINGS_BASE=$VLLM_BASE_DIR/tiktoken_encodings
ENV PATH=$VLLM_BASE_DIR:$PATH

Expand Down
13 changes: 13 additions & 0 deletions mods/diffusiongemma/diffusiongemma-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,19 @@ index cf0c1d417..6a48b6282 100644

# Dict to store valid cudagraph dispatching keys.
self.cudagraph_keys: dict[CUDAGraphMode, set[BatchDescriptor]] = {
@@ -215,7 +211,11 @@ class CudagraphDispatcher:
cudagraph_capture_sizes_for_decode = [
x
for x in self.compilation_config.cudagraph_capture_sizes
- if x <= max_num_tokens and x >= uniform_decode_query_len
+ if (
+ x <= max_num_tokens
+ and x >= uniform_decode_query_len
+ and x % uniform_decode_query_len == 0
+ )
]
for bs, num_active_loras in product(
cudagraph_capture_sizes_for_decode, lora_cases
diff --git a/vllm/v1/engine/core.py b/vllm/v1/engine/core.py
index 08c814ab3..6258c8199 100644
--- a/vllm/v1/engine/core.py
Expand Down
44 changes: 44 additions & 0 deletions mods/exp-gb300-trtllm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Experimental GB300 TRTLLM startup mod

This runtime mod accelerates the post-load TensorRT-LLM NVFP4 MoE weight-layout
conversion when selected expert weights have been offloaded with vLLM's UVA
backend on a Grace-Blackwell system.

vLLM normally sees a UVA mapping as a CUDA tensor and therefore performs the
TRTLLM expert permutation directly against host LPDDR. This mod detects the
`FLASHINFER_TRTLLM` NVFP4 MoE backend and uses vLLM's internal
`_vllm_is_uva_offloaded` parameter marker to clone every parameter that was
actually UVA-offloaded for the current MoE layer into HBM. It runs the existing
conversion unchanged, then lets vLLM copy the converted tensors back to pinned
LPDDR before proceeding to the next layer.

The internal marker is the source of truth after vLLM applies both
`--cpu-offload-params` and `--cpu-offload-gb`. Consequently, the mod does not
assume names such as `w13_weight` or `w2_weight`; it also handles broader
selectors such as `experts`, future parameter names, and a final layer that is
only partially offloaded because the byte budget was reached.

The staging is bounded to one MoE layer at a time. It does not change runtime
weight placement, KV-cache placement, model output, or the selected inference
kernel. It does temporarily increase load-time HBM usage by the staged layer
plus TRTLLM conversion intermediates.

Apply it like the other spark-vllm mods:

```bash
./launch-cluster.sh --solo \
--apply-mod mods/exp-gb300-trtllm \
exec vllm serve nvidia/GLM-5.2-NVFP4 ...
```

The patch targets the source layout used by vLLM 0.25.1 and fails closed if its
expected anchors are not found. It is idempotent. During model loading, each
staged layer emits a line similar to:

```text
Staged 2 UVA-offloaded TRTLLM NVFP4 MoE parameters (4.50 GiB) in HBM for post-load layout conversion.
```

If loading runs out of HBM before KV-cache allocation, remove this mod; do not
raise `--cpu-offload-gb` merely to compensate, because that does not increase
the temporary HBM headroom available during conversion.
159 changes: 159 additions & 0 deletions mods/exp-gb300-trtllm/patch_vllm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#!/usr/bin/env python3
"""Patch vLLM to stage marked UVA-offloaded TRTLLM MoE weights in HBM."""

from __future__ import annotations

import sys
from pathlib import Path
from typing import NoReturn


PREFIX = "[exp-gb300-trtllm]"
MARKER = "exp-gb300-trtllm: stage marked TRTLLM MoE UVA weights in HBM"
TARGET_RELATIVE_PATH = Path("vllm/model_executor/model_loader/utils.py")


def fail(message: str) -> NoReturn:
raise SystemExit(f"{PREFIX} {message}")


def replace_once(text: str, old: str, new: str, description: str) -> str:
count = text.count(old)
if count != 1:
fail(
f"expected exactly one source anchor for {description}, found {count}; "
"refusing to patch an unknown vLLM source layout"
)
return text.replace(old, new, 1)


def main() -> None:
if len(sys.argv) != 2:
fail("usage: patch_vllm.py SITE_PACKAGES")

site_packages = Path(sys.argv[1]).resolve()
target = site_packages / TARGET_RELATIVE_PATH
if not target.is_file():
fail(f"vLLM source file not found: {target}")

original = target.read_text()
if MARKER in original:
print(f"{PREFIX} Patch is already applied; skipping.")
return

text = original

text = replace_once(
text,
""" with device_loading_context(module, target_device):
quant_method.process_weights_after_loading(module)
""",
f""" # {MARKER}
# A CUDA UVA view reports itself as a CUDA tensor, so the generic
# loading context otherwise leaves these large, randomly indexed
# tensors in host LPDDR during TRTLLM layout conversion.
nvfp4_backend = getattr(quant_method, "nvfp4_backend", None)
stage_trtllm_moe_uva = (
getattr(nvfp4_backend, "name", None) == "FLASHINFER_TRTLLM"
)
with device_loading_context(
module,
target_device,
stage_trtllm_moe_uva=stage_trtllm_moe_uva,
):
quant_method.process_weights_after_loading(module)
""",
"quantized post-load device context",
)

text = replace_once(
text,
"""@contextmanager
def device_loading_context(module: torch.nn.Module, target_device: torch.device):
""",
"""@contextmanager
def device_loading_context(
module: torch.nn.Module,
target_device: torch.device,
*,
stage_trtllm_moe_uva: bool = False,
):
""",
"device_loading_context signature",
)

text = replace_once(
text,
""" original_device_states: dict[str, torch.device] = {}
uva_offloaded_parameters: list[str] = []

# Store original device states and move parameters to GPU if they're on CPU
""",
""" original_device_states: dict[str, torch.device] = {}
uva_offloaded_parameters: list[str] = []
staged_uva_backings: list[torch.Tensor] = []
staged_uva_bytes = 0
staged_uva_count = 0

# Keep the original UVA views alive until the converted HBM tensors have
# been copied back to new pinned CPU storage in the finally block.
# Store original device states and move parameters to GPU if they're on CPU.
""",
"UVA staging state",
)

text = replace_once(
text,
""" if getattr(p, "_vllm_is_uva_offloaded", False):
uva_offloaded_parameters.append(name)
# Parameters already on target device are not touched

try:
""",
""" if getattr(p, "_vllm_is_uva_offloaded", False):
uva_offloaded_parameters.append(name)
if stage_trtllm_moe_uva:
# A same-device .to() is a no-op for a UVA CUDA view. clone()
# allocates fresh CUDA storage, which is HBM on GB300, and copies
# exactly the parameters vLLM actually offloaded, including a
# partially offloaded final module, through the C2C link once.
staged_uva_backings.append(p.data)
p.data = p.data.clone(memory_format=torch.preserve_format)
delattr(p, "_vllm_is_uva_offloaded")
staged_uva_bytes += p.numel() * p.element_size()
staged_uva_count += 1
# Parameters already on target device are not touched.

if staged_uva_bytes:
logger.info(
"Staged %d UVA-offloaded TRTLLM NVFP4 MoE parameters (%.2f GiB) "
"in HBM for post-load layout conversion.",
staged_uva_count,
staged_uva_bytes / (1024**3),
)

try:
""",
"marker-driven UVA-to-HBM staging loop",
)

# The existing finally block re-offloads a parameter whenever its original
# name was UVA-backed and the current Parameter no longer carries the UVA
# marker. Staging deliberately removes that marker, so both in-place and
# replacement-style quantization paths are restored without another change.

try:
compile(text, str(target), "exec")
except SyntaxError as exc:
fail(f"patched source failed Python syntax validation: {exc}")

target.write_text(text)

print(
f"{PREFIX} Applied marker-driven HBM staging for UVA-offloaded "
"TRTLLM NVFP4 MoE post-load conversion."
)


if __name__ == "__main__":
main()
25 changes: 25 additions & 0 deletions mods/exp-gb300-trtllm/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail

PYTHON_ROOT="${PYTHON_ROOT:-${VLLM_SITE_PACKAGES:-/usr/local/lib/python3.12/dist-packages}}"
MOD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PREFIX="[exp-gb300-trtllm]"

if ! command -v python3 >/dev/null 2>&1; then
echo "$PREFIX python3 is required to apply this mod." >&2
exit 1
fi

if [ ! -d "$PYTHON_ROOT/vllm" ]; then
echo "$PREFIX vLLM package not found at $PYTHON_ROOT/vllm" >&2
exit 1
fi

python3 "$MOD_DIR/patch_vllm.py" "$PYTHON_ROOT"

# Do not leave bytecode compiled from the pre-patch source around. The patcher
# syntax-checks the result, so clearing the generated cache is safe.
find "$PYTHON_ROOT/vllm/model_executor/model_loader" \
-name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true

echo "$PREFIX Enabled GB300 HBM staging for TRTLLM NVFP4 MoE conversion."
Loading