Skip to content

refactor(nvidia): use vLLM binary for gptq marlin repack - #857

Draft
voltjia wants to merge 1 commit into
masterfrom
refactor/source-gptq-marlin-repack
Draft

refactor(nvidia): use vLLM binary for gptq marlin repack#857
voltjia wants to merge 1 commit into
masterfrom
refactor/source-gptq-marlin-repack

Conversation

@voltjia

@voltjia voltjia commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the checked-in gptq_marlin_repack CUDA implementation with an adapter to an installed vLLM _C binary.
  • Resolve the operator through the PyTorch Dispatcher, validate its exact schema and CUDA dispatch key at CMake configure time, and preserve the existing InfiniOps API.
  • Link the installed vLLM binary in place with the required build/install RPATH; discovery and validation stay in the existing src/CMakeLists.txt, with no new provider layer.

Motivation

The previous implementation copied upstream kernel code and generated CUDA sources into InfiniOps. That approach increases source ownership, license-review, regeneration, and update costs for every third-party internal operator.

This PR is a deliberately narrow external-binary pilot for one representative operator. vLLM already registers gptq_marlin_repack with the PyTorch Dispatcher, which gives InfiniOps a typed, discoverable boundary above device binaries. The adapter therefore uses the registered schema instead of binding an unstable implementation symbol. For a future library that has no Dispatcher or equivalent registry, a stable exported host C/C++ entry point discovered with tools such as nm -D -C is the next acceptable boundary; no generic provider framework is introduced before a second concrete case exists.

Upstream implementation: vLLM gptq_marlin_repack.cu at bc150f50.

N/A - no linked issue.

External Binary Contract

Boundary Contract
InfiniOps API gptq_marlin_repack(b_q_weight, perm, size_k, size_n, num_bits, is_a_8bit, out)
Required vLLM schema _C::gptq_marlin_repack(Tensor b_q_weight, Tensor perm, SymInt size_k, SymInt size_n, int num_bits, bool is_a_8bit) -> Tensor
Dispatch A CUDA kernel must be registered for the exact schema
Output mapping The adapter copies vLLM's returned Tensor into InfiniOps' trailing out Tensor
Discovery Auto-detect the single installed vllm/_C.*.so, or use INFINI_OPS_VLLM_LIBRARY
Packaging Link the installed binary in place; do not copy it into the InfiniOps wheel

The vLLM binary must be compatible with the active PyTorch, CUDA, and C++ ABI. CMake fails during configuration when the library is missing, the schema differs, or no CUDA implementation is registered.

Type of Change

  • feat - new feature / new operator / new platform
  • fix - bug fix
  • perf - performance improvement (no behavioral change)
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

Remote environment: ssh nvidia, docker.1ms.run/verlai/verl:vllm020.dev2, NVIDIA A100, PyTorch 2.11.0+cu130, vLLM 0.20.2, CUDA 13.0.

python -m pytest tests -m smoke -q
70 passed, 19 skipped, 7518 deselected in 5.76s

The existing smoke operator list was not expanded for this integration. The focused operator build used INFINI_OPS_OPS=gptq_marlin_repack and a minimal generated-Torch allowlist. The smoke build did not select gptq_marlin_repack, and configured successfully without probing vLLM.

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA Yes Focused pruned build and existing smoke passed tests/test_gptq_marlin_repack.py --devices nvidia -q: 13 passed in 1.99s
Iluvatar No N/A - not affected N/A
MetaX No N/A - not affected N/A
Cambricon No N/A - not affected N/A
Moore No N/A - not affected N/A
Ascend No N/A - not affected N/A
Additional validation output
# Exact vLLM binary gate
_C::gptq_marlin_repack(Tensor b_q_weight, Tensor perm, SymInt size_k,
                       SymInt size_n, int num_bits, bool is_a_8bit) -> Tensor
CUDA dispatch kernel: present

# An explicit gptq_marlin_repack selection without Torch fails at configuration time
INFINI_OPS_OPS=gptq_marlin_repack, WITH_TORCH=OFF
NEGATIVE_CONFIG_GATE=PASS

# Native installation preserves vLLM lookup
cmake_install.cmake INSTALL_RPATH includes:
/usr/local/lib/python3.12/dist-packages/vllm
NATIVE_INSTALL_RPATH=PASS

# Installed libinfiniops.so
NEEDED: [_C.abi3.so]
RUNPATH: $ORIGIN:/usr/local/lib/python3.12/dist-packages/torch/lib:
         /usr/local/lib/python3.12/dist-packages/vllm:$ORIGIN/../vllm

# Static checks
git diff --check origin/master...HEAD: passed

No full test suite was run. Per the agreed validation scope, this PR uses the pruned operator build, the focused operator test, and the existing smoke suite.

Benchmark / Performance Impact

N/A - this PR changes kernel source ownership and linkage, not the public operator contract, and makes no performance claim. The adapter performs one device-to-device copy from the vLLM-returned Tensor into the existing trailing out Tensor.

Notes for Reviewers

  • Review the operator-gated external-binary block in src/CMakeLists.txt: exact schema validation, CUDA kernel validation, no-AS-NEEDED linkage, and runtime lookup paths.
  • Review the boxed Dispatcher call in src/torch/ops/gptq_marlin_repack/gptq_marlin_repack.cc, especially SymInt and output-copy handling.
  • No vLLM source, generated kernel, or binary is vendored or redistributed by this PR.
  • No providers directory or generic binary-provider layer is introduced. Shared CMake machinery remains deferred until another concrete integration demonstrates reusable requirements.
  • The public InfiniOps API and existing operator tests are unchanged.

@voltjia
voltjia force-pushed the refactor/source-gptq-marlin-repack branch from 6ea84ce to c753381 Compare July 29, 2026 10:46
@voltjia voltjia changed the title refactor(nvidia): source gptq marlin repack from vLLM refactor(nvidia): use vLLM binary for gptq marlin repack Jul 29, 2026
@voltjia
voltjia force-pushed the refactor/source-gptq-marlin-repack branch from c753381 to 2f5391b Compare July 31, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant