Fixes #181735
The old eager_input_vals propagation in replace_by_example assumed the
eager trace and the val trace would produce replacement graphs with the
same number of nodes. That is not true for
triton_kernel_wrapper_functional when the decomposition clones an
as_strided view with a dynamic size-1 leading dimension.
Keep the existing generic eager_input_vals propagation for the
auto_functionalized paths, but make replace_by_example return the
inserted replacement nodes so decompositions can attach metadata
explicitly when needed. Use that only for
triton_kernel_wrapper_functional, propagating eager_input_vals directly
to the inserted triton_kernel_wrapper_mutation node.
We were not able to come up with a failing auto_functionalized repro
before this change, and we do not understand that case well enough to
justify touching it here, so this patch intentionally leaves that path
alone.
Also add a regression test for the Triton fail-before case and a direct
test for the replace_by_example return value.
Test Plan:
python test/inductor/test_needs_exact_strides.py -v
python test/inductor/test_pattern_matcher.py -v -k replace_by_example
python test/inductor/test_triton_kernels.py -v
AI-Assisted: Authored with Claude and Codex.
[ghstack-poisoned]
SOCIAL SHARE CARD GENERATOR