[GH-ISSUE #6275] provide better hashing algorithm #3932

Closed
opened 2026-04-12 14:48:35 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @olumolu on GitHub (Aug 9, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6275

Blake3 is better faster more secure and more advance switching to this makes sense so switch to it from sha256 will give a better faster safer alternative.

Originally created by @olumolu on GitHub (Aug 9, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6275 Blake3 is better faster more secure and more advance switching to this makes sense so switch to it from sha256 will give a better faster safer alternative.
GiteaMirror added the feature request label 2026-04-12 14:48:35 -05:00
Author
Owner

@mxyng commented on GitHub (Aug 15, 2024):

While blake3 is faster in theory, the (go) implementation still isn't quite there. Here's a comparison of 2 popular implementations vs. crypto/sha256 hashing llama3.1:8b-instruct-q4_0 (approx. 4.3GB) with a 8KB buffer on M3 Max:

$ benchstat -col /hash bench.txt
goos: darwin
goarch: arm64
pkg: github.com/ollama/ollama
        │ crypto-sha256 │       lukechampine.com-blake3       │       github.com-zeebo-blake3       │
        │    sec/op     │   sec/op    vs base                 │   sec/op    vs base                 │
Hash-16      1.930 ± 1%   6.483 ± 0%  +235.83% (p=0.000 n=10)   5.882 ± 0%  +204.67% (p=0.000 n=10)

        │ crypto-sha256 │       lukechampine.com-blake3        │       github.com-zeebo-blake3        │
        │     B/op      │     B/op      vs base                │     B/op      vs base                │
Hash-16    40.47Ki ± 0%   58.34Ki ± 0%  +44.17% (p=0.000 n=10)   50.97Ki ± 0%  +25.95% (p=0.000 n=10)

        │ crypto-sha256 │   lukechampine.com-blake3    │   github.com-zeebo-blake3    │
        │   allocs/op   │ allocs/op   vs base          │ allocs/op   vs base          │
Hash-16      9.000 ± 0%   9.000 ± 0%  ~ (p=1.000 n=10)   9.000 ± 0%  ~ (p=1.000 n=10)

In summary, crypto/sha256 is really fast, roughly 3x faster than either blake3 implementations.

This is not to say ollama is committed to using sha256 forever. Ollama will continue to use the best tools for the job whether that is sha256 or blake3 or some other algorithm.

<!-- gh-comment-id:2292040032 --> @mxyng commented on GitHub (Aug 15, 2024): While blake3 is faster in theory, the (go) implementation still isn't quite there. Here's a comparison of 2 popular implementations vs. crypto/sha256 hashing llama3.1:8b-instruct-q4_0 (approx. 4.3GB) with a 8KB buffer on M3 Max: ``` $ benchstat -col /hash bench.txt goos: darwin goarch: arm64 pkg: github.com/ollama/ollama │ crypto-sha256 │ lukechampine.com-blake3 │ github.com-zeebo-blake3 │ │ sec/op │ sec/op vs base │ sec/op vs base │ Hash-16 1.930 ± 1% 6.483 ± 0% +235.83% (p=0.000 n=10) 5.882 ± 0% +204.67% (p=0.000 n=10) │ crypto-sha256 │ lukechampine.com-blake3 │ github.com-zeebo-blake3 │ │ B/op │ B/op vs base │ B/op vs base │ Hash-16 40.47Ki ± 0% 58.34Ki ± 0% +44.17% (p=0.000 n=10) 50.97Ki ± 0% +25.95% (p=0.000 n=10) │ crypto-sha256 │ lukechampine.com-blake3 │ github.com-zeebo-blake3 │ │ allocs/op │ allocs/op vs base │ allocs/op vs base │ Hash-16 9.000 ± 0% 9.000 ± 0% ~ (p=1.000 n=10) 9.000 ± 0% ~ (p=1.000 n=10) ``` In summary, `crypto/sha256` is really fast, roughly 3x faster than either blake3 implementations. This is not to say ollama is committed to using sha256 forever. Ollama will continue to use the best tools for the job whether that is sha256 or blake3 or some other algorithm.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3932