1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: MIT OR Apache-2.0
//! 2026-09-25: [`SchedulerConfig`]: everything one scheduler run is given at
//! construction. Built by `serve_load` and by the trace harness.
//!
//! Owner: scheduler.
//! Invariants: none beyond the types.
use std::sync::Arc;
use crate::grammar::GrammarEngine;
use crate::scheduler::helpers::WatchdogParams;
use crate::scheduler::levers::SchedLevers;
use crate::scheduler::limits::SchedLimits;
use crate::scheduler::vocab_masks::VocabMasks;
use crate::scheduling_policy::SchedulingPolicy;
use crate::session_manager::SessionSsmManager;
pub struct SchedulerConfig {
pub eos_tokens: Vec<u32>,
pub max_batch_size: usize,
pub use_speculative: bool,
pub dflash_verify_raw_argmax: bool,
pub num_drafts: usize,
/// 2026-09-25: `--scheduler {fifo|slai}`: admission and ordering.
pub policy: Box<dyn SchedulingPolicy>,
pub max_prefill_tokens: usize,
pub max_batch_tokens: usize,
pub use_self_speculative: bool,
pub use_ngram_speculative: bool,
/// 2026-10-02: Prompt-lookup decoding (`--prompt-lookup-decoding`) and its
/// settings; `None` when off. It composes with MTP: a sequence whose history
/// holds a match verifies the copy that round instead of the drafter's chain.
pub prompt_lookup: Option<metrale_speculative::prompt_lookup::PromptLookupConfig>,
/// 2026-10-04: The cross-request prompt-lookup cache
/// (`--prompt-lookup-shared-cache-mb`) and the model and tokenizer it is
/// keyed by; `None` when off.
pub shared_lookup: Option<crate::scheduler::shared_lookup_step::SharedLookupSetup>,
pub swap_space_gb: usize,
pub high_speed_swap_cfg: Option<metrale_storage::HighSpeedSwapConfig>,
pub block_size: usize,
pub think_end_token: Option<u32>,
pub think_start_token: Option<u32>,
pub code_fence_token: Option<u32>,
pub tool_call_start_token: Option<u32>,
pub tool_call_end_token: Option<u32>,
pub grammar_engine: Option<GrammarEngine>,
pub adaptive_sampling: bool,
pub session_manager: SessionSsmManager,
pub spontaneous_think_budget: Option<u32>,
/// 2026-09-25: Per-token masks for this model's vocabulary, indexed by token id.
pub vocab_masks: VocabMasks,
/// 2026-09-25: This model's hard stops: two tokenizer-resolved token ids and the
/// served-context ceiling.
pub limits: SchedLimits,
/// 2026-09-25: This model's watchdog tunables (MODEL.toml `[behavior]` and the
/// overrides that outrank it).
pub watchdog: WatchdogParams,
/// 2026-09-25: Shared with the dashboard, whose `/watchdog` command toggles the
/// loop watchdog mid-run.
pub levers: Arc<SchedLevers>,
/// 2026-09-25: The scheduler snapshot cell, shared with the dashboard.
pub snapshot: Arc<metrale_speculative::snapshot::SnapshotCell>,
/// 2026-09-25: The DFlash gamma resolver, configured at serve time.
pub dflash_rung: metrale_speculative::dflash_rung::DflashRung,
/// 2026-09-25: The instrument set this run feeds (`metrale_telemetry::global()` when
/// serving).
pub telemetry: &'static metrale_telemetry::Telemetry,
/// 2026-09-25: Fault injection for the pipelined decode lane; `PipelineFaults::NONE`
/// when serving.
pub pipeline_faults: super::PipelineFaults,
}