Skip to content

[Build][spinloop] USE_SABI 3.11 breaks build on Python 3.10 — Py_buffer not in stable ABI until 3.11 #11

Description

@pasta-paul

Summary

The spinloop C extension declared in CMakeLists.txt uses USE_SABI 3.11, which sets Py_LIMITED_API=0x030b0000 on the C/CXX compile flags. Py_buffer and PyBuffer_Release were only promoted to the stable ABI in Python 3.11; on Python 3.10 the build fails with error: 'Py_buffer' was not declared in this scope.

Repro

Build the ds4-sm120-preview-dev branch (SHA c79225692) against Python 3.10:

cd ~/src/vllm   # cloned from jasl/vllm@ds4-sm120-preview-dev
python --version
# Python 3.10.12
TORCH_CUDA_ARCH_LIST=12.0a MAX_JOBS=32 \
    pip install --no-build-isolation -v --no-deps .

First object file to compile is csrc/spinloop.cpp, and it fails:

[1/366] Building CXX object CMakeFiles/spinloop.dir/csrc/spinloop.cpp.o
FAILED: CMakeFiles/spinloop.dir/csrc/spinloop.cpp.o
/usr/bin/c++ -DPy_LIMITED_API=0x030b0000 ...
  -isystem /usr/include/python3.10 ...
/.../csrc/spinloop.cpp:58:3: error: 'Py_buffer' was not declared in this scope; did you mean 'setbuffer'?
   58 |   Py_buffer buffer;
/.../csrc/spinloop.cpp:70:37: error: 'buffer' was not declared in this scope
/.../csrc/spinloop.cpp:76:5: error: 'PyBuffer_Release' was not declared in this scope
[...]

Why this matters

Brev g7e.24xlarge (a popular RTX PRO 6000 Blackwell SKU) ships Ubuntu 22.04 with default Python 3.10. AWS DLAMI Ubuntu 22.04 ships 3.10. Many "fresh box" environments are stuck on Py 3.10 unless the user goes out of their way to install 3.11. The current ds4-sm120-preview-dev branch can't be built on those boxes without intervention.

Workaround

sed -i '/USE_SABI 3\.11/d' ~/src/vllm/CMakeLists.txt

This builds the spinloop extension against Python 3.10's full API (no Py_LIMITED_API flag), which works. The extension still functions correctly — the stable ABI is a forward-compatibility nicety, not a correctness requirement.

We document this workaround in our RTX 6000 Pro recipe: canada-quant/dsv4-flash-w4a16-fp8-mtp/RECIPE_RTX6000PRO.md §1.

Proposed fix (one of)

Option A — drop USE_SABI 3.11 for the spinloop target if Python 3.10 is detected by CMake's Python_FOUND / Python_VERSION checks:

if(Python_VERSION VERSION_GREATER_EQUAL "3.11")
    set(_SPINLOOP_SABI USE_SABI 3.11)
else()
    set(_SPINLOOP_SABI "")
endif()
define_extension_target(
    spinloop
    DESTINATION vllm
    LANGUAGE CXX
    SOURCES ${VLLM_SPINLOOP_EXT_SRC}
    COMPILE_FLAGS ${SPINLOOP_COMPILE_FLAGS}
    ${_SPINLOOP_SABI}
    WITH_SOABI
)

Option B — document the Python 3.11+ requirement in the README's build prerequisites and have CMake error early with a clear message:

if(Python_VERSION VERSION_LESS "3.11")
    message(FATAL_ERROR
        "Building the spinloop extension with USE_SABI 3.11 requires Python ≥ 3.11. "
        "Either upgrade Python or remove the USE_SABI 3.11 directive from "
        "CMakeLists.txt around the spinloop target.")
endif()

Either is fine. Option A is more user-friendly; option B trades convenience for explicitness.

Notes

  • Likely a clean drop-in for jasl's branches that derive from this same CMake structure.
  • May or may not affect upstream vllm-project/vllm depending on whether spinloop has landed there yet; if so, same patch applies.
  • The repro is from canada-quant/dsv4-flash-w4a16-fp8-mtp building against your ds4-sm120-preview-dev branch — full recipe + bench numbers there if useful context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions