Skip to content

triton: Add version 3.9.0 - #4895

Open
luhenry wants to merge 7 commits into
mainfrom
triton
Open

luhenry wants to merge 7 commits into
mainfrom
triton

Conversation

@luhenry

@luhenry luhenry commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Builds Triton's Python-AST-to-TTIR frontend against a CPU/riscv64 codegen backend (triton-shared's TTIR->Linalg lowering, then Buddy Compiler's Linalg->LLVM-MLIR lowering, then LLVM llc), replacing upstream's NVIDIA/AMD-only codegen. Upstream triton-lang/triton has no riscv64 target at all (gotcha 41).

Reuses triton-riscv's own scripts/release.sh directly instead of reimplementing its build.

Differs from upstream

  • Builds the triton-riscv fork, not triton-lang/triton directly - upstream has no riscv64 codegen to build.
  • LLVM and Buddy Compiler come from buddy-mlir's prebuilt riscv64 release tarballs, not a from-source LLVM build.

Matrix: single cp312-abi3 manylinux build; the stable-ABI build covers 3.12+, and buddy-mlir publishes no riscv64-musl toolchain release to build musllinux from.

Testing

  • Installs this registry's own riscv64 torch wheel and runs a vector-add kernel, checked against torch's own CPU result.

License: MIT (triton, triton-shared). The wheel also bundles Apache-2.0-WITH-LLVM-exception LLVM tools and Apache-2.0 buddy-mlir tools (opt, llc, buddy-*), stripped binaries from triton-riscv's own prebuilt release.

Upstream triton-lang/triton is GPU-only with no riscv64 target (gotcha
41, not-feasible). This builds the RuyiAI-Stack/triton-riscv fork
instead, which replaces the NVIDIA/AMD codegen with a CPU/riscv64
backend (triton-shared -> Buddy Compiler -> LLVM llc) against prebuilt
riscv64 LLVM/buddy-mlir toolchains, and reuses that fork's own
scripts/release.sh directly rather than reimplementing its build.
luhenry added a commit that referenced this pull request Nov 16, 2026
uv pip install only honors UV_* env vars, never PIP_* - PIP_EXTRA_INDEX_URL
silently no-ops, so uv only ever saw public PyPI (no riscv64 torch there)
and never consulted this registry at all (gotcha 244). Confirmed from this
PR's own CI run 43873735422/job 133321388047: the wheel build itself
succeeded, only the torch install in the test step failed, with uv's error
citing only PyPI's own non-riscv64 torch releases.

Rename to UV_EXTRA_INDEX_URL and add UV_INDEX_STRATEGY: unsafe-best-match
so uv actually queries this registry and picks its riscv64 wheel over
PyPI's incompatible ones, matching the pattern used by ~90 other
build-*.yml workflows in this repo.
Real riscv64 CI: the first successful build of this PR (run 43873735422)
took the whole wheel-build step close to 7h end to end. A rerun of the
exact same commit (run 43947463976) hit the previous 360-minute
(6h) cap, cancelled mid-build - pip's own 'Building editable for triton:
still running...' heartbeat printed continuously right up to the timeout,
so the build was never hung, just genuinely this slow (and apparently
somewhat variable) on this hardware. The original 360 was a guess from
upstream's x86_64 CI timing, not this fleet's own riscv64 numbers.

600 gives real headroom above the observed ~7h without masking an actual
hang, which would still show up as a timeout well past that.
Real riscv64 CI (run 44039510021, job 133890584028): the actual build
succeeded and torch+triton installed fine, but the smoke test crashed
with ValueError: '@jit functions should be defined in a Python file'.
triton.jit's JITFunction.__init__ calls inspect.getsourcelines(fn) to
grab the decorated function's source, which raises OSError('could not
get source code') for anything defined via python3 -c - there is no
real file on disk for inspect to read lines from. This has nothing to
do with riscv64; the same script would fail identically on any
platform, it just never ran far enough to hit this until the earlier
UV_EXTRA_INDEX_URL and 600-minute-timeout fixes landed.

Write the kernel to test_triton_kernel.py via a heredoc and run that
file directly instead.
…r-translate

Real riscv64 CI (run 44093346560, job 134074094167): the kernel test now
actually compiles (the earlier real-file fix held) and fails further in,
inside triton_shared's own backend:

    RuntimeError: Unable to locate LLVM tool 'mlir-translate' via
    LLVM_BINARY_DIR, the bundled package bin/, or PATH.

Confirmed against the real triton-riscv source (backend/paths.py's
_get_llvm_bin_path, backend/compiler.py's two mlir-translate call sites,
and scripts/release.sh's own packaging loop): release.sh copies opt,
buddy-llc, llvm-objdump, llvm-readobj, buddy-opt and buddy-translate into
the wheel's backend/bin/, but never mlir-translate, so neither the
bundled-copy nor the PATH fallback in paths.py ever finds it.

scripts/setup.sh's download_release() unpacks the real LLVM release
tarball (which does ship mlir-translate) under triton-riscv/.cache/llvm,
and release.sh's own docker invocation bind-mounts the checkout into the
container rather than copying it in, so that directory is still present
on the runner's filesystem here, in the step right after the build
step's container has already exited. Point LLVM_BINARY_DIR (paths.py's
first-checked resolution path) at it directly, rather than patching
upstream's packaging list.
Real riscv64 CI (run 44157994959, job 134304033843): the 'Building
editable for triton' step ran for ~1h40m then died with exit code 137
(SIGKILL) and no other error text - gotcha 421's signature on this
fleet's low-RAM, no-swap riscv64 runners, exactly as this step's own
prior comment anticipated.

release.sh's own docker-run wrap forwards no MAX_JOBS/
CMAKE_BUILD_PARALLEL_LEVEL into the container, so there is no env var
on the host side that reaches the actual ninja/make invocation deep
inside triton's own build. release.sh already supports being invoked
with IN_DOCKER pre-set (it then skips its own docker-run wrapping
entirely), so this reproduces its exact documented riscv64 container
invocation itself, adding only --cpuset-cpus to halve the visible core
count - nproc and hardware_concurrency() respect cpuset affinity but
not a cgroup CPU quota, so --cpus alone would not actually have
reduced the inferred build parallelism.

This branch has not been deployed

No deployments
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