mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2646] [CLOSED] batch: repetition / frequency / presence penalties apply in the batch windows (a slot counts its own conversation's tokens) #4188
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4188
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2646
Author: @qiuzan2001
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:qiuzan2001/batch-penalties📝 Commits (1)
5145439batch: repetition, frequency and presence penalties apply in the batch windows (one window at a time; a slot counts its own conversation's tokens)📊 Changes
5 files changed (+78 additions, -10 deletions)
View changed files
📝
docs/BATCHING.md(+4 -2)📝
docs/DETAILS.md(+3 -1)📝
include/strata/core/verify.hpp(+16 -3)📝
src/core/verify.cpp(+15 -4)📝
src/program/generate.cpp(+40 -0)📄 Description
docs/BATCHING.md lists, under "Limits (for now)": Repetition / frequency / presence penalties are not applied in batch windows. This applies them.
What it changes
Verifier::sample_rows(src/core/verify.cpp) clearedpenalty_last_nfor every slot row and handed the sampler no history, so a request withrepetition_penalty/frequency_penalty/presence_penaltydecoded in a slot as if it had none. It now samples a row whose slot has penalties on the host side with that row's history, greedy or not (the graph's argmax pick is replaced, as the solo path does for a greedy request with penalties).batch_step(src/program/generate.cpp) stages one history row per window row from the slot's own tokens,idsfollowed by the token the row feeds, and with--batch-mtpthe proposal row follows the fed token too. The rows are built by the samestrata::kernels::penalty_rowsthe solo path uses, so a slot counts exactly what plain decode of that conversation would count. A newVerifier::set_slot_historyhands them over (it reaches the last stage of a layer split, where the rows are sampled; the buffer is on that device, next to the solo path's).BSlot::penalty_last_n, set at admission from the request's sampling.tools/batch_test.pyrow says how to check it. docs/DETAILS.md: one sentence in the penalties paragraph.What it leaves alone
penalty_last_nis 0).--batch-groupsabove 1) never stage rows and are unchanged. The docs say so.verify.cpp/generate.cppand is not changed; its batch windows still skip penalties (the docs say so).How it was checked
RTX 5070 Ti 16 GB, Ryzen 7 5800X3D, Linux, CUDA 13.1 (arch 120); Swift 1.5 IQ3_S;
tools/batch_test.py --batch 2 --n 2 --max-new 64 --extra "--max-context 32768 --pcie-frac 0 --adapt-every 1000000"(the script setsSTRATA_IQ_MT_MIN=1), on the binary before this change and after it, the engine restarted for every arm:--keyspenalty_repeat=1.5 penalty_last_n=64--batch-mtp... temperature=0.7 top_k=20 seed=11The solo tokens with penalties are the same on both binaries. An independent review pass read the diff (row/slot mapping across stages, the history contract against the solo path's
consumed+window, buffer bounds, the no-penalty path) and found nothing to change beyond the docs wording above.Not built: HIP (no AMD card here;
src/core/verify.cppandsrc/program/generate.cppare the shared sources), Metal (no Mac). SYCL not touched.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.