Skip to content

Fix joint full-batch and minibatch condition loading - #863

Merged
ndem0 merged 3 commits into
PINA-org:devfrom
GiovanniCanali:fix_datamodule
Nov 11, 2026
Merged

ndem0 merged 3 commits into
PINA-org:devfrom
GiovanniCanali:fix_datamodule

Conversation

@GiovanniCanali

Copy link
Copy Markdown
Collaborator

Description

This PR fixes #862

Restore joint-condition optimizer steps following the condition/datamodule refactor. Previously, the refactored loader yielded one condition batch per step, changing the training objective between steps and causing instability, especially with L-BFGS.

The datamodule now:

  • Groups one stored batch per active condition into each step.
  • Cycles shorter conditions until the longest is exhausted.
  • Preserves per-condition batch sizes.
  • Evaluates all conditions together in full-batch mode.
  • Keeps the current condition structure and materialization API unchanged.

Additional tests are generated by an AI agent.

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 requested review from ndem0 and a balanced review from Copilot November 8, 2026 17:39
@GiovanniCanali GiovanniCanali self-assigned this Nov 8, 2026
@GiovanniCanali
GiovanniCanali requested a review from a team as a code owner November 8, 2026 17:39
@GiovanniCanali GiovanniCanali added bug Something isn't working high priority Higher priority pr-to-review Label for PR that are ready to been reviewed labels Nov 8, 2026

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 was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

ndem0 added 2 commits November 9, 2026 17:31
Refactor data module to improve batching and aggregation methods. Update batching mode and implement condition row aggregation.

@GiovanniCanali GiovanniCanali left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Looks good, @ndem0!

Please, remove the print statements and commented code.

)

print("Condition losses:", condition_losses)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Remove print statement.

for batch_id in indices[val_end:]:
test_rows.append([condition_id, batch_id])
# test_rows.append([condition_id, batch_id])
condition_test_rows.append([condition_id, batch_id])

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Remove commented code.


print("Train rows:", train_rows)
print("Val rows:", val_rows)
print("Test rows:", test_rows)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Remove print statements.

@dario-coscia dario-coscia left a comment

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.

I am not a fan of [B, conditions, 2]; maybe I prefer tuple([B, conditions]) idk if it is feasible and equivalently faster. Or even better iterate on a NamedTuple data, condition_name. What do you think?

@ndem0

ndem0 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

I am not a fan of [B, conditions, 2]; maybe I prefer tuple([B, conditions]) idk if it is feasible and equivalently faster. Or even better iterate on a NamedTuple data, condition_name. What do you think?

Not really sure I got what you meant. We're still wondering if a list(list(list)) could be better than the tensorized version. But mainly to allow batches with different numbers of conditions inside: maybe not the most common thing, but it may happen, and in this structure everything is still doable.
Why do you like the tuple version more? Here anyway the issue about this #864

@ndem0

ndem0 commented Nov 11, 2026

Copy link
Copy Markdown
Member

I'm going to merge this PR even though modifications are still needed, I'm afraid to keep this small patch open for too long. We are still in the dev branch, so we can continue discussing batching (here #864)

@ndem0
ndem0 merged commit 80b9d38 into PINA-org:dev Nov 11, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working high priority Higher priority 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.

4 participants