Skip to content

Conversation

GiovanniCanali
Copy link
Collaborator

@GiovanniCanali GiovanniCanali commented Aug 29, 2025

Description

This PR fixes #619.

This PR also adds the SelfAdaptiveWeighting class. Reference (page 9): https://arxiv.org/pdf/2507.08972.
Moreover, it introduces the possibility to update weights via the update_and_aggregate and _update methods.

Checklist

  • Code follows the project’s Code Style Guidelines
  • Tests have been added or updated
  • Documentation has been updated if necessary
  • Pull request is linked to an open issue

@GiovanniCanali GiovanniCanali self-assigned this Aug 29, 2025
@GiovanniCanali GiovanniCanali added enhancement New feature or request low priority Low priority fix labels Aug 29, 2025
@GiovanniCanali GiovanniCanali changed the base branch from master to dev August 29, 2025 17:18
@dario-coscia
Copy link
Collaborator

Hi @GiovanniCanali! I was having a look at this even tho it is not marked as review yet.

I like your changes! One thing I would try is to add a kwarg (e.g. update_every_nepoch or something similar) to all methodologies where the values of the weights are updated (ofc this doesn't change the "static" weightings). A simple way to achieve this is to put it in the init of weighting interface. Then we can make a method in the same class (e.g. update_and_aggregate or something similar) which we simply overload aggregate and call it if trainer.current_epoch% update_every_nepoch==0. This method is also called in the solver in _optimization_cycle instead of the current aggregate. What do you think?

@GiovanniCanali
Copy link
Collaborator Author

Hi @GiovanniCanali! I was having a look at this even tho it is not marked as review yet.

I like your changes! One thing I would try is to add a kwarg (e.g. update_every_nepoch or something similar) to all methodologies where the values of the weights are updated (ofc this doesn't change the "static" weightings). A simple way to achieve this is to put it in the init of weighting interface. Then we can make a method in the same class (e.g. update_and_aggregate or something similar) which we simply overload aggregate and call it if trainer.current_epoch% update_every_nepoch==0. This method is also called in the solver in _optimization_cycle instead of the current aggregate. What do you think?

I agree with you. I just need to think a bit about the changes with respect to the solver, but it should not be a big deal.

@dario-coscia
Copy link
Collaborator

I agree with you. I just need to think a bit about the changes with respect to the solver, but it should not be a big deal.

I think we just need to change this line https://github.com/mathLab/PINA/blob/master/pina/solver/solver.py#L252 with the new update method which overloads aggregate

@GiovanniCanali GiovanniCanali added the pr-to-fix Label for PR that needs modification label Sep 1, 2025
@dario-coscia
Copy link
Collaborator

@GiovanniCanali For me is ready, let me know what you think about it!

@dario-coscia dario-coscia force-pushed the fix_weighting branch 2 times, most recently from 4a08069 to ab22331 Compare September 1, 2025 12:52
@dario-coscia
Copy link
Collaborator

@GiovanniCanali I see some tests are failing. This is because some solvers override _optimization_cycle. That's not something it supposed to happen. Maybe we can modify those bugs now, merge the PR in dev and update those solvers such that _optimization_cycle is only in solverinterface

Copy link
Collaborator Author

@GiovanniCanali GiovanniCanali left a comment

Choose a reason for hiding this comment

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

Great @dario-coscia, everything looks good to me.

I just highlighted some minor issues related to the documentation, let's fix them before merging!

@GiovanniCanali GiovanniCanali force-pushed the fix_weighting branch 6 times, most recently from bc81ad0 to d7909b1 Compare September 5, 2025 08:53
@GiovanniCanali
Copy link
Collaborator Author

Hi @dario-coscia,

This PR is now complete and ready for review. Commits have been squashed, so that we now have one commit per new feature.

Tests are failing due to #621. I would suggest fixing that issue before merging, so we can also check that the tests pass on Ubuntu and macOS.

@GiovanniCanali GiovanniCanali added pr-to-review Label for PR that are ready to been reviewed and removed pr-to-fix Label for PR that needs modification labels Sep 5, 2025
@GiovanniCanali GiovanniCanali marked this pull request as ready for review September 5, 2025 09:29
@GiovanniCanali GiovanniCanali merged commit ef35424 into mathLab:dev Sep 8, 2025
18 of 19 checks passed
@GiovanniCanali GiovanniCanali deleted the fix_weighting branch September 8, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority Low priority fix pr-to-review Label for PR that are ready to been reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add link between SolverInterface and WeightingInterface
2 participants