Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ jobs:
cmake -S vllm-cpp-sys/vllm.cpp -B target/vulkan-native \
-G Ninja -DCMAKE_BUILD_TYPE=Release \
-DVLLM_CPP_BUILD_TESTS=ON -DVLLM_CPP_BUILD_EXAMPLES=OFF \
-DVLLM_CPP_SERVER=OFF -DVLLM_CPP_CUDA=OFF \
-DVLLM_CPP_METAL=OFF -DVLLM_CPP_MLX=OFF \
-DVLLM_CPP_VULKAN=ON -DVLLM_CPP_TRITON=OFF
-DVLLM_CPP_SERVER=OFF -DVLLM_CPP_HIP=OFF \
-DVLLM_CPP_TENSTORRENT=OFF -DVLLM_CPP_LITERAL_STATIC=OFF \
-DVLLM_CPP_BENCH_PROFILE_CONTROL=OFF -DVLLM_CPP_NCCL=OFF \
-DVLLM_CPP_MARLIN=ON -DVLLM_CPP_FLASH_ATTN=ON \
-DVLLM_CPP_CUDA=OFF -DVLLM_CPP_METAL=OFF \
-DVLLM_CPP_MLX=OFF -DVLLM_CPP_VULKAN=ON \
-DVLLM_CPP_TRITON=OFF -DVLLM_CPP_TRITON_REGEN=OFF \
-DVLLM_CPP_TRITON_VENDORED_ARCH= \
-DVLLM_CPP_TRITON_TARGET= -DVLLM_CPP_CUTLASS_FETCH=OFF \
-DVLLM_CPP_SANITIZE=OFF
cmake --build target/vulkan-native --target test_vulkan_backend test_backend_cross_device
ctest --test-dir target/vulkan-native --output-on-failure \
--tests-regex '^(test_vulkan_backend|test_backend_cross_device)$'
85 changes: 65 additions & 20 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,17 @@ sys: bindings-check header-check build-support-test backend-config backend-integ

# Test all Linux CPU link modes and the exact shared-library exports.
link-modes:
just --justfile '{{ root }}/Justfile' _link-modes \
'{{ root }}/vllm-cpp-sys' \
"${CARGO_TARGET_DIR:-{{ root }}/target/link-modes}"

[private]
_link-modes crate_root target_base:
#!/usr/bin/env bash
set -euo pipefail
repo_root={{ quote(root) }}
target_base=${CARGO_TARGET_DIR:-"$repo_root/target/link-modes"}
crate_root={{ quote(crate_root) }}
target_base={{ quote(target_base) }}
crate_root=$(cd "$crate_root" && pwd -P)
mkdir -p "$target_base"
target_base=$(cd "$target_base" && pwd -P)
recipe_base="$target_base/vllm-cpp-sys-link-modes"
Expand All @@ -114,7 +121,7 @@ link-modes:
esac
}
trap cleanup EXIT
cd "$repo_root"
cd "$crate_root"
export CARGO_TERM_COLOR=never

find_one() {
Expand Down Expand Up @@ -218,7 +225,7 @@ link-modes:

prefix="$work/system-prefix"
mkdir -p "$prefix/include" "$prefix/lib" "$prefix/lib64" "$prefix/blake3-lib"
cp vllm-cpp-sys/vllm.cpp/include/vllm.h "$prefix/include/"
cp vllm.cpp/include/vllm.h "$prefix/include/"

bundled_static_lib=$(find_installed_library \
"$bundled_static_target/release/build" libvllm.a)
Expand Down Expand Up @@ -395,8 +402,8 @@ package-test:
echo 'could not read the native project version from vllm.cpp/CMakeLists.txt' >&2
exit 1
}
[[ $native_version == "$version" ]] || {
echo "native and crate versions differ: native=$native_version crates=$version" >&2
[[ $native_version == 0.0.2 ]] || {
echo "expected pinned native version 0.0.2, found $native_version" >&2
exit 1
}
jq -e --arg version "$version" '
Expand Down Expand Up @@ -445,13 +452,14 @@ package-test:
diff -u "$sys_list" <(archive_inventory "$sys_package" "vllm-cpp-sys-$version")
diff -u "$safe_list" <(archive_inventory "$safe_package" "vllm-cpp-$safe_version")

native_exclude_pattern='^vllm\.cpp/cmake/(CudaArchFeaturesTest|CudaSourceGencodeTest|DumpTritonAOTContract|InSourceGuardTest|TritonAOTDefaultTest|TritonAOTMultiArchTest|VerifyExports)\.cmake$|^vllm\.cpp/include/vt/rocm/(rocm_gelu_mul_sep|rocm_gemma4_expert_geglu|rocm_matmul_batch|rocm_rmsnorm_plus_add)\.h$|^vllm\.cpp/src/vllm/entrypoints/openai/(api_server|server_main)\.cpp$|^vllm\.cpp/src/vllm/platforms/tenstorrent\.cpp$|^vllm\.cpp/src/vt/cuda/marlin/.*/generate_kernels\.py$|^vllm\.cpp/src/vt/rocm/[^/]+\.hip$|^vllm\.cpp/src/vt/tenstorrent/|^vllm\.cpp/src/vt/vulkan/shaders/'
native_inventory() {
local base=$1
local member
shift
for member in "$@"; do
find "$base/$member" -type f -print
done | sed "s#^$base/##" | LC_ALL=C sort
done | sed "s#^$base/##" | grep -Ev "$native_exclude_pattern" | LC_ALL=C sort
}
native_members=(
vllm.cpp/CMakeLists.txt
Expand All @@ -461,9 +469,11 @@ package-test:
vllm.cpp/include
vllm.cpp/src
vllm.cpp/scripts/triton-aot-compile.py
vllm.cpp/tests/vt/test_rocm_backend.cpp
vllm.cpp/triton_kernels
vllm.cpp/third_party/README.md
vllm.cpp/third_party/blake3
vllm.cpp/third_party/doctest/doctest.h
vllm.cpp/third_party/minja
vllm.cpp/third_party/nlohmann
vllm.cpp/third_party/vulkan
Expand All @@ -481,6 +491,7 @@ package-test:
README.md \
THIRD_PARTY.md \
build.rs \
licenses/DOCTEST-MIT.txt \
licenses/FLASH-ATTENTION-BSD-3-CLAUSE.txt \
licenses/FLASH-LINEAR-ATTENTION-MIT.txt \
src/bindings.rs \
Expand All @@ -500,7 +511,7 @@ package-test:
<(native_inventory "$repo_root/vllm-cpp-sys" "${native_members[@]}") \
<(native_inventory "$sys_root" "${native_members[@]}")
diff -u \
<(printf '%s\n' CMakeLists.txt LICENSE NOTICE cmake include scripts src third_party triton_kernels | LC_ALL=C sort) \
<(printf '%s\n' CMakeLists.txt LICENSE NOTICE cmake include scripts src tests third_party triton_kernels | LC_ALL=C sort) \
<(find "$sys_root/vllm.cpp" -mindepth 1 -maxdepth 1 -printf '%f\n' | LC_ALL=C sort)

safe_expected="$temp/vllm-cpp.expected"
Expand Down Expand Up @@ -535,6 +546,7 @@ package-test:
required_sys_members=(
README.md
THIRD_PARTY.md
licenses/DOCTEST-MIT.txt
licenses/FLASH-ATTENTION-BSD-3-CLAUSE.txt
licenses/FLASH-LINEAR-ATTENTION-MIT.txt
vllm.cpp/include/vllm.h
Expand All @@ -546,13 +558,24 @@ package-test:
vllm.cpp/src/vt/cuda/cuda_matmul_fp8_cutlass.cu
vllm.cpp/src/vt/cuda/flash_attn/src/flash.h
vllm.cpp/src/vt/cuda/marlin/core/scalar_type.hpp
vllm.cpp/src/vt/cuda/triton_aot_vendored/sm_80/MANIFEST
vllm.cpp/src/vt/cuda/triton_aot_vendored/sm_86/MANIFEST
vllm.cpp/src/vt/cuda/triton_aot_vendored/sm_89/MANIFEST
vllm.cpp/src/vt/cuda/triton_aot_vendored/sm_90a/MANIFEST
vllm.cpp/src/vt/cuda/triton_aot_vendored/sm_100a/MANIFEST
vllm.cpp/src/vt/cuda/triton_aot_vendored/sm_121a/MANIFEST
vllm.cpp/src/vt/metal/metal_mlx_provider.mm
vllm.cpp/src/vt/vulkan/vulkan_spirv.h
vllm.cpp/src/vllm/platforms/rocm.cpp
vllm.cpp/include/vt/rocm/rocm_arch.h
vllm.cpp/include/vt/rocm/rocm_runtime.h
vllm.cpp/tests/vt/test_rocm_backend.cpp
vllm.cpp/scripts/triton-aot-compile.py
vllm.cpp/triton_kernels/chunk_delta_h.py
vllm.cpp/src/vt/vulkan/vulkan_spirv.h
vllm.cpp/third_party/README.md
vllm.cpp/third_party/blake3/LICENSE_A2
vllm.cpp/third_party/blake3/LICENSE_CC0
vllm.cpp/third_party/doctest/doctest.h
vllm.cpp/third_party/minja/LICENSE
vllm.cpp/third_party/nlohmann/json.hpp
vllm.cpp/third_party/vulkan/vulkan_core.h
Expand Down Expand Up @@ -580,17 +603,37 @@ package-test:
vllm.cpp/benchmarks
vllm.cpp/docs
vllm.cpp/examples
vllm.cpp/tests
vllm.cpp/tools
vllm.cpp/third_party/doctest
vllm.cpp/third_party/httplib
vllm.cpp/cmake/CudaArchFeaturesTest.cmake
vllm.cpp/cmake/CudaSourceGencodeTest.cmake
vllm.cpp/cmake/DumpTritonAOTContract.cmake
vllm.cpp/cmake/InSourceGuardTest.cmake
vllm.cpp/cmake/TritonAOTDefaultTest.cmake
vllm.cpp/cmake/TritonAOTMultiArchTest.cmake
vllm.cpp/cmake/VerifyExports.cmake
vllm.cpp/src/vllm/entrypoints/openai/api_server.cpp
vllm.cpp/src/vllm/entrypoints/openai/server_main.cpp
vllm.cpp/src/vllm/platforms/tenstorrent.cpp
vllm.cpp/src/vt/cuda/marlin/libtorch_stable/moe/marlin_moe_wna16/generate_kernels.py
vllm.cpp/src/vt/rocm
vllm.cpp/src/vt/tenstorrent
vllm.cpp/src/vt/vulkan/shaders
)
for member in "${denied_sys_members[@]}"; do
[[ ! -e $sys_root/$member ]] || {
echo "denied upstream tree or record leaked into sys package: $member" >&2
exit 1
}
done
diff -u \
<(printf '%s\n' vllm.cpp/tests/vt/test_rocm_backend.cpp) \
<(find "$sys_root/vllm.cpp/tests" -type f -printf '%P\n' \
| sed 's#^#vllm.cpp/tests/#' | LC_ALL=C sort)
diff -u \
<(printf '%s\n' vllm.cpp/third_party/doctest/doctest.h) \
<(find "$sys_root/vllm.cpp/third_party/doctest" -type f -printf '%P\n' \
| sed 's#^#vllm.cpp/third_party/doctest/#' | LC_ALL=C sort)

forbidden_pattern='(^|/)(target|stuff|\.git|\.github|__pycache__|\.cache|cache|fixtures?|downloads?|_deps|sdk)(/|$)|(^|/)(cutlass)(/|$)|(^|/)(model\.safetensors|tokenizer\.json|tokenizer_config\.json)$|\.(o|obj|a|so|dylib|dll|pyc|safetensors|gguf|pt|pth)$'
for listing in "$sys_list" "$safe_list"; do
Expand Down Expand Up @@ -633,6 +676,7 @@ package-test:
LICENSE-MIT \
NOTICE \
THIRD_PARTY.md \
licenses/DOCTEST-MIT.txt \
licenses/FLASH-ATTENTION-BSD-3-CLAUSE.txt \
licenses/FLASH-LINEAR-ATTENTION-MIT.txt \
vllm.cpp/LICENSE \
Expand Down Expand Up @@ -671,13 +715,16 @@ package-test:

sys_package_size=$(stat -c '%s' "$sys_package")
sys_unpacked_size=$(du -sb "$sys_root" | cut -f1)
sys_regular_file_bytes=$(find "$sys_root" -type f -printf '%s\n' \
| awk '{ total += $1 } END { print total + 0 }')
sys_package_sha256=$(sha256sum "$sys_package" | awk '{ print $1 }')
sys_entry_count=$(wc -l < "$sys_list")
safe_package_size=$(stat -c '%s' "$safe_package")
safe_unpacked_size=$(du -sb "$safe_root" | cut -f1)
safe_entry_count=$(wc -l < "$safe_list")
((sys_package_size <= 6 * 1024 * 1024))
((sys_unpacked_size <= 36 * 1024 * 1024))
((sys_entry_count <= 1300))
((sys_unpacked_size <= 40 * 1024 * 1024))
((sys_entry_count <= 1400))
((safe_package_size <= 128 * 1024))
((safe_unpacked_size <= 256 * 1024))
((safe_entry_count <= 40))
Expand All @@ -693,11 +740,8 @@ package-test:
and .[0].features.default == ["bundled"]
' <(cargo metadata --manifest-path "$sys_root/Cargo.toml" \
--locked --offline --no-deps --format-version 1) >/dev/null
(
cd "$sys_root"
CARGO_NET_OFFLINE=true CARGO_TARGET_DIR="$temp_target" \
cargo test --locked --release --tests --offline
)
just --justfile "$repo_root/Justfile" _link-modes \
"$sys_root" "$temp/extracted-link-modes"

sys_consumer="$temp/sys-consumer"
mkdir -p "$sys_consumer/src"
Expand Down Expand Up @@ -819,8 +863,9 @@ package-test:
cargo run --locked --release --offline
)

printf 'sys package: %d entries, %d bytes unpacked, %d bytes compressed\n' \
"$sys_entry_count" "$sys_unpacked_size" "$sys_package_size"
printf 'sys package: %d entries, %d regular-file bytes, %d du bytes, %d compressed bytes, sha256 %s\n' \
"$sys_entry_count" "$sys_regular_file_bytes" "$sys_unpacked_size" \
"$sys_package_size" "$sys_package_sha256"
printf 'safe package: %d entries, %d bytes unpacked, %d bytes compressed\n' \
"$safe_entry_count" "$safe_unpacked_size" "$safe_package_size"

Expand Down
20 changes: 20 additions & 0 deletions vllm-cpp-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,31 @@ include = [
"/licenses/**",
"/vllm.cpp/CMakeLists.txt",
"/vllm.cpp/cmake/**",
"!/vllm.cpp/cmake/CudaArchFeaturesTest.cmake",
"!/vllm.cpp/cmake/CudaSourceGencodeTest.cmake",
"!/vllm.cpp/cmake/DumpTritonAOTContract.cmake",
"!/vllm.cpp/cmake/InSourceGuardTest.cmake",
"!/vllm.cpp/cmake/TritonAOTDefaultTest.cmake",
"!/vllm.cpp/cmake/TritonAOTMultiArchTest.cmake",
"!/vllm.cpp/cmake/VerifyExports.cmake",
"/vllm.cpp/include/**",
"!/vllm.cpp/include/vt/rocm/rocm_gelu_mul_sep.h",
"!/vllm.cpp/include/vt/rocm/rocm_gemma4_expert_geglu.h",
"!/vllm.cpp/include/vt/rocm/rocm_matmul_batch.h",
"!/vllm.cpp/include/vt/rocm/rocm_rmsnorm_plus_add.h",
"/vllm.cpp/src/**",
"!/vllm.cpp/src/vllm/entrypoints/openai/api_server.cpp",
"!/vllm.cpp/src/vllm/entrypoints/openai/server_main.cpp",
"!/vllm.cpp/src/vllm/platforms/tenstorrent.cpp",
"!/vllm.cpp/src/vt/cuda/marlin/**/generate_kernels.py",
"!/vllm.cpp/src/vt/rocm/*.hip",
"!/vllm.cpp/src/vt/tenstorrent/**",
"!/vllm.cpp/src/vt/vulkan/shaders/**",
"/vllm.cpp/tests/vt/test_rocm_backend.cpp",
"/vllm.cpp/triton_kernels/**",
"/vllm.cpp/scripts/triton-aot-compile.py",
"/vllm.cpp/third_party/blake3/**",
"/vllm.cpp/third_party/doctest/doctest.h",
"/vllm.cpp/third_party/minja/**",
"/vllm.cpp/third_party/nlohmann/**",
"/vllm.cpp/third_party/vulkan/**",
Expand Down
8 changes: 5 additions & 3 deletions vllm-cpp-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Raw Rust bindings and native linking for the stable C API of [vllm.cpp](https://

This crate exposes checked-in generated unsafe declarations for the 35 exported C symbols in ABI version 17. Callers are responsible for pointer validity, lifetimes, callback threading, status/error handling, and matching every native allocation with its documented free function. Applications should prefer the current safe [`vllm-cpp`](https://docs.rs/vllm-cpp) crate unless they require direct ABI access. Ordinary consumers do not need Just, bindgen, or libclang.

The package contains Rust declarations and conformance tests, native build/link integration, the pinned native source inputs required by the supported feature set, and their licenses/notices. It excludes upstream tests, fixtures, models, examples, benchmarks, agent records, fetched SDKs, external CUTLASS trees, and build output. See the repository [changelog](https://github.com/querymt/vllm-cpp-rs/blob/main/CHANGELOG.md) and [release process](https://github.com/querymt/vllm-cpp-rs/blob/main/RELEASING.md) for the coordinated crate boundary.
The package contains Rust declarations and conformance tests, native build/link integration, the pinned native source inputs required by the supported feature set, and their licenses/notices. It excludes upstream test trees except for one unconditional ROCm syntax-check translation unit, plus fixtures, models, examples, benchmarks, agent records, fetched SDKs, external CUTLASS trees, and build output. See the repository [changelog](https://github.com/querymt/vllm-cpp-rs/blob/main/CHANGELOG.md) and [release process](https://github.com/querymt/vllm-cpp-rs/blob/main/RELEASING.md) for the coordinated crate boundary.

## Link Modes

Expand All @@ -28,12 +28,14 @@ Feature selection is build configuration, not runtime or hardware evidence. Acce
|---|---|---|
| `cuda` | Linux x86_64/aarch64; requires exact `VLLM_CPP_CUDA_ARCHITECTURES` | Static mode links CMake's exact `CUDA_CUDART` and `CUDA_cublasLt_LIBRARY` results; dynamic mode relies on `libvllm.so` dependencies |
| `cuda-cutlass` | Implies CUDA; requires canonical `VLLM_CPP_CUTLASS_DIR` with CUTLASS >=4.5.0; fetch is OFF; `103a`/`110` rejected | Header-only external input |
| `triton-aot` | Implies CUDA; checked-in single-architecture artifacts only; regeneration is OFF | Static mode also links CMake's exact `CUDA_cuda_driver_LIBRARY`; dynamic mode relies on `libvllm.so` |
| `triton-aot` | Implies CUDA; embeds all six checked-in AOT trees; regeneration is OFF | Static mode also links CMake's exact `CUDA_cuda_driver_LIBRARY`; dynamic mode relies on `libvllm.so` |
| `vulkan` | Linux x86_64/aarch64; packaged Khronos headers and checked-in SPIR-V | No Vulkan SDK link; runtime loader uses `dlopen` |
| `metal` | Exact `aarch64-apple-darwin`; native MSL backend | Static mode links `c++`, then `Metal` and `Foundation` frameworks |
| `mlx` | Implies Metal; requires canonical external `MLX_ROOT` with `include/mlx/array.h`, `lib/libmlx.dylib`, and `lib/mlx.metallib` | Static mode adds `$MLX_ROOT/lib` before `dylib=mlx`; no rpath or packaged MLX payload |

CUDA architectures are exactly `80`, `86`, `87`, `89`, `90a`, `100a`, `103a`, `110`, `120a`, `121a`, or `120a;121a`. Triton accepts only `80`, `86`, `89`, `90a`, `100a`, or `121a`. Plain CUDA passes a nonexistent CUTLASS root to CMake so ambient source cannot silently change the build. Use separate `CARGO_TARGET_DIR` values for each backend/link combination.
CUDA architectures are exactly `80`, `86`, `87`, `89`, `90a`, `100a`, `103a`, `110`, `120a`, `121a`, or `120a;121a`. `triton-aot` accepts every one of those values, including the fat `120a;121a` build, and embeds the complete `sm_80`, `sm_86`, `sm_89`, `sm_90a`, `sm_100a`, and `sm_121a` vendored set. Runtime dispatch selects only an exact-SM cubin; architectures without an exact tree use the portable CUDA path rather than a neighboring cubin. Plain CUDA passes a nonexistent CUTLASS root to CMake so ambient source cannot silently change the build. Use separate `CARGO_TARGET_DIR` values for each backend/link combination.

Cargo builds explicitly disable HIP/ROCm, Tenstorrent, NCCL, native tests/examples, and the HTTP server. CUTLASS fetching and Triton regeneration remain OFF, so supported bundled builds never download native inputs. Marlin and FlashAttention remain explicitly enabled when their CUDA architecture and external CUTLASS prerequisites are satisfied.

Metal and MLX remain bundled-only and do not imply `bundled`; `--no-default-features` callers must explicitly select `bundled,metal` or `bundled,mlx`. Setting `MLX_ROOT` without `mlx` is rejected. MLX is never downloaded, copied, or packaged, and applications are responsible for making `libmlx.dylib` and its metallib deployment visible at runtime.

Expand Down
3 changes: 2 additions & 1 deletion vllm-cpp-sys/THIRD_PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
| Marlin / GPTQ-Marlin slice | `vllm.cpp/src/vt/cuda/marlin/**` | vLLM commit `e24d1b24`, with retained file notices and vllm.cpp adapter changes | Apache-2.0 in `vllm.cpp/LICENSE` and retained source notices |
| Flash Linear Attention Triton kernels | `vllm.cpp/triton_kernels/**`, generated AOT files under `vllm.cpp/src/vt/cuda/triton_aot_vendored/**` | FLA source ported through vLLM 0.24.0; exact source and artifact hashes are pinned in each AOT `MANIFEST` | `licenses/FLASH-LINEAR-ATTENTION-MIT.txt` |
| nlohmann/json | `vllm.cpp/third_party/nlohmann/**` | nlohmann/json 3.12.0 | MIT notice retained in `json.hpp` |
| doctest | `vllm.cpp/third_party/doctest/doctest.h` | doctest 2.5.2, required by the packaged ROCm syntax-check source | `licenses/DOCTEST-MIT.txt` |

The package excludes upstream tests, fixtures, benchmarks, models, external SDKs, and build output. It contains only native source/build inputs and required licenses/notices.
The package excludes upstream tests, fixtures, benchmarks, models, external SDKs, and build output. It contains only native source/build inputs and required licenses/notices, including the one ROCm test translation unit compiled unconditionally as a syntax check.

vllm.cpp is an independent community project and is not affiliated with or endorsed by the vLLM project, the PyTorch Foundation, or the Linux Foundation.
2 changes: 2 additions & 0 deletions vllm-cpp-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ fn main() {
"vllm.cpp/cmake",
"vllm.cpp/include/vllm.h",
"vllm.cpp/src",
"vllm.cpp/tests/vt/test_rocm_backend.cpp",
"vllm.cpp/triton_kernels",
"vllm.cpp/scripts/triton-aot-compile.py",
"vllm.cpp/third_party/blake3",
"vllm.cpp/third_party/doctest/doctest.h",
"vllm.cpp/third_party/minja",
"vllm.cpp/third_party/nlohmann",
"vllm.cpp/third_party/vulkan",
Expand Down
Loading
Loading