Repository navigation
Fix: preserve direction and input identity in memoized evaluations - #821
Open
AHMETHAKANBEZIR1 wants to merge 2 commits into
Open
AHMETHAKANBEZIR1 wants to merge 2 commits into
AHMETHAKANBEZIR1 wants to merge 2 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
MemoizeOperatorcurrently treats a cached forward(x, Ax)pair as an adjoint result, returningxforA.H @ (A @ x). It also matches nearby input vectors withallclose, which can reuse a stale result while an iterative solver is making small updates, and can return a lower-precision cached output for an equal-valued higher-precision input.For
A = Diagonal([2., 3., 4.])andx = [1., -2., .5], the original cached adjoint returns[1., -2., .5]instead of[4., -18., 8.]. A three-iteration CGLS solve then has solution error about 187.31, whereas the underlying operator recovers the known solution to floating-point precision. After separating directions, a tighter Split Bregman/CGLS integration check exposed a remaining ~2.17e-5 discrepancy from approximate cache hits.Tag entries by direction and require identical input values and dtype for a hit. Keep the documented
(x, y)store entries and shared FIFOmax_nevalbudget. Document the matching rule and add a small executable example. Approximate equality may now result in more operator evaluations, preserving the requested numerical result.Validation on Windows / Python 3.12.14 / NumPy 2.5.4 / SciPy 1.18.1:
pytest pytests/test_memoizeoperator.py pytests/test_solver.py pytests/test_leastsquares.py: 163 passed. The checkout import path was checked in the same test process.git diff --check, and the example pass.CPU validation only; no CuPy runtime or full repository suite claim.
AI disclosure: code, tests, and this description were prepared by an autonomous AI coding agent at the account owner's request. No independent human code review is claimed.