Development¶
The repository holds two packages. cyxla/ is the runtime, and cyxla-pjrt-cpu/ packs
the CPU plugin. The documentation sits next to the runtime in cyxla/docs.
Setup and tests¶
uv sync builds the extension module in editable mode and installs the plugin package
from ../cyxla-pjrt-cpu. Set CYXLA_PJRT_CPU_LIBRARY to a plugin library first when no
release of that package exists yet. The tests need 100% coverage, including the Cython
module, whose lines the development build traces. They also run the code blocks of the
README and of these pages, which carry a <!-- name: test_... --> comment.
Layout¶
src/cyxla/_runtime.pyis the Cython module in pure Python mode._runtime.pxddeclares what extension modules cimport, and_runtime.pyitypes the Python-visible part._pjrt.pxddeclares the part of the PJRT C API that the runtime uses._platform.hholds every operating system call: loading libraries, aligned memory and the clock. The runtime stays portable to Linux, macOS and Windows through it._plugins.pyfinds and loads plugins,_lowering.pylowers functions,_cache.pyholds the disk cache and_ffi.pyregisters custom call handlers.tests/downstreamis a small package that builds against an installed cyxla, andtests/ffi_libraryis a C++ handler for the custom call tests.notebooks/colab_gpu_tests.ipynbruns the checks on a CUDA GPU, which CI does not have.
Conventions¶
- Bump
ABI_VERSIONin_runtime.pxdwhenever a declared struct, enum or function signature changes. - Code is formatted and linted with Ruff and type-checked with
ty. Avoid inheritance, prefer protocols and plain functions, and usematchstatements where they replace chains of conditions. - The Cython code uses the pure Python syntax, and the functions that Python sees have type stubs.
Continuous integration¶
The cyxla workflow tests on Linux, macOS and Windows with Python 3.11 and 3.13, checks
combined coverage and lint, and builds wheels and the sdist with cibuildwheel. The tests
take the plugin library from the latest run of the cyxla-pjrt-cpu workflow that built
one for their platform.
The cyxla-pjrt-cpu workflow builds the plugin on four platforms, packs the wheels,
installs each wheel and runs a program on it. A tag cyxla-v<version> publishes cyxla
to PyPI, and cyxla-pjrt-cpu-v<version> does the same for the plugin package with
trusted publishing. Running either workflow by hand with release set does the same
from main, and it creates the tag itself, for a session that cannot push tags.
Documentation¶
The site uses Zensical. A build from cyxla/ looks like this:
The workflow docs.yml publishes it to GitHub Pages on every push to main.
mkdocstrings generates the API reference from the docstrings, so each docstring is
also documentation.