-
Notifications
You must be signed in to change notification settings - Fork 78
Compositional sampling diffusion #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
arrjon
wants to merge
114
commits into
dev
Choose a base branch
from
compositional_sampling_diffusion
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # bayesflow/networks/diffusion_model/diffusion_model.py # bayesflow/utils/integrate.py
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces compositional sampling support to the BayesFlow framework, enabling diffusion models to handle multiple compositional conditions efficiently. The main changes span the continuous approximator, diffusion model, and inference network modules, adding new methods and refactoring existing ones to support compositional structures in sampling, inference, and diffusion processes.
Larger changes include:
compositional_samplemethod toContinuousApproximator, which generates samples with compositional structure and handles flattening, reshaping, and prior score computation for multiple compositional conditions. Supporting internal method_compositional_samplewas also introduced.DiffusionModel, implemented compositional diffusion support including:compositional_bridgeandcompositional_velocitymethods for compositional score calculation._compute_individual_scoreshelper for handling multiple compositional conditions._inverse_compositionalmethod for inverse compositional diffusion sampling.The idea is that the workflow now has the method
compositional_sample, which expects conditions in the form (n_datasets, n_conditions, ...). Then we can perform compositional sampling with diffusion models.compositional_sampleallows to set amini_batch_sizefor memory efficient computation of the compositional score, which does not work withjaxbackend however, asjaxdoes not like stochasticity in its integrators which cannot be precomputed. We could support here only fixed step sizes though?To compute the compositional score we need access to the score of the prior. Here we need to handle the adapter carefully so that we compute the correct score. In the current draft, I am not sure I computed the prior score correctly. Some ideas would be great, currently it fails for
jaxbecause the adpater is converting stuff tonumpyback and forth, but fortorchit is working.