Commit 27a6498
Fix FxConverter mutation tracking and scatter_reduce kwargs for FXIR backend (#175860)
Summary:
Three fixes for scatter_reduce opinfo e2e tests through the FXIR codegen path:
1. **Fix sym_sum decomposition (export.py)**: `_decompose_sym_sum` assumed
`torch.sym_sum` args are in `n.kwargs["args"]`, but the FX tracer records
them as positional args in `n.args[0]`. This caused `KeyError: 'args'`
during `symbolic_shape_decompose`.
2. **Propagate include_self kwarg (wrapper_fxir.py)**: The FxConverter's
`_generate_scatter_fallback` only extracted the `reduce` kwarg, silently
dropping `include_self`. This caused `scatter_reduce` with
`include_self=False` to default to `True`, producing wrong results.
3. **Track in-place mutations in FxConverter (wrapper_fxir.py)**: For mutation
ops like `scatter_reduce_` and `index_put_`, the FxConverter created a new
output buffer but never updated `buffer_to_node` for the mutated input.
Downstream references to the mutated buffer still pointed to the
pre-mutation copy, so the mutation result was completely ignored. Fixed by
updating `buffer_to_node` for all mutated names after creating the fallback
call node.
Test Plan:
Validated 13 scatter_reduce opinfo e2e tests across all reduce modes (amax,
amin, mean, prod), multiple dtypes (f16, bf16, f32), both include_self values,
and both dim values:
```
OPINFO_START_INDEX=8268 OPINFO_END_INDEX=8269 OPINFO_LOWERING_MODE=AFG_INDUCTOR_COMPILE OPINFO_AUTO_DS=1 buck2 run fbcode//mtia/compiler/graph_compiler/test_library/afg_opinfo_e2e_tests:test_afg_opinfo_e2e
```
Pull Request resolved: #175860
Approved by: https://github.com/sidt-meta1 parent 1f9e1e5 commit 27a6498
1 file changed
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
880 | 881 | | |
881 | 882 | | |
882 | 883 | | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
883 | 889 | | |
884 | 890 | | |
885 | 891 | | |
| |||
914 | 920 | | |
915 | 921 | | |
916 | 922 | | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
917 | 932 | | |
918 | 933 | | |
919 | 934 | | |
| |||
0 commit comments