Repository navigation
Fix tokenizer and sampling edge cases and make asset downloads atomic - #8
Merged
Merged
Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
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.
This batch fixes tokenizer boundaries and malformed merge handling, checks numerical preconditions before allocation, and makes invalid sampling inputs report clear errors. It also makes GPT-2 downloads atomic so interrupted transfers cannot leave a partial file at the final path.
23 focused updates, preserved across 24 commits including formatting, cover matrix/norm/RoPE/attention dimension checks; GPT-2 whitespace and hash-prefixed BPE merges; malformed/duplicate/missing merge entries; checked decoding and sampling APIs; f64 sampling weights; deterministic top-k ties; zero-probability boundaries; generation stop-token validation; public MLP layer validation; atomic downloads with output-directory, timeout, force-refresh and transfer-length options; and downloader CI/documentation. Final review also added signed-zero tie handling and fast returns for empty matrix outputs.
Tokenizer boundaries and header handling were checked against the Hugging Face GPT-2 implementation. Seeded stochastic output may differ from earlier versions because candidate ordering and probability arithmetic changed. Existing decoding methods retain their permissive API; the new try_decode methods reject unknown IDs.
Validation: regression tests include overflow, whitespace, hash merges, invalid logits/temperature, sampling boundaries, mutated model layers, and mocked download success/failure/truncation. Required Linux/macOS CI passed. Ubuntu ran 68 library tests, 5 CLI tests, 6 network-free downloader tests, formatting, Clippy, and CLI smoke checks. macOS passed its release build, Metal-inclusive Clippy, and Rust tests. The downloader tests use no network; pretrained GPT-2 assets and on-device Metal parity are not exercised by this batch.