Skip to content

llama: enable shape-aware sampler probing - #29180

Closed
aparmp-quic wants to merge 2 commits into
ggml-org:masterfrom
qualcomm:aparmp/shape-aware-sampler
Closed

aparmp-quic wants to merge 2 commits into
ggml-org:masterfrom
qualcomm:aparmp/shape-aware-sampler

Conversation

@aparmp-quic

Copy link
Copy Markdown
Contributor

Overview

Backend sampler capability checks currently use a fixed candidate count when probing backend support. This may reject valid backend configurations for models with smaller vocabularies.

This change makes sampler probing shape-aware by using the actual model vocabulary size when evaluating backend support.

Additional information

The sampler currently checks backend support using a hardcoded candidate count of 1024 * 1024. Since models can have different vocabulary sizes, this can incorrectly reject valid TOP_K configurations.

Motivation: This issue was identified while enabling TOP_K support for the Hexagon backend (PR #29113). Model vocabularies such as Qwen (~152K) and Gemma (~262K) are significantly smaller than the probe size, which can incorrectly reject otherwise supported configurations. The sampler now uses the model vocabulary size during backend capability probing.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, for identifying the corresponding sampler changes. All the changes are manually reviewed and tested.

@github-actions github-actions Bot added the testing Everything test related label Sep 20, 2026
@aparmp-quic

Copy link
Copy Markdown
Contributor Author

cc: @max-krasnyansky

@max-krasnyansky

Copy link
Copy Markdown
Member

@ggerganov any comments/suggestions on this?
If you want to iterate further I can move it to a branch in ggml-org/llama.cpp

@ggerganov

Copy link
Copy Markdown
Member

This change would require a major version bump. If we can just reduce the probe size to something like 128k, I would prefer this since it's much simpler solution.

@max-krasnyansky

Copy link
Copy Markdown
Member

This change would require a major version bump. If we can just reduce the probe size to something like 128k, I would prefer this since it's much simpler solution.

New PR coming shortly.

@max-krasnyansky

Copy link
Copy Markdown
Member

@ggerganov
Here is the simpler version #29285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants