Skip to content

test(bnb): opt into the Triton policy at module construction (#4764) - #5179

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
Qubitium:test/bnb-triton-policy-snapshot-4764
Nov 18, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
Qubitium:test/bnb-triton-policy-snapshot-4764

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

tests/kernels/test_bitsandbytes_rocm_triton.py::test_selected_gpu_module_matches_oracle_without_expanded_storage
enabled the bitsandbytes Triton path with a process-wide configure_kernel(...)
after the module was constructed. Since #4585 the module snapshots the
policy in __init__ (WeightOnlyQuantLinear.__init__ ->
self.kernel = snapshot_kernel_config(kernel)), so the late change was
correctly ignored and the four Triton cases asserted against a module that
never took the Triton path:

E   assert 0 == 2
FAILED ...::test_selected_gpu_module_matches_oracle_without_expanded_storage[nf4-triton-dtype0]
FAILED ...::test_selected_gpu_module_matches_oracle_without_expanded_storage[nf4-triton-dtype1]
FAILED ...::test_selected_gpu_module_matches_oracle_without_expanded_storage[fp4-triton-dtype0]
FAILED ...::test_selected_gpu_module_matches_oracle_without_expanded_storage[fp4-triton-dtype1]

This is entry 4 of #4764 (stale test, not a library bug).

Fixes #4764

What Changed

Tests

Red on base (origin/main @ fba0d0ec), green with the fix, same command:

# Emulate a tuned Triton family on this GB10 host (sm_121) so the Triton cases
# execute instead of skipping. Local harness only, not repo code:
#   /tmp/patch_bnb_tile.py: pytest_configure -> bt._BNB_GEMM_LAUNCH.setdefault("blackwell", bt._DEFAULT_GEMM)
PYTHONPATH=/tmp /root/venv/bin/python -m pytest -q -p no:cacheprovider -p patch_bnb_tile \
  "tests/kernels/test_bitsandbytes_rocm_triton.py::test_selected_gpu_module_matches_oracle_without_expanded_storage"

# base:  4 failed, 9 passed, 2 skipped   (all four Triton cases: assert 0 == 2)
# fixed: 13 passed, 2 skipped

The emulation only adds the blackwell family key so available_for() stops
rejecting this device; the executed code path is the real Triton
matmul_4bit with the default tile, not a mock.

Full file on this host, unemulated (Triton cases skip, no tuned tile for
sm_121):

/root/venv/bin/python -m pytest -q -p no:cacheprovider tests/kernels/test_bitsandbytes_rocm_triton.py
# 36 passed, 8 skipped

Related contract suites:

/root/venv/bin/python -m pytest -q -p no:cacheprovider \
  tests/kernels/test_bitsandbytes_rocm_triton.py \
  tests/module_tree/test_fusion_kernel_backends.py \
  tests/test_rocm_kernel_contracts.py
# 580 passed, 116 skipped
bash format/check.sh
# All checks passed!

Unverified here: the real Ada (sm_89) / RDNA4 (gfx1201) run, because this host
is a single NVIDIA GB10 (sm_121) with no tuned bitsandbytes tile. The Triton
cases skip without the emulation, and the skip is not counted as native
evidence.

Model Support / Module Plan

Not applicable: test-only change, no model/definition/fusion changes.

Logic Flow Documentation

Not applicable: no control flow or selection-order change.

Kernel Accuracy Requirements

Not applicable to the change itself. The four Triton cases keep comparing
against the independent FP64 decode oracle; the fix only makes them actually
execute the path they assert.

Notes

Also verified on fba0d0ec while triaging #4764: entries 1, 3, 5, 6, 7 and 8
now pass (tests/kernels/test_fp8_kernel.py, tests/test_fp8_bias_range.py,
tests/test_tenstorrent_support.py, the two GGUF C++ files,
tests/test_auto_module_decoder.py, tests/kernels/test_gptq.py). Entry 2 is
fixed (scripts/marlin_scratch_fixture.py now passes layer._kernel_bias(a)),
but executing it needs a Marlin JIT build and this host has no CUDA toolkit.
Entry 9 is fixed by gating the test on requires_nvidia_cuda(); it cannot run
on this host either. So all nine entries are addressed; only entry 4 needed a
change in this PR.

@Qubitium
Qubitium marked this pull request as ready for review November 18, 2026 08:27
@Qubitium
Qubitium merged commit 0a181af into ModelCloud:main Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant