mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2977] [CLOSED] [Engine] logit_bias: accept it with --batch (one bias table per slot) #4375
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#4375
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/2977
Author: @qni-live
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:logit-bias-batch📝 Commits (1)
648c43clogit_bias: accept it with --batch, one bias table per slot📊 Changes
8 files changed (+221 additions, -20 deletions)
View changed files
📝
docs/LOGIT_BIAS.md(+20 -6)📝
include/strata/core/verify.hpp(+14 -1)📝
serve/logit_bias.py(+5 -4)📝
serve/test_logit_bias.py(+5 -0)📝
src/core/verify.cpp(+37 -1)📝
src/program/generate.cpp(+8 -3)➕
tools/batch_bias_reuse_test.py(+101 -0)📝
tools/batch_test.py(+31 -5)📄 Description
Problem and result
logit_biasis refused whenever the engine runs with--batch. That makes the Han/Kana/Hangul ban (docs/LOGIT_BIAS.md) unusable on a 4-slot server, which is the setup for several parallel agents.Result: each batch slot can carry its own bias table, and a bias reaches only its own request. A slot that is reused by a request without a bias carries nothing over.
--batch-mtpstill refuses it.This PR is rebased on
mainfor 0.2.0-beta (e88ee39d, tagv0.2.0-beta); it applies without conflicts. #1891 is already inmain, so nothing of it is repeated here.Related discussion
none. There is no open issue;
--batchanswerslogit_biaswith HTTP 400 today. It is a focused change that lifts one refusal and adds no new request field.Approach
include/strata/core/verify.hpp,src/core/verify.cpp:Verifier::set_slot_logit_bias(slot, bias, err)andslot_has_bias(slot). Only the final stage allocates a table (one float per vocabulary entry, about 1 MB for 248,320 tokens) and copies it, and only when it changed.set_slot_samplingkeeps the slot's table pointer.init_slotsfrees and clears the tables.sample_rows: a greedy row whose slot has a table is drawn on the last stage like a sampled row, because the graph's argmax does not know the bias. Rows without a table take the same path as before.src/program/generate.cpp: the bias is set at admission, beforeset_slot_sampling; an empty one clears the slot.--batch-mtpstill answersERR logit_bias: --batch-mtp does not take it yet.INFOadvertiseslogit_bias_batch=1.serve/logit_bias.py: the server refuses--batchonly when the engine does not advertiselogit_bias_batch=1, so older engines keep the clear 400.tools/batch_test.py --bias-han(every second prompt carries the ban and asks for Chinese) and the newtools/batch_bias_reuse_test.py(3 waves, banned and free prompts swap slots every wave; a slot's tokens must equal its solo tokens).docs/LOGIT_BIAS.mdandserve/test_logit_bias.pyupdated.Validation
Environment: 2x RTX PRO 4500 Blackwell (32 GB each), Linux 7.0.0-38, driver 595.91.07, CUDA 13.4 source build (sm_120) of
maine88ee39dplus this commit (a7026916), Swift IQ3_XXS,--batch 4 --trim-stage-weights --pipeline-windows 2, layer split 25,STRATA_IQ_MT_MIN=1 --pcie-frac 0 --adapt-every 1000000, 64 new tokens, 65,842 banned tokens (all Han/Kana/Hangul). Each test compares a slot's tokens with the same request run alone. Run on 2026-10-19; logpr2977-tests-lauf.log.Passed:
python3 tools/batch_test.py ... --batch 4 --n 4 --extra "--pcie-frac 0 --adapt-every 1000000 --batch-groups 1", no bias anywhere: 4 of 4 slots identical to solo.--bias-han, ban on 2 of 4 slots, greedy,--batch-groups 1: 4 of 4 identical, 0 Han/Kana/Hangul characters in the banned slots.--batch-groupsauto: 4 of 4 identical, 0 CJK characters in the banned slots.python3 tools/batch_bias_reuse_test.py ... --waves 3, greedy: 12 of 12 slot rows identical to solo, RESULT: PASS.temperature=0.7 top_k=20 seed=7): 12 of 12 identical, RESULT: PASS.python3 -m pytest serve/test_logit_bias.py: 12 passed, 19 subtests passed.cmake --build build -j 40: builds (CUDA).Failed:
none observed on this revision. My first run of the series used a relative
--exethat resolved to an older build and answeredcontinuous batching is not supported; I discarded it and reran with an absolute path. The results above are from the rerun only.Not run:
src/core/verify.cppandsrc/program/generate.cpp; only CUDA was built and run.--batch) against the packaged 0.2.0-beta engine 0.1.45.3. The no-bias slots equal their solo run on the changed build; I did not diff them against the release binary.--batch-mtpwith a bias after the rebase (it is unchanged by this PR), the Qwen3.6 engine path, layer splits over three or more GPUs, and a start with the Windows or Mac engine.Limits
--batch-mtpstill refuseslogit_bias.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.