fix[next]: Fix StaticArgs injection#2659
Open
SF-N wants to merge 4 commits into
Open
Conversation
tehrengruber
requested changes
Jun 17, 2026
Comment on lines
+669
to
+670
| # Only inject a `StaticArg` descriptor mapping when static arguments were | ||
| # actually given. |
Contributor
There was a problem hiding this comment.
Suggested change
| # Only inject a `StaticArg` descriptor mapping when static arguments were | |
| # actually given. |
Contributor
There was a problem hiding this comment.
Nitpicking: This is just reiterating what the code does anyway.
| # the dict directly. Note that we don't need to check any args, since the pool checks | ||
| # this on compile anyway. | ||
| if "_compiled_programs" not in self.__dict__: | ||
| static_params: tuple[str, ...] = () |
Contributor
There was a problem hiding this comment.
The changes here are not doing anything, the other path where the argument descriptors are built is in _make_compiled_programs_pool and that needs to be kept in sync with CompiledProgramsPool.compile
Comment on lines
+131
to
+146
| empty_static_args = {} | ||
| decorator_path_testee = compile_testee.with_backend(cartesian_case.backend) | ||
| decorator_path_testee.compile( | ||
| offset_provider=cartesian_case.offset_provider, **empty_static_args | ||
| ) | ||
| decorator_path_mapping = decorator_path_testee._compiled_programs.argument_descriptor_mapping | ||
| assert arguments.StaticArg not in decorator_path_mapping | ||
|
|
||
| compiled_program_path_testee = compile_testee.with_backend(cartesian_case.backend) | ||
| compiled_program_path_pool = compiled_program_path_testee._make_compiled_programs_pool( | ||
| static_params=(), static_domains=False | ||
| ) | ||
| compiled_program_path_pool.argument_descriptor_mapping = None | ||
| compiled_program_path_pool.compile(offset_providers=[cartesian_case.offset_provider]) | ||
|
|
||
| assert compiled_program_path_pool.argument_descriptor_mapping == decorator_path_mapping |
Contributor
There was a problem hiding this comment.
Suggested change
| empty_static_args = {} | |
| decorator_path_testee = compile_testee.with_backend(cartesian_case.backend) | |
| decorator_path_testee.compile( | |
| offset_provider=cartesian_case.offset_provider, **empty_static_args | |
| ) | |
| decorator_path_mapping = decorator_path_testee._compiled_programs.argument_descriptor_mapping | |
| assert arguments.StaticArg not in decorator_path_mapping | |
| compiled_program_path_testee = compile_testee.with_backend(cartesian_case.backend) | |
| compiled_program_path_pool = compiled_program_path_testee._make_compiled_programs_pool( | |
| static_params=(), static_domains=False | |
| ) | |
| compiled_program_path_pool.argument_descriptor_mapping = None | |
| compiled_program_path_pool.compile(offset_providers=[cartesian_case.offset_provider]) | |
| assert compiled_program_path_pool.argument_descriptor_mapping == decorator_path_mapping | |
| empty_static_args = {} | |
| precompiled_testee = compile_testee.with_backend(cartesian_case.backend) | |
| precompiled_testee.compile( | |
| offset_provider=cartesian_case.offset_provider, **empty_static_args | |
| ) | |
| precompiled_arg_descr_mapping = decorator_path_testee._compiled_programs.argument_descriptor_mapping | |
| jit_testee = compile_testee.with_backend(cartesian_case.backend) | |
| jit_testee(...) | |
| jit_arg_descr_mapping = decorator_path_testee._compiled_programs.argument_descriptor_mapping | |
| assert precompiled_arg_descr_mapping == jit_arg_descr_mapping |
| assert np.allclose(kwargs["out"].ndarray, args[0].ndarray + args[1].ndarray) | ||
|
|
||
|
|
||
| def test_compile_with_empty_static_args_matches_no_static_args(cartesian_case, compile_testee): |
Contributor
There was a problem hiding this comment.
Suggested change
| def test_compile_with_empty_static_args_matches_no_static_args(cartesian_case, compile_testee): | |
| def test_precompile_and_jit_have_same_arg_descr_mapping(cartesian_case, compile_testee): |
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.
This pull request updates the compilation logic in
CompiledProgramto ensure that static argument descriptors are only injected when static arguments are actually provided.