Skip to content

fix(models): close eos range, Z1T sequence and K2-Horizon reasoning gaps #3299

Closed

Description

@inureyes

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: 4294967298 and [-1] make both validate() calls return Err; 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_id with 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> generation abc\n</ifm|think>\nanswer yields reasoning_content abc and content answer, for all three effort variants, streaming and non-streaming.
  • /v1/chat/completions on models/k2-horizon-0.9b returns non-empty reasoning_content and no ifm|think text in content.

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

  1. added
    status:ready
    type:bug
    priority:low
    area:models
    status:in-progress
    status:review
    status:done
    and removed
    status:ready
    status:in-progress
    status:review
    on Nov 23, 2026
  2. added a commit that references this issue on Nov 23, 2026
    ca7ea1b
  3. added this to the 0.9 milestone on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:modelspriority:lowstatus:donetype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions