Repository navigation
Make whole-word generation faster and give it natural context - #26
Conversation
Each beam extension ran its own forward pass. Extensions at one depth share a length, so they now run as one batched pass over a selectable attention cache, using a Llama forward adapted from candle-transformers 0.11.0 with the same operation order. Search stops once later completions, bounded by each beam's non-boundary probability, can no longer change the ranked words, so results match the full search. Generation now sees the current sentence as typed instead of lowercased and stripped of punctuation. Reranking and statistical prediction are unchanged. generation_evaluate.py gains --natural-context to measure it. On the frozen workload (AVX2, 1,760 queries) median latency falls from 581 to 121 ms with identical words; portable falls from 1,257 to 424 ms. Natural context raises six-slot top six from 72.4% to 73.2%. Closes #25 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 1600 ms check now reserves the previous batch's duration, so a batch cannot start just before the cutoff and overrun the parent deadline. An ignored real-model test compares every batched row with a single-row forward. The early-stop property test also covers an empty context, and more opening quotes are dropped from generation context. Refs #25 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review of
|
|
CI generation-qualification on
On the Windows runner the old search hit the 1,600 ms cutoff on most queries (median above 1,600 ms), so results there depend on timing. The new search still hits the cutoff often on that runner. On a local Ryzen, the portable worker went from 1,257 ms to 424 ms with identical words. The single macOS generation failure isn't explained by the report. The previous run had a comparable single rerank failure. A real-device macOS check would rule out a deadline problem. |
Closes #25
The model, tokenizer,
model-bundle.json, search policy (width 8, 8 tokens, 64 evaluations, 1,600 ms cutoff) and worker protocol 2 are unchanged. No release is prepared.Changes
neural/worker/src/generation.rs,llama.rs,model.rs). Every extension at a depth has the same length, so they run as one forward pass. The rows of the attention cache are selected by parent beam.llama.rsadapts candle-transformers 0.11.0quantized_llama(MIT OR Apache-2.0) and keeps its operation order. Each extension still counts as one evaluation. The 1,600 ms cutoff is checked before each depth and reserves the previous batch's duration.neural/src/lib.rs).generation_contextkeeps the current sentence as typed. It collapses whitespace and drops trailing opening quotes and brackets.effective_context(reranking) is unchanged.--natural-contextforscripts/generation_evaluate.py, anddocs/generation-performance.md.Results
Frozen workload, Windows 11 on a Ryzen AI 9 HX 370, 4 threads, fresh context per query:
With natural context, six-slot top six goes from 72.4% to 73.2% (28 queries gained, 15 lost), and neural fill goes from 93.7% to 94.8%. Peak RSS is unchanged at about 660 MiB. A 16-wide beam added only 0.5 points for 65% more latency, so width stays at 8. macOS ARM was not measured here.
Validation
cargo fmt --check,cargo clippy --workspace --all-targets --features test-support --locked -D warningsandcargo test --workspace --features test-support --lockedall pass.pinned_model_order_and_session_cacheshows the adapted forward pass reproduces the frozen ranking, andbatched_rows_match_single_row_forwardschecks every batched row against a single-row forward pass (within 1e-3).python -m unittest test_neuralpasses.Rolling this out to Switchify PC needs a release with new worker binaries and a library pin bump. The model bundle is unchanged.
🤖 Generated with Claude Code