Skip to main content

triton-blackhole

Open In Colab PyPI License: MIT

torch.allclose failed. Now what?

triton-blackhole is a deterministic numerical debugger for Triton kernels. It finds where your output diverges from a PyTorch reference — and whether it's benign fp16/bf16 drift or a real bug — without tl.device_print floods or TRITON_INTERPRET.

from triton_blackhole import verify_drift

@verify_drift(torch_ref, block_sizes=(BLOCK_M, BLOCK_N))
def run(a, b):
    return launch_triton(a, b)

run(a, b)  # silent if OK; AssertionError + drift artifact if not

▶ Open the 2‑minute Colab demo (Runtime → GPU)


The pain

You try… What happens
torch.allclose(...) False. No index. No cause.
tl.device_print Thousands of unsynced lines. No tensor context.
TRITON_INTERPRET=1 Breaks on bf16 / tl.load(tl.load(...)). Not your real kernel.

The fix (TritonDrift loop)

Feature What you get
@verify_drift Drop-in decorator: capture inputs, compare, emit artifact
Output → program_id Map hotspot [i,j] → tile / program_id via BLOCK_*
AST probe injection Rewrite kernel AST; dump intermediates only on the failing pid
Precision-aware diff bf16/fp16 tolerances + classify_drift
Terminal artifact Failing block, expected vs actual, probe stats
from triton_blackhole import verify_drift, run_drift_verify, index_to_program_id

# Decorator (pytest-friendly)
@verify_drift(torch_ref, block_sizes=(32, 32), raise_on_fail=True)
def run(a, b):
    return triton_launch(a, b)

# Or functional
art = run_drift_verify(tri_out, ref_out, block_sizes=(32, 32))
print(art.report())  # compare + grid map + bisect

Optional: AST dump on the failing block

def relaunch(ikernel, failing_pid, debug_buf, a, b):
    out = torch.empty_like(...)
    ikernel[(grid,)](
        a, b, out, ...,
        _bh_dbg_ptr=debug_buf,
        _BH_FAILING_PID=failing_pid,
    )
    return out

@verify_drift(
    torch_ref,
    block_sizes=(BLOCK_M, BLOCK_N),
    kernel=my_kernel,          # original @triton.jit fn
    probes=["acc"],            # local names assigned in the kernel
    relaunch=relaunch,
)
def run(a, b):
    return launch(a, b)

Install

pip install triton-blackhole

Optional (Linux / WSL2 / Colab with NVIDIA):

pip install triton-blackhole[triton]
# On Colab, pin Triton to whatever torch wants, e.g.:
# pip install "triton==3.6.0"

From source:

pip install -e ".[dev]"

Platforms

Piece Native Windows WSL2 + NVIDIA Linux + NVIDIA Colab GPU
Debugger (compare / bisect / classify) ✅ ✅ ✅ ✅
Live Triton kernels ❌ ✅ ✅ ✅

No NVIDIA laptop? Use the Colab badge above.


Tile bisection (real kernels)

from triton_blackhole import bisect_tiles

def launch(pid_lo, pid_hi):
    return run_triton_kernel(..., pid_lo=pid_lo, pid_hi=pid_hi)

print(bisect_tiles(launch, torch_ref, num_programs=grid).report())

Stage probes (not device_print)

from triton_blackhole.probe import ProbeBank

bank = ProbeBank()
bank.capture("pre_softmax", scores_ref, side="ref")
bank.capture("pre_softmax", scores_tri, side="tri")
print(bank.report())  # first diverging stage

CLI

triton-blackhole compare triton_out.pt torch_ref.pt --bisect --suggest

Why not TRITON_INTERPRET?

We never interpret the kernel. We bisect:

  1. Output space (tensor axes)
  2. Grid space (program_id)
  3. Stage space (named intermediates)

Same binary as production — bf16, tensor cores, indirect loads included.


Examples

python examples/demo_verify_drift.py
python examples/demo_verify_ast_triton.py  # needs CUDA + triton
python examples/demo_softmax_drift.py
python examples/demo_tile_bisect.py
python examples/demo_triton_add.py

License

MIT · brian-mwirigi/triton-blackhole

Metadata

Release files for triton-blackhole 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for triton-blackhole 0.2.0
File Size Uploaded Provenance Actions
triton_blackhole-0.2.0.tar.gz 28.4 kB With provenance Details for triton_blackhole-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for triton-blackhole 0.2.0
File Interpreter ABI Platform Actions
triton_blackhole-0.2.0-py3-none-any.whl Python 3 none any Details for triton_blackhole-0.2.0-py3-none-any.whl

Total release size: 58.1 kB

Release files / triton_blackhole-0.2.0.tar.gz

Download URL triton_blackhole-0.2.0.tar.gz
Size 28.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a40b7ed0e3c4007a55539c85aa9bc209d9087aedc7f370d335b4d0b3095ead85
BLAKE2b-256 checksum
How to use checksums
c972e077939ccd0b1c0f4262161ae2e07a55e2e8d21934c17a90121b39266a6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release files / triton_blackhole-0.2.0-py3-none-any.whl

Download URL triton_blackhole-0.2.0-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
763f0cfe0beb08d55f5ecb56e3efa54057eaf687535c4961438710ae1ad7ce92
BLAKE2b-256 checksum
How to use checksums
5f9862f2dc2036ab8902fe09dd8ca50cdf43cb773b970b3f2ce7cca2700fad57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Security for triton-blackhole 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for triton_blackhole-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page