Repository navigation
[Fix][Arith] Translate boolean bitwise operations to logic in the Z3 prover - #88
Open
stealth-rklopper wants to merge 1 commit into
Open
stealth-rklopper wants to merge 1 commit into
stealth-rklopper wants to merge 1 commit into
Conversation
…prover Z3Prover translated bitwise_and, bitwise_or, bitwise_xor and bitwise_not through bit-vectors, also for boolean operands. TileLang writes a condition with `&`, such as `(bx % 10 < 2) & (tk > 0)`, as a bitwise_and of two booleans. As a constraint, its bit-vector terms used up the rlimit budget of the solver, so an easy proof under it returned unknown, and ThreadSync of TileLang aborted the compile. A bitwise operation with a scalar boolean result now becomes the logical operation of its boolean operands. Integer bitwise operations keep their bit-vector translation. test_z3_proves_under_bitwise_and_of_booleans checks a proof of ThreadSync under such a binding. It fails before this change.
stealth-rklopper
added a commit
to thesm-os/tilelang
that referenced
this pull request
Oct 26, 2026
Point 3rdparty/tvm at 815a438 of thesm-os/tvm, the fix of tile-ai/tvm#88. The Z3 prover then reads & and | of two conditions as logic, so ThreadSync proves a partial barrier under such a condition warp-uniform, as tile-ai#3653 reports.
stealth-rklopper
added a commit
to thesm-os/tilelang
that referenced
this pull request
Oct 26, 2026
Point 3rdparty/tvm at the Z3 fix of tile-ai/tvm#88 on top of 4211874e9, the commit that upstream pins. The previous base, 5959716 of tilelang_main, has the HIP device query of tile-ai/tvm#79. The HIP stub of TileLang throws in hipGetDeviceCount without libamdhip64.so, so a ROCm target fails on a machine without ROCm. tile-ai#3425 changes the stub and moves 3rdparty/tvm past tile-ai#79.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Z3Provertranslatesbitwise_and,bitwise_or,bitwise_xorandbitwise_notthrough bit-vectors, also when the operands are booleans. TileLang writes a condition with&, such as(bx % 10 < 2) & (tk > 0), as abitwise_andof two booleans. As a constraint, its bit-vector terms use up therlimitbudget of the solver, and an easy proof under it returns unknown.ThreadSyncof TileLang aborts the compile withLOG(FATAL)in two such cases:&condition ([BUG][ice-on-valid-code] ThreadSync rejects a 448-thread partial barrier as not warp-uniform under an&condition instead of emitting it tilelang#3653).inside = (slot >= 0) & (slot < pages). It then places a barrier inside the guardtx < 128, and it cannot prove that this guard is warp-uniform either.With
T.Andin place of&, the proofs hold. This PR translates a bitwise operation of booleans to its logical operation, so both forms give the same proofs.Reproduction and cause
The binding of each thread instance is the form in which
ThreadSyncpasses the constraints of a statement to the solver.VisitBitwiseOpconverts each operand withint2bvand the result withbv2int(..., true), so each boolean becomes a 1-bit vector. The claim itself has no bitwise operation, but the solver gives up on it within its budget of 10,000 steps. The prover sets that budget withSetRLimit(1e4), so a longer timeout gives the same result.Changes
VisitExpr_(const CallNode *)translatesbitwise_and,bitwise_or,bitwise_xorandbitwise_notwith a scalar boolean result to&&,||,!=and!of the boolean operands.test_z3_proves_under_bitwise_and_of_booleansintests/python/arith/test_arith_simplify.pychecks the proof above. It fails before this change and passes after it.Validation
python -m pytest tests/python/arith -qgives 1019 passed, 21 failed, 1 skipped and 8 xfailed. Without this change it gives 1018 passed and 22 failed. The 21 failures are the same on both builds: the vscale and SVE cases,test_domain_touched,test_domain_touched_vectorand one case ofTestFloormodIndex. The 22nd failure is the new test.3rdparty/tvm, TileLang lowers the reproduction of [BUG][ice-on-valid-code] ThreadSync rejects a 448-thread partial barrier as not warp-uniform under an&condition instead of emitting it tilelang#3653. Without it, the reproduction fails with the error of the issue. The 203 tests oftesting/python/transform/test_tilelang_transform_thread_sync.pyandtesting/python/arithpass with it. Both TileLang builds are 80364b3 ofmainwith [BugFix][CUDA] Pack a float32 broadcast to 8 lanes without the address of a temporary tilelang#3681, [BugFix][Transform] Fix divergent and missing barriers in thread_storage_sync tilelang#3682 and thesm-os/tilelang@fc5c79b merged. These commits change three files of TileLang and do not change3rdparty/tvm.ruff checkandruff format --checkof ruff 0.12.3 pass ontest_arith_simplify.py. clang-format 20.1.8 leaves the added lines ofz3_prover_on.ccunchanged. It also reformats many lines of the file that this PR does not touch, and the PR leaves those lines as they are.git diff --checkpasses.A TileLang PR follows with the bump of
3rdparty/tvmand regression tests for both cases ofThreadSync.