Repository navigation
Description
Problem / Background
Three small gaps from recent model ports. Implement all three in one PR, run the verification block once at the end, and keep pushes to a minimum.
1. eos_token_id wraps silently when narrowed to i32
LimiteConfig::eos_token_ids (src/models/limite_config.rs:335-346, #3251) and Xing4.0's parse_eos (src/models/xing4_0.rs:133-144, #3276) convert as_i64() with as i32, so an id outside the i32 range wraps to a different token and generation stops on the wrong id, and a negative id is accepted although it can never match. Refuse such ids in each config's existing validate() (limite_config.rs:187, xing4_0.rs:148) with an error naming the value, and convert with i32::try_from as src/loading/mod.rs:121 already does.
- Tests fail on current main:
eos_token_id: 4294967298and[-1]make bothvalidate()calls returnErr; in-range ids parse as today.
2. Z1T panics on a sequence id it has not prepared
Z1t::forward_rows_for_sequence (src/models/z1t.rs:257-261, #3249) uses with_existing_sequence_state and panics with Z1T missing model-owned sequence state when the id was not prepared. 32 sibling families (AFMoE's forward_for_sequence, src/models/afmoe.rs:1495) create the state lazily with with_or_create_sequence_state(seq_id, || self.fresh_states(), ..). Switch Z1T's single-sequence path to that; the batched path's validate_sequence_states panic stays, matching siblings.
- Test fails on current main:
forward_with_sequence_idwith a fresh id returns logits equal to the no-id forward of the same prompt.
3. K2-Horizon reasoning stays in content
The K2-Horizon template (models/k2-horizon-0.9b/chat_template.jinja:1018-1028, #3243) primes the generation prompt with <ifm|think>, <ifm|think_fast> or <ifm|think_faster> (by reasoning_effort), so the model emits only the reasoning and the matching close tag. None of the marker tables know these pairs, so the reasoning and </ifm|think> reach content (documented as a limitation in docs/supported-models.md). Register the three pairs in all five tables: SINGLE_TOKEN_PAIRS (src/tokenizer/mod.rs:544), resolve_thinking_token_ids (src/server/thinking_budget.rs:254), CHAT_DELIMITERS and the pair lookup (src/server/tool_calls/stream_filter.rs:418, :195) and THINKING_MARKER_PAIRS (src/server/tool_calls/parser.rs:47), with the primed-open handling Kimi K3 uses. Remove the limitation from the docs.
- Parser and stream-filter tests fail on current main: a primed
<ifm|think>generationabc\n</ifm|think>\nansweryieldsreasoning_contentabcandcontentanswer, for all three effort variants, streaming and non-streaming. -
/v1/chat/completionsonmodels/k2-horizon-0.9breturns non-emptyreasoning_contentand noifm|thinktext incontent.
Verification
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --features metal,accelerate -- -D warnings
cargo test --workspace --profile test-fast --features metal,accelerate -- --test-threads=1 limite xing4_0 z1t tool_calls thinking tokenizer
Activity
fix(models): close eos range, Z1T sequence and K2-Horizon reasoning gaps
fix(models): close eos range, Z1T sequence and K2-Horizon reasoning g…