Skip to content

Enhance scatter! to support const destination with no derivative output - #768

Open
Parvm1102 wants to merge 1 commit into
FluxML:masterfrom
Parvm1102:enzyme-scatter-const-dst
Open

Enhance scatter! to support const destination with no derivative output#768
Parvm1102 wants to merge 1 commit into
FluxML:masterfrom
Parvm1102:enzyme-scatter-const-dst

Conversation

@Parvm1102

Copy link
Copy Markdown
Contributor

scatter! with a Const dst hit an internal assertion:

AssertionError: !(OutType <: EnzymeCore.Const)

The new rule handles this. The scatter still runs, and nothing flows
back to src, since a Const dst carries no derivative.

Dropping the assertion on its own would not have been enough: the primal was
only run for Duplicated/BatchDuplicated, so a Const dst would have
skipped the scatter entirely and left dst unwritten. The test checks that the
mutation still happens, not just that it no longer errors.

Fixes #766.

PR Checklist

  • Tests are added
  • Documentation, if applicable

Signed-off-by: Parvm1102 <parvmittal31757@gmail.com>
@Parvm1102
Parvm1102 force-pushed the enzyme-scatter-const-dst branch from 3349ae5 to 649e5e8 Compare August 20, 2026 15:25
@Parvm1102

Copy link
Copy Markdown
Contributor Author

Resolved the Merge conflicts

@Parvm1102

Copy link
Copy Markdown
Contributor Author

@CarloLucibello please review this.

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.

Enzyme: scatter! rule hits a bare @assert when dst is Const

1 participant