Skip to content

feat[next]: Elementwise operations on Tuples - #2834

Open
SF-N wants to merge 7 commits into
sf_n_tracer_supportfrom
sf_n_tracer_support_element_wise
Open

SF-N wants to merge 7 commits into
sf_n_tracer_supportfrom
sf_n_tracer_support_element_wise

Conversation

@SF-N

@SF-N SF-N commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

See https://hackmd.io/PxqTkA4rSGCgCmUAPq15SA for some unsorted discussion.

tehrengruber and others added 4 commits August 27, 2026 19:44
The GTIR 'concat_where' type synthesizer derives the result dims via
'type_info.promote(tb, fb)', which asserted that the promoted dtypes are
'ScalarType'. A local field carries a 'ListType' dtype at the GTIR
level, so any 'concat_where' with a local-field branch failed with a
bare 'AssertionError' during type inference -- and it did so even though
both branches have the identical dtype, since the assertion is on the
dtype's kind, not on the operands differing.

Let 'promote' handle 'ListType' the same way it handles 'ScalarType':
both promote only between equal types, so the two cases collapse into a
single check. The docstring records that a 'ListType' only ever reaches
'promote' from the ITIR level, because the frontend represents the same
concept as a field with a local dimension in 'dims' and a scalar dtype.

The combination was previously untested ('test_concat_where.py' had no
local-dimension coverage), so the latent assert never fired in CI.
@tehrengruber-ai

Copy link
Copy Markdown

@SF-N #2931 parameterizes how 'tree_map' enumerates a node's children ('collection_elements', living alongside 'collection_type' and 'result_collection_constructor' as the membership/decomposition/reconstruction facets of a traversable collection) and removes the 'iter'/'len' container dunders from the type specs; type-tree traversal now goes through 'type_info.tree_map_type', which is also usable as a parametrized decorator. This PR should adopt that instead of the length-1 view via 'XVarArgType.iter'/'len': as a dunder, "a variable-length tuple has length 1" is observable by any code that happens to iterate or 'len()' a type, while as a 'collection_elements' policy it is explicit and local to the traversal that wants representative-element semantics. Concretely, after rebasing onto main with #2931: drop 'iter'/'len' from 'XVarArgType' (note 'XTupleType' also loses the inherited ones), and let '_deduce_elementwise_binop_type' call 'type_info.tree_map_type' with a 'collection_elements' that yields the representative 'element_type' for 'XVarArgType' and '.types' otherwise — the 'broadcast_leaves' zipping semantics (same kind, same length, leaves repeated) stay as they are and compose with it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants