Repository navigation
Conversation
…lding one string The prompt key hashed a comma-joined string of every token id: on a 94K-token prompt that is ~700 KB of text plus 94K small strings, about 12 MiB allocated per request, all thrown away once the digest exists. Feed the same bytes to sha256 in 4096-token slices instead, with the comma the boundary needs, so the digest and the seed are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Effect
seed_foron a 94K-token prompt stops building a ~700 KB string and ~94K small strings: about 12 MiB allocated per request becomes ~30 KB a slice.Reproduce
python3 -m pytest -q tests/test_seed_for.py # the sliced digest equals the one-join form at 0, 1, 4095, 4096, 4097, 8192, 8193 and 50k tokensChange
exact_sampling.seed_for:hashlib.sha256()updated once per 4096-token slice, then the salt; the joined form is gone.Why
Type
type: fix: a bug fix, or a fix after review findingsTests
tests/test_seed_for.py: 12 cases, all passing;test_seed_salt.pyandtest_exact_sampling.pyunchanged (the one failure there is inknown-test-failures.txt).Checklist
AI disclosure
AI: Claude Opus 5.5 via Hermes Agent
Checked: by author