Merge branch 'main' into claude/debt-low-docs

This commit is contained in:
Pavlo Ratushnyi
2026-11-14 21:40:20 +01:00
661 changed files with 2699 additions and 2909 deletions
Generated
+1
View File
@@ -1350,6 +1350,7 @@ dependencies = [
"leleka-cuda-driver",
"leleka-engine-core",
"leleka-experimental-ref",
"leleka-gateway-text",
"leleka-memory",
"leleka-memory-os",
"leleka-model-format",
-3
View File
@@ -3,8 +3,6 @@
"violations": [],
"oversize": {},
"source": {
"allow-unused-imports:leleka-engine-core": 18,
"allow-unused-imports:leleka-engine-qwen35-cuda": 166,
"dyn-trait:leleka-cuda-driver": 45,
"dyn-trait:leleka-engine-core": 18,
"dyn-trait:leleka-engine-fake": 1,
@@ -12,7 +10,6 @@
"env-read:leleka-engine-qwen35-cuda": 1,
"env-read:strata-control": 3,
"glob-super-import:leleka-cuda-driver": 2,
"glob-super-import:leleka-engine-qwen35-cuda": 70,
"instant-now:leleka-cuda-driver": 25,
"instant-now:leleka-engine-qwen35-cuda": 16,
"instant-now:leleka-native-cpu-expert": 27,
@@ -120,8 +120,6 @@ pub struct ConversationCache<E: ParkedConversation = SavedConversation> {
mod tests;
mod conversation_checkpoint;
#[allow(unused_imports)]
pub use conversation_checkpoint::conversation_prefix;
#[allow(unused_imports)]
pub use conversation_checkpoint::prefix_len;
mod conversation_cache;
@@ -1,5 +1,6 @@
//! Methods of `ConversationCache`: `new`, `enabled`, `budget`, `slots` and 15 more. Functions: `deepest_key`.
//! Split out of `cache` to keep its files under the line limit.
//! Behaviour of the parked-conversation cache: byte and slot accounting, the retained K/V reuse buffers, best-prefix
//! lookup, making room by eviction, removal of superseded copies and `put`.
//! Pure CPU policy; the types and the `ParkedConversation` trait it works on are in the parent `cache` module.
use super::{
CheckpointKey, ConversationCache, ConversationImageKey, ConversationKv, ConversationKvReuse, Match,
@@ -1,5 +1,5 @@
//! Methods of `ConversationCheckpoint`: `bytes`. Methods of `ConversationKv`: `bytes`, `buffers`, `buffers_mut`.
//! Implements `Default for SavedConversation`, `ParkedConversation for SavedConversation`.
//! Byte accounting of a saved checkpoint and of a layer's K/V buffers, the reuse bookkeeping for retained K/V, and
//! the `ParkedConversation` view of a host-memory `SavedConversation` (live and checkpoint keys, steering, size).
use super::{
CheckpointKey, ConversationBuffer, ConversationCheckpoint, ConversationImageKey, ConversationKv,
@@ -1,6 +1,6 @@
//! Tests of tests by topic (moved out of the test file by STRA-338):
//! retained_buffers_count_against_bytes_but_not_slots, a_b_a_recovery_and_slot_eviction,
//! checkpoints_steering_and_boundary_rules, image_identity_is_part_of_the_prefix ....
//! Pins the cache accounting and eviction rules: retained K/V buffers cost bytes but no slot, A-B-A recovery, slot
//! and byte eviction oldest first, checkpoint, steering and boundary matching, image identity as part of the prefix,
//! and superseded copies of one conversation never pushing another out.
use super::{A, B, ConversationCache, ConversationImageKey, ConversationKv, cp, exact_kv_layers, image, size_of, with};
@@ -1,6 +1,5 @@
//! Tests of `tests` by topic: what_is_not_superseded,
//! disabled_caches_store_nothing, take_out_of_range_is_none_and_prefix_len_is_generic_over_token_types,
//! struct_sizes_match_the_64_bit_original_layout.
//! Pins what the cache must NOT treat as superseded (other conversations sharing only a root, a different steering
//! mode, entries without checkpoints), plus the disabled-cache, out-of-range `take` and struct-layout edge cases.
use super::{
A, B, ConversationCache, ConversationCheckpoint, ConversationImageKey, ConversationKv, SavedConversation, cp,
-14
View File
@@ -45,29 +45,15 @@ struct Verifier<'a> {
}
mod layout;
#[allow(unused_imports)]
pub use layout::kv_bytes;
#[allow(unused_imports)]
pub use layout::kv_capture_bytes;
#[allow(unused_imports)]
use layout::kv_q4_bytes_per_head;
#[allow(unused_imports)]
use layout::layout;
#[allow(unused_imports)]
use layout::region;
#[allow(unused_imports)]
use layout::transfer_err;
#[allow(unused_imports)]
use layout::valid;
#[allow(unused_imports)]
use layout::valid_extent;
mod kv_image_save_restore;
#[allow(unused_imports)]
pub use kv_image_save_restore::kv_restore;
#[allow(unused_imports)]
pub use kv_image_save_restore::kv_save;
#[allow(unused_imports)]
pub use kv_image_save_restore::kv_validate;
mod kv_image_readback;
#[allow(unused_imports)]
pub use kv_image_readback::kv_verify;
@@ -1,5 +1,5 @@
//! Functions: `verify_ring`, `kv_verify`.
//! Split out of `kv` to keep its files under the line limit.
//! Read-back check of a restored K/V layer: the saved bytes and the drafter ring's resident pages are compared with
//! the device and the authoritative payload is fingerprinted. Diagnostic only; it never changes model state.
use super::{
ConvResult, ConversationKv, KvLayer, KvPool, KvTarget, QsaDesc, StateMemory, Verifier, kv_validate, region,
@@ -1,5 +1,6 @@
//! Methods of `Verifier`: `compare`, `failure`.
//! Functions: `set_geometry`, `reusable_prefix`, `capture_buffer`, `capture_layer` and 5 more.
//! Capture, validation and restore of one layer's K/V image against device memory. Capture keeps the unchanged prefix
//! of buffers retained from an earlier restore and copies only the rest; restore refills streamed residency.
//! Also the `Verifier` that compares device bytes with the image for the read-back check.
use super::{
ConvError, ConvResult, ConversationKv, IDX_BLOCK, KvLayer, KvPool, KvTarget, Layout, ModelGeometry, PAGE_SIZE,
@@ -1,5 +1,5 @@
//! Methods of `Layout`: `sizes`.
//! Functions: `kv_q4_bytes_per_head`, `valid_extent`, `geometry_ok`, `check_layout_inputs` and 12 more.
//! Byte layout of one layer's K/V image: the snapshot format code, the extent and geometry checks, and the sizes of
//! keys, values, scales and pooled indexer rows. `kv_bytes` and `kv_capture_bytes` give the sizes a capture needs.
use super::{
ConvError, ConvResult, ConversationKv, IDX_BLOCK, KV_HYBRID, KV_ROTATED, KvLayer, KvPool, Layout, ModelGeometry,
@@ -113,10 +113,7 @@ pub struct ConversationManager {
}
mod conversation_options_default;
#[allow(unused_imports)]
pub use conversation_options_default::images_below;
#[allow(unused_imports)]
use conversation_options_default::is_allocation;
#[allow(unused_imports)]
pub use conversation_options_default::starts_with;
mod conversation_manager;
@@ -1,5 +1,5 @@
//! Groups the submodules `conversation_resume_checkpoints`, `conversation_state_events`.
//! Split out of `manager` to keep its files under the line limit.
//! Hub of the `ConversationManager` implementation: the resume and checkpoint half and the state and parking half
//! live in the two child modules and share the imports declared here.
use super::{
CheckpointKey, ConvError, ConvResult, ConversationCache, ConversationCheckpoint, ConversationImageKey,
@@ -1,5 +1,6 @@
//! Methods of `ConversationManager`: `pick_resume`, `take_incoming`, `restore_parked`, `align_to_request` and 10 more.
//! Split out of `conversation_manager` to keep its files under the line limit.
//! The request path of `ConversationManager`: choose what a request resumes from (live session, checkpoint or parked
//! conversation), restore and position the device, then keep the checkpoint chain through the prompt and at the end.
//! Mirrors the resume choice and `checkpoint_at` of the Original's `generate.cpp`.
use super::{
ConvError, ConvResult, ConversationCheckpoint, ConversationImageKey, ConversationManager, PromptAction, PromptPath,
@@ -1,5 +1,5 @@
//! Methods of `ConversationManager`: `new`, `options`, `live`, `live_ok` and 13 more.
//! Split out of `conversation_manager` to keep its files under the line limit.
//! The state half of `ConversationManager`: construction, read-only views of the live tokens, checkpoints and cache,
//! the event log, invalidation, and the parking of the current session (size estimate, making room, capture, store).
use super::{
CheckpointKey, ConvResult, ConversationCache, ConversationCheckpoint, ConversationKvReuse, ConversationManager,
@@ -1,5 +1,5 @@
//! Implements `Default for ConversationOptions`. Functions: `images_below`, `starts_with`, `is_allocation`.
//! Split out of `manager` to keep its files under the line limit.
//! Default `ConversationOptions` and the prompt-prefix helpers the manager uses: picture positions below a limit,
//! the "saved point is a prefix of the request" test, and the classification of allocation failures.
use super::{ConvError, ConversationImageKey, ConversationOptions};
@@ -61,24 +61,10 @@ mod continuing_chat_reuses;
mod random_traffic_resumes_into_exact_prefix_state;
mod hash;
#[allow(unused_imports)]
use hash::hash;
#[allow(unused_imports)]
use hash::idx;
#[allow(unused_imports)]
use hash::pat;
#[allow(unused_imports)]
use hash::pattern;
mod sim_device_session_device;
#[allow(unused_imports)]
use sim_device_session_device::ReplayedRequest;
#[allow(unused_imports)]
use sim_device_session_device::chat;
#[allow(unused_imports)]
use sim_device_session_device::gen_tokens;
#[allow(unused_imports)]
use sim_device_session_device::options;
#[allow(unused_imports)]
use sim_device_session_device::prompt_options;
#[allow(unused_imports)]
use sim_device_session_device::world;
@@ -1,8 +1,7 @@
//! Tests of manager_tests by topic (moved out of the test file by STRA-338):
//! the_byte_budget_and_slot_limit_evict_oldest_first,
//! an_incompatible_parked_image_is_discarded_and_the_request_falls_back,
//! a_failed_restore_transfer_is_fatal_to_the_request,
//! switching_steering_invalidates_checkpoints_and_isolates_parked_images ....
//! Pins the manager's budget and failure rules: the byte budget and slot limit evict oldest first, an incompatible
//! parked image is discarded, a failed restore transfer is fatal, steering switches isolate parked images, a
//! cancelled prompt keeps its checkpoints, periodic checkpoints follow the chunk stride, and pictures and the PLE
//! history window are part of the resume identity.
use super::{ConversationImageKey, DeviceEngine, ReplayedRequest, TURN, chat, gen_tokens, options, world};
@@ -1,7 +1,6 @@
//! Tests of manager_tests by topic (moved out of the test file by STRA-338):
//! a_continuing_chat_reuses_the_live_session_without_a_copy, an_identical_prompt_still_reads_its_last_token,
//! a_rewritten_tail_resumes_from_the_turn_boundary_checkpoint, the_shared_root_is_pinned_while_other_checkpoints_rotate
//! ....
//! Pins which source a request resumes from: a continuing chat reuses the live session without a copy, a rewritten
//! tail resumes from the turn-boundary checkpoint, the shared root stays pinned while other checkpoints rotate,
//! switching conversations parks and restores exactly, and physical-memory admission gates parking.
use super::{GIB, ReplayedRequest, Run, TURN, World, chat, gen_tokens, options, world};
@@ -1,5 +1,5 @@
//! Methods of `SimDevice`: `per`, `row_bytes`, `write_cell`, `mirror_ring` and 7 more.
//! Implements `StateMemory for SimDevice`. Functions: `hash`, `pat`, `pattern`, `idx`.
//! The simulated device memory of the manager tests: token-prefix hashing and patterns, the `SimDevice` byte regions
//! (running state, K/V pools, indexer rows, drafter ring) and its `StateMemory` implementation.
use super::{
IdxKind, KvLayer, KvPool, PAGE, RingBlocks, SLOTS, SimDevice, StateMemory, StateRegion, kv_region, state_sizes,
@@ -1,5 +1,5 @@
//! Methods of `ReplayedRequest`: `new`. Methods of `World`: `read_plan`, `request`.
//! Implements `SessionDevice for SimDevice`.
//! The simulated world of the manager tests: `SimDevice` as a `SessionDevice`, the small model geometry, the
//! `World` that replays requests (reading a prompt plan into device state) and the chat and token generators.
use super::{
ConversationImageKey, ConversationManager, ConversationOptions, DeviceEngine, Fixture, FixtureGeometry, GIB,
@@ -57,34 +57,18 @@ struct Pools {
mod layer_snapshots_are_byte_exact;
mod kv_region;
#[allow(unused_imports)]
use kv_region::equal;
#[allow(unused_imports)]
pub(super) use kv_region::kv_region;
#[allow(unused_imports)]
use kv_region::mk_view;
#[allow(unused_imports)]
use kv_region::q4_per_head;
mod kv_level;
#[allow(unused_imports)]
use kv_level::kv_level;
mod full_session;
#[allow(unused_imports)]
use full_session::full_session;
mod fixture;
mod pools;
#[allow(unused_imports)]
use fixture::fixture;
mod golden_state;
#[allow(unused_imports)]
use golden_state::assert_checkpoint;
#[allow(unused_imports)]
use golden_state::assert_image;
#[allow(unused_imports)]
use golden_state::assert_kv;
#[allow(unused_imports)]
use golden_state::fnv;
#[allow(unused_imports)]
use golden_state::fnv_buf;
#[allow(unused_imports)]
use golden_state::golden_state;
@@ -1,5 +1,5 @@
//! Methods of `Fx`: `new`, `unchanged`, `restore`, `reject` and 13 more.
//! Functions: `fixture_geometry`, `fixture_session`, `fixture_checkpoint`, `fixture_image` and 3 more.
//! The fixture of the snapshot tests: a small model with a first, a last and a drafter layer registered in host
//! memory, a complete saved image, and the checks `Fx` runs on it (sizes, save, restore, rejection before any write).
use super::{
ConversationCheckpoint, ConversationImageKey, ConversationKvReuse, ConversationView, HostMemory, IDX_BLOCK,
@@ -1,5 +1,5 @@
//! Methods of `Session`: `new`, `spare`, `fill`, `save_checkpoint` and 9 more.
//! Functions: `session_geometry`, `put_session_regions`, `session_spec`, `full_session`. Defines `Session`.
//! The whole-session scenario of the snapshot tests: a main and a draft layer with running state and checkpoints in
//! one host memory, saved and restored, with the observations compared against the golden values.
use super::{
ConversationCheckpoint, ConversationImageKey, ConversationKv, ConversationKvReuse, Fixture, HYBRID, HostMemory,
@@ -1,5 +1,5 @@
//! Functions: `golden_state`, `fnv`, `fnv_buf`, `assert_kv` and 2 more.
//! Split out of `snapshot_tests` to keep its files under the line limit.
//! Helpers that compare saved images, K/V layers and checkpoints with the golden JSON the Original's C++ produced:
//! FNV fingerprints of the buffers and the field-by-field assertions.
use super::{ConversationCheckpoint, ConversationKv, SavedConversation};
@@ -1,5 +1,5 @@
//! Methods of `Level`: `save`, `restore`, `reject_hybrid_streaming`, `reject_bad_extents` and 5 more.
//! Functions: `kv_level`. Defines `Level`.
//! The per-layer K/V scenario of the snapshot tests: for one format and residency mode, save, restore, verify, and
//! reject hybrid-streaming and bad extents, over one fixture layer in host memory.
use super::{
ConversationKv, Fixture, HYBRID, HostMemory, KV_INT8, KV_Q4, KV_VALUE_INT8, KvLayer, KvPool, KvTarget, equal,
@@ -1,5 +1,5 @@
//! Methods of `Alloc`: `put`. Methods of `Fixture`: `new`, `with_geometry`, `source`, `fill` and 1 more.
//! Functions: `kv_region`, `mk_view`, `equal`, `q4_per_head` and 8 more. Defines `Alloc`, `Dims`.
//! Allocation of the K/V pools of a snapshot-test layer (fp16, INT8, Q4_0 and hybrid formats, device slots and host
//! pools) in host memory, and the region and view helpers the other snapshot tests share.
use super::{
ConversationCheckpoint, ConversationImageKey, ConversationKv, ConversationView, Fixture, FixtureGeometry, HYBRID,
@@ -1,7 +1,6 @@
//! Tests of snapshot_tests by topic (moved out of the test file by STRA-338):
//! layer_snapshots_are_byte_exact_across_formats_and_residency_modes, whole_session_snapshots_round_trip_exactly,
//! validation_rejects_before_any_device_write_and_faults_are_fatal,
//! checkpoint_save_restore_round_trips_through_host_memory ....
//! Pins the snapshot contracts: layer and whole-session images are byte exact across formats and residency modes,
//! validation rejects before any device write, checkpoints round-trip through host memory, and geometry, carve sizes,
//! layouts and payload hashes match the Original's golden values.
use super::{
ConversationCheckpoint, ConversationKv, Fixture, HYBRID, HostMemory, IDX_BLOCK, IdxKind, KV_F16, KV_INT8, KV_Q4,
@@ -1,5 +1,5 @@
//! Methods of `Pools`: `new`, `register`, `image`. Functions: `mark_present`.
//! Split out of `snapshot_tests` to keep its files under the line limit.
//! The K/V pool set of a snapshot-test layer: which buffers a format has (fp16, INT8, Q4_0), registering them in host
//! memory and building the matching image.
use super::{
ConversationKv, HostMemory, IdxKind, KvLayer, KvPool, ModelGeometry, Pools, QsaDesc, StateRegion, kv_region,
@@ -201,5 +201,4 @@ mod tests;
mod decayed;
mod policy_params_default;
mod prefix_store;
#[allow(unused_imports)]
use decayed::decayed;
@@ -1,6 +1,4 @@
//! Functions: `decayed`.
//! Split out of `store` to keep its files under the line limit.
//! Half-life decay of a hit mass or prior with age, shared by the store's value estimate.
pub(super) fn decayed(value: f64, age: u64, half_life: f64) -> f64 {
if value == 0.0 { 0.0 } else { value * 0.5f64.powf(age as f64 / half_life) }
@@ -1,5 +1,4 @@
//! Methods of `Candidate`: `key`, `blocks`. Implements `Default for PolicyParams`.
//! Split out of `store` to keep its files under the line limit.
//! The operator-facing default values of `PolicyParams`, and the accessors of an admission `Candidate`.
use super::{Candidate, PolicyParams};
@@ -1,5 +1,5 @@
//! Groups the submodules `admit`, `prefix_store_consider_commit`, `prefix_store_evict_and_budget` and 2 more.
//! Split out of `store` to keep its files under the line limit.
//! Hub of the `PrefixStore` implementation: admission, the consider and commit path, eviction and budget, the
//! statistics and clock, and node scoring each live in a child module over the shared store types.
use super::{
Block, ByteSize, CHAIN_SEED, Candidate, Consider, HashMap, HashSet, KeptTail, Match, Node, NodePayload,
@@ -1,5 +1,5 @@
//! Methods of `PrefixStore`: `consider`, `consider_tail`, `candidate_value`, `commit` and 3 more.
//! Split out of `prefix_store` to keep its files under the line limit.
//! Admission decision and commit of prefix-store nodes: `consider` (is a node worth its bytes), the request-end tail
//! variants, the value estimate of a candidate, and `commit` once the caller has built the payloads.
use super::{ByteSize, Candidate, Consider, HashSet, KeptTail, NodePayload, PrefixStore, Reject};
@@ -1,9 +1,9 @@
//! Methods of `PrefixStore`: `enforce_budget`, `abort`, `release_orphans`, `evict` and 6 more.
//! Split out of `prefix_store` to keep its files under the line limit.
//! Removal from the prefix store: enforcing the byte budget, aborting a candidate, evicting a node together with the
//! blocks only it covered, orphan release, clearing, and the invariant check.
use super::{ByteSize, Candidate, HashSet, Node, PrefixStore};
#[cfg(any(test, feature = "testing"))]
use super::HashMap;
use super::{ByteSize, Candidate, HashSet, Node, PrefixStore};
impl<N: ByteSize, B: ByteSize> PrefixStore<N, B> {
pub(in super::super) fn enforce_budget(&mut self, fresh: u64) {
@@ -1,5 +1,5 @@
//! Methods of `PrefixStore`: `new`, `config`, `stats`, `bytes` and 26 more.
//! Split out of `prefix_store` to keep its files under the line limit.
//! Construction, statistics, request clock and expiry of the prefix store, and its lookups: the longest token-exact
//! match, the hash-only prefix match a router uses, the node heads, and the hit and miss records that feed admission.
use super::{
ByteSize, CHAIN_SEED, HashMap, HashSet, Match, Node, PrefixStore, Stats, StoreConfig, chain_step, decayed,
@@ -1,8 +1,6 @@
//! Tests of tests by topic (moved out of the test file by STRA-338):
//! a_hit_by_another_session_makes_a_shared_root_outlive_private_leaves,
//! thinning_a_chain_keeps_the_deepest_node_and_the_blocks_it_needs,
//! the_budget_is_enforced_again_when_the_real_payload_is_bigger_than_the_estimate,
//! commit_refuses_blocks_that_are_not_the_candidates ....
//! Pins the store's sharing and budget behaviour: a hit by another session keeps a shared root alive, chains are
//! thinned, the budget is enforced again when a payload exceeds its estimate, collisions are never matched, the node
//! cap evicts by value, and long agent sessions stay inside the budget with a fast lookup.
use super::{
BLOCK, Consider, G, Payload, PolicyParams, PrefixStore, Reject, STATE, StoreConfig, chain, put, store, tokens,
@@ -1,7 +1,6 @@
//! Tests of tests by topic (moved out of the test file by STRA-338):
//! a_request_resumes_from_the_deepest_node_of_any_session, common_prefixes_are_stored_once,
//! a_node_with_descendants_is_a_branch_point_and_a_frontier_is_not,
//! the_prompt_end_checkpoint_survives_the_decode_end_checkpoint_of_its_request ....
//! Pins resume and eviction semantics of the store: resume from the deepest node of any session, shared prefixes
//! stored once, branch points versus frontiers, request-end tail nodes and their supersession, retention and expiry,
//! and value-ordered eviction under a full budget.
use super::{
BLOCK, Consider, G, MINUTE, Payload, PolicyParams, PrefixStore, Reject, STATE, StoreConfig, put, put_tail,
-3
View File
@@ -139,9 +139,6 @@ mod grid_tests;
#[path = "prompt/prompt_options.rs"]
mod prompt_options;
#[allow(unused_imports)]
pub use prompt_options::choose_auto_capacity;
#[allow(unused_imports)]
pub use prompt_options::drive;
#[allow(unused_imports)]
pub use prompt_options::request_capacity;
@@ -1,5 +1,5 @@
//! Methods of `PromptOptions`: `original_mode17`.
//! Methods of `PromptPlan`: `new_in_context`, `new`, `prompt`, `next_segment` and 1 more.
//! Prompt planning of the Original serve path: the options and capacity choice (auto ladder, cache-slot loan), the
//! validity checks, the `PromptPlan` iterator that cuts a prompt into segments, and `drive`, which runs a plan.
use super::{
DriveError, DriveSummary, PlanError, PlanLimits, PromptAction, PromptOptions, PromptPath, PromptPlan, PromptRunner,
-4
View File
@@ -192,13 +192,9 @@ pub struct SpecStats {
mod tests;
mod adaptive_config;
#[allow(unused_imports)]
use adaptive_config::logit;
#[allow(unused_imports)]
use adaptive_config::m_bucket;
#[allow(unused_imports)]
use adaptive_config::p_bucket;
#[allow(unused_imports)]
use adaptive_config::sigmoid;
mod adaptive_policy;
mod decide;
@@ -1,5 +1,5 @@
//! Methods of `AdaptiveConfig`: `new`, `with_policy`, `set_option`, `set_tuning` and 1 more.
//! Methods of `Cell`: `rate`, `add`. Functions: `p_bucket`, `m_bucket`, `logit`, `sigmoid`.
//! Constants of the adaptive window policy: construction, the `LELEKA_SPEC_POLICY` presets, named options for replay
//! arms, the acceptance `Cell` statistics, and the probability bucketing and logit helpers.
use super::{AdaptiveConfig, Cell, FLOOR_CEILING, FLOOR_CEILING_LEGACY, MAX_T, P_BUCKETS, P_EDGES};
@@ -1,5 +1,5 @@
//! Methods of `AdaptivePolicy`: `new`, `config`, `rounds`, `begin_request` and 7 more.
//! Split out of `adaptive` to keep its files under the line limit.
//! State and calibration of the adaptive window policy: per-request reset, the acceptance rate of an MTP draft or a
//! suffix row, the per-width cost mean and its fit, and the candidate widths offered to the decision.
use super::{
AdaptiveConfig, AdaptivePolicy, Cand, Cell, M_BUCKETS, MAX_T, N0_BUCKET, N0_DEPTH, N0_SUFFIX, Offer, Origin,
@@ -1,5 +1,5 @@
//! Methods of `SpecStats`: `record`, `line`.
//! Split out of `adaptive` to keep its files under the line limit.
//! Per-round statistics of the adaptive policy (width, accepted rows, flags, milliseconds) and the one-line report
//! printed from them.
use super::{MAX_T, RoundFlags, SpecStats};
@@ -1,6 +1,5 @@
//! Tests of tests by topic (moved out of the test file by STRA-338):
//! the_default_ceiling_is_the_new_one_and_the_legacy_switch_restores_the_old_policy_exactly,
//! the_smooth_floor_moves_continuously_with_the_bar, a_trace_is_reproducible, stats_line_reports_the_histograms.
//! Pins the policy constants: the default draft-floor ceiling is the new one, the legacy switch restores the earlier
//! policy exactly, the smooth floor moves continuously with the bar, traces are reproducible, and the stats line.
use super::{
AdaptiveConfig, AdaptivePolicy, CODE_COSTLY, FLOOR_CEILING, P_BUCKETS, P_EDGES, PROSE_CHEAP, Rng, RoundFlags,
@@ -1,6 +1,6 @@
//! Tests of `tests` by topic: stationary_regimes_reach_the_best_fixed_width,
//! it_widens_when_rows_are_cheap_and_narrows_when_they_are_not, it_follows_a_change_of_content_and_of_cost,
//! reaction_to_a_switch_takes_tens_of_rounds_not_hundreds ....
//! Pins the adaptive window's learning: stationary regimes reach the best fixed width, it widens when rows are cheap
//! and narrows when not, follows a change of content or cost, explores cheaply, interpolates unmeasured widths, and
//! keeps the draft plan inside its bounds.
use super::{
AdaptivePolicy, CODE_CHEAP, CODE_COSTLY, Choice, MAX_T, Offer, Origin, PROSE_CHEAP, PROSE_COSTLY, REPEAT, Rng,
+2
View File
@@ -46,5 +46,7 @@ workspace = true
[dev-dependencies]
serde_json = "1"
leleka-engine-core = { path = "../engine-core", features = ["testing"] }
# The GPU proofs render prompts with the gateway renderer itself (they used to compile its source file as a module).
leleka-gateway-text = { path = "../gateway-text" }
# Model-free device probe of the VRAM expert tier (test builds only).
leleka-cuda-driver = { path = "../cuda-driver", features = ["cuda-driver", "expert-tier-probe"] }
-9
View File
@@ -157,11 +157,9 @@ mod backend_measurement_sdet;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/combined_prefix_numeric.rs"]
mod combined_prefix_numeric;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/combined_prefix_numeric_sdet.rs"]
mod combined_prefix_numeric_sdet;
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
mod original_serve_arms;
@@ -179,37 +177,30 @@ mod original_serve_smoke;
mod original_serve_ttft;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/singleload_proof.rs"]
mod singleload_proof;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/resident_mmq_model_proof.rs"]
mod resident_mmq_model_proof;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/native_resident_mmq_model_proof.rs"]
mod native_resident_mmq_model_proof;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/layer0_native_mmq_proof.rs"]
mod layer0_native_mmq_proof;
#[cfg(feature = "preview-path")]
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[path = "gpu_proofs/combined_changed_boundary_proof.rs"]
mod combined_changed_boundary_proof;
#[cfg(feature = "preview-path")]
#[cfg(all(test, target_os = "linux", target_arch = "x86_64"))]
#[path = "gpu_proofs/native_down_public_pair.rs"]
mod native_down_public_pair;
#[cfg(feature = "preview-path")]
#[cfg(all(test, target_os = "linux", target_arch = "x86_64"))]
#[path = "gpu_proofs/native_down_candidate_only.rs"]
mod native_down_candidate_only;
#[cfg(test)]
@@ -1,7 +1,11 @@
//! The request clocks of the backend on a manual clock (STRA-338 S14): the terminal publication deadline, the
//! prefill/decode accounting of the measurement recorder and the clock reads of the source verification.
use super::*;
use super::{
BACKPRESSURE_TIMEOUT, Clock, ContractError, Duration, EvaluationMeasurement, FinishReason, GenerationEvent,
GenerationFailure, GenerationSink, GenerationTerminal, NativeBackendConfig, Usage, emit_event, emit_terminal,
measurement, verify_sources_parallel,
};
use leleka_obs::time::ManualClock;
fn completed() -> GenerationTerminal {
@@ -1,8 +1,12 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::*;
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenForward, QwenSession};
use super::{
Driver, EvaluationExecution, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1,
Tokenizer, VerifiedGgufFile,
};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners as LoadedTarget;
use std::env;
#[path = "combined_changed_boundary_proof/rig.rs"]
pub(super) mod rig;
use rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in, unwrap_phase};
@@ -1,7 +1,11 @@
//! The loaded real owners the single-load GPU proofs share: the pinned binding over the inherited sealed archive,
//! the device owners built on one bounded Context, a phase run on a fresh target owner, and the teardown whose
//! results are asserted only after every attempt was made. Opening and scheduling stay with each proof.
use super::*;
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
use super::{
InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile,
};
use std::{
env,
panic::{AssertUnwindSafe, catch_unwind},
@@ -1,7 +1,15 @@
//! Disposable, real-owner numerical observation. Never an actor publication gate.
//! Forced inputs are public IDs; no expected model tensors or invented state.
use super::combined_changed_boundary_proof::rig::Owners;
use super::*;
use super::{
AtomicBool, EvaluationExecution, FinishReason, Generation, GenerationSink, ModelBinding, MtpContinuation, Mutex,
Shared, SystemClock, Tokenizer, generate_mtp_resume,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, KarPleCache, MoeWeightCache, MtpDecoder, OutputStage, QwenSession, TargetStepProduct,
TokenId,
};
use crate::qwen_forward::mtp::KnownNext;
use crate::qwen_forward::mtp_decode::DraftHeadOwners;
use crate::qwen_forward::{mtp::PrefixDraftSnapshot, session::ResetReplaySnapshot};
@@ -3,7 +3,9 @@
use super::combined_changed_boundary_proof::rig::{
DEVICE_BUDGET, MOE_REFUSAL, Owners, PinnedTokenizer, bind_pinned_with_tokenizer, require_opt_in,
};
use super::*;
use super::{Driver, ModelBinding, PathBuf, Rc, Tokenizer};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenSession};
use std::{
env,
panic::{AssertUnwindSafe, catch_unwind, resume_unwind},
@@ -1,5 +1,11 @@
//! The single-token generation step loop.
use super::*;
use super::{
AtomicBool, BackendError, Clock, DenseWeightCache, Dimension, ErrorCode, EvaluationExecution, FinishReason,
GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationSink, Instant, KarPleCache, ModelBinding,
MoeWeightCache, MtpDecoder, Ordering, OutputStage, Position, QwenForward, QwenSession, Shared, SystemClock,
TargetStepProduct, TokenId, Tokenizer, Usage, Utf8Pending, emit_event, error, exhausted, generate_mtp, invalid,
measurement, native_position, unavailable, unsupported,
};
use crate::qwen_forward::executor::{PrefillChunkInputs, StepCaches, StepRequest};
pub(super) struct Generation<'a, 'context, 'driver, C: Clock = SystemClock> {
@@ -1,6 +1,8 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in};
use super::*;
use super::{Driver, EvaluationExecution, ModelBinding, PathBuf, Rc};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenForward};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use std::{env, panic::resume_unwind};
@@ -5,7 +5,10 @@
//! `FakeDevice` (no GPU). Time is a `ManualClock` that the device moves by the scripted cost of a chunk or a round, so
//! the deadline and the prefill/decode accounting are exact. Normal completion, stop, length, acceptance and timing
//! are here; `ends` holds the cancel, deadline and error exits, `prefix` the cross-session cache.
use super::*;
use super::{
Arc, AtomicBool, ErrorCode, FinishReason, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink,
GenerationStream, GenerationTerminal, Mutex, Ordering, Shared, Tokenizer, Usage, original_serve,
};
use crate::qwen_forward::original_serve_engine::{ServeOutcome, ServeStop};
use crate::qwen_forward::original_serve_request::{ServeDevice, ServeError, ServeRequest};
use crate::qwen_forward::original_serve_stack::lifecycle_fake::{FakeDevice, FakeStack, Script, greedy_continuation};
@@ -1,6 +1,12 @@
//! The owner-side Load: bind the sources, open CUDA, build the caches, then serve generations until Unload.
//! The phases live in `load_*.rs`; this file fixes the order they run in.
use super::*;
use super::{
Announcement, BackendError, Bound, Closed, Command, EvaluationExecution, EvaluationObserver, Identity, LoadedModel,
ModelDescriptor, NativeBackendConfig, OptimizedBackendConfig, Ordering, QwenSession, Rc, Receiver, Reply,
RuntimeConfig, Serving, Shared, SystemClock, admit_load, bind_model, build_loaded, check_not_cancelled,
close_context, close_weights, experimental_modes, launch_original, load_weights, new_conversations,
open_checked_context, open_driver, original_serve, probe_experimental_plan, serve_commands, start_governor,
};
use leleka_cuda_driver::Context;
/// Everything one Load needs from its owner thread.
@@ -1,5 +1,9 @@
//! The CUDA half of a Load: driver, device context, load-time probes and the hand-over to the Original serve stack.
use super::*;
use super::{
Announcement, BackendError, Bound, Driver, Governed, LoadEnv, LoadPhase, ModelBinding, NativeBackendConfig, Rc,
build_loaded, exhausted, experimental_modes, load_failure, original_serve, probe_experimental,
probe_kar_level_decode, unavailable,
};
use leleka_cuda_driver::Context;
pub(super) fn open_driver() -> Result<Driver, BackendError> {
@@ -1,6 +1,9 @@
//! What the phase functions of the Load (STRA-338 S5b) must keep from the code they replaced: the policy flags, the
//! execution gates and the weight-cache log line, each compared with the expressions of the former `serve_load`.
use super::*;
use super::{
Counters, EvaluationExecution, OptimizedBackendConfig, OptimizedOwnerPolicy, PolicyFlags, execution_gate_message,
generation_cache_line,
};
#[cfg(feature = "preview-path")]
use crate::qwen_forward::dense_weight_cache::DenseCacheCounters;
#[cfg(feature = "preview-path")]
@@ -1,5 +1,8 @@
//! The weight caches a native Load builds on the CUDA context: output head, KAR PLE cache, dense and MoE weights.
use super::*;
use super::{
BackendError, Bound, DenseWeightCache, KarPleCache, LoadEnv, LoadPhase, ModelBinding, MoeWeightCache, OutputStage,
PolicyFlags, exhausted, invalid, load_failure, load_forward_failure, load_moe,
};
use leleka_cuda_driver::Context;
type ForwardResult<T> = Result<T, crate::qwen_forward::contract::Error>;
@@ -1,6 +1,13 @@
//! Candidate-only PUBLIC quality proof against one retained actual Native arm.
//! Historical wall time is never used as an A/B measurement.
use super::*;
use super::{
AtomicBool, CacheCounts, DenseWeightCache, Digest, Driver, Duration, EvaluationExecution, EvaluationMeasurement,
FRAME_LIMIT, FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink,
GenerationStream, GenerationTerminal, InheritedKarArchive, Instant, KAR_MTP_PROFILE, KarPleCache, MODEL_DIGEST,
ModelBinding, MoeWeightCache, MtpContinuation, Mutex, Ordering, OutputStage, PathBuf, QUEUE, Qwen4ExpArtifact,
QwenForward, QwenSession, Rc, SHARD0, SHARD1, Sha256, Shared, SystemClock, Tokenizer, Usage, VerifiedGgufFile,
WindowWitness, emit_terminal, generate_mtp_resume, measurement, prepare_prompt, request, thread,
};
use serde_json::{Value, json};
use std::{
env,
@@ -10,29 +17,22 @@ use std::{
panic::{AssertUnwindSafe, catch_unwind, resume_unwind},
};
// EXACT existing daemon pure renderer, Effort::None. No hand-built ChatML.
#[path = "../../../../crates/gateway-text/src/prompt.rs"]
#[allow(dead_code)]
mod public_renderer;
use leleka_gateway_text::prompt as public_renderer;
// Files, request framing and counters shared with the one-load pair (native_down_public_pair.rs).
#[path = "native_down_pair_io.rs"]
mod pair_io;
use pair_io::*;
// The retained completed Native arm and the checks of the MTP window witnesses.
#[path = "native_down_pair_checks.rs"]
mod pair_checks;
use pair_checks::*;
// One actual owner generation on a fresh target/draft state.
#[path = "native_down_pair_arm.rs"]
mod pair_arm;
use pair_arm::*;
// The one loaded owner, its ordered teardown and the run of a proof on it.
#[path = "native_down_pair_owner.rs"]
mod pair_owner;
use pair_owner::*;
#[path = "native_down_pair_run.rs"]
mod pair_run;
use pair_run::*;
#[path = "native_down_pair_proofs.rs"]
mod pair_proofs;
use pair_proofs::*;
#[test]
@@ -90,7 +90,6 @@ fn pinned_five_public_cases_resident_owners() {
}
// Private framing only; Root owns the unchanged five-case consumer/caller.
#[path = "fivecase_frames.rs"]
mod fivecase_frames;
impl Inputs<'_, '_, '_> {
fn prepare_five_public_frames(&self) -> (PathBuf, String) {
@@ -99,7 +98,6 @@ impl Inputs<'_, '_, '_> {
}
// Private loaded-owner helper; Root supplies sealed genuine tokenizer frames.
#[path = "fivecase_runtime.rs"]
mod fivecase_runtime;
impl Inputs<'_, '_, '_> {
fn arm_five_public_cases(
@@ -111,5 +109,4 @@ impl Inputs<'_, '_, '_> {
}
}
#[path = "native_down_adaptive_candidate_only.rs"]
mod adaptive_slots;
@@ -1,14 +1,19 @@
//! Configured five PUBLIC cases on one actual Strata adaptive cache owner.
//! No Native inference replay; original paired quality/timing remains separately required.
use super::super::combined_changed_boundary_proof::rig::close_context_flags;
use super::*;
use super::{
AssertUnwindSafe, AtomicBool, BASELINE_SHA, Baseline, CAP, DEVICE_BUDGET, Driver, InheritedKarArchive, Inputs,
KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, Mutex, OpenOptions, OpenOptionsExt, PathBuf, Qwen4ExpArtifact, Rc,
Read, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile, baseline, catch_unwind, env, fivecase_runtime,
json, metadata, path, request, resume_unwind, save, sha, token_ids,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, Instant, KarPleCache, MoeWeightCache, OutputStage};
use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport};
use std::path::Path;
#[path = "native_down_adaptive_candidate_only/observe.rs"]
mod observe;
use observe::*;
#[path = "native_down_adaptive_candidate_only/cleanup.rs"]
mod cleanup;
use cleanup::*;
@@ -30,7 +35,7 @@ fn save_public_admission(root: &Path, baseline: &Baseline, tokenizer: &Tokenizer
let (req, ids, canonical) = request(tokenizer);
assert_eq!(ids, baseline.input_ids);
assert_eq!(ids.len(), 202);
let renderer = sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs"));
let renderer = sha(include_bytes!("../../../../gateway-text/src/prompt.rs"));
save(
root,
"BASELINE-ADMISSION.json",
@@ -1,5 +1,8 @@
//! The cleanup documents of the adaptive proof and the assertions made once every teardown attempt was done.
use super::*;
use super::{
AdaptiveClosed, AssertUnwindSafe, Baseline, InheritedKarArchive, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, Path,
Value, bank_copies_json, catch_unwind, fivecase_runtime, json, resume_unwind, save, token_ids,
};
/// The owner wall profile as the artifacts record it.
pub(super) struct OwnerWall {
@@ -1,5 +1,7 @@
//! What the adaptive owners reported before and during their ordered teardown.
use super::*;
use super::{AdaptiveOwners, ModelBinding, Value, bank_report_json, json};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, MoeWeightCache};
/// A completion counter as the artifacts record it, and whether it is positive.
pub(super) struct Count {
@@ -1,6 +1,9 @@
//! Private CPU-only framing on the caller's already admitted tokenizer.
//! No model load, generation, expected outputs or state/capability publication.
use super::*;
use super::{
CAP, GenerationRequest, Inputs, MODEL_DIGEST, OpenOptions, OpenOptionsExt, PathBuf, Read, Tokenizer, Value, env,
json, path, prepare_prompt, public_renderer, request, save, sha,
};
use std::os::unix::fs::{MetadataExt, PermissionsExt};
const BASE_FRAME_SHA: &str = "9512d4883fca31282206c3a03c8d4d3f3085b5c1dfedd998c8957061e01514e4";
@@ -142,7 +145,7 @@ fn write_frame(
pub(super) fn prepare(inputs: &Inputs<'_, '_, '_>) -> (PathBuf, String) {
let (root, uid) = fresh_frames_root();
let requests = build_requests(inputs);
let renderer = sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs"));
let renderer = sha(include_bytes!("../../../../gateway-text/src/prompt.rs"));
check_requests(&requests);
let entries: Vec<Value> = requests
.iter()
@@ -1,6 +1,9 @@
//! Private five fresh public requests on the caller's one admitted model owner.
//! This helper neither loads weights nor supplies an output oracle.
use super::*;
use super::{
Arm, CAP, EvaluationExecution, FinishReason, GenerationRequest, Inputs, KAR_MTP_PROFILE, MODEL_DIGEST, OpenOptions,
OpenOptionsExt, Read, Tokenizer, Value, candidate_windows, env, json, path, prepare_prompt, save, sha, token_ids,
};
use std::os::unix::fs::MetadataExt;
const CASE_COUNT: usize = 5;
const BASE_FRAME_SHA: &str = "9512d4883fca31282206c3a03c8d4d3f3085b5c1dfedd998c8957061e01514e4";
@@ -94,7 +97,7 @@ fn admit_manifest_header(manifest: &Value) -> String {
assert_eq!(number(manifest, "case_count"), CASE_COUNT as u64);
assert_eq!(text(manifest, "baseline_frame_sha256"), BASE_FRAME_SHA);
assert_eq!(text(manifest, "model_digest"), MODEL_DIGEST);
let renderer = sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs"));
let renderer = sha(include_bytes!("../../../../gateway-text/src/prompt.rs"));
assert_eq!(text(manifest, "renderer_source_sha256"), renderer);
renderer
}
@@ -1,6 +1,13 @@
//! One actual owner generation on a fresh target/draft state: bounded stream consumer, failure artifact and the
//! measurement record of a completed arm.
use super::*;
use super::{
AtomicBool, CacheCounts, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason,
Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream,
GenerationTerminal, ModelBinding, MtpContinuation, Ordering, QUEUE, Rc, Shared, SystemClock, Tokenizer, Usage,
Value, WindowWitness, cache, cache_json, emit_terminal, generate_mtp_resume, json, measurement, path, save, thread,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, Instant, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
const WALL_BOUNDARY: &str = "immediately before generate_mtp_resume through terminal, actual channel EOF and \
consumer join; excludes session teardown and helpers";
@@ -1,5 +1,5 @@
//! The retained completed Native arm and the checks of the MTP window witnesses of a candidate arm.
use super::*;
use super::{Arm, FRAME_LIMIT, Value, WindowWitness, json, sealed_bytes, sha};
pub(super) const BASELINE_SHA: &str = "4d61ee949d37a738500c889f23f07310b6d75c7c8dfe5f50173eceafe1882fbe";
pub(super) struct Baseline {
@@ -1,6 +1,11 @@
//! The one loaded owner of the PUBLIC candidate proofs: admission of the sealed inputs, the load, the ordered
//! teardown and the artifacts of it. The proofs differ only in the `Proof` hooks (`native_down_pair_proofs.rs`).
use super::*;
use super::{
AtomicBool, BASELINE_SHA, Baseline, CAP, DenseWeightCache, GenerationRequest, InheritedKarArchive, Inputs, Instant,
KAR_MTP_PROFILE, KarPleCache, MODEL_DIGEST, ModelBinding, MoeWeightCache, Mutex, OpenOptions, OpenOptionsExt,
OutputStage, PathBuf, Qwen4ExpArtifact, Rc, Read, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile,
baseline, env, json, metadata, path, request, save, sha,
};
use crate::qwen_forward::owner_wall_profile::{self, Sample};
use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport};
use std::os::unix::fs::PermissionsExt;
@@ -105,7 +110,7 @@ fn pinned_tokenizer(artifact: &Qwen4ExpArtifact) -> (Tokenizer, u32) {
(tokenizer, eos)
}
fn renderer_sha() -> String {
sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs"))
sha(include_bytes!("../../../../gateway-text/src/prompt.rs"))
}
fn baseline_admission_json() -> Value {
json!({"baseline_sha256":BASELINE_SHA,"retained_run":"24993ad2-9c7c-4a90-bfac-3e6e0b5685c1",
@@ -1,6 +1,10 @@
//! The four PUBLIC candidate proofs: they differ in the caches they load, in what they generate and in what
//! they conclude; the owner, the teardown and the artifacts are shared (`native_down_pair_run.rs`).
use super::*;
use super::{
Arm, BASELINE_SHA, Baseline, CAP, Check, DenseWeightCache, EvaluationExecution, Finish, FinishReason,
KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, MoeFacts, MoeWeightCache, Owner, Proof, QwenForward, QwenSession, Rc,
RunCtx, Value, cache_json, candidate_windows, fivecase_runtime, json, merged, save, token_ids, with_counters,
};
use crate::qwen_forward::moe_expert::LoadedArms;
use crate::qwen_forward::moe_weight_cache::LearnedMainWitness;
use fivecase_runtime::FiveCaseReport;
@@ -1,6 +1,9 @@
//! Runs a `Proof` on the one loaded owner: generation, ordered teardown, the cleanup artifacts that survive a
//! failed generation, and the assertions that follow every attempted teardown.
use super::*;
use super::{
AssertUnwindSafe, DEVICE_BUDGET, Driver, Finish, Host, InheritedKarArchive, ModelBinding, Owner, OwnerCounters,
Proof, Rc, RunCtx, Teardown, Value, Witnessed, bank_json, catch_unwind, json, merged, resume_unwind, save,
};
use crate::qwen_forward::owner_wall_profile::{self, Sample};
const SCOPE: &str =
@@ -1,6 +1,9 @@
//! Files, environment, request framing and counters shared by the PUBLIC pair proofs.
//! Included by `native_down_candidate_only.rs` and `native_down_public_pair.rs` (each owns its copy of the state).
use super::*;
use super::{
CacheCounts, Digest, GenerationRequest, OpenOptions, OpenOptionsExt, Ordering, PathBuf, Read, Sha256, Tokenizer,
Value, Write, env, json, prepare_prompt, public_renderer,
};
pub(super) const ARTIFACT_CAP: usize = 16 * 1024 * 1024;
pub(super) static ARTIFACT_BYTES: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
@@ -1,5 +1,15 @@
//! One-load private PUBLIC generation pair; actual owner timings, never HTTP timings.
use super::*;
#[cfg(test)]
use super::prepare_prompt;
use super::{
AtomicBool, CacheCounts, Digest, Driver, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT,
FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream,
GenerationTerminal, InheritedKarArchive, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, MtpContinuation, Mutex,
Ordering, PathBuf, QUEUE, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Sha256, Shared, SystemClock, Tokenizer, Usage,
VerifiedGgufFile, WindowWitness, emit_terminal, generate_mtp_resume, measurement, request, thread,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
use serde_json::{Value, json};
use std::{
env,
@@ -9,20 +19,15 @@ use std::{
panic::{AssertUnwindSafe, catch_unwind, resume_unwind},
};
// EXACT existing daemon pure renderer, Effort::None. No hand-built ChatML.
#[path = "long_public_preflight/long_public_request.rs"]
mod long_public_preflight;
#[path = "../../../../crates/gateway-text/src/prompt.rs"]
#[allow(dead_code)]
mod public_renderer;
use leleka_gateway_text::prompt as public_renderer;
// Files, request framing and counters shared with the candidate-only proofs (native_down_candidate_only.rs).
#[path = "native_down_pair_io.rs"]
mod pair_io;
use pair_io::*;
// One actual owner generation, and the run of the pair on the one loaded owner.
#[path = "native_down_public_pair_arm.rs"]
mod pair_arm;
use pair_arm::*;
#[path = "native_down_public_pair_run.rs"]
mod pair_run;
#[test]
@@ -1,5 +1,6 @@
//! Offline/private producer; call with the actual already-bound model tokenizer.
//! No asset opening, model hash scan, GPU allocation or inference occurs here.
use leleka_gateway_text::prompt as public_renderer;
use leleka_tokenizer::Tokenizer;
use serde_json::{Value, json};
use sha2::{Digest, Sha256};
@@ -9,9 +10,6 @@ use std::{
os::unix::fs::OpenOptionsExt,
path::Path,
};
#[path = "../../../../../crates/gateway-text/src/prompt.rs"]
#[allow(dead_code)]
mod public_renderer;
const BYTE_CAP: usize = 1024 * 1024;
const ARTIFACT_CAP: usize = 16 * 1024 * 1024;
const CONTEXT: usize = 262144;
@@ -176,7 +174,7 @@ fn push_frame_summary(
bound_model_digest: &str,
artifacts: &mut Vec<Artifact>,
) -> io::Result<Value> {
let renderer = digest(include_bytes!("../../../../../crates/gateway-text/src/prompt.rs"));
let renderer = digest(include_bytes!("../../../../gateway-text/src/prompt.rs"));
let frame = json!({
"schema":"public-long-preflight-v1","model_digest":bound_model_digest,
"renderer_source_sha256":renderer,
@@ -1,6 +1,13 @@
//! One actual owner generation of the one-load PUBLIC pair on a fresh target/draft state: bounded stream
//! consumer, failure artifact and the measurement record of a completed arm.
use super::*;
use super::{
AtomicBool, CacheCounts, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason,
Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream,
GenerationTerminal, ModelBinding, MtpContinuation, QUEUE, Rc, Shared, SystemClock, Tokenizer, Usage, Value,
WindowWitness, cache, cache_json, emit_terminal, generate_mtp_resume, json, measurement, path, save, thread,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
pub(super) struct Arm {
pub(super) measurement: EvaluationMeasurement,
@@ -1,5 +1,13 @@
//! The one-load PUBLIC pair: sealed inputs, one owner load, four arms (two warm, two measured) and the artifacts.
use super::*;
use super::{
ARTIFACT_BYTES, ARTIFACT_CAP, Arm, AssertUnwindSafe, AtomicBool, CAP, DEVICE_BUDGET, Driver, Duration,
EvaluationExecution, GenerationRequest, InheritedKarArchive, Inputs, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding,
Mutex, Ordering, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile,
catch_unwind, env, json, long_public_preflight, merged, metadata, ns, path, request, reserve_artifacts,
resume_unwind, save, sha,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage};
use std::os::unix::fs::PermissionsExt;
const NATIVE_POLICY: &str = "native64-same-dual-cache-retained-mtp-kv";
@@ -69,7 +77,7 @@ fn pinned_tokenizer(artifact: &Qwen4ExpArtifact) -> (Tokenizer, u32) {
(tokenizer, eos)
}
fn frame_json(case: &Case) -> Value {
json!({"renderer_source_sha256":sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs")),
json!({"renderer_source_sha256":sha(include_bytes!("../../../../gateway-text/src/prompt.rs")),
"framed_prompt":case.req.prompt,"framed_prompt_sha256":sha(case.req.prompt.as_bytes()),
"input_token_ids":case.ids,"framed_count":case.ids.len(),"model_digest":MODEL_DIGEST,
"max_output_tokens":CAP,"temperature_milli":0})
@@ -1,6 +1,8 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in};
use super::*;
use super::{Driver, EvaluationExecution, ModelBinding, PathBuf, Rc};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenForward};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use std::{env, panic::resume_unwind};
@@ -134,17 +134,10 @@ pub(super) mod runner;
mod tests;
mod original_serve_mode;
#[allow(unused_imports)]
pub(super) use original_serve_mode::choose;
#[allow(unused_imports)]
pub(super) use original_serve_mode::context_fits;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[allow(unused_imports)]
pub(super) use original_serve_mode::current_unsealed;
#[cfg(not(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64")))]
#[allow(unused_imports)]
pub(super) use original_serve_mode::current_unsealed;
#[allow(unused_imports)]
use original_serve_mode::ineligible;
#[allow(unused_imports)]
pub(super) use original_serve_mode::published_prefix_summary;
@@ -1,5 +1,5 @@
//! Methods of `OriginalServeMode`: `parse`, `as_str`. Methods of `ExpertSource`: `parse`, `as_str`.
//! Implements `Default for OriginalServeOptions`.
//! Parsing and printing of the Original-path choices (`OriginalServeMode`, `ExpertSource`, `PrefixTail`), the
//! published prefix-cache pool summary, and the default and run-time validation of `OriginalServeOptions`.
use super::{
BackendError, ConfigFacts, ExpertSource, OriginalServeChoice, OriginalServeMode, OriginalServeOptions,
@@ -94,43 +94,27 @@ mod capture_tests {
}
mod stack_config_and_reports;
#[allow(unused_imports)]
use stack_config_and_reports::CapturedIds;
#[allow(unused_imports)]
use stack_config_and_reports::PhaseDurations;
#[allow(unused_imports)]
use stack_config_and_reports::admission_error;
#[allow(unused_imports)]
use stack_config_and_reports::capture_request;
#[allow(unused_imports)]
use stack_config_and_reports::gpu_probe;
#[allow(unused_imports)]
use stack_config_and_reports::log_request_end;
#[allow(unused_imports)]
use stack_config_and_reports::meta_facts;
#[allow(unused_imports)]
use stack_config_and_reports::open_error;
#[allow(unused_imports)]
use stack_config_and_reports::publish_prefix_summary;
#[allow(unused_imports)]
use stack_config_and_reports::stack_config;
mod request_generation;
#[allow(unused_imports)]
pub(in super::super) use request_generation::generate;
#[allow(unused_imports)]
pub(in super::super) use request_generation::{ClientLink, RequestToServe, TokenVocabulary};
mod owner_run_steps;
#[allow(unused_imports)]
use owner_run_steps::{
GenerateEnv, RecordedModel, abandon_stack, close_context, close_stack, open_run_stack, publish_open,
serve_generate, sweep_idle,
};
mod command_loop;
#[allow(unused_imports)]
use command_loop::{LoopCtx, announce, answer_unload, command_loop};
mod reconfigure_command;
#[allow(unused_imports)]
use reconfigure_command::{Live, ReopenEnv, reconfigure};
mod owner_run;
#[allow(unused_imports)]
pub(in super::super) use owner_run::run;
@@ -1,5 +1,5 @@
//! The command loop of the Original owner, moved out of `run` by STRA-338 (size): receive, sweep the idle sessions,
//! and answer each command in the order `run` did.
//! The command loop of the Original owner: publish readiness, then receive commands, sweep idle sessions while none
//! arrives, and answer Load (refused), Reconfigure, Unload and Generate until unload or shutdown.
use super::{
BackendError, Command, Duration, GenerateEnv, IdleSweep, Live, LoadPhase, LoadedModel, Ordering,
@@ -1,8 +1,13 @@
//! The steps of the Original owner loop `run`: open and report the stack, admit and serve a generate command,
//! sweep idle sessions and close everything; early exits stay in `run`.
#[allow(unused_imports)]
use super::*;
use super::{
ActiveGuard, AtomicBool, BackendError, ClientLink, DeferredTail, ErrorCode, GenerationFailure, GenerationRequest,
GenerationSink, GenerationTerminal, IdleSweep, LoadPhase, LoadedModel, ModelBinding, Ordering,
OriginalServeOptions, OriginalServeStack, PathBuf, QUEUE, Rc, Reply, RequestToServe, Shared, SystemClock,
TokenVocabulary, Tokenizer, context_fits, emit_terminal, exhausted, generate, invalid, load_failure, meta_facts,
open_error, prepare_prompt, publish_prefix_summary, stack_config, unavailable,
};
use leleka_backend_api::GenerationStream;
use leleka_cuda_driver::Context;
use std::sync::Arc;
@@ -1,6 +1,8 @@
//! Unit tests of `original_serve`.
//! Pins the Original-path selection and options: modes parse and print symmetrically, `Auto` takes the Original path
//! only when everything is sealed and fed, explicit `Original` never falls back and names what is missing, `Preview`
//! is never overridden, option bounds, the conversation-cache defaults, and the eight-cell slack of the fit test.
use super::*;
use super::{ConfigFacts, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, PathBuf, choose, context_fits};
fn facts() -> ConfigFacts {
ConfigFacts {
@@ -28,21 +28,7 @@
//! Run: `cargo test -p leleka-engine-qwen35-cuda --features cuda-driver[,sm86] --release -- --ignored --nocapture
//! original_serve_laptop_bench`.
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc,
Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock,
Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, load, request,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile,
};
use crate::qwen_forward::{
original_serve_engine::ServeOutcome,
@@ -1,22 +1,5 @@
//! The serving passes of the laptop bench: the sequence, the soak limits and the per-request reports.
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, OriginalServeStack, PathBuf, Plan, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact,
Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeOutcome, ServeRequest,
Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile,
WindowWitness, elapsed, env, laptop_request, memory_line, request, soak,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
use super::{OriginalServeStack, Plan, ServeError, ServeOutcome, ServeRequest, env, laptop_request, memory_line};
/// The serving sequence and the soak limits.
pub(super) struct Soak {
@@ -23,7 +23,10 @@
//!
//! Output lines: `MEM-REPORT <tag> <json>` (the governor's full report), `MEM-CENSUS <json>`, `MEM-SOAK ...`, `MEM-SHED
//! ...`, `MEM-RESULT`.
use super::*;
use super::{
Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer,
VerifiedGgufFile,
};
use crate::qwen_forward::original_serve_stack::dbg_el;
use crate::qwen_forward::{
original_serve_request::{ServeError, ServeRequest},
@@ -1,24 +1,6 @@
//! The inventory scenario: the allocation inventory and the load ledger at idle, after a long request and with the
//! prefix cache full.
use super::{
Admission, Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError,
BackendIdentity, CacheCounts, Census, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode,
EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent,
GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, Governor, HostProc, InferenceMode,
InheritedKarArchive, InputBindingError, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig,
LOAD_CONFIG_VERSION, Level, LoadedModel, MeasurementFailure, Mem, ModelBinding, ModelDescriptor, Mutex, Ordering,
OriginalServeChoice, OriginalServeMode, OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget,
PrefixCacheOptions, PrefixConfig, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver,
RecentIds, RequestShape, RuntimeConfig, ServeError, ServeRequest, Sha256, StackConfig, SupportedModelTuple,
SyncSender, SystemClock, Tokenizer, Tolerances, Usage, VerifiedGgufFile, WindowWitness, guard, inventory, list,
number, print_report,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
use super::{Mem, list, number, print_report};
/// The number after `key` in a prefix metrics line.
fn metric(line: &str, key: &str) -> Option<u64> {
@@ -3,7 +3,7 @@
//! prefix store and the glibc heap, then fits the slope of each series against the request count after the
//! warm-up and prints it with its confidence interval.
use super::traffic::{Tally, TrafficRequest};
use super::*;
use super::{Census, Mem, PathBuf, env, list, number, print_report};
const TSV_HEADER: &str = "t_s\treq\trss\trss_anon\trss_file\trss_shmem\tswap\tavail\tcached\tshmem_sys\t\
active_file\tinactive_file\tvram_used\tvram_acct\tprefix_store\tmalloc_arena\tmalloc_in_use\tmalloc_free\t\
@@ -1,6 +1,10 @@
//! Loads the pinned model under the memory governor, opens the serve stack as production starts it and runs the
//! scenario of `LELEKA_MEM_SCENARIO` on it.
use super::*;
use super::{
CancelAt, Census, Driver, Governor, InheritedKarArchive, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget,
PrefixConfig, Qwen4ExpArtifact, Rc, Rng, SHARD0, SHARD1, ServeError, StackConfig, Tokenizer, VerifiedGgufFile,
census, dbg_el, env, filler, guard, number, print_report, required_path, serve_one, text,
};
/// What the operator asked for.
struct Plan {
@@ -1,5 +1,5 @@
//! Model-free probe of the sealed KAR memfd under the governor's residency guard.
use super::*;
use super::{Governor, InheritedKarArchive, env, guard, number, required_path};
/// One second of the probe: the memfd's swapped bytes, the cost of looking, and the swap counters since the last.
fn probe_second(governor: &Governor, t: u64, last_in: &mut Option<(u64, u64)>) {
@@ -1,7 +1,7 @@
//! The reader scenario: decode speed and the memfd's residency while a competing reader streams a big file
//! through the page cache (what the Original did when it read the KAR file next to the memfd): phase A without the
//! reader, B with it, C after.
use super::*;
use super::{Mem, NO_STOP, PathBuf, number, print_report, text};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
@@ -1,6 +1,6 @@
//! The shed scenario: the prefix cache evicted, requests refused and the budget restored, driven by floors moved
//! next to the memory the host has now, so the real limit is never approached.
use super::*;
use super::{Admission, Level, Mem, RequestShape, number, print_report};
use std::time::Duration;
fn available() -> u64 {
@@ -1,6 +1,6 @@
//! The soak scenario: mixed requests (cancels, refusals, long prompts, prefix-cache churn) judged flat after warm-up.
use super::traffic::{Tally, TrafficRequest};
use super::*;
use super::{Census, Mem, Tolerances, check_flat, list, number, print_report};
/// The knobs of the soak.
struct Soak {
@@ -1,6 +1,6 @@
//! The mixed traffic of the soak and the leak scenarios: sessions that grow by tool turns, big prompts,
//! unshared prompts, cancels and requests the governor must refuse.
use super::*;
use super::{Admission, Mem, RequestShape, ServeError};
/// What the traffic has done so far.
#[derive(Default)]
@@ -33,7 +33,10 @@
//!
//! Run: `cargo test -p leleka-engine-qwen35-cuda -- --ignored --exact
//! backend::original_serve_prefix_smoke::original_serve_prefix_cache_smoke`.
use super::*;
use super::{
Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer,
VerifiedGgufFile,
};
use crate::qwen_forward::original_serve_stack::dbg_el;
use crate::qwen_forward::{
original_serve_request::{ServeError, ServeRequest},
@@ -1,7 +1,7 @@
//! What the prefix-cache smoke does around the served requests: the per-request accounting, the verification
//! against a full read, the summary, the pool protocol on the live cache and the cancellation checks.
use super::run::Pfx;
use super::*;
use super::{CancelAt, ServeError, Served, env, filler, ids, mem_available_mib, rss_mib, serve_one};
/// What the served requests added up to.
#[derive(Default)]
@@ -1,7 +1,11 @@
//! Loads the pinned model, opens the stack in the mode asked for and serves the scripted workload.
use super::extras::{RequestAt, Tally};
use super::workload::{Plan, Workload};
use super::*;
use super::{
CancelAt, Driver, InheritedKarArchive, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget, PrefixConfig,
Qwen4ExpArtifact, Rc, SHARD0, SHARD1, ServeError, Served, StackConfig, Tokenizer, VerifiedGgufFile, dbg_el, env,
filler, mem_available_mib, number, required_path, rss_mib, serve_one, text, workload,
};
/// The pinned tokenizer and EOS, the KAR archive and the binding with its expert source.
struct Pinned {
@@ -1,22 +1,5 @@
//! The knobs and the scripted workload of the prefix-cache smoke (identical for every mode).
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail,
Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, Rng, RuntimeConfig, ServeError,
ServeRequest, Session, Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage,
VerifiedGgufFile, WindowWitness, env, filler, number, text,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
use super::{Rng, Session, Tokenizer, env, filler, number, text};
/// What the operator asked for.
pub(super) struct Plan {
@@ -31,21 +31,7 @@
//! Run (inside a holder job): `<test binary> --ignored --nocapture original_serve_replay_smoke`.
use super::super::qwen_forward::original_serve_stack::dbg_el;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc,
Receiver, RecentIds, Reply, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock,
Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, request,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile,
};
use crate::qwen_forward::{
original_serve_request::{ServeError, ServeRequest},
@@ -65,5 +51,4 @@ fn original_serve_replay_smoke() {
}
mod required_path;
#[allow(unused_imports)]
use required_path::required_path;
@@ -1,21 +1,6 @@
//! The captured requests and the pinned model of the replay.
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail,
Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, ServeError,
ServeRequest, Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage,
VerifiedGgufFile, WindowWitness, env, required_path,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, SHARD0, SHARD1, VerifiedGgufFile, env, required_path,
};
pub(super) fn number(name: &str, default: usize) -> usize {

Some files were not shown because too many files have changed in this diff Show More