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

Less Sampler Allocations #735

Merged
merged 5 commits into from
May 14, 2024

Conversation

martindevans
Copy link
Collaborator

Reduced the number of allocations required for sampling, by allowing passing in a temporary blob of memory to work in.

  • Using this new method in LLamaContext and BaseSamplingPipeline.
  • Using Guidance method in guidance example, instead of low level one working directly on logits.
  • Fixed Guidance method passing incorrectly sized span.

…g passing in a temporary blob of memory to work in. Using this new method in `LLamaContext` and `BaseSamplingPipeline`.

 - Using `Guidance` method in guidance example, instead of low level one working directly on logits.
 - Fixed `Guidance` method passing incorrectly sized span.
@martindevans
Copy link
Collaborator Author

@Lyrcaxis I'd appreciate your review on this since you've been looking at sampling things recently.

Copy link
Collaborator

@AsakusaRinne AsakusaRinne left a comment

Choose a reason for hiding this comment

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

The overall looks good except two concerns. It seems that this PR will obviously improve the performance, which is inspiring!

LLama/Sampling/BaseSamplingPipeline.cs Show resolved Hide resolved
LLama/Native/LLamaTokenDataArray.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@Lyrcaxis Lyrcaxis left a comment

Choose a reason for hiding this comment

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

Nice!

LLama/Sampling/BaseSamplingPipeline.cs Show resolved Hide resolved
LLama/Native/LLamaTokenDataArray.cs Outdated Show resolved Hide resolved
LLama/Native/LLamaTokenDataArray.cs Outdated Show resolved Hide resolved
LLama/Native/LLamaTokenDataArray.cs Outdated Show resolved Hide resolved
@martindevans martindevans merged commit 4657e98 into SciSharp:master May 14, 2024
6 checks passed
@martindevans martindevans deleted the less_sampler_allocations branch May 14, 2024 22:25
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.

None yet

3 participants