Skip to content

Conversation

@Scienfitz
Copy link
Collaborator

@Scienfitz Scienfitz commented Aug 21, 2025

Implements #621

New: A Symmetry class which is part of baybe Surrogates. Three distinct symmetries are included, for more info check the userguide and for a demonstration of the effect see the new example. The ability to perform data augmentation has been included for all symmetries.

I have left some initial comments on design questions that are still open or where I am kind of indifferent and just had to choose one. Feel free to leave an opinion there first so the large-scale design picture can be finalized independent of small comments.

TODO

  • CHANGELOG (after architecture is logged in)
  • Remember to compress finalized svg picture

Other Notes
Symmetries and constraints are conceptually so similar that they should probably have the same interface. The design here has been done from scratch completely ignoring the constraint interface because it is already known to be not optimal and needs refactoring.

  • There is no overarching shared attribute parameters or similar because some symmetries allow single and some multiple such parameters. Instead the parameters are treated like the objectives treat target(s)
  • Contrary to dependency constraint, dependency symmetry can only hold 1 set of dependencies. The constraint should be refactored to look the same.
  • There is one exception I made but I'm open to still changing it

@Scienfitz Scienfitz self-assigned this Aug 21, 2025
@Scienfitz Scienfitz added the new feature New functionality label Aug 21, 2025
@Scienfitz Scienfitz linked an issue Aug 21, 2025 that may be closed by this pull request
@AVHopp
Copy link
Collaborator

AVHopp commented Aug 25, 2025

@Scienfitz just to make sure - I guess since this is marked as a draft, you do not require a PR review for now, right? Is there anything else that we can assist with?

@Scienfitz
Copy link
Collaborator Author

@AVHopp yes exactly and it will always be like that for PR's that I open in draft: Ignore until requested or asked in any other way

@Scienfitz Scienfitz force-pushed the feature/invariance_augmentation branch from 00cfef8 to 5ba4cb1 Compare September 10, 2025 08:10
@Scienfitz Scienfitz force-pushed the feature/invariance_augmentation branch 3 times, most recently from bc671eb to db98f64 Compare September 25, 2025 10:32
@Scienfitz Scienfitz force-pushed the feature/invariance_augmentation branch from db98f64 to aedafa7 Compare September 25, 2025 10:41
@Scienfitz Scienfitz marked this pull request as ready for review September 25, 2025 11:01
Copilot AI review requested due to automatic review settings September 25, 2025 11:01
Similar to objectives, the Symmetry constructors now expect single parameter names or a sequence thereof, depending on their core logic.
@Scienfitz Scienfitz force-pushed the feature/invariance_augmentation branch from 98c29e8 to 0e05880 Compare October 24, 2025 18:12
@Scienfitz Scienfitz force-pushed the feature/invariance_augmentation branch from 46bc49c to 859ca3b Compare October 31, 2025 18:23
Done to make the name consistent with the other packages.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So far this is a large monolith of a file. Large part of this is validation, so I can see how this is just split up into

  • symmetries
    • symmetries.base
    • symmetries.core
    • symmetries.validation

However this would require outsourcing the content of the validate_searchspace_context, so they would effectively become empty hulls calling a utility imported from symmetries.validation. I also like the closeness of the Raises section and the functional content to the actual class. So Im not sure if I should outsource the validations.


# Object variables
# TODO: Needs inner converter to tuple
copermuted_groups: tuple[tuple[str, ...], ...] = field(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the only exception where I did still somewhat follow the design of the corresponding constraint. Because all cosntraints share parameters this symmetry requires to specify copermuted_groups as separate attribute. But actually all the groups could be combined into a single attribute.

Instead of parameter_names=["a1", "a2"] and copermuted_groups=[["b1", "b2"],["c1","c2"]] we would have permutation_groups = [["a1","a2"], ["b1", "b2"], ["c1","c2"]]. This is certainly more lgical but maybe a bit less userfirendly if there is really just 1 group.

This would have as consequence that we need to (re)define what the parameters property even should contain or whether it should even be dropped.

In the absence of opinions this wills tay as it is.

# Validate compatibility of surrogate symmetries with searchspace
if hasattr(self._surrogate_model, "symmetries"):
for s in self._surrogate_model.symmetries:
s.validate_searchspace_context(searchspace)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Important: Validation so far is only part of the recommend call here in the recommenders. Validation has not been included in the Campaign yet. This is due to two factors

  • To properly validate the symmetries and searchspace compatibility there needs to be a mechanism that can iterate over all possible recommenders of a metarecommender. Otherwise this upfront validation already fails for the two phase recommender if the second recommender has symmetries
  • There would be double validation with campaign and recommend call so the context info of whether validation was already performed needs to be passed somewhere. Likely fixable with settings mechanism not yet available

@Scienfitz Scienfitz marked this pull request as ready for review November 3, 2025 17:31
@Scienfitz Scienfitz requested a review from Copilot November 4, 2025 08:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Scienfitz Scienfitz requested a review from Copilot November 4, 2025 11:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 27 out of 29 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Data Augmentation for Invariant Contraints

3 participants