Deterministic numerical bisection debugger for Triton kernel floating-point drift
Project description
triton-blackhole
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 diagnose
print(diagnose(triton_out, torch_ref))
# → hotspot index, drift kind, minimal failing region
▶ 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
| Tool | What you get |
|---|---|
compare |
Max-error indices, hotspots, neighborhoods, bf16-aware tolerances |
bisect_axes |
Minimal failing sub-tensor |
bisect_tiles |
Failing program_id range on the compiled kernel |
classify_drift |
localized_bug vs reduction_order vs dtype_cast vs … |
ProbeBank |
Fusion-boundary stage diffs (not print spam) |
from triton_blackhole import compare, bisect_axes, classify_drift, format_report
from triton_blackhole.classify import format_classification
print(format_report(compare(triton_out, torch_ref)))
print(format_classification(classify_drift(triton_out, torch_ref)))
print(bisect_axes(triton_out, torch_ref).report())
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:
- Output space (tensor axes)
- Grid space (
program_id) - Stage space (named intermediates)
Same binary as production — bf16, tensor cores, indirect loads included.
Examples
python examples/demo_softmax_drift.py
python examples/demo_tile_bisect.py
python examples/demo_triton_add.py # needs CUDA + triton
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file triton_blackhole-0.1.0.tar.gz.
File metadata
- Download URL: triton_blackhole-0.1.0.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dc63698980d7a52bcb6d618f5ddae5df607e1908e3c8060d9611d1be47771dd
|
|
| MD5 |
62aac80a49c2f77201733ad23eb0707d
|
|
| BLAKE2b-256 |
9ed42f46df2f590993e293baacd3ea9ceab90f840005e8dc4d33fa8d4afb1e1a
|
Provenance
The following attestation bundles were made for triton_blackhole-0.1.0.tar.gz:
Publisher:
publish.yml on brian-mwirigi/triton-blackhole
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triton_blackhole-0.1.0.tar.gz -
Subject digest:
3dc63698980d7a52bcb6d618f5ddae5df607e1908e3c8060d9611d1be47771dd - Sigstore transparency entry: 2226650583
- Sigstore integration time:
-
Permalink:
brian-mwirigi/triton-blackhole@bac7871728bcee8eb271d93cb75e50974f67a4a7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/brian-mwirigi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bac7871728bcee8eb271d93cb75e50974f67a4a7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file triton_blackhole-0.1.0-py3-none-any.whl.
File metadata
- Download URL: triton_blackhole-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac2adb38ab3b42aff32b76ba7374c1d16b8e5f758f5f61deb9479452c0d08674
|
|
| MD5 |
1053112964f9c42e5c9799afa8da7b44
|
|
| BLAKE2b-256 |
9a6a94e87207acbfc0fdc1909026cee4337f9b7493acde113d29efae42167fd2
|
Provenance
The following attestation bundles were made for triton_blackhole-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on brian-mwirigi/triton-blackhole
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triton_blackhole-0.1.0-py3-none-any.whl -
Subject digest:
ac2adb38ab3b42aff32b76ba7374c1d16b8e5f758f5f61deb9479452c0d08674 - Sigstore transparency entry: 2226650966
- Sigstore integration time:
-
Permalink:
brian-mwirigi/triton-blackhole@bac7871728bcee8eb271d93cb75e50974f67a4a7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/brian-mwirigi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bac7871728bcee8eb271d93cb75e50974f67a4a7 -
Trigger Event:
workflow_dispatch
-
Statement type: