Skip to content

Cleaning Solver - #836

Draft
ndem0 wants to merge 1 commit into
devfrom
solver_improvement
Draft

ndem0 wants to merge 1 commit into
devfrom
solver_improvement

Conversation

@ndem0

@ndem0 ndem0 commented Sep 23, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes #ISSUE_NUMBER.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Solver-specific _compute_condition_loss overrides in SelfAdaptive/Competitive don’t apply the new _weight_condition_loss hook, causing functional inconsistency vs BaseSolver’s updated loss pipeline.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

This PR refactors the solver subsystem to consolidate initialization in BaseSolver, simplify mixin responsibilities (notably multi-model vs ensemble forwarding), and separate additive regularization from multiplicative loss weighting via a new hook.

Changes:

  • Merge solver component setup + weighting/loss initialization into BaseSolver.__init__, updating core solver classes to pass all init args in one call.
  • Introduce BaseSolver.forward (default: first model) and remove redundant forward overrides from SelfAdaptive/Competitive solvers.
  • Split loss post-processing into two hooks: _regularize_condition_loss (additive) and _weight_condition_loss (multiplicative), migrating residual-based attention to the new weighting hook.
File Description
pina/​_src/​solver/​base_solver.py Expands __init__, adds default forward, and adds _weight_condition_loss hook into the loss pipeline.
pina/​_src/​solver/​single_model_solver.py Updates initialization to pass model/optimizer/scheduler/weighting/loss into BaseSolver.__init__.
pina/​_src/​solver/​multi_model_solver.py Updates initialization to pass models/optimizers/schedulers/weighting/loss into BaseSolver.__init__ and sets manual optimization directly.
pina/​_src/​solver/​ensemble_solver.py Updates initialization to pass models/optimizers/schedulers/weighting/loss into BaseSolver.__init__ and sets manual optimization directly.
pina/​_src/​solver/​mixin/​multi_model_mixin.py Removes stacking forward; mixin now focuses on multi-optimizer configuration + convenience properties.
pina/​_src/​solver/​mixin/​manual_optimization_mixin.py Removes _init_manual_optimization helper; callers now set automatic_optimization directly.
pina/​_src/​solver/​mixin/​residual_based_attention_mixin.py Renames residual-attention hook to _weight_condition_loss and updates docstring accordingly.
pina/​_src/​solver/​self_adaptive_physics_informed_solver.py Removes redundant forward override following BaseSolver default-forward addition.
pina/​_src/​solver/​competitive_physics_informed_solver.py Removes redundant forward override following BaseSolver default-forward addition.
pina/​_src/​solver/​REFACTORING.md Adds design/architecture documentation for the refactor and new hook responsibilities.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

"""
return self.model(x)

def _compute_condition_loss(self, condition, data, batch_idx):
"""
return self.model(x)

def _compute_condition_loss(self, condition, data, batch_idx):
@GiovanniCanali
GiovanniCanali changed the base branch from master to dev October 1, 2026 11:32
@GiovanniCanali
GiovanniCanali self-requested a review October 1, 2026 11:33

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.

2 participants