Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d09caac
[FEAT] Add tvm-ffi-orcjit addon with ORC JIT support
cyx-6 Mar 23, 2026
3d802f2
Merge commit 'd153a2c9407ee04ec3dc1ccbdf6a0664854337b7' into orcjit
cyx-6 Mar 23, 2026
ba5c121
add a primer document for the reader to understand the techniques use…
yaoyaoding Mar 23, 2026
d9fa347
Correct an error resulting from AI hallucination
yaoyaoding Mar 23, 2026
87ce090
add more intro to Platform
yaoyaoding Mar 23, 2026
da45d5a
[FIX] Fix ref cycle in InitFiniPlugin and dangling pointer in GetFunc…
cyx-6 Mar 24, 2026
edef2a9
[EXTRA] Address review feedback: rename tools to scripts, simplify ru…
cyx-6 Mar 24, 2026
925aeec
[FIX] Update CI workflow to reference scripts/ instead of tools/
cyx-6 Mar 24, 2026
8715111
[FIX] Move LLVM environment vars from pyproject.toml to workflow YAML
cyx-6 Mar 24, 2026
ce36430
[EXTRA] Rename call_llvm to TVM_FFI_ORCJIT_LLVM_CALL macro; rename pr…
cyx-6 Mar 24, 2026
45252b9
[EXTRA] Unify tvm_ffi.cpp.build API with single sources parameter
cyx-6 Mar 24, 2026
8afa314
fix CIBW_BEFORE_TEST path: {project} is already the repo root
cyx-6 Mar 24, 2026
2637553
fix CI: install tvm-ffi from source after wheel to prevent PyPI override
cyx-6 Mar 24, 2026
06a41bf
fix CI: add ninja to test requires, drop --no-deps to get full depend…
cyx-6 Mar 24, 2026
4225c06
fix test: use pytest_configure hook to build objects before collection
cyx-6 Mar 24, 2026
2a3535a
fix: add -mno-outline-atomics on aarch64, use clang-cl on Windows
cyx-6 Mar 24, 2026
6a01796
fix: return correct intermediate object name for C files on Windows
cyx-6 Mar 24, 2026
5170092
fix cmake-format: rewrap comment line
cyx-6 Mar 24, 2026
e3475c2
address review feedback: null checks, atomic counter, docstrings, ver…
cyx-6 Mar 25, 2026
f3aa823
fix: use correct symbol name in VisitContextSymbols callback
cyx-6 Mar 25, 2026
44a6c49
doc: add three-platform init/fini strategy documentation
cyx-6 Mar 25, 2026
a2226bb
fix: use plain comments to avoid stray backtick/hash compiler errors
cyx-6 Mar 25, 2026
aec22bd
doc: clarify initialize/deinitialize refcount balance in GetSymbol
cyx-6 Mar 26, 2026
d73f00a
fix: use conda zstd-static instead of building from source
cyx-6 Mar 26, 2026
c48c353
fix: remove zstd build-from-source, hide symbols by default
cyx-6 Mar 26, 2026
7deaae9
doc: add build-from-source instructions, remove stale script references
cyx-6 Mar 26, 2026
9cd4e4b
fix: cmake-format set_target_properties
cyx-6 Mar 26, 2026
c0a896f
fix: rename tvm-ffi-orcjit folder to tvm_ffi_orcjit
cyx-6 Mar 27, 2026
b36e343
refactor: simplify orcjit test structure
cyx-6 Mar 27, 2026
929618c
fix: remove unused Path import, fix ruff import ordering
cyx-6 Mar 27, 2026
3aad6d9
fix: cuda tests
cyx-6 Mar 27, 2026
1a9f575
ci: add reusable orcjit wheel action, integrate into CI, add publish …
cyx-6 Mar 27, 2026
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
114 changes: 114 additions & 0 deletions .github/actions/build-orcjit-wheel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Build OrcJIT Wheel
description: >
Build and test OrcJIT wheels for a given OS/architecture combination.
Handles LLVM caching, conda installation, and cibuildwheel execution.

inputs:
arch:
description: "Target architecture (e.g., x86_64, aarch64, arm64, AMD64)"
required: true
build:
description: "cibuildwheel build selector (e.g., cp312-manylinux_x86_64)"
required: true
checkout_ref:
description: "Branch, tag, or SHA to check out before building"
required: true

runs:
using: "composite"
steps:
- name: Check out source
uses: actions/checkout@v5
with:
ref: ${{ inputs.checkout_ref }}
submodules: recursive

- uses: ./.github/actions/detect-env-vars
id: env_vars

# ---- Cache LLVM prefix ----
- name: Cache LLVM
uses: actions/cache@v4
id: llvm-cache
with:
path: ${{ runner.os == 'Windows' && 'C:/opt/llvm' || '/opt/llvm' }}
key: llvm-22.1.0-${{ runner.os }}-${{ inputs.arch }}-v3

# ---- Install LLVM via conda (cache miss only) ----
- name: Setup conda
if: steps.llvm-cache.outputs.cache-hit != 'true'
uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
continue-on-error: true
id: conda1
with:
miniforge-version: latest

- name: Setup conda (retry with tar.bz2)
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.conda1.outcome == 'failure'
uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
with:
miniforge-version: latest
use-only-tar-bz2: true

- name: Create /opt/llvm (macOS)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
shell: bash
run: sudo mkdir -p /opt/llvm && sudo chown -R $(whoami) /opt/llvm

- name: Install LLVM (Unix)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
shell: bash -l {0}
run: |
conda create -q -p /opt/llvm -c conda-forge \
llvmdev=22.1.0 clangdev=22.1.0 compiler-rt=22.1.0 zlib zstd-static \
-y

- name: Install LLVM (Windows)
if: steps.llvm-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
shell: cmd /C call {0}
run: |
conda create -q -p C:\opt\llvm -c conda-forge llvmdev=22.1.0 zlib zstd-static -y

# ---- Build and test wheels ----
- name: Build and test wheels
uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1
with:
package-dir: addons/tvm_ffi_orcjit
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ inputs.build }}
CIBW_ARCHS_LINUX: ${{ inputs.arch }}
CIBW_ARCHS_MACOS: ${{ inputs.arch }}
CIBW_ARCHS_WINDOWS: ${{ inputs.arch }}
CIBW_BUILD_VERBOSITY: 1
CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
CIBW_ENVIRONMENT: LLVM_PREFIX=/opt/llvm
CIBW_ENVIRONMENT_WINDOWS: LLVM_PREFIX="C:/opt/llvm"
CIBW_CONTAINER_ENGINE: "docker; create_args: --volume /opt/llvm:/opt/llvm"
CIBW_TEST_REQUIRES: pytest ninja
CIBW_TEST_COMMAND: >-
pip install --force-reinstall {project} &&
pytest {project}/addons/tvm_ffi_orcjit/tests -v &&
python {project}/addons/tvm_ffi_orcjit/examples/quick-start/run.py --lang cpp &&
python {project}/addons/tvm_ffi_orcjit/examples/quick-start/run.py --lang c
CIBW_TEST_COMMAND_WINDOWS: >-
pip install --force-reinstall {project} &&
pytest {project}/addons/tvm_ffi_orcjit/tests -v &&
python {project}/addons/tvm_ffi_orcjit/examples/quick-start/run.py --lang c
42 changes: 42 additions & 0 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
should_skip_ci_docs_only: ${{ steps.detect.outputs.should_skip_ci_docs_only }}
cpp_changed: ${{ steps.cpp_files.outputs.changed }}
cpp_files: ${{ steps.cpp_files.outputs.files }}
orcjit_changed: ${{ steps.orcjit_files.outputs.changed }}
steps:
- uses: actions/checkout@v5
with:
Expand All @@ -54,6 +55,13 @@ jobs:
src/ tests/ | grep -E '\.(c|cc|cpp|cxx)$' | tr '\n' ' ')
echo "files=$FILES" >> $GITHUB_OUTPUT
[ -n "$FILES" ] && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
- name: Get changed OrcJIT files
id: orcjit_files
run: |
FILES=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}...HEAD -- \
addons/tvm_ffi_orcjit/ .github/actions/build-orcjit-wheel/ | tr '\n' ' ')
echo "files=$FILES" >> $GITHUB_OUTPUT
[ -n "$FILES" ] && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT

lint:
needs: [prepare]
Expand Down Expand Up @@ -199,3 +207,37 @@ jobs:
working-directory: rust
run: |
cargo test

orcjit:
needs: [lint, prepare]
if: >
needs.prepare.outputs.orcjit_changed == 'true' &&
needs.prepare.outputs.should_skip_ci_commit != 'true' &&
needs.prepare.outputs.should_skip_ci_docs_only != 'true'
name: orcjit ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, arch: x86_64, build: "cp312-manylinux_x86_64"}
- {os: ubuntu-24.04-arm, arch: aarch64, build: "cp312-manylinux_aarch64"}
- {os: macos-14, arch: arm64, build: "cp312-macosx_arm64"}
- {os: windows-latest, arch: AMD64, build: "cp312-win_amd64"}

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 1

- name: Build OrcJIT wheel
uses: ./.github/actions/build-orcjit-wheel
with:
arch: ${{ matrix.arch }}
build: ${{ matrix.build }}
checkout_ref: ${{ github.sha }}

- uses: actions/upload-artifact@v4
with:
name: cibw-orcjit-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ strategy.job-index }}
path: wheelhouse/*.whl
83 changes: 83 additions & 0 deletions .github/workflows/publish_orcjit_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Publish OrcJIT wheel

on:
workflow_dispatch:
inputs:
tag:
description: "Tag to publish (manual run)"
required: true

jobs:
build_wheels:
name: ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-latest, arch: x86_64, build: "cp312-manylinux_x86_64"}
- {os: ubuntu-24.04-arm, arch: aarch64, build: "cp312-manylinux_aarch64"}
- {os: macos-14, arch: arm64, build: "cp312-macosx_arm64"}
- {os: windows-latest, arch: AMD64, build: "cp312-win_amd64"}

steps:
- name: Checkout repository (for local composite action)
uses: actions/checkout@v5
with:
fetch-depth: 1

- name: Build OrcJIT wheel
uses: ./.github/actions/build-orcjit-wheel
with:
arch: ${{ matrix.arch }}
build: ${{ matrix.build }}
checkout_ref: ${{ inputs.tag }}

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: cibw-orcjit-wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

upload_pypi:
needs: [build_wheels]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
attestations: write
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-orcjit-*
path: dist
merge-multiple: true

- name: Generate artifact attestation for wheels
uses: actions/attest-build-provenance@v1
with:
subject-path: dist/*

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
verbose: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ celerybeat-schedule
# Allow composite actions under .github/actions despite build-* ignore pattern
!.github/actions/build-wheel-for-publish/
!.github/actions/build-wheel-for-publish/action.yml
!.github/actions/build-orcjit-wheel/
!.github/actions/build-orcjit-wheel/action.yml
celerybeat.pid

# SageMath parsed files
Expand Down
Loading
Loading