Skip to content

Give SymmetrizedModel the keys of the wrapped model - #412

Open
ppegolo wants to merge 1 commit into
metatensor:mainfrom
ppegolo:fix-symmetrized-empty-blocks
Open

ppegolo wants to merge 1 commit into
metatensor:mainfrom
ppegolo:fix-symmetrized-empty-blocks

Conversation

@ppegolo

@ppegolo ppegolo commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Since #363, SymmetrizedModel evaluates several systems in the same model call. If the model's keys include the atomic type (like it can happen for PET in metatrain), systems with different species batched together get empty blocks for missing species that are instead present in other systems within the same batch. The keys can then differ between calls, and averaging fails with could not find blocks matching the selection.

Now each system averages only its own non-empty blocks, and SymmetrizedModel returns the same keys as the wrapped model.

Contributor (creator of pull-request) checklist

  • Tests updated (for new features and bugfixes)?
  • Documentation updated (for new features)?
  • Issue referenced (for PRs that solve an issue)?

Reviewer checklist

  • CHANGELOG updated with public API or any other important changes?

Models with keys that depend on the systems of a call (e.g. one block per
atomic type) give empty blocks for the keys of the other systems batched
in the same call. The keys of the outputs of one system then changed
between calls, and accumulating its moments failed to find the reference
block.

Each system now only accumulates its blocks with samples. The blocks
without samples in a whole call are collected and evaluated once at the
end, so the results have the keys returned by the model.
@ppegolo
ppegolo requested a review from Luthaf December 2, 2026 11:03
Comment on lines +1565 to +1567
# the model can give empty blocks for the keys (e.g. atomic
# types) of the other Systems of the call, which change from
# one call to the next

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model could also give no blocks, i.e. return a different set of keys from one system to another. Is this handled as well?

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.

2 participants