feat: per-string hashing of Ragged containers (md5/sha256/rapidhash)#65
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add noqa rationale comment to def hash() matching rag.zip style - Parametrize rapidhash grouped test over both _chars_r2 and _opaque_under_axis - Add test_leading_fixed_dims_regular_output verifying the (B, M, None) reshape branch - Fix SKILL.md quick-ref table hash row to have 3 columns Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Merging this PR will not alter performance
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
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.
Summary
Adds per-string hashing of
Raggedstring containers via three algorithms, backed by a single rayon-parallel Rust kernel:seqpro.rag.hash(rag, algo, *, seed=None)(canonical free function) andRagged.hash(algo, *, seed=None)(thin delegator).algo:"md5"→(N, 16)uint8,"sha256"→(N, 32)uint8,"rapidhash"→(N,)uint64.seedis rapidhash-only.Raggedreusing the input's outer offsets when they are.'S'leaf and chars|S1leaf) at ragged depth R=1 and R=2.Implementation
src/hashing.rs):_ragged_hashPyO3 kernel — generichash_elems<D: Digest>for md5/sha256 (RustCrypto), portable C++-compatiblerapidhash_v1for rapidhash. All compute runs insidepy.detach(...)capturing onlyUngilslices, per the project's PyO3 convention. Depsdigest/md-5/sha2/rapidhashadded; registered inlib.rs.rag/_ops.py,_core.py,__init__.py): normalizes any string representation to the kernel's(data, delimiters)contract viato_packed(), then shapes the output. Follows the free-function-canonical / method-delegator idiom (mirrorsreverse_complement,concatenate).skills/seqpro/SKILL.md"Hashing strings" subsection + quick-ref row;CLAUDE.mdrecords the free-function/delegator idiom convention.Testing
tests/test_ragged_hash.py— 22 tests: crypto byte-for-byte vshashlib, rapidhash identity/seed/determinism, both string representations × R=1/R=2, grouped→Ragged with correct outer offsets, leading-fixed-dims reshape path, gathered/unpacked input, empty container, and all error paths (numeric, record, unknown algo, seed-on-crypto). Full suite: 612 passed, 2 skipped, 2 xfailed, 2 xpassed.cargo fmt/clippyandruffclean.Developed task-by-task via subagent-driven development; final whole-branch review (Opus) verified GIL detachment, rapidhash v1 portability/determinism, and the unified delimiter contract across all four input shapes — ready to merge, zero Critical/Important findings.
🤖 Generated with Claude Code