[Lang] Make qd.static not bypass the pure-kernel purity check#733
Draft
hughperkins wants to merge 5 commits into
Draft
[Lang] Make qd.static not bypass the pure-kernel purity check#733hughperkins wants to merge 5 commits into
hughperkins wants to merge 5 commits into
Conversation
A captured module global wrapped in qd.static(...) previously skipped the [PURE.VIOLATION] check because both purity gates were guarded by `not is_in_static_scope`. That is unsound for fastcache: qd.static only controls compile-time evaluation and never puts the value into the cache key, so a static-wrapped global is still a purity violation (stale-cache hazard). Remove the static-scope exemption from both gates (build_Name and build_Attribute). Legitimate static metaprogramming over parameters/locals is unaffected, since those never set violates_pure. Document in fastcache.md that qd.static is not a purity escape hatch.
A captured string only affects a fastcache kernel through compile-time qd.static branches, but its value never enters the cache key, so it is cache-unsafe in the same way as a captured int/float. Add str to the flagged types in build_Name and build_Attribute, and document it in fastcache.md. Update the tile and src_ll_cache tests that captured globals (bools, strings) inside qd.static in pure kernels to pass those values as template parameters so the values enter the cache key.
…ion) During a transition period, a captured global accessed inside a qd.static scope of a pure kernel now emits a warning rather than raising a QuadrantsCompilationError, giving downstream code time to migrate such constants to kernel parameters. Direct captured-global access (not wrapped in qd.static) still raises. Adds a test covering both the captured-name and captured-attribute paths, and updates the fastcache user guide.
…erage, comment width - test_pure_validation_static_scope_warns: restrict to a single (CPU) arch. The purity check is an arch-independent AST analysis; running it across multiple archs in one xdist worker let a fastcache hit from one arch suppress the warning on the next, making pytest.warns flaky on Mac (arm64 after vulkan). - Add test_pure_validation_str covering the captured-str purity violation (str branch was previously untested). - Wrap two transition-period comments to <=120 chars (drop the em-dash).
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.
A captured module global wrapped in qd.static(...) previously skipped the
[PURE.VIOLATION] check because both purity gates were guarded by
not is_in_static_scope. That is unsound for fastcache: qd.static onlycontrols compile-time evaluation and never puts the value into the cache key,
so a static-wrapped global is still a purity violation (stale-cache hazard).
Remove the static-scope exemption from both gates (build_Name and
build_Attribute). Legitimate static metaprogramming over parameters/locals is
unaffected, since those never set violates_pure. Document in fastcache.md that
qd.static is not a purity escape hatch.Issue: #
Brief Summary
copilot:summary
Walkthrough
copilot:walkthrough