[PR #15158] [MERGED] bench: add prompt calibration, context size flag, and NumCtx reporting #25594

Closed
opened 2026-04-19 18:17:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15158
Author: @dhiltgen
Created: 3/31/2026
Status: Merged
Merged: 4/2/2026
Merged by: @dhiltgen

Base: mainHead: bench_ctx


📝 Commits (1)

  • 35f69c7 bench: add prompt calibration, context size flag, and NumCtx reporting

📊 Changes

1 file changed (+61 additions, -8 deletions)

View changed files

📝 cmd/bench/bench.go (+61 -8)

📄 Description

Add --num-ctx flag to set context size, and report NumCtx in model info header. Calibrate tokens-per-word ratio during warmup using actual tokenization metrics from the model, replacing the fixed 1.3 heuristic. This produces more accurate prompt token counts for --prompt-tokens.

Also add fetchContextLength() to query running model context via /api/ps.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15158 **Author:** [@dhiltgen](https://github.com/dhiltgen) **Created:** 3/31/2026 **Status:** ✅ Merged **Merged:** 4/2/2026 **Merged by:** [@dhiltgen](https://github.com/dhiltgen) **Base:** `main` ← **Head:** `bench_ctx` --- ### 📝 Commits (1) - [`35f69c7`](https://github.com/ollama/ollama/commit/35f69c7529a5f02c92d9492ee56bffdcf474f23e) bench: add prompt calibration, context size flag, and NumCtx reporting ### 📊 Changes **1 file changed** (+61 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `cmd/bench/bench.go` (+61 -8) </details> ### 📄 Description Add --num-ctx flag to set context size, and report NumCtx in model info header. Calibrate tokens-per-word ratio during warmup using actual tokenization metrics from the model, replacing the fixed 1.3 heuristic. This produces more accurate prompt token counts for --prompt-tokens. Also add fetchContextLength() to query running model context via /api/ps. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:17:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25594