Skip to content
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

Feature: Multinomial sampling #2850

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Pablo1785
Copy link
Contributor

@Pablo1785 Pablo1785 commented Feb 28, 2025

Pull Request Template

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

Would resolve:
#1121

Since the discussion seemed to die down in the issue and I found myself in need of the Multinomial distribution sampler, I decided to take a shot at implementing this.

One issue to solve is how to pass the probabilities to the Cube Launch (how to turn a Tensor into a TensorArg?)

Changes

Add multinomial distribution implementation for all backends. Potential breaking change: Distribution can no longer derive Copy, since Multinomial distribution has to contain a collection of probabilities, which could potentially be very large.

Testing

Describe how these changes have been tested.

@ArthurBrussee
Copy link
Contributor

Great timing as I quite need this function! I just need the CubeCL version, would you say that is already usable? Any plans to continue this PR? Thank you for the contribution

@Pablo1785
Copy link
Contributor Author

@ArthurBrussee Hey, so I am currently kinda stuck on the CubeCL version, as I am very new to CubeCL in general.

I will then want to run some benchmarks to make sure nothing silly is happening, especially with the Candle backend. I tested it a little locally and it seems to work well, but I wanna make sure it is at least as good as the CPU impl for large Tensors + that it uses GPU resources as much as possible.

@Pablo1785 Pablo1785 force-pushed the feat/multinomial_sampling branch from dd3883c to b1a0b95 Compare March 18, 2025 08:44
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