[Bugfix] Copy pass_configs dict to prevent mutation across multiple JIT compilations #1776
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
pass_configsdictionary was shared and mutated across multiple JIT kernel compilationscompile_flagswould accumulate (e.g.,['-O3']→['-O3', '-O3'])pass_configsbefore modifying it in_compile_and_create_adapterRoot Cause Analysis
This is a classic Python mutable object sharing issue.
How Python handles objects
In Python, variables store references (pointers) to objects, not the objects themselves:
What happened in this bug
When using the
@tilelang.jitdecorator:The
pass_configsdictionary is created once when the decorator is applied. Every subsequent call tomatmul()reuses the same dictionary object.When the code modifies this dictionary:
All future calls see the accumulated modifications:
compile_flags_cfg = None→ sets['-O3']compile_flags_cfg = ['-O3']→ sets['-O3', '-O3']compile_flags_cfg = ['-O3', '-O3']→ sets['-O3', '-O3', '-O3']The fix
Copy the dictionary before modifying:
Test plan
Summary by CodeRabbit