[FIX] Fix 5 ReduceSymbolicExpr / symbolic engine regressions#306
Closed
[FIX] Fix 5 ReduceSymbolicExpr / symbolic engine regressions#306
Conversation
16a2f6e to
d358c4f
Compare
Sanitizer Performance Benchmark
Iterations: 1 warmup + 40 measured |
- Propagate dtype in UnarySymbolicExpr (fixes NoneType dtype in reduce/expand_dims) - Preserve block_type in CastSymbolicExpr and _resolve_element_dtype (fixes reduce on block_ptr data) - Monkey-patch tl.constexpr.to() for interpreter mode (fixes constexpr .to(dtype)) - Wrap scalar constexprs in tl.constexpr, convert bool args to int (fixes float .to and int1 bitwidth) - Unwrap tl.constexpr in SymbolicExpr.from_value to prevent downstream type errors
d358c4f to
4c14d42
Compare
Jokeren
reviewed
Mar 3, 2026
|
|
||
| _MISSING = object() | ||
|
|
||
| # Monkey-patch tl.constexpr to add .to() for interpreter mode. |
Member
There was a problem hiding this comment.
This should be in an existing function or a new function
| self.add_child("src", src) | ||
| self.add_child("dst_type", dst_type) | ||
| self.dtype = self.dst_type.to_py() | ||
| dst = self.dst_type.to_py() |
Collaborator
Author
There was a problem hiding this comment.
self.dst_type is a SymbolicExpr node wrapping the actual dtype value. to_py() unwraps it to get the raw Python object (e.g. tl.float32).
| # Walk the ptr chain to find the MakeBlockPtrSymbolicExpr for block shape | ||
| block_shape = None | ||
| cur: SymbolicExpr | None = ptr | ||
| while cur is not None: |
Member
There was a problem hiding this comment.
Cannot you just store the block_shape attribute in the symbol?
| call_args[name] = arg | ||
| ret = arg | ||
| call_args[name] = ( | ||
| tl.constexpr(arg) if isinstance(arg, (int, float, bool)) else arg |
Member
There was a problem hiding this comment.
Which test case would trigger this bug?
Member
There was a problem hiding this comment.
I don't understand why the fix just handles int float and bool
…r-regressions # Conflicts: # tests/end_to_end/test_sanitizer.py
Instead of walking the ptr chain to find MakeBlockPtrSymbolicExpr, propagate block_shape_values at construction time so it can be looked up directly via getattr.
Collaborator
Author
|
Closing in favor of 4 independent PRs that split each fix into its own iteration:
Each PR carries only the minimal code fix + its specific regression test(s). |
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.
Summary
UnarySymbolicExprdidn't propagatedtype, causingNoneTypeerrors intl.sum(tl.exp(...))andexpand_dimsaftertl.expconstexprfloats lacked.to()in interpreter mode — added monkey-patch ontl.constexprand wrap scalar constexprs intl.constexprboolargs hit numpy int1 bitwidth mismatch — convertbooltointbefore_implicit_cvt_resolve_element_dtypereturned scalar dtype instead ofblock_typefor block pointer loads, andCastSymbolicExprdidn't preserveblock_typetl.constexprinSymbolicExpr.from_valueto prevent downstream type errors from constexpr wrappingxfailmarkers from regression testsTest plan
test_reduce_symbolic_nonetype,test_expand_dims_scalar_attr,test_float_no_attr_to,test_numpy_int1_bitwidth,test_reduce_symbolic_core_dtype)