Skip to content

Composite Sampler #250

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Composite Sampler #250

wants to merge 4 commits into from

Conversation

abhash-er
Copy link
Collaborator

@abhash-er abhash-er commented Apr 28, 2025

This PR adds-

  1. CompositeSampler - Sampler from a mixture of sub-sampler (in an order)
  2. CompositeProfile - Takes in a list of SamplerTypes and corresponding configs for sampling.

@abhash-er abhash-er requested a review from Neonkraft April 28, 2025 17:29
self.arch_parameters = arch_parameters

# get sample frequency from the samplers
self.sample_frequency = arch_samplers[0].sample_frequency
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still use sampling frequency in the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, we never change it to epoch in our experiments, but we have option to do that. I'm not sure how handy this can come later, but I think it doesn't hurt to leave it there

from confopt.oneshot.base import OneShotComponent


class CompositeSampler(OneShotComponent):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why inherit from OneShotComponent? Why not inherit from BaseSampler?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was in 2 minds with it as well, but for me, functionality wise- I don't see it as a child of BaseSampler, since it takes a list of BaseSampler within its initialisation which i thought is a special case. So I thought a OneShotComponent is a better option for it. Let me know your opinion about it.


if sampler == SamplerType.COMPOSITE:
sub_samplers: list[BaseSampler] = []
for _, sampler_config in config.items():
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, config.items() might not return the values in a specific order. This might mean that multiple instantiations of the CompositeSampler with the same samplers might have the samplers in different order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think with python versions 3.7 and above, the insertion order is preserved

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