Skip to content

grammars: fix resampling logic regression - #7424

Merged
ochafik merged 2 commits into
ggml-org:masterfrom
ochafik:grammar-resampling
May 21, 2024
Merged

ochafik merged 2 commits into
ggml-org:masterfrom
ochafik:grammar-resampling

Conversation

@ochafik

@ochafik ochafik commented May 21, 2024 •

Copy link
Copy Markdown
Collaborator

I think #6240 may have undone the performance gains of #4306 (just because of extra negation in !is_resampling)

This brings them back / makes grammar sampling fast again! (#4218)

I've tested this along with #7370 (early exit) & #6811 (cache codepoints) & other changes (see benchmarks): looks like only this PR & to a lesser degree, the codepoint caching, are needed / useful.

cc/ @kalomaze, @mscheong01, @HanClinto, @AlienKevin

I'm not sure if the performance benchmark bot would now catch this kind of regression, ideas welcome!

@ochafik ochafik added performance Speed related topics and removed examples labels May 21, 2024
@mofosyne mofosyne added the Review Complexity : Low Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix label May 21, 2024

@mscheong01 mscheong01 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I believe this fix is valid. My PR modifies the optimization behavior to apply grammar checks first and then resample without them if necessary(which wouldn't happen at all since grammar checks are already applied) while it should be the opposite. Thank you for addressing this 🙇‍♂️ 🙇‍♂️

@HanClinto

Copy link
Copy Markdown
Contributor

Sorry I missed reviewing this before -- this would have been good to get vetted / merged, but now I suspect that this is going to conflict a fair bit with #8643 -- I'm not sure how imminent that PR is, but this one still may be worth pushing through.

@ggerganov ggerganov mentioned this pull request Aug 9, 2024
3 of 6 tasks
@ggerganov

Copy link
Copy Markdown
Member

I made a note to apply it within #8643

Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples performance Speed related topics Review Complexity : Low Trivial changes to code that most beginner devs (or those who want a break) can tackle. e.g. UI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants