Conversation
The compiled sanitizer's evaluator becomes tilelens.ir.lowering, the one reading of the TTIR reader's term algebra as Z3 terms, so the compiled race detector can sit on the same semantics instead of a second copy. - lowering.py is mechanism only: operator semantics (truncating division, unsigned ops and predicates as their signed twins under the width obligations, IntCast as its operand, i1 coercion, loop terms) live there; every leaf (scalar arguments, pids, grid, lanes, the loop iteration, observations, unmodeled values) comes from the client's TermLeaves, which also raises the client's own refusals. - It never creates a Z3 context: constants use the leaves' context and every other term its operands', so a client keeps all of its terms in one context (per check for the sanitizer). - The walk is iterative and memoized by term identity, so terms deeper than the recursion limit lower. - The sanitizer keeps its policy (obligation findings, refusals, solving, timeouts). Its leaves reach the lowering through a weak proxy and a refused loop keeps a never-raised copy of its refusal, so a check's Z3 context is freed when the check returns instead of by the cyclic GC on another thread (concurrent checks could hang or crash). - Its walks stop at the induction variable, as before, so a loop bound read only through a Select arm keeps that arm's guard. No verdict, finding or witness changes: the sanitizer's results match the previous evaluator on the golden texts and the differential corpus on Triton 3.6 and 3.8. Hand-built graphs outside the reader's invariants (e.g. an iter arg naming another loop) now raise instead of being misread.
This branch has not been deployed
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
Moves the compiled sanitizer's Term → Z3 evaluator into a shared module,
tilelens/ir/lowering.py: the one reading of the TTIR reader's term algebra as Z3 terms. The compiled race detector, which is being ported next, will build on the same semantics instead of a second copy. No user-visible change.Stacked on #480 (base branch
ir-mode), which is stacked on #479; review and merge those first.What changes
tilelens/ir/lowering.py(new) is mechanism only:///%, unsigned ops and predicates read as their signed twins andIntCastas its operand (exact under the reader's width obligations, which the client discharges), i1 coercion, andLoopVar/IterArgOffsetthrough the client's loop iteration;TermLeaves, which also raises the client's own refusals;oob.py) runs on it. Its policy (overflow and division-by-zero findings, refusals, solving, timeouts) is unchanged. Two points worth a look:weakref.proxy, and a refused loop keeps a never-raised copy of its refusal, so each check's Z3 context is freed when the check returns. A reference cycle would leave it to the cyclic GC on an arbitrary thread; concurrent checks hung or crashed that way in testing;tl.wherearm keeps that arm's guard.Evaluation
Parity with the previous evaluator, every field compared (status, findings with their witnesses, refusals, abstentions):
A single-operator mutant of the lowering changes 47 of the 556 rows, so the comparison is sensitive.
Differential corpus (223 kernels against Triton's interpreter): 0 false proofs and 0 false out-of-bounds findings on Triton 3.6 and 3.8. The results are byte-identical to [FEAT] Add a compiled mode to the sanitizer #480's, and so is every solver query's SMT-LIB text.
Testing
tests/unit/ir/test_lowering.py(52 tests): context ownership (no context created; main vs. given context), depth-5000 chains, operator semantics, and out-of-algebra terms.tl.wherearm (2 cases), and no Z3 object left to the cyclic GC (a check with a finding, and a check whose loop is refused).