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

Implement new sampler API and bump llama.cpp #580

Merged
merged 8 commits into from
Nov 27, 2024

Conversation

volesen
Copy link
Contributor

@volesen volesen commented Nov 26, 2024

llama.cpp introduces a new sampling API in b3680. This PR aims to replace the previous custom sampling API, with a wrapper around the new llama.cpp sampling abstraction.

We remove the custom sampling functions from LlamaContext, so this is a breaking change.

Furthermore, we bump llama.cpp to b3750, which finalizes the new llama_perf features, so we can more easily preserve the timings API.

Credits to @brittlewis12, whose draft we copied in large parts. (#548)

It's probably worth it to squash commits before merging.

The new sampler is showcased in the simple example and can be used like this:

let sampler_params = LlamaSamplerChainParams::default();
let mut sampler = LlamaSampler::new(sampler_params)?.add_dist(seed.unwrap_or(1234));
let new_token = sampler.sample(&ctx, batch.n_tokens() - 1);
sampler.accept(token);

This commit implements the new sampler API from `llama.cpp`
introduced in b3680 and removes the custom sampling logic.

The new sampling API is exposes through a builder pattern.

Made tests pass.
@MarcusDunn
Copy link
Contributor

MarcusDunn commented Nov 27, 2024

awesome work! I'll get this in + release soon as checks look good.

@MarcusDunn MarcusDunn merged commit 42aaeeb into utilityai:main Nov 27, 2024
2 of 5 checks passed
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.

3 participants