Anchor the bnb bind assertion on the symbol, not the module alias (#7590)

#7578 and #7580 landed within a minute of each other and compose correctly in
kernels/utils.py, but the source-text assertion #7578 added does not: it looked for
the literal "bnb.functional.lib" under the guard, and #7580 renamed that binding to
"bnb_functional.lib" to survive a half-imported bitsandbytes. Git merged both cleanly
because they touch different lines, so the break only shows at test time.

Match "lib.cdequantize_blockwise_fp32" instead. That still pins the binds to the guard,
which is what the test is for, and no longer breaks when the module alias changes.

Co-authored-by: unslothai <unslothai@gmail.com>
This commit is contained in:
Daniel Han 2026-07-28 21:35:04 -07:00 committed by GitHub
commit f4f36a0d2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,7 +155,10 @@ def test_the_ctypes_binds_are_gated_on_the_same_verdict():
"if bnb is None or not native_kernels_ready(bnb, DEVICE_TYPE):" in source
), "the ctypes bind block must take the _bnb_required branch on a dead library too"
guarded = source.split("if bnb is None or not native_kernels_ready(bnb, DEVICE_TYPE):")[1]
assert "bnb.functional.lib" in guarded, "the binds must sit under that guard"
# Anchor on the symbol, not the module alias: #7580 renamed the binding from
# `bnb.functional.lib` to `bnb_functional.lib`, which is exactly the kind of rename
# this assertion should survive.
assert "lib.cdequantize_blockwise_fp32" in guarded, "the binds must sit under that guard"
def test_the_kernel_check_reads_the_submodule_not_the_parent_attribute():