Skip to content

refactor(linked): migrate gptq_marlin_repack provider - #857

Merged
voltjia merged 4 commits into
refactor/linked-flash-attn-with-kvcachefrom
refactor/source-gptq-marlin-repack
Aug 7, 2026
Merged

refactor(linked): migrate gptq_marlin_repack provider#857
voltjia merged 4 commits into
refactor/linked-flash-attn-with-kvcachefrom
refactor/source-gptq-marlin-repack

Conversation

@voltjia

@voltjia voltjia commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a second src/linked contract for operators exposed through the PyTorch Dispatcher while retaining the existing direct-symbol contract.
  • Replace the checked-in NVIDIA gptq_marlin_repack CUDA kernel with a thin linked adapter to the installed vLLM _C binary.
  • Preserve the existing InfiniOps operator name, parameter order, trailing out, tests, and implementation slot.

Motivation

The previous NVIDIA implementation adapted vLLM's GPTQ Marlin repack kernel into InfiniOps. Repeating that pattern transfers source ownership, license review, regeneration, and upstream maintenance into this repository.

vLLM already exposes this operator through a typed PyTorch Dispatcher schema. This PR uses that stable host-side boundary instead of copying kernel source or binding an implementation-specific mangled symbol. It is the second representative src/linked operator and exercises a different binary contract from the direct-symbol flash_attn_with_kvcache provider in the preceding stacked PR.

Upstream implementation: vLLM gptq_marlin_repack.cu at bc150f50.

N/A - no linked issue.

Linked Contracts

Each linked binding declares exactly one of these contracts:

Contract Configure-time validation Runtime call
Direct symbol (required_symbols) Exact exported C++ symbol set Provider-specific C++ adapter
PyTorch operator (operator_schema + dispatch_key) Exact registered operator schema plus required dispatch key Boxed Dispatcher stack

All selected Dispatcher libraries are loaded together in one isolated configure-time process before their schemas and dispatch keys are checked. This matches the final runtime load set and catches duplicate or conflicting static registrations before compilation.

For this operator:

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 CUDA kernel registered for the exact schema
Output mapping Copy the returned Tensor into InfiniOps' trailing out Tensor
Discovery Installed Python distribution package vllm, exact library glob vllm/_C.*.so
Packaging Link the installed DSO in place; do not copy it into the InfiniOps wheel

The adapter installs the caller's stream before ATen tensor construction, Dispatcher execution, and the output copy. The vLLM binary must be ABI-compatible with the active PyTorch and CUDA installation.

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

The focused linked build uses WITH_TORCH=OFF: this provider depends on PyTorch's C++ ABI and Dispatcher, but it is not a generated src/torch backend.

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.

cmake -S . -B build-linked-gptq-smoke -G Ninja \
  -DWITH_CPU=ON -DWITH_NVIDIA=ON -DWITH_TORCH=ON -DWITH_LINKED=ON \
  -DAUTO_DETECT_DEVICES=OFF -DAUTO_DETECT_BACKENDS=OFF \
  -DGENERATE_PYTHON_BINDINGS=ON -DINFINI_OPS_SMOKE_BUILD=ON
cmake --build build-linked-gptq-smoke --target ops -j16
python3 -m pytest tests -m smoke --devices nvidia -q

78 passed, 20 skipped, 7559 deselected in 19.20s

The existing smoke operator list was not expanded. The smoke configuration resolved 0 linked operators, so the new Dispatcher contract does not make an unrelated pruned build depend on vLLM.

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Focused Result / Notes
NVIDIA Yes Operator-pruned build and existing smoke passed tests/test_gptq_marlin_repack.py --devices nvidia -q: 13 passed
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
# Resolver contract tests
python3 -m pytest tests/test_resolve_linked_ops.py -q
21 passed

# Exact installed provider gate
torch=2.11.0+cu130
vllm=0.20.2
provider=/usr/local/lib/python3.12/dist-packages/vllm/_C.abi3.so
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
CUDA dispatch kernel: present

# 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

git diff --check 0e634d51..9bed36a5
exit 0

The manual remote build used the current InfiniRT integration prefix. Two pre-existing stacked-base metadata compatibility patches were applied only to the remote validation copy; neither touches this PR's diff. GitHub CI validates the unmodified branch. No full test suite was run, following the agreed pruned-build, focused-test, and smoke-test scope.

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

  • Commit f375d69d adds the generic Dispatcher contract; commit c53489f1 migrates only gptq_marlin_repack; commit 60b72868 applies CI's Ruff formatting; commit 9bed36a5 renames the public binding field to operator_schema.
  • Review the aggregate isolated DSO validation and the local --push-state,--no-as-needed linker scope.
  • Review the boxed stack types, especially c10::SymInt, and the trailing-output copy.
  • No vLLM source, generated kernel, or provider binary is vendored or redistributed.
  • The public InfiniOps API and the existing operator test matrix 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
@voltjia voltjia changed the title refactor(nvidia): use vLLM binary for gptq marlin repack refactor(nvidia): use vLLM binary for gptq_marlin_repack Aug 2, 2026
@voltjia
voltjia force-pushed the refactor/source-gptq-marlin-repack branch from 2f5391b to c53489f Compare August 7, 2026 02:18
@voltjia voltjia changed the title refactor(nvidia): use vLLM binary for gptq_marlin_repack refactor(linked): migrate gptq_marlin_repack provider Aug 7, 2026
@voltjia
voltjia changed the base branch from master to refactor/linked-flash-attn-with-kvcache August 7, 2026 02:19
@voltjia
voltjia marked this pull request as ready for review August 7, 2026 03:36
@voltjia
voltjia requested a review from Ziminli August 7, 2026 03:36
@voltjia voltjia changed the title refactor(linked): migrate gptq_marlin_repack provider refactor(linked): migrate gptq_marlin_repack provider Aug 7, 2026
@voltjia
voltjia merged commit b6e489c into master Aug 7, 2026
6 checks passed
@voltjia
voltjia deleted the refactor/source-gptq-marlin-repack branch August 7, 2026 11:01
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.

3 participants