Skip to content

[Relax][Frontend][Torch] Support masked_scatter in from_exported_program - #21049

Open
aliqyan-21 wants to merge 1 commit into
apache:mainfrom
aliqyan-21:fix-ep-masked-scatter
Open

aliqyan-21 wants to merge 1 commit into
apache:mainfrom
aliqyan-21:fix-ep-masked-scatter

Conversation

@aliqyan-21

Copy link
Copy Markdown

Fixes #21048

aten.masked_scatter.default was only convertible through from_fx, so from_exported_program failed with Unsupported function types ['masked_scatter.default'].

  • Move _masked_scatter from fx_translator.py into BaseFXGraphImporter and register masked_scatter.default for the exported-program path.
  • Clamp the gather index at 0. Positions before the first True in the mask produced index -1, which take(mode="fast") doesn't bounds-check. Those lanes are discarded by where, but the read itself was out of bounds.
  • Update the expected IR in the existing fx test for the added maximum.
  • Add test_masked_scatter for the exported-program path, comparing numerically against PyTorch (1-D and N-D masks, flat and ranked sources, masks starting with False).

Also verified on a Gemma-4 FX graph (graph_007, 6184 ATen nodes, contains masked_scatter): from_exported_program previously failed with Unsupported function types ['masked_scatter.default']. It now converts and the resulting module passes check_well_formed.

@aliqyan-21

aliqyan-21 commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

CI shows "This commit cannot be built" on all the checks. In the Jenkins log fails at checkout with fatal: couldn't find remote ref refs/pull/21049/head, so it looks like a CI infrastructure issue rather than a build failure. Could a maintainer re-trigger CI? Thanks!

cc @tlopex

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.

[Bug] [Relax] [Frontend] [Torch] from_exported_program: aten.masked_scatter.default unsupported

1 participant