[PR #13513] re-enable granite-embedding #40121

Open
opened 2026-04-23 01:06:04 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13513
Author: @mxyng
Created: 12/17/2025
Status: 🔄 Open

Base: mainHead: mxyng/tokenizer


📝 Commits (2)

  • 05711b7 re-enable new engine granite embedding
  • f52671e refactor: bpe and spm tokenizer merges

📊 Changes

4 files changed (+78 additions, -135 deletions)

View changed files

📝 model/bytepairencoding.go (+38 -58)
📝 model/models/bert/embed.go (+3 -0)
📝 model/sentencepiece.go (+37 -76)
📝 server/routes.go (+0 -1)

📄 Description

  • merge candidates and pairs which are essentially the same other than the type for rank/score
  • use binaryheap in sentencepiece instead of implement custom structure
  • update merging algorithm so it uses about 15% less allocations
goos: darwin
goarch: arm64
pkg: github.com/ollama/ollama/model
cpu: Apple M3 Max
                                  │   old.txt   │              new.txt               │
                                  │   sec/op    │   sec/op     vs base               │
BytePairEncoding/encode1-16         805.6n ± 1%   807.9n ± 1%        ~ (p=0.394 n=6)
BytePairEncoding/encode10-16        1.877µ ± 1%   1.868µ ± 0%        ~ (p=0.113 n=6)
BytePairEncoding/encode100-16       17.57µ ± 1%   17.00µ ± 1%   -3.24% (p=0.002 n=6)
BytePairEncoding/encode1000-16      156.1µ ± 1%   151.7µ ± 0%   -2.81% (p=0.002 n=6)
BytePairEncoding/encode10000-16     1.491m ± 0%   1.452m ± 0%   -2.66% (p=0.002 n=6)
BytePairEncoding/encode100000-16    15.00m ± 2%   14.56m ± 1%   -2.95% (p=0.002 n=6)
BytePairEncoding/encode1000000-16   156.5m ± 0%   152.2m ± 2%   -2.74% (p=0.002 n=6)
BytePairEncoding/encode3202320-16   535.8m ± 9%   471.0m ± 1%  -12.10% (p=0.002 n=6)
geomean                             545.0µ        526.4µ        -3.40%

                                  │   old.txt    │               new.txt                │
                                  │     B/op     │     B/op      vs base                │
BytePairEncoding/encode1-16           712.0 ± 1%     712.0 ± 1%       ~ (p=1.000 n=6)
BytePairEncoding/encode10-16        1.523Ki ± 0%   1.523Ki ± 0%       ~ (p=1.000 n=6) ¹
BytePairEncoding/encode100-16       13.35Ki ± 2%   12.14Ki ± 2%  -9.07% (p=0.002 n=6)
BytePairEncoding/encode1000-16      118.1Ki ± 0%   109.4Ki ± 0%  -7.34% (p=0.002 n=6)
BytePairEncoding/encode10000-16     1.102Mi ± 0%   1.014Mi ± 0%  -8.01% (p=0.002 n=6)
BytePairEncoding/encode100000-16    11.42Mi ± 0%   10.61Mi ± 0%  -7.05% (p=0.002 n=6)
BytePairEncoding/encode1000000-16   118.1Mi ± 0%   110.0Mi ± 0%  -6.91% (p=0.002 n=6)
BytePairEncoding/encode3202320-16   372.9Mi ± 0%   347.4Mi ± 0%  -6.82% (p=0.002 n=6)
geomean                             422.6Ki        398.5Ki       -5.71%
¹ all samples are equal

                                  │   old.txt   │               new.txt                │
                                  │  allocs/op  │  allocs/op   vs base                 │
BytePairEncoding/encode1-16          21.00 ± 0%    21.00 ± 0%        ~ (p=1.000 n=6) ¹
BytePairEncoding/encode10-16         39.00 ± 0%    39.00 ± 0%        ~ (p=1.000 n=6) ¹
BytePairEncoding/encode100-16        308.0 ± 0%    262.0 ± 0%  -14.94% (p=0.002 n=6)
BytePairEncoding/encode1000-16      2.464k ± 0%   2.140k ± 0%  -13.15% (p=0.002 n=6)
BytePairEncoding/encode10000-16     23.39k ± 0%   20.04k ± 0%  -14.32% (p=0.002 n=6)
BytePairEncoding/encode100000-16    227.1k ± 0%   196.6k ± 0%  -13.42% (p=0.002 n=6)
BytePairEncoding/encode1000000-16   2.281M ± 0%   1.973M ± 0%  -13.52% (p=0.002 n=6)
BytePairEncoding/encode3202320-16   7.191M ± 0%   6.230M ± 0%  -13.36% (p=0.002 n=6)
geomean                             9.262k        8.286k       -10.53%
¹ all samples are equal

🔄 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/13513 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 12/17/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `mxyng/tokenizer` --- ### 📝 Commits (2) - [`05711b7`](https://github.com/ollama/ollama/commit/05711b77daf1f6d1812cc4d1807957cc1d48045c) re-enable new engine granite embedding - [`f52671e`](https://github.com/ollama/ollama/commit/f52671ecc680c3d09b739b36a8570467f41c40a7) refactor: bpe and spm tokenizer merges ### 📊 Changes **4 files changed** (+78 additions, -135 deletions) <details> <summary>View changed files</summary> 📝 `model/bytepairencoding.go` (+38 -58) 📝 `model/models/bert/embed.go` (+3 -0) 📝 `model/sentencepiece.go` (+37 -76) 📝 `server/routes.go` (+0 -1) </details> ### 📄 Description - merge candidates and pairs which are essentially the same other than the type for rank/score - use binaryheap in sentencepiece instead of implement custom structure - update merging algorithm so it uses about 15% less allocations - ``` goos: darwin goarch: arm64 pkg: github.com/ollama/ollama/model cpu: Apple M3 Max │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ BytePairEncoding/encode1-16 805.6n ± 1% 807.9n ± 1% ~ (p=0.394 n=6) BytePairEncoding/encode10-16 1.877µ ± 1% 1.868µ ± 0% ~ (p=0.113 n=6) BytePairEncoding/encode100-16 17.57µ ± 1% 17.00µ ± 1% -3.24% (p=0.002 n=6) BytePairEncoding/encode1000-16 156.1µ ± 1% 151.7µ ± 0% -2.81% (p=0.002 n=6) BytePairEncoding/encode10000-16 1.491m ± 0% 1.452m ± 0% -2.66% (p=0.002 n=6) BytePairEncoding/encode100000-16 15.00m ± 2% 14.56m ± 1% -2.95% (p=0.002 n=6) BytePairEncoding/encode1000000-16 156.5m ± 0% 152.2m ± 2% -2.74% (p=0.002 n=6) BytePairEncoding/encode3202320-16 535.8m ± 9% 471.0m ± 1% -12.10% (p=0.002 n=6) geomean 545.0µ 526.4µ -3.40% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ BytePairEncoding/encode1-16 712.0 ± 1% 712.0 ± 1% ~ (p=1.000 n=6) BytePairEncoding/encode10-16 1.523Ki ± 0% 1.523Ki ± 0% ~ (p=1.000 n=6) ¹ BytePairEncoding/encode100-16 13.35Ki ± 2% 12.14Ki ± 2% -9.07% (p=0.002 n=6) BytePairEncoding/encode1000-16 118.1Ki ± 0% 109.4Ki ± 0% -7.34% (p=0.002 n=6) BytePairEncoding/encode10000-16 1.102Mi ± 0% 1.014Mi ± 0% -8.01% (p=0.002 n=6) BytePairEncoding/encode100000-16 11.42Mi ± 0% 10.61Mi ± 0% -7.05% (p=0.002 n=6) BytePairEncoding/encode1000000-16 118.1Mi ± 0% 110.0Mi ± 0% -6.91% (p=0.002 n=6) BytePairEncoding/encode3202320-16 372.9Mi ± 0% 347.4Mi ± 0% -6.82% (p=0.002 n=6) geomean 422.6Ki 398.5Ki -5.71% ¹ all samples are equal │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ BytePairEncoding/encode1-16 21.00 ± 0% 21.00 ± 0% ~ (p=1.000 n=6) ¹ BytePairEncoding/encode10-16 39.00 ± 0% 39.00 ± 0% ~ (p=1.000 n=6) ¹ BytePairEncoding/encode100-16 308.0 ± 0% 262.0 ± 0% -14.94% (p=0.002 n=6) BytePairEncoding/encode1000-16 2.464k ± 0% 2.140k ± 0% -13.15% (p=0.002 n=6) BytePairEncoding/encode10000-16 23.39k ± 0% 20.04k ± 0% -14.32% (p=0.002 n=6) BytePairEncoding/encode100000-16 227.1k ± 0% 196.6k ± 0% -13.42% (p=0.002 n=6) BytePairEncoding/encode1000000-16 2.281M ± 0% 1.973M ± 0% -13.52% (p=0.002 n=6) BytePairEncoding/encode3202320-16 7.191M ± 0% 6.230M ± 0% -13.36% (p=0.002 n=6) geomean 9.262k 8.286k -10.53% ¹ all samples are equal ``` --- <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-23 01:06:04 -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#40121