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
2 changes: 1 addition & 1 deletion .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
env:
CMAKE_BUILD_PARALLEL_LEVEL: "2"
CMAKE_GENERATOR: Ninja
NATIVE_SHA: 34aedfbe8ed9779697905541a62e2160ccfd9c05
NATIVE_SHA: 7020de93652ca920424a10ac5255b34810dd2f24

jobs:
msrv:
Expand Down
24 changes: 20 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ link-modes:
vllm_chat_stream
vllm_complete
vllm_complete_stream
vllm_complete_tokens
vllm_completion_free
vllm_embed
vllm_embedding_result_free
vllm_engine_free
vllm_engine_load
vllm_last_error
Expand All @@ -176,8 +179,21 @@ link-modes:
vllm_request_submit
vllm_request_wait
vllm_sampling_params_default
vllm_server_main
vllm_string_free
vllm_transcribe
vllm_transcription_free
vllm_transcription_params_default
vllm_version
vllm_video_engine_free
vllm_video_engine_load
vllm_video_generate
vllm_video_model_params_default
vllm_video_mux_argv
vllm_video_mux_argv_free
vllm_video_mux_params_default
vllm_video_params_default
vllm_video_result_free
EOF
diff -u "$expected" "$actual"
}
Expand Down Expand Up @@ -701,8 +717,8 @@ package-test:
use vllm_cpp_sys as ffi;

fn main() {
assert_eq!(ffi::VLLM_ABI_VERSION, 10);
assert_eq!(unsafe { ffi::vllm_abi_version() }, 10);
assert_eq!(ffi::VLLM_ABI_VERSION, 17);
assert_eq!(unsafe { ffi::vllm_abi_version() }, 17);
let version = unsafe { CStr::from_ptr(ffi::vllm_version()) };
assert!(!version.to_bytes().is_empty());

Expand Down Expand Up @@ -772,8 +788,8 @@ package-test:
};

fn main() {
assert_eq!(expected_abi_version(), 10);
assert_eq!(abi_version(), 10);
assert_eq!(expected_abi_version(), 17);
assert_eq!(abi_version(), 17);
assert!(!version().expect("native version").is_empty());
let _params = SamplingParams::greedy()
.max_tokens(1)
Expand Down
8 changes: 4 additions & 4 deletions vllm-cpp-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Raw Rust bindings and native linking for the stable C API of [vllm.cpp](https://github.com/mudler/vllm.cpp).

This crate exposes checked-in generated unsafe declarations for the 19 exported C symbols in ABI version 10. 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.
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.

Expand All @@ -14,7 +14,7 @@ The package contains Rust declarations and conformance tests, native build/link

`bundled` and `system` are mutually exclusive. CPU runtime support is limited to native Linux x86_64; Linux aarch64 and Apple ARM64 have model-free build/test surfaces. Accelerator features below are experimental build configuration.

System mode requires `VLLM_CPP_ROOT`, whose prefix must contain `include/vllm.h` plus a `lib` or `lib64` directory. `VLLM_CPP_LIB_DIR` can override the vllm library directory. Consumer builds validate that the selected system header exists but do not compare its layout. The maintainer integration test compiles its C probe at test runtime against that header, compares its C layouts with the generated Rust declarations, and the runtime test requires ABI version 10.
System mode requires `VLLM_CPP_ROOT`, whose prefix must contain `include/vllm.h` plus a `lib` or `lib64` directory. `VLLM_CPP_LIB_DIR` can override the vllm library directory. Consumer builds validate that the selected system header exists but do not compare its layout. The maintainer integration test compiles its C probe at test runtime against that header, compares its C layouts with the generated Rust declarations, and the runtime test requires ABI version 17.

Upstream's normal CMake install provides `libvllm` and `vllm.h` but does not install the private `libblake3_vendored.a` target. A stock install therefore works directly with `system,dynamic-link`. System static mode requires callers to provision the matching `libblake3_vendored.a` separately and set `VLLM_CPP_BLAKE3_LIB_DIR`; when the variable is unset, the build script checks the selected vllm library directory for backward compatibility. It does not search arbitrary build trees.

Expand All @@ -41,15 +41,15 @@ These features do not claim runtime support. Known native blockers remain: a CUD

## Generated Bindings

The bundled source is pinned to commit `34aedfbe8ed9779697905541a62e2160ccfd9c05` and exposes C ABI version 10. Bindings are generated with bindgen 0.72.1 from `wrapper.h`, which includes `vllm.cpp/include/vllm.h`, and committed to `src/bindings.rs`. The exported stable C boundary is narrower than the broader native C++ implementation; these declarations do not promise access to undocumented internals. Maintainers use Just 1.40 or newer from the repository root:
The bundled source is pinned to vllm.cpp `v0.0.2` at commit `7020de93652ca920424a10ac5255b34810dd2f24` and exposes C ABI version 17. Bindings are generated with bindgen 0.72.1 from `wrapper.h`, which includes `vllm.cpp/include/vllm.h`, and committed to `src/bindings.rs`. The exported stable C boundary is narrower than the broader native C++ implementation; these declarations do not promise access to undocumented internals. Maintainers use Just 1.40 or newer from the repository root:

```console
just bindings
just sys
just link-modes
```

The conformance gate verifies the generated output, C and C++ header compatibility, C/Rust layout, the exact 19-symbol export set, pure backend plans/cache parsing, Apple/MLX validation and link ordering, pinned CUDA architecture mappings, Triton AOT drift, and compile-time/runtime ABI 10. CI separately runs bundled static/dynamic and fixture-backed system static/dynamic CPU tests; dynamic tests set the required loader path. `build.rs` only performs consumer native build/link integration and does not compile or execute the layout probe. `tests/layout.rs` compiles and executes `tests/layout.c` with the bundled header or `VLLM_CPP_ROOT/include/vllm.h` at test runtime using the Rust standard library. Native Linux CPU is the supported runtime target; cross-compiling that integration test is unsupported.
The conformance gate verifies the generated output, C and C++ header compatibility, C/Rust layout, the exact 35-symbol export set, pure backend plans/cache parsing, Apple/MLX validation and link ordering, pinned CUDA architecture mappings, Triton AOT drift, and compile-time/runtime ABI 17. CI separately runs bundled static/dynamic and fixture-backed system static/dynamic CPU tests; dynamic tests set the required loader path. `build.rs` only performs consumer native build/link integration and does not compile or execute the layout probe. `tests/layout.rs` compiles and executes `tests/layout.c` with the bundled header or `VLLM_CPP_ROOT/include/vllm.h` at test runtime using the Rust standard library. Native Linux CPU is the supported runtime target; cross-compiling that integration test is unsupported.

The Rust crate is dual-licensed under MIT or Apache-2.0. The bundled vllm.cpp source retains its upstream Apache-2.0 license and notices.

Expand Down
2 changes: 1 addition & 1 deletion vllm-cpp-sys/THIRD_PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Component | Packaged source | Provenance | License text |
|---|---|---|---|
| vllm.cpp | `vllm.cpp/**` | vllm.cpp commit `34aedfbe8ed9779697905541a62e2160ccfd9c05` | `vllm.cpp/LICENSE`, `vllm.cpp/NOTICE` |
| vllm.cpp | `vllm.cpp/**` | vllm.cpp `v0.0.2`, commit `7020de93652ca920424a10ac5255b34810dd2f24` | `vllm.cpp/LICENSE`, `vllm.cpp/NOTICE` |
| BLAKE3 C reference | `vllm.cpp/third_party/blake3/**` | BLAKE3 1.5.5, commit `81f772a` | `vllm.cpp/third_party/blake3/LICENSE_A2`, `vllm.cpp/third_party/blake3/LICENSE_CC0` |
| google/minja | `vllm.cpp/third_party/minja/**` | minja commit `021c229` | `vllm.cpp/third_party/minja/LICENSE` |
| Vulkan-Headers | `vllm.cpp/third_party/vulkan/**` | Vulkan SDK 1.4.328.1, generated Khronos headers | Apache-2.0 in each generated header and `vllm.cpp/LICENSE` |
Expand Down
167 changes: 166 additions & 1 deletion vllm-cpp-sys/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* automatically generated by rust-bindgen 0.72.1 */

pub const VLLM_ABI_VERSION: u32 = 10;
pub const VLLM_ABI_VERSION: u32 = 17;
pub const vllm_status_VLLM_OK: vllm_status = 0;
pub const vllm_status_VLLM_ERR_INVALID_ARGUMENT: vllm_status = 1;
pub const vllm_status_VLLM_ERR_MODEL_LOAD: vllm_status = 2;
Expand Down Expand Up @@ -34,6 +34,9 @@ pub struct vllm_model_params {
pub scheduling_policy: *const ::std::os::raw::c_char,
pub kv_transfer_config: *const ::std::os::raw::c_char,
pub enable_jump_forward: i32,
pub device: i32,
pub gpu_memory_utilization: f64,
pub kv_cache_memory_bytes: i64,
}
pub type vllm_logits_processor = ::std::option::Option<
unsafe extern "C" fn(
Expand Down Expand Up @@ -101,6 +104,18 @@ unsafe extern "C" {
out: *mut vllm_completion,
) -> vllm_status;
}
unsafe extern "C" {
pub fn vllm_complete_tokens(
engine: *mut vllm_engine,
prompt_tokens: *const i32,
n_prompt_tokens: i32,
params: *const vllm_sampling_params,
out_tokens: *mut i32,
max_out_tokens: i32,
n_out_tokens: *mut i32,
out: *mut vllm_completion,
) -> vllm_status;
}
pub type vllm_token_callback = ::std::option::Option<
unsafe extern "C" fn(
delta_text: *const ::std::os::raw::c_char,
Expand Down Expand Up @@ -157,6 +172,153 @@ unsafe extern "C" {
user_data: *mut ::std::os::raw::c_void,
) -> vllm_status;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_transcription_params {
pub audio_path: *const ::std::os::raw::c_char,
pub pcm: *const f32,
pub n_samples: i64,
pub sample_rate: i32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_transcription {
pub text: *mut ::std::os::raw::c_char,
pub token_ids: *mut i32,
pub n_token_ids: i32,
pub has_text: i32,
}
unsafe extern "C" {
pub fn vllm_transcription_params_default() -> vllm_transcription_params;
}
unsafe extern "C" {
pub fn vllm_transcribe(
engine: *mut vllm_engine,
params: *const vllm_transcription_params,
out: *mut vllm_transcription,
) -> vllm_status;
}
unsafe extern "C" {
pub fn vllm_transcription_free(out: *mut vllm_transcription);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_embedding_result {
pub values: *mut f32,
pub n_embeddings: i32,
pub dim: i32,
pub prompt_tokens: i32,
}
unsafe extern "C" {
pub fn vllm_embed(
engine: *mut vllm_engine,
texts: *const *const ::std::os::raw::c_char,
n_texts: i32,
out: *mut vllm_embedding_result,
) -> vllm_status;
}
unsafe extern "C" {
pub fn vllm_embedding_result_free(out: *mut vllm_embedding_result);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_video_engine {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_video_model_params {
pub dit_path: *const ::std::os::raw::c_char,
pub encoder_path: *const ::std::os::raw::c_char,
pub tokenizer_path: *const ::std::os::raw::c_char,
pub video_vae_path: *const ::std::os::raw::c_char,
pub video_vae_config_path: *const ::std::os::raw::c_char,
pub audio_vae_path: *const ::std::os::raw::c_char,
pub audio_vae_config_path: *const ::std::os::raw::c_char,
pub prompt_embeds_path: *const ::std::os::raw::c_char,
pub partition: *const ::std::os::raw::c_char,
pub device: i32,
pub dequant_bf16: i32,
pub fp4_resident: i32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_video_params {
pub prompt: *const ::std::os::raw::c_char,
pub width: i32,
pub height: i32,
pub num_frames: i32,
pub steps: i32,
pub seed: u64,
pub has_seed: i32,
pub first_frame: *const ::std::os::raw::c_char,
pub last_frame: *const ::std::os::raw::c_char,
pub ref_image: *const ::std::os::raw::c_char,
pub ref_video: *const ::std::os::raw::c_char,
pub ref_audio: *const ::std::os::raw::c_char,
pub noise_aug: f32,
pub output_dir: *const ::std::os::raw::c_char,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_video_result {
pub frame_dir: *mut ::std::os::raw::c_char,
pub audio_path: *mut ::std::os::raw::c_char,
pub frame_count: i32,
pub width: i32,
pub height: i32,
pub fps: i32,
pub sample_rate: i32,
pub mux_argv: *mut *mut ::std::os::raw::c_char,
pub mux_argc: i32,
}
unsafe extern "C" {
pub fn vllm_video_model_params_default() -> vllm_video_model_params;
}
unsafe extern "C" {
pub fn vllm_video_params_default() -> vllm_video_params;
}
unsafe extern "C" {
pub fn vllm_video_engine_load(
params: *const vllm_video_model_params,
out: *mut *mut vllm_video_engine,
) -> vllm_status;
}
unsafe extern "C" {
pub fn vllm_video_engine_free(engine: *mut vllm_video_engine);
}
unsafe extern "C" {
pub fn vllm_video_generate(
engine: *mut vllm_video_engine,
params: *const vllm_video_params,
out: *mut vllm_video_result,
) -> vllm_status;
}
unsafe extern "C" {
pub fn vllm_video_result_free(out: *mut vllm_video_result);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct vllm_video_mux_params {
pub frames: *const ::std::os::raw::c_char,
pub audio_path: *const ::std::os::raw::c_char,
pub output_path: *const ::std::os::raw::c_char,
pub fps: i32,
pub crf: i32,
}
unsafe extern "C" {
pub fn vllm_video_mux_params_default() -> vllm_video_mux_params;
}
unsafe extern "C" {
pub fn vllm_video_mux_argv(
params: *const vllm_video_mux_params,
out_argv: *mut *mut *mut ::std::os::raw::c_char,
out_argc: *mut i32,
) -> vllm_status;
}
unsafe extern "C" {
pub fn vllm_video_mux_argv_free(argv: *mut *mut ::std::os::raw::c_char, argc: i32);
}
unsafe extern "C" {
pub fn vllm_string_free(s: *mut ::std::os::raw::c_char);
}
Expand All @@ -169,6 +331,9 @@ unsafe extern "C" {
unsafe extern "C" {
pub fn vllm_version() -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
pub fn vllm_server_main(argc: i32, argv: *mut *mut ::std::os::raw::c_char) -> i32;
}
unsafe extern "C" {
pub fn vllm_abi_version() -> i32;
}
8 changes: 4 additions & 4 deletions vllm-cpp-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Raw FFI declarations for the stable vllm.cpp C API.
//!
//! The checked-in bindings are generated from `vllm.cpp/include/vllm.h` and
//! expose that header's 19-symbol C boundary, versioned structs, constants, and
//! callback signatures. They target ABI version 10 from pinned vllm.cpp commit
//! `34aedfbe8ed9779697905541a62e2160ccfd9c05`. This exported ABI is narrower than
//! expose that header's 35-symbol C boundary, versioned structs, constants, and
//! callback signatures. They target ABI version 17 from pinned vllm.cpp commit
//! `7020de93652ca920424a10ac5255b34810dd2f24` (`v0.0.2`). This exported ABI is narrower than
//! the broader native C++ implementation and does not expose undocumented
//! vllm.cpp internals.
//!
Expand All @@ -14,7 +14,7 @@
//! header. They must check returned status values, copy thread-local error text
//! before another API call on that thread, and release engines, requests,
//! completions, and allocated strings with their matching `vllm_*_free`
//! functions. In particular, ABI version 10 prohibits waiting for or freeing a
//! functions. In particular, ABI version 17 prohibits waiting for or freeing a
//! request from that request's callback thread. Prefer the safe `vllm-cpp` crate
//! unless direct ABI access is required.
//!
Expand Down
Loading
Loading