Fix scan_save_mem with 0 steps#1977
Merged
Merged
Conversation
555633f to
7861ab7
Compare
jessegrabowski
approved these changes
Mar 17, 2026
| [n_steps, x0], ys_trace.shape[0], accept_inplace=True | ||
| ) | ||
| assert debug_fn(n_steps=1000, x0=[1, 1]) == 3 | ||
| mode = get_default_mode() |
Member
There was a problem hiding this comment.
this test appears to be marked as skip, why update it?
Member
Author
There was a problem hiding this comment.
I think you were mislead by github folding text. this is test_while_scan_taps and is not skipped
Comment on lines
+1727
to
+1733
| if ( | ||
| not isinstance(mode.linker, JITLinker) | ||
| and config.scan__allow_output_prealloc | ||
| ): | ||
| assert debug_fn(n_steps=1000, x0=[1, 1]) == 3 | ||
| else: | ||
| assert debug_fn(n_steps=1000, x0=[1, 1]) == 2 |
Member
There was a problem hiding this comment.
Suggested change
| if ( | |
| not isinstance(mode.linker, JITLinker) | |
| and config.scan__allow_output_prealloc | |
| ): | |
| assert debug_fn(n_steps=1000, x0=[1, 1]) == 3 | |
| else: | |
| assert debug_fn(n_steps=1000, x0=[1, 1]) == 2 | |
| using_jit_linker = ( | |
| isinstance(mode.linker, JITLinker) | |
| and config.scan__allow_output_prealloc | |
| ) | |
| assert debug_fn(n_steps=1000, x0=[1, 1]) == (3 - using_jit_linker) |
too cute?
Member
Author
There was a problem hiding this comment.
it's a bit cute, I'll store the expected result in a variable first. Also my baseline would be 2 + (does_prealloc), not 3 - (does_not)
mit-mot outputs are never memory optimized. Skipping these outputs lets us get rid of two faulty logical branches that existed to mask each: 1. an `if i <= op.info.n_mit_mot:` inside an `else` branch. This was logically wrong in that it included the first non mit-mot output (should have been <, not <=). When this was the output of a while scan it created an artificial dependency on the scan output shape, and didn't allow the rewrite to happen. 2. because of this the outer `if(i <= op.info.n_mit_mot and ...)` had been added to sidestep this artificial dependency. The comment mentioned in was supposed to specifically handle sit-sot/mit-sot of while loops, but it was again looking at all mit-mots + first non mit-mot input. It was logically wrong but canceled the first logical mistake. If we remove both things just work.
7861ab7 to
d6fcc91
Compare
Contributor
|
Yup that does seem good thx |
|
Thanks 😊 |
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.
Closes #1878
Closes #1902
At some point Scan was allowed to do zero steps, but the scan_save_mem rewrite still insisted that that was invalid.