Skip to content

Ensures source and target IDs are paired up in SGD#296

Merged
weefuzzy merged 5 commits intoflucoma:mainfrom
weefuzzy:fix/mlp_unaligned_data
Apr 6, 2025
Merged

Ensures source and target IDs are paired up in SGD#296
weefuzzy merged 5 commits intoflucoma:mainfrom
weefuzzy:fix/mlp_unaligned_data

Conversation

@weefuzzy
Copy link
Copy Markdown
Member

fixes #292

Ok, ok, I know this looks like a massive PR, but it's not really 😄

The problem

SGD::train assumes that its source and target data are aligned, i.e. that each index represents the same ID. This not necessarily the case because we're using unordered containers by design. You can make training silently fail to do anything sensible by adding points to source and target in a different order, for instance. This is baaaaad.

But why is this diff so large, you 'orrible man?

The core of this PR is decoupling the batching and sampling of data from SGD, a bit like pytorch. I like that SGD doesn't want to know about DataSet, it just needed to go further.

So we have

  • some new classes that do data sampling: a base class, an implementation that properly matches source and target IDs, and a simple implementation for when data really are aligned (this opens up some cool future extensions*).
  • changes to SGD to remove its batching code and use this instead
  • supporting changes to FluidDataSet, FluidTensorView
  • some tests
  • updates to MLP clients to actually check that IDs match and use appropriate sampler

User-side, nothing much should change besides a couple of error messages: so, reviewers: please test this proposition by training against your own stuff and making sure it still works as it did.

* Like, it would now be pretty easy to enable quicker n' dirtier MLP training (resp. the rest of the data objects) with CCE buffers alone for those cases where people don't want / care about IDs. I think this would have significant workflow and teaching upsides...

@weefuzzy weefuzzy added bug Something isn't working enhancement New feature or request labels Mar 20, 2025
@weefuzzy weefuzzy self-assigned this Mar 20, 2025
@tremblap
Copy link
Copy Markdown
Member

tremblap commented Mar 21, 2025

Thanks for this mammoth work! Maybe @lewardo wants to also try this in his spare time. That will have consequences for the WiP of DataSeries for which @weefuzzy has another idea IIRC but for now it would be good to also get him to read it. Also if @AlexHarker wants to try this bespoke objects for his piece from that branch that might be a good idea. I will run the test on Monday as I am in compo/impro/code residency for the next days...

@tremblap
Copy link
Copy Markdown
Member

it all works here. Is it possible that it doesn't bounce as much as before, or have I been lucky?

@tremblap
Copy link
Copy Markdown
Member

I think I've been lucky. In all cases it works fine.

@jamesb93
Copy link
Copy Markdown
Member

Working for me!

@weefuzzy weefuzzy force-pushed the fix/mlp_unaligned_data branch from 2aae3ba to 0454ce0 Compare April 5, 2025 16:09
@weefuzzy weefuzzy merged commit e04085f into flucoma:main Apr 6, 2025
3 checks passed
@weefuzzy weefuzzy deleted the fix/mlp_unaligned_data branch April 8, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MLP*: Doesn't respect input IDs

3 participants