diff --git a/architecture-baseline.json b/architecture-baseline.json index 193f620e..e7d21c90 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -4,21 +4,16 @@ "oversize": {}, "source": { "dyn-trait:leleka-cuda-driver": 45, - "dyn-trait:leleka-engine-core": 18, - "dyn-trait:leleka-engine-fake": 1, - "dyn-trait:leleka-engine-qwen35-cuda": 53, + "dyn-trait:leleka-engine-qwen35-cuda": 9, "env-read:leleka-control-plane": 3, - "env-read:leleka-engine-qwen35-cuda": 1, "glob-super-import:leleka-cuda-driver": 2, "instant-now:leleka-control-plane": 15, "instant-now:leleka-cuda-driver": 25, "instant-now:leleka-engine-host": 4, - "instant-now:leleka-engine-qwen35-cuda": 16, "instant-now:leleka-native-cpu-expert": 27, "path-include:leleka-cuda-driver": 1, "process-global:leleka-control-plane": 2, "process-global:leleka-cuda-driver": 96, - "process-global:leleka-engine-qwen35-cuda": 59, "process-global:leleka-native-cpu-expert": 27 }, "mechanical_names": [] diff --git a/architecture.json b/architecture.json index 319eb675..41247851 100644 --- a/architecture.json +++ b/architecture.json @@ -158,7 +158,64 @@ {"crate": "leleka-gateway-text", "file": "src/prompt/renderer.rs", "ratchet": "process-global", "reason": "the compiled pinned chat template: immutable, built on first use, read by every request"}, {"crate": "leleka-control-plane", "file": "src/request_log.rs", "ratchet": "process-global", "reason": "the process-wide request counters and histograms that /metrics renders; written by every request"}, {"crate": "leleka-control-plane", "file": "src/responses/harmony_prompt.rs", "ratchet": "process-global", "reason": "the gpt-oss prompt date: configuration set once by serve before the first request"}, - {"crate": "leleka-control-plane", "file": "src/stage_trace.rs", "ratchet": "process-global", "reason": "diagnostic stage table of the replay harness and STRATA_STAGE_TRACE: one table per process by design"} + {"crate": "leleka-control-plane", "file": "src/stage_trace.rs", "ratchet": "process-global", "reason": "diagnostic stage table of the replay harness and STRATA_STAGE_TRACE: one table per process by design"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/settings/source.rs", "ratchet": "env-read", "reason": "the one reader of the process environment of the engine: ProcessEnv is the adapter of the EnvSource port, and Settings parses every variable into typed fields there (S13)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per traced port call, only when the bring-up trace is on); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_lookahead.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per routing prediction on the lookahead thread); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_pool/direct_group_steps.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per CPU expert group of a decode round); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_pool/direct_tier.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per eager admission, once at start-up); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_pool.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per pool phase lap of a decode round); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_residency/pcie_share_controllers.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per PCIe lag probe and adaptation round); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/prefill_profile.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per prefill stage span, only when the profile switch is on); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs", "ratchet": "instant-now", "reason": "measurement timer in a hot loop (one reading per GDN layer producer lap, only when the command profile is on); a Clock parameter would add a generic to every owner on the path, which is the S14 follow-up; the reading is a Duration that only feeds a log line or a counter"}, + {"crate": "leleka-engine-core", "file": "src/family.rs", "ratchet": "dyn-trait", "reason": "EngineFamily::spawn returns Box: the family seam is the process boundary of the engine, called once at start-up"}, + {"crate": "leleka-engine-fake", "file": "src/lib.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/family.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/spawn.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/spawn_optimized.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/spawn_original.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/spawn_preview.rs", "ratchet": "dyn-trait", "reason": "Box is the process boundary: the factory hands the composed engine to the host, which holds one Backend per process (startup composition only, never per round)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/measurement.rs", "ratchet": "dyn-trait", "reason": "the evaluation measurement sink is a stored callback handed in by the host (observer port, called once per request)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/original_serve/runner.rs", "ratchet": "dyn-trait", "reason": "the GPU telemetry probe is a stored callback handed in by the host at load (port, sampled by the telemetry tick, not per token)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/original_serve/runner/owner_run_steps.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/original_serve/runner/reconfigure_command.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/backend/session.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/conversation/memory.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/memory_governor.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/memory_governor/page_cache.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/model_binding/weight_binding.rs", "ratchet": "process-global", "reason": "instance-local lazy cell (std::cell::OnceCell), not a process global: the gate pattern matches the type name"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/model_binding/weight_binding/binding_identity.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/model_binding/weight_binding/model_binding.rs", "ratchet": "process-global", "reason": "instance-local lazy cell (std::cell::OnceCell), not a process global: the gate pattern matches the type name"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/contract.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp/mtp_frame.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp/state/dense_kv.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp/state/prefix_draft_snapshot.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp/state/warming.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp_attention/dense_geometry.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp_decode/mtp_decoder/decoder_entry.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/mtp_decode/mtp_window_spec.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_residency/split_group_pcie.rs", "ratchet": "process-global", "reason": "the adaptive-tier tuning constants, derived once from the settings capture (immutable after the first read)"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack.rs", "ratchet": "process-global", "reason": "the epoch of the bring-up trace timestamps (DBG_T0), set once; diagnostics only"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/stack_phases/open_cache_steps.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_memory_classes.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open/assemble.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_phase.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/prefix/prefix_config.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs", "ratchet": "process-global", "reason": "reaches the process-wide memory governor through Governor::global(); the governor is one per process by design (host RAM is process-wide) and the handle is threaded through StackConfig and the request environment in the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_serve_stack/stack_config.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_spec_controller/trace_enabled.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_spec_draft.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/original_spec_draft/prefill_records.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/qsa_index/context.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/qsa_native_resources.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session.rs", "ratchet": "process-global", "reason": "instance-local lazy cell (std::cell::OnceCell), not a process global: the gate pattern matches the type name"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session/chunk/host_charge_bounded.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session/chunk/verify/verified_target_prefix.rs", "ratchet": "process-global", "reason": "reads the serving context (cells) that the engine configures once at start-up (leleka-cuda-model::serving_context, an immutable bound afterwards); threading it through every position check is the S13/S14 injection"}, + {"crate": "leleka-engine-qwen35-cuda", "file": "src/qwen_forward/session/qwen_session.rs", "ratchet": "process-global", "reason": "instance-local lazy cell (std::cell::OnceCell), not a process global: the gate pattern matches the type name"} ], "source_patterns": [ {"id": "env-read", "regex": "\\benv::var(_os)?\\(", "why": "configuration must be parsed once into a Settings struct (S13), not read all over the code"}, diff --git a/crates/engine-core/src/conversation/kv.rs b/crates/engine-core/src/conversation/kv.rs index 5b2522b9..d1487791 100644 --- a/crates/engine-core/src/conversation/kv.rs +++ b/crates/engine-core/src/conversation/kv.rs @@ -37,8 +37,8 @@ pub struct KvTarget<'a> { pub has_index_rows: bool, } -struct Verifier<'a> { - mem: &'a mut dyn StateMemory, +struct Verifier<'a, M: StateMemory + ?Sized> { + mem: &'a mut M, buffer: Vec, hash: u64, error: Option, diff --git a/crates/engine-core/src/conversation/kv/kv_image_readback.rs b/crates/engine-core/src/conversation/kv/kv_image_readback.rs index 4f8886c9..6294a029 100644 --- a/crates/engine-core/src/conversation/kv/kv_image_readback.rs +++ b/crates/engine-core/src/conversation/kv/kv_image_readback.rs @@ -7,8 +7,8 @@ use super::{ /// Compare the pages of the drafter ring (the last `st.n_slots` pages of the saved pool) with the device's resident /// copy of them; false once a page differs or cannot be read (the verifier holds the failure). -fn verify_ring( - v: &mut Verifier<'_>, +fn verify_ring( + v: &mut Verifier<'_, M>, saved: &crate::conversation::buffer::ConversationBuffer, (begin, end): (i64, i64), (layer, pool, st): (KvLayer, KvPool, &QsaDesc), @@ -30,7 +30,11 @@ fn verify_ring( /// Diagnostic read-back after a synchronised restore: compares the /// authoritative bytes (and the resident draft-ring pages), fingerprinting the /// authoritative payload only (FNV-1a 64). Never changes model state. -pub fn kv_verify(image: &ConversationKv, target: KvTarget<'_>, mem: &mut dyn StateMemory) -> ConvResult { +pub fn kv_verify( + image: &ConversationKv, + target: KvTarget<'_>, + mem: &mut M, +) -> ConvResult { let KvTarget { layer, st, g, upto, has_index_rows: index } = target; kv_validate(image, st, g, upto, index)?; let mut v = Verifier { mem, buffer: vec![0; 65536], hash: 1469598103934665603, error: None }; diff --git a/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs b/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs index bfb979f5..ae430f30 100644 --- a/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs +++ b/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs @@ -91,11 +91,11 @@ fn capture_layer( /// only for storage retained from an image actually restored into this /// session, bounded by every subsequent rewrite: equal token IDs alone do not /// establish that its K/V bytes are unchanged. -pub fn kv_save( +pub fn kv_save( image: &mut ConversationKv, target: KvTarget<'_>, unchanged_tokens: i64, - mem: &mut dyn StateMemory, + mem: &mut M, reused_bytes: Option<&mut usize>, ) -> ConvResult<()> { let KvTarget { layer, st, g, upto, has_index_rows: index } = target; @@ -159,7 +159,11 @@ fn restore_buffer( /// Write the image into the layer; refills streamed residency afterwards. /// The caller synchronises the device before and after the whole session. -pub fn kv_restore(image: &ConversationKv, target: KvTarget<'_>, mem: &mut dyn StateMemory) -> ConvResult<()> { +pub fn kv_restore( + image: &ConversationKv, + target: KvTarget<'_>, + mem: &mut M, +) -> ConvResult<()> { let KvTarget { layer, st, g, upto, has_index_rows: index } = target; kv_validate(image, st, g, upto, index)?; for (buffer, pool) in image.buffers().into_iter().zip(KvPool::ALL) { @@ -180,7 +184,7 @@ pub fn kv_restore(image: &ConversationKv, target: KvTarget<'_>, mem: &mut dyn St Ok(()) } -impl Verifier<'_> { +impl Verifier<'_, M> { /// Compare device bytes at `base + ..` with `expected`, chunked through a /// 64 KiB workspace; optionally fold them into the fingerprint. pub(super) fn compare(&mut self, loc: StateRegion, base: usize, expected: &[u8], include_hash: bool) -> bool { diff --git a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs index c579b7ac..f7860474 100644 --- a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs +++ b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs @@ -167,9 +167,9 @@ impl ConversationManager { /// continue the live session, restore a checkpoint, restore a parked /// conversation (parking the outgoing one first), or start empty. Any /// error is fatal for the request and the device state is then undefined. - pub fn begin_request( + pub fn begin_request( &mut self, - engine: &mut dyn SessionEngine, + engine: &mut E, ids: &[i32], req_imgs: &[ConversationImageKey], want_cvec: bool, @@ -215,9 +215,9 @@ impl ConversationManager { /// A checkpoint of the state after `ids[..position]`. `Ok` also when /// checkpoints are off. An existing checkpoint at the position just /// becomes the most recently used. - pub fn checkpoint_at( + pub fn checkpoint_at( &mut self, - engine: &mut dyn SessionEngine, + engine: &mut E, ids: &[i32], req_imgs: &[ConversationImageKey], position: usize, @@ -247,9 +247,9 @@ impl ConversationManager { /// A batched prompt chunk finished and the prompt is read up to `done`: /// take the periodic checkpoint when it is due. - pub fn chunk_done( + pub fn chunk_done( &mut self, - engine: &mut dyn SessionEngine, + engine: &mut E, ids: &[i32], req_imgs: &[ConversationImageKey], done: usize, @@ -267,9 +267,9 @@ impl ConversationManager { /// and the turn/root checkpoint when the action ends its segment. // Used by the Original-path prompt driver (the plan type is crate-private). #[allow(dead_code)] - pub fn after_prompt_action( + pub fn after_prompt_action( &mut self, - engine: &mut dyn SessionEngine, + engine: &mut E, ids: &[i32], req_imgs: &[ConversationImageKey], action: &PromptAction, diff --git a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs index 0814efe3..5eac9cd0 100644 --- a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs +++ b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs @@ -170,7 +170,11 @@ impl ConversationManager { /// an incoming image that is still alive during the exchange. Anything /// recoverable (nothing to park, no room, no RAM, allocation failure) /// skips parking and returns `Ok`; a device failure is fatal. - pub(in super::super) fn park_current(&mut self, engine: &mut dyn SessionEngine, held: usize) -> ConvResult<()> { + pub(in super::super) fn park_current( + &mut self, + engine: &mut E, + held: usize, + ) -> ConvResult<()> { if !self.cache.enabled() || !self.live_ok || self.live.is_empty() { return Ok(()); } diff --git a/crates/engine-core/src/conversation/manager_tests.rs b/crates/engine-core/src/conversation/manager_tests.rs index 7db74a4a..f8417d0d 100644 --- a/crates/engine-core/src/conversation/manager_tests.rs +++ b/crates/engine-core/src/conversation/manager_tests.rs @@ -53,8 +53,8 @@ struct Run { /// Deterministic xorshift for the property test. struct Rng(u64); -#[path = "manager_tests/byte_budget_and_slot.rs"] -mod byte_budget_and_slot; +#[path = "manager_tests/budget_and_failure_rules.rs"] +mod budget_and_failure_rules; #[path = "manager_tests/continuing_chat_reuses.rs"] mod continuing_chat_reuses; #[path = "manager_tests/random_traffic_resumes_into_exact_prefix_state.rs"] diff --git a/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs b/crates/engine-core/src/conversation/manager_tests/budget_and_failure_rules.rs similarity index 100% rename from crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs rename to crates/engine-core/src/conversation/manager_tests/budget_and_failure_rules.rs diff --git a/crates/engine-core/src/conversation/snapshot.rs b/crates/engine-core/src/conversation/snapshot.rs index ff583283..b701dca5 100644 --- a/crates/engine-core/src/conversation/snapshot.rs +++ b/crates/engine-core/src/conversation/snapshot.rs @@ -241,11 +241,11 @@ fn begin_capture( } /// Capture the K/V of every layer, then the draft's; returns the bytes the retained storage let it skip. -fn capture_kv( +fn capture_kv( captured: &mut SavedConversation, view: &ConversationView<'_>, session: SnapshotSession<'_>, - mem: &mut dyn StateMemory, + mem: &mut M, unchanged: i64, ) -> ConvResult { let SnapshotSession { ss, g, draft } = session; @@ -270,10 +270,10 @@ fn capture_kv( /// Builds into a new object so a failure cannot publish a partial snapshot. /// `reuse` is consumed, including on failure. The caller admits the estimate /// first; the active session is never modified by capture. -pub fn snapshot_save( +pub fn snapshot_save( view: &ConversationView<'_>, session: SnapshotSession<'_>, - mem: &mut dyn StateMemory, + mem: &mut M, reuse: ConversationKvReuse, reused_bytes: Option<&mut usize>, ) -> ConvResult { @@ -335,12 +335,12 @@ pub fn snapshot_validate( // Restore a whole image. Invalid images are rejected before any device /// write; a transfer failure may leave partial state. -pub fn snapshot_restore( +pub fn snapshot_restore( image: &SavedConversation, ss: &SessionSpec, g: &ModelGeometry, draft: &QsaDesc, - mem: &mut dyn StateMemory, + mem: &mut M, ) -> RestoreOutcome { if let Err(e) = snapshot_validate(image, ss, g, draft) { return RestoreOutcome::Invalid(e.0); @@ -349,7 +349,7 @@ pub fn snapshot_restore( return RestoreOutcome::TransferFailed(e.0); } let upto = image.live.ids.len() as i64; - let restore = |mem: &mut dyn StateMemory| -> ConvResult<()> { + let restore = |mem: &mut M| -> ConvResult<()> { for j in 0..ss.owned_qsa() { let st = ss.owned(j).ok_or_else(|| ConvError("conversation snapshot: missing QSA state".into()))?; kv_restore(&image.kv[j], KvTarget { layer: KvLayer::Main(j), st, g, upto, has_index_rows: true }, mem)?; diff --git a/crates/engine-core/src/conversation/state.rs b/crates/engine-core/src/conversation/state.rs index 771eb9eb..0a375908 100644 --- a/crates/engine-core/src/conversation/state.rs +++ b/crates/engine-core/src/conversation/state.rs @@ -188,11 +188,11 @@ fn alloc_payloads(c: &mut ConversationCheckpoint, ss: &SessionSpec, z: &StateSiz /// Capture the running state at `c.ids.len()` tokens into `c`'s payloads. /// The caller synchronises the device first. -pub fn checkpoint_save( +pub fn checkpoint_save( c: &mut ConversationCheckpoint, ss: &SessionSpec, g: &ModelGeometry, - mem: &mut dyn StateMemory, + mem: &mut M, ) -> ConvResult<()> { let z = checkpoint_targets(ss, g, c.ids.len())?; alloc_payloads(c, ss, &z)?; @@ -208,11 +208,11 @@ pub fn checkpoint_save( } /// Restore the indexer state of QSA layer `j`; the spare (moving) pooled row is reconstructed from the dead key. -fn restore_indexer( +fn restore_indexer( c: &ConversationCheckpoint, j: usize, (z, g): (&StateSizes, &ModelGeometry), - mem: &mut dyn StateMemory, + mem: &mut M, ) -> ConvResult<()> { let idx = |kind| StateRegion::Idx { layer: j, kind }; let dead = &c.dead[j * z.dead..(j + 1) * z.dead]; @@ -228,11 +228,11 @@ fn restore_indexer( } /// Restore a validated checkpoint; invalid input writes nothing. -pub fn checkpoint_restore( +pub fn checkpoint_restore( c: &ConversationCheckpoint, ss: &SessionSpec, g: &ModelGeometry, - mem: &mut dyn StateMemory, + mem: &mut M, ) -> ConvResult<()> { checkpoint_validate(c, ss, g)?; let z = session_sizes(g, ss)?; diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store.rs b/crates/engine-core/src/prefix_cache/store/prefix_store.rs index f36680bf..75c92501 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store.rs @@ -7,7 +7,7 @@ use super::{ }; mod admit; +mod eviction; +mod lookup_clock; mod prefix_store_consider_commit; -mod prefix_store_evict_and_budget; -mod prefix_store_stats_and_clock; mod scoring; diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_evict_and_budget.rs b/crates/engine-core/src/prefix_cache/store/prefix_store/eviction.rs similarity index 100% rename from crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_evict_and_budget.rs rename to crates/engine-core/src/prefix_cache/store/prefix_store/eviction.rs diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_stats_and_clock.rs b/crates/engine-core/src/prefix_cache/store/prefix_store/lookup_clock.rs similarity index 100% rename from crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_stats_and_clock.rs rename to crates/engine-core/src/prefix_cache/store/prefix_store/lookup_clock.rs diff --git a/crates/engine-qwen35-cuda/src/backend.rs b/crates/engine-qwen35-cuda/src/backend.rs index c2deffa2..5960364a 100644 --- a/crates/engine-qwen35-cuda/src/backend.rs +++ b/crates/engine-qwen35-cuda/src/backend.rs @@ -5,17 +5,17 @@ mod original_serve; use crate::experimental::{self as experimental_modes, ExperimentalConfig}; use crate::model_binding::kar_expert_source::KarExpertSource; pub use crate::model_binding::kar_expert_source::{KarArchiveRef, KarExpertLevels, KarExpertSourceConfig}; -pub use crate::model_binding::qwen4exp_kar_ple::InheritedKarArchive; +pub use crate::model_binding::kar_ple_source::InheritedKarArchive; pub use original_serve::{ ExpertSource, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, PrefixCacheOptions, PrefixTail, }; mod measurement; -use crate::model_binding::qwen4exp_input::{InputBindingError, ModelBinding}; +use crate::model_binding::weight_binding::{InputBindingError, ModelBinding}; // What only the preview serve path (generation loop, weight caches, resident conversations) works with. #[cfg(feature = "preview-path")] use crate::{ conversation::resident::{ResidentConversations, ResidentPolicy}, - model_binding::qwen4exp_input::InputConstants, + model_binding::weight_binding::InputConstants, qwen_forward::{ contract::{Dimension, Position, TokenId}, dense_weight_cache::DenseWeightCache, @@ -153,14 +153,11 @@ mod lifecycle_tests; mod tests; #[cfg(test)] -mod backend_measurement_sdet; +mod measurement_bookkeeping_proof; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod combined_prefix_numeric; -#[cfg(feature = "preview-path")] -#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -mod combined_prefix_numeric_sdet; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod original_serve_arms; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] @@ -177,6 +174,9 @@ 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"))] +mod prefix_equivalence_gate; +#[cfg(feature = "preview-path")] +#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod singleload_proof; #[cfg(feature = "preview-path")] diff --git a/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs b/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs index f37392a9..1713d297 100644 --- a/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs +++ b/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs @@ -8,8 +8,8 @@ use super::{ Dimension, Instant, MtpDecoder, MtpWindowError, MtpWindowSpec, TargetStepProduct, TokenId, native_position, }; use crate::qwen_forward::mtp::KnownNext; -mod prefill_tiles_and_windows; -use prefill_tiles_and_windows::{begin_decoder, commit_window, emit_token_text, prefill_tiles, verified_window}; +mod mtp_loop_steps; +use mtp_loop_steps::{begin_decoder, commit_window, emit_token_text, prefill_tiles, verified_window}; pub(super) fn generate_mtp( run: Generation<'_, '_, '_, C>, diff --git a/crates/engine-qwen35-cuda/src/backend/generate_mtp/prefill_tiles_and_windows.rs b/crates/engine-qwen35-cuda/src/backend/generate_mtp/mtp_loop_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/backend/generate_mtp/prefill_tiles_and_windows.rs rename to crates/engine-qwen35-cuda/src/backend/generate_mtp/mtp_loop_steps.rs diff --git a/crates/engine-qwen35-cuda/src/backend/backend_measurement_sdet.rs b/crates/engine-qwen35-cuda/src/backend/measurement_bookkeeping_proof.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/backend/backend_measurement_sdet.rs rename to crates/engine-qwen35-cuda/src/backend/measurement_bookkeeping_proof.rs diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner.rs index 0b4a6c61..6d8cd566 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner.rs @@ -1,5 +1,5 @@ -//! Defines `GpuProbe`, `Run`. -//! Split out of `original_serve` to keep its files under the line limit. +//! The state of the Original owner loop: `Run` (everything `serve_load` hands the loop once the context exists) and the +//! GPU telemetry probe port the host injects. The loop's steps live in the `runner/` files. use super::super::{ ActiveGuard, BackendError, Command, DeferredTail, ErrorCode, FinishReason, GENERATION_TIMEOUT, GenerationEvent, @@ -93,17 +93,17 @@ mod capture_tests { } } -mod stack_config_and_reports; -use stack_config_and_reports::CapturedIds; -use stack_config_and_reports::PhaseDurations; -use stack_config_and_reports::admission_error; -use stack_config_and_reports::capture_request; -use stack_config_and_reports::gpu_probe; -use stack_config_and_reports::log_request_end; -use stack_config_and_reports::meta_facts; -use stack_config_and_reports::open_error; -use stack_config_and_reports::publish_prefix_summary; -use stack_config_and_reports::stack_config; +mod stack_reports; +use stack_reports::CapturedIds; +use stack_reports::PhaseDurations; +use stack_reports::admission_error; +use stack_reports::capture_request; +use stack_reports::gpu_probe; +use stack_reports::log_request_end; +use stack_reports::meta_facts; +use stack_reports::open_error; +use stack_reports::publish_prefix_summary; +use stack_reports::stack_config; mod request_generation; pub(in super::super) use request_generation::generate; pub(in super::super) use request_generation::{ClientLink, RequestToServe, TokenVocabulary}; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/stack_config_and_reports.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/stack_reports.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/backend/original_serve/runner/stack_config_and_reports.rs rename to crates/engine-qwen35-cuda/src/backend/original_serve/runner/stack_reports.rs index 258895bc..1ba4fd2b 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/stack_config_and_reports.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/stack_reports.rs @@ -244,6 +244,11 @@ fn capture_json( ) } +/// Token ids as the comma-separated line of the capture file. +fn join_ids(ids: &[T]) -> String { + ids.iter().map(ToString::to_string).collect::>().join(",") +} + /// The prompt ids and the generated ids of one request, as the capture records them. #[derive(Clone, Copy)] pub(super) struct CapturedIds<'a> { @@ -265,9 +270,8 @@ pub(super) fn capture_request( let CapturedIds { prompt, generated } = ids; static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); let index = NEXT.fetch_add(1, Ordering::Relaxed); - let join = |ids: &mut dyn Iterator| ids.map(|t| t.to_string()).collect::>().join(","); - let prompt_line = join(&mut prompt.iter().map(|&t| i64::from(t))); - let generated_line = join(&mut generated.iter().map(|&t| i64::from(t))); + let prompt_line = join_ids(prompt); + let generated_line = join_ids(generated); let lines = (prompt_line.as_str(), generated_line.as_str()); let json = capture_json(index, request, lines, (rounds, reused, prompt.len(), generated.len())); if std::fs::create_dir_all(dir).is_err() { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/arm_flags.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/arm_flags.rs index c5602109..83195c95 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/arm_flags.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/arm_flags.rs @@ -26,7 +26,7 @@ pub(super) struct ArmShape { pub(super) flags: ArmFlags, } /// 1 when `on` is set, 0 when `off` is, else -1. -fn tri(has: &dyn Fn(&str) -> bool, on: &str, off: &str) -> i8 { +fn tri(has: &impl Fn(&str) -> bool, on: &str, off: &str) -> i8 { if has(on) { 1 } else if has(off) { @@ -43,7 +43,7 @@ fn tail_flag(flags: &str) -> Option { /// docs/upstream-port-plan.md rows 2.4 / 2.5: `kh` / `rec` / `orig` (the prompt GDN recurrence: the /// three-value-heads kernel, the two-barrier kernel, the sealed Original one); `wide` / `fast` (the prompt top-k) and /// `cluster` / `nocluster` (the decode window's top-k on a thread-block cluster) are plain on/off flags. -fn gdn_flag(has: &dyn Fn(&str) -> bool) -> i8 { +fn gdn_flag(has: &impl Fn(&str) -> bool) -> i8 { if has("kh") { 1 } else if has("rec") { @@ -113,7 +113,7 @@ impl ArmFlags { } /// `mode@CAP[/BLOCK][!flag...]`: the mode may carry the arm's own prefill chunk and grid: `reply@8192` (chunk 8192, /// grid = chunk) or `reply@8192/2048`. A bare mode takes `default_capacity()`. -pub(super) fn parse(arm: &str, default_capacity: &dyn Fn() -> usize) -> ArmShape { +pub(super) fn parse(arm: &str, default_capacity: &impl Fn() -> usize) -> ArmShape { let Some((mode, shape)) = arm.split_once('@') else { let flags = ArmFlags::environment(); return ArmShape { mode: arm.to_owned(), capacity: default_capacity(), block: 0, tiers: None, flags }; diff --git a/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs b/crates/engine-qwen35-cuda/src/backend/prefix_equivalence_gate.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs rename to crates/engine-qwen35-cuda/src/backend/prefix_equivalence_gate.rs diff --git a/crates/engine-qwen35-cuda/src/backend/sources.rs b/crates/engine-qwen35-cuda/src/backend/sources.rs index 9186cb09..f1cd1ea8 100644 --- a/crates/engine-qwen35-cuda/src/backend/sources.rs +++ b/crates/engine-qwen35-cuda/src/backend/sources.rs @@ -26,7 +26,7 @@ fn verify_shard1(config: &NativeBackendConfig, clock: &impl Clock) -> Result InputResultKar { let started = clock.now(); - let result = crate::model_binding::qwen4exp_kar_ple::load_pinned_inherited_archive(archive); + let result = crate::model_binding::kar_ple_source::load_pinned_inherited_archive(archive); crate::load_clock::span("kar_inspect_verify", started); result } diff --git a/crates/engine-qwen35-cuda/src/backend/utf8.rs b/crates/engine-qwen35-cuda/src/backend/utf8.rs index 2dd26b95..d2c7352c 100644 --- a/crates/engine-qwen35-cuda/src/backend/utf8.rs +++ b/crates/engine-qwen35-cuda/src/backend/utf8.rs @@ -67,7 +67,7 @@ pub(super) fn emit_terminal( /// says so or the reader is gone. pub(super) fn emit_event( sink: &GenerationSink, - cancelled: &dyn Fn() -> bool, + cancelled: &impl Fn() -> bool, clock: &impl Clock, event: GenerationEvent, ) -> Result<(), GenerationFailure> { diff --git a/crates/engine-qwen35-cuda/src/load_clock.rs b/crates/engine-qwen35-cuda/src/load_clock.rs index 45fc6554..6b3b5182 100644 --- a/crates/engine-qwen35-cuda/src/load_clock.rs +++ b/crates/engine-qwen35-cuda/src/load_clock.rs @@ -4,6 +4,7 @@ //! //! `lap` times a phase of the loading thread since the previous lap; `span` times a phase that ran on //! another thread (the parallel verifications), so overlapping phases can be told apart in the log. +use leleka_obs::time::{Clock as _, SystemClock}; use std::{ io::Write, sync::Mutex, @@ -28,7 +29,7 @@ fn emit(phase: &str, seconds: Duration, total: Duration) { /// Start the clock of one load. pub(crate) fn begin() { - let now = Instant::now(); + let now = SystemClock.now(); if let Ok(mut clock) = CLOCK.lock() { *clock = Some(Clock { start: now, last: now }); } @@ -36,7 +37,7 @@ pub(crate) fn begin() { /// The phase of the calling thread that ended now, started at the previous lap. pub(crate) fn lap(phase: &str) { - let now = Instant::now(); + let now = SystemClock.now(); if let Ok(mut guard) = CLOCK.lock() && let Some(clock) = guard.as_mut() { @@ -49,7 +50,7 @@ pub(crate) fn lap(phase: &str) { /// A phase that started at `started` (possibly on another thread) and ended now. Does not move the lap mark. pub(crate) fn span(phase: &str, started: Instant) { - let now = Instant::now(); + let now = SystemClock.now(); if let Ok(guard) = CLOCK.lock() && let Some(clock) = guard.as_ref() { diff --git a/crates/engine-qwen35-cuda/src/memory_governor.rs b/crates/engine-qwen35-cuda/src/memory_governor.rs index ee3320c6..ae9c6ad3 100644 --- a/crates/engine-qwen35-cuda/src/memory_governor.rs +++ b/crates/engine-qwen35-cuda/src/memory_governor.rs @@ -140,9 +140,9 @@ fn fixed_items(g: &Governor, args: &StartArgs, settings: &Settings) -> Vec KarForm { match args.kar_file_backed { - Some(true) => KarForm::File { bytes: crate::model_binding::qwen4exp_kar_ple::PINNED_ARCHIVE_BYTES }, + Some(true) => KarForm::File { bytes: crate::model_binding::kar_ple_source::PINNED_ARCHIVE_BYTES }, _ => KarForm::MemfdInherited { - bytes: args.kar_sparse_bytes.unwrap_or(crate::model_binding::qwen4exp_kar_ple::PINNED_ARCHIVE_BYTES), + bytes: args.kar_sparse_bytes.unwrap_or(crate::model_binding::kar_ple_source::PINNED_ARCHIVE_BYTES), }, } } @@ -190,7 +190,7 @@ pub(crate) fn startup(args: &StartArgs, settings: &Settings) -> Result<&'static #[cfg(all(target_os = "linux", target_arch = "x86_64"))] pub(crate) fn guard_archive( g: &Governor, - archive: &crate::model_binding::qwen4exp_kar_ple::InheritedKarArchive, + archive: &crate::model_binding::kar_ple_source::InheritedKarArchive, ) -> Result<(), BackendError> { use std::os::fd::AsFd; if archive.file_backed() { @@ -201,7 +201,7 @@ pub(crate) fn guard_archive( let extents = archive.sparse_extents(); g.guard_archive_extents( archive.archive_handle().as_fd(), - crate::model_binding::qwen4exp_kar_ple::PINNED_ARCHIVE_BYTES, + crate::model_binding::kar_ple_source::PINNED_ARCHIVE_BYTES, extents.as_deref(), ) .map(|_| ()) @@ -225,7 +225,7 @@ fn archive_inventory(extents: Option<&[(u64, u64)]>) -> (u64, &'static str) { (PLE rows, header, directory); the rest is a hole", ), None => ( - crate::model_binding::qwen4exp_kar_ple::PINNED_ARCHIVE_BYTES, + crate::model_binding::kar_ple_source::PINNED_ARCHIVE_BYTES, "the pinned level-2 archive, sealed memfd (55,295,529,472 B), shared with the holder", ), } @@ -389,7 +389,7 @@ pub(crate) fn complement_room(available: u64) -> u64 { #[cfg(target_os = "windows")] pub(crate) fn guard_archive( _g: &Governor, - _archive: &crate::model_binding::qwen4exp_kar_ple::InheritedKarArchive, + _archive: &crate::model_binding::kar_ple_source::InheritedKarArchive, ) -> Result<(), BackendError> { Ok(()) } diff --git a/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs b/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs index 02f599a6..d99e075b 100644 --- a/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs +++ b/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs @@ -1,4 +1,5 @@ -//! Page-cache release after the load (`drop_file_cache`), moved out of `memory_governor` by STRA-338 (size). +//! Page-cache release after the load (`drop_file_cache`): the kernel gets the pages of the shard files back once the +//! weights are on the device. use super::{Governor, HostFacts, HostProc}; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source.rs index 081eea89..d7b411be 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source.rs @@ -1,6 +1,6 @@ //! Explicit, immutable experimental PLE source. This module never owns CUDA or sessions. #![allow(dead_code)] -use super::qwen4exp_input::{BindingIdentity, InputBindingError, InputResult, PLE_ROWS}; +use super::weight_binding::{BindingIdentity, InputBindingError, InputResult, PLE_ROWS}; use leleka_model_format::kar::{ KarError, KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, VerifiedKarPleArtifact, }; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_archive.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_archive.rs index 5521d204..98f88bcc 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_archive.rs @@ -1,5 +1,5 @@ -//! Methods of `InheritedKarArchive`: `open`, `open_sparse`, `open_sparse`, `sparse_extents` and 7 more. -//! Functions: `open_sealed_archive_fd`, `open_read_only_archive`, `check_read_only_archive`, `reopen_read_only_archi... +//! The KAR PLE archive handed down by the parent process: a sealed memfd, a sparse extent map or an ordinary read-only +//! file. Opening it checks the kind, length, links, owner and permission bits; readers are independent reopens of it. use super::{ ARCHIVE_DIGEST, File, InheritedKarArchive, InputBindingError, InputResult, PINNED_ARCHIVE_BYTES, PROVENANCE_DIGEST, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive/weight_source_tests.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_archive/weight_source_tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive/weight_source_tests.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_archive/weight_source_tests.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_tests.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_tests.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/inherited_kar_tests.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/load_pinned_inherited_archive.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/load_pinned_inherited_archive.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/load_pinned_inherited_archive.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/load_pinned_inherited_archive.rs index afa36b82..8363e59c 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/load_pinned_inherited_archive.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/load_pinned_inherited_archive.rs @@ -1,5 +1,5 @@ -//! Methods of `KarRowPacket`: `payload`, `partition`. Methods of `KarRowReader`: `read_rows`. -//! Functions: `open_archive_reader`, `load_pinned_inherited_archive`, `log_startup_read`, `load_pinned_inherited_arc... +//! Loads the verified PLE artifact from the inherited archive: the read handle, the startup log line of what was read, +//! and the row packets and readers the PLE cache takes its rows from. Windows keeps only the file-backed form. use super::{ BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPleBinding, KarRowPacket, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/pinned_profile.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/pinned_profile.rs index 136c70bf..bc188cd0 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/pinned_profile.rs @@ -1,5 +1,5 @@ -//! Methods of `InheritedKarArchive`: `expert_capture_observation`. -//! Functions: `pinned_profile`, `pinned_parts`, `pinned_profile_spec`, `load_pinned_archive` and 3 more. +//! The pinned KAR PLE profile: the conversion receipts it expects, the partition of the rows, and the verification of +//! the archive against them. Linux freezes a private inode before inspection; other platforms refuse the path form. use super::{ ARCHIVE_DIGEST, File, InheritedKarArchive, InputBindingError, InputResult, KarPlePartProvenance, KarPleProfile, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/pinned_profile_tests.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/pinned_profile_tests.rs index fc20946a..0b530f82 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/pinned_profile_tests.rs @@ -1,5 +1,5 @@ -//! Implements `Write for BrokenSink`. -//! Functions: `diagnostic_cases`, `assert_kar_diagnostic_redacts`, `assert_input_diagnostic_survives_broken_sink`, `... +//! Pins the PLE profile: its numbers match the independent conversion receipts, the partitions cover the rows exactly, +//! and load diagnostics redact their causes yet keep the typed failure even when the diagnostic sink is broken. use super::{ InputBindingError, KarError, LoadPhase, NATIVE_DIGESTS, PLE_ROWS, error, input_diagnostic, kar_diagnostic, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy.rs index 0b4b73ee..c5a4d5b2 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy.rs @@ -1,5 +1,5 @@ -//! Defines `Inode`, `IoPhase`, `OwnedCopy`. -//! Split out of `qwen4exp_kar_ple` to keep its files under the line limit. +//! Types of the private copy: the inode identity, the I/O phase a failure is reported against, and `OwnedCopy`, the +//! handle that removes its file when dropped. The operations are in `inode` and `checked_reader`. use super::{InputBindingError, InputResult, LoadPhase, input_failure}; #[cfg(target_os = "linux")] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/checked_reader.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy/checked_reader.rs similarity index 93% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/checked_reader.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy/checked_reader.rs index e4b13051..0f5ec0a6 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/checked_reader.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy/checked_reader.rs @@ -1,5 +1,5 @@ -//! Functions: `checked_reader`, `copy_exact`, `copy_exact_reporting`, `copy_buffer` and 1 more. -//! Split out of `private_copy` to keep its files under the line limit. +//! Reading side of the private copy: a checked reader over the frozen inode and `copy_exact`, which copies exactly the +//! pinned byte count and refuses a source that holds more. use super::{COPY_BUFFER, InputBindingError, InputResult, IoPhase, LoadPhase, Read, Write, input_failure, report_io}; #[cfg(not(target_os = "linux"))] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy/inode.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy/inode.rs index 22418bf1..ad6b6c93 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/private_copy/inode.rs @@ -1,5 +1,5 @@ -//! Methods of `OwnedCopy`: `create`, `created`, `writer`, `detach` and 2 more. Implements `Drop for OwnedCopy`. -//! Functions: `inode`, `diagnostic`, `report_io`, `phase_error` and 8 more. +//! The private copy of a source file as an owned inode: create, write, seal, reopen read-only and detach, with the +//! checks that the sealed inode is the one this owner created and that no name refers to it any more. use super::{ File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/win_archive.rs b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/win_archive.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/win_archive.rs rename to crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/win_archive.rs index 57a94c1a..5a4d1f2d 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/win_archive.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/kar_ple_source/win_archive.rs @@ -1,5 +1,5 @@ -//! Functions: `io_error`, `open_regular`, `open_read_only_archive`, `check_len` and 3 more. -//! Split out of `qwen4exp_kar_ple` to keep its files under the line limit. +//! Windows form of the inherited archive: a regular file opened with a sharing mode that keeps writers out, a length +//! check, independent positional reopens and the provenance digest check. use super::{InputBindingError, InputResult}; use std::{ diff --git a/crates/engine-qwen35-cuda/src/model_binding/mod.rs b/crates/engine-qwen35-cuda/src/model_binding/mod.rs index 896574b4..cb429cb9 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/mod.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/mod.rs @@ -3,8 +3,8 @@ pub(crate) mod kar_expert_source; pub(crate) mod kar_levels; -pub(crate) mod qwen4exp_input; -pub(crate) mod qwen4exp_kar_ple; +pub(crate) mod kar_ple_source; +pub(crate) mod weight_binding; #[cfg(test)] #[path = "../../tests/stra161_reference.rs"] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding.rs index ed680078..f508fc69 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/weight_binding.rs @@ -103,7 +103,7 @@ pub(crate) struct ModelBinding { layers: Box<[BoundLayer]>, expert_count: u32, expert_used_count: u32, - kar_ple: Option, + kar_ple: Option, kar_experts: Option, mtp: Option, /// Lazily opened batched PLE reader; `None` inside means synchronous reads. @@ -145,7 +145,7 @@ mod native_output; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))] pub(crate) use native_output::NativeOutputRole; -mod binding_identity_and_input_binding_error; +mod binding_identity; mod model_binding; mod validate_ple_descriptor; use validate_ple_descriptor::bind_layers; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/binding_identity.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/binding_identity.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/decode.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/decode.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/decode.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/decode.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/gdn.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/gdn.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/gdn/tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/gdn/tests.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/gr.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/gr.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/gr/tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/gr/tests.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/model_binding.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/model_binding.rs index 08b6a223..5b6817d3 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/model_binding.rs @@ -45,7 +45,7 @@ impl ModelBinding { kar: leleka_model_format::kar::VerifiedKarPleArtifact, ) -> InputResult { let mut binding = Self::from_artifact(artifact)?; - binding.kar_ple = Some(super::super::qwen4exp_kar_ple::KarPleBinding::new(&binding.identity, kar)?); + binding.kar_ple = Some(super::super::kar_ple_source::KarPleBinding::new(&binding.identity, kar)?); Ok(binding) } /// Select the KAR routed-expert weight source before publishing the @@ -68,7 +68,7 @@ impl ModelBinding { pub(crate) fn kar_expert_source(&self) -> Option<&super::super::kar_expert_source::KarExpertSource> { self.kar_experts.as_ref() } - pub(crate) fn kar_ple_binding(&self) -> Option<&super::super::qwen4exp_kar_ple::KarPleBinding> { + pub(crate) fn kar_ple_binding(&self) -> Option<&super::super::kar_ple_source::KarPleBinding> { self.kar_ple.as_ref() } /// Operator paths are consumed inside model binding, never from a request. @@ -78,7 +78,7 @@ impl ModelBinding { source: &std::path::Path, owner_root: &std::path::Path, ) -> InputResult { - let kar = super::super::qwen4exp_kar_ple::load_pinned_archive(source, owner_root)?; + let kar = super::super::kar_ple_source::load_pinned_archive(source, owner_root)?; Self::from_artifact_with_kar_ple(artifact, kar) } pub(crate) fn expert_count(&self) -> u32 { @@ -87,9 +87,9 @@ impl ModelBinding { pub(crate) fn from_artifact_with_inherited_kar_ple( artifact: Qwen4ExpArtifact, - source: &super::super::qwen4exp_kar_ple::InheritedKarArchive, + source: &super::super::kar_ple_source::InheritedKarArchive, ) -> InputResult { - let kar = super::super::qwen4exp_kar_ple::load_pinned_inherited_archive(source)?; + let kar = super::super::kar_ple_source::load_pinned_inherited_archive(source)?; Self::from_artifact_with_kar_ple(artifact, kar) } @@ -140,7 +140,7 @@ impl ModelBinding { /// Both providers are fully admitted before publishing this fresh binding. pub(crate) fn from_artifact_with_inherited_kar_mtp( artifact: Qwen4ExpArtifact, - source: &super::super::qwen4exp_kar_ple::InheritedKarArchive, + source: &super::super::kar_ple_source::InheritedKarArchive, mtp_source: &std::path::Path, mtp_root: &std::path::Path, ) -> InputResult { diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/encoded_finite.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/encoded_finite.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/encoded_finite.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/encoded_finite.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/model_binding.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/model_binding.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/model_binding/model_binding_moe_descriptors.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/model_binding/model_binding_moe_descriptors.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/moe_expert_block_reads.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/model_binding/moe_expert_block_reads.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/moe_expert_block_reads.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/model_binding/moe_expert_block_reads.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/moe_expert_weights.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/moe_expert_weights.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_routed_source_scope.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/moe_routed_source_scope.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_routed_source_scope.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/moe_routed_source_scope.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/routed_source_descriptor.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_expert/routed_source_descriptor.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_route.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_route.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_route.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/moe_route.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp.rs similarity index 68% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp.rs index 70a0b676..713b6956 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp.rs @@ -37,24 +37,24 @@ use read_expert_rows::read_expert_rows; use read_expert_rows::row_range; use read_expert_rows::validate_numeric; -mod mtp_kind_types; -use mtp_kind_types::Dense; -use mtp_kind_types::Descriptor; -pub(crate) use mtp_kind_types::MtpExpertMatrix; -pub(crate) use mtp_kind_types::MtpExpertRef; -pub(crate) use mtp_kind_types::MtpKind; -pub(crate) use mtp_kind_types::MtpRole; -mod descriptors_types; -use descriptors_types::DESCRIPTORS; -mod dense_bytes_types; -use dense_bytes_types::DENSE_BYTES; -use dense_bytes_types::EXPERT_BLOB; -use dense_bytes_types::EXPERT_BYTES; -use dense_bytes_types::FILE_PINS; -use dense_bytes_types::INDEX_BYTES; -use dense_bytes_types::INDEX_LIMIT; -use dense_bytes_types::MAX_READ; -use dense_bytes_types::MAX_ROWS; -use dense_bytes_types::MtpIndex; -pub(crate) use dense_bytes_types::MtpRows; -pub(crate) use dense_bytes_types::MtpWeights; +mod pack_vocabulary; +use pack_vocabulary::Dense; +use pack_vocabulary::Descriptor; +pub(crate) use pack_vocabulary::MtpExpertMatrix; +pub(crate) use pack_vocabulary::MtpExpertRef; +pub(crate) use pack_vocabulary::MtpKind; +pub(crate) use pack_vocabulary::MtpRole; +mod tensor_table; +use tensor_table::DESCRIPTORS; +mod pack_pins; +use pack_pins::DENSE_BYTES; +use pack_pins::EXPERT_BLOB; +use pack_pins::EXPERT_BYTES; +use pack_pins::FILE_PINS; +use pack_pins::INDEX_BYTES; +use pack_pins::INDEX_LIMIT; +use pack_pins::MAX_READ; +use pack_pins::MAX_ROWS; +use pack_pins::MtpIndex; +pub(crate) use pack_pins::MtpRows; +pub(crate) use pack_pins::MtpWeights; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/backing.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/backing.rs index dc31258b..c29ea781 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/backing.rs @@ -1,5 +1,5 @@ -//! Methods of `OwnedCopy`: `create`, `writer`, `owns_directory`, `owns_file` and 1 more. -//! Implements `Drop for OwnedCopy`. Functions: `inode`, `regular`, `root`, `copy_exact` and 8 more. +//! Linux and macOS test-build backing of the MTP pack: the pinned file is copied into a private, sealed, unlinked inode +//! (`OwnedCopy`) that the verifier reads, so a writer of the source can no longer change what was verified. #[cfg(test)] use super::{EXPERT_BLOB, MtpExpertMatrix, MtpKind, read_exact_range, read_expert_rows}; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/mtp_weight_reads.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/mtp_weight_reads.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/pack_identity.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/pack_identity.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/pack_pins.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/pack_pins.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/pack_vocabulary.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/pack_vocabulary.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/read_expert_rows.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/read_expert_rows.rs index 3c75033f..ce49da67 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/read_expert_rows.rs @@ -1,5 +1,5 @@ -//! Functions: `read_expert_rows`, `read_expert_row`, `row_range`, `allocate` and 3 more. -//! Split out of `mtp` to keep its files under the line limit. +//! Reads the rows of one MTP expert matrix from the pinned pack: range arithmetic, positional reads on the frozen copy, +//! the interleave of the Q2 codes and scales, and the finiteness check of what was read. #[cfg(not(target_os = "linux"))] use super::backing; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/tensor_table.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/tensor_table.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/mtp/tests.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/native_output.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/native_output.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/native_output.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/native_output.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/original_file_expert_source.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/original_file_expert_source.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/original_file_expert_source.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/original_file_expert_source.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/output.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/output.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/output.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/output.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/ple.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/ple.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/ple.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/ple.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/ple_reader.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/ple_reader.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/ple_reader.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/ple_reader.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/qsa.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/qsa.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/qsa.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/qsa.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/resident_expert_source.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/resident_expert_source.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/resident_expert_source.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/resident_expert_source.rs diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/weight_binding/validate_ple_descriptor.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs rename to crates/engine-qwen35-cuda/src/model_binding/weight_binding/validate_ple_descriptor.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/bound_expert.rs b/crates/engine-qwen35-cuda/src/qwen_forward/bound_expert.rs index 936a0d13..6231b7d7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/bound_expert.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/bound_expert.rs @@ -1,5 +1,5 @@ //! The expert a projection, a cache fill or a loan refers to. -use crate::model_binding::qwen4exp_input::{ModelBinding, MoeExpertSelection, MoeExpertWeights}; +use crate::model_binding::weight_binding::{ModelBinding, MoeExpertSelection, MoeExpertWeights}; /// One expert (a routed slot or the shared expert) of validated expert weights, under the binding that admitted /// them. The three always travel together: weights are only meaningful for their binding, and the selection says diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/contract.rs b/crates/engine-qwen35-cuda/src/qwen_forward/contract.rs index 60a9c40c..64e8041a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/contract.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/contract.rs @@ -2,7 +2,7 @@ // These declarations intentionally have no production caller until leaf handoff. #![allow(dead_code)] -use crate::model_binding::qwen4exp_input::BindingError; +use crate::model_binding::weight_binding::BindingError; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) enum Stage { @@ -238,7 +238,7 @@ impl TokenLayer { #[cfg(test)] mod tests { use super::*; - use crate::model_binding::qwen4exp_input::ModelBinding; + use crate::model_binding::weight_binding::ModelBinding; #[test] fn positive_dimensions_have_checked_driver_representations() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cpu_expert_miss.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cpu_expert_miss.rs index 6ec86655..445f41da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cpu_expert_miss.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cpu_expert_miss.rs @@ -1,6 +1,6 @@ //! Safe actor-side source association; native ownership lives in the leaf crate. //! Returned bytes are NOT source/current-row/Context/publication certificates. -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, InputBindingError, ModelBinding, MoeMatrixRole, MoeRoutedSourceScope, MoeWeightDescriptor, }; use leleka_native_cpu_expert::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs index 72ba859c..a3a5a7e8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache.rs @@ -8,7 +8,7 @@ use super::qsa_index::{QsaIndexKeyCache, QsaPrior, QsaSelectedCache}; use super::qsa_index::{QsaInputLease, QsaInputScratch}; use super::qsa_index::{binding_error, driver_error}; use super::router_scratch::{RouterLease, RouterScratch}; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, BoundLayerKind, GdnMatrixKind, GdnMatrixRole, GdnWeights, GrRole, GrWeights, ModelBinding, PleMatrixRole, PleWeights, QsaMatrixKind, QsaMatrixRole, QsaWeights, }; @@ -96,7 +96,7 @@ pub(crate) struct DenseWeightCache<'ctx> { mod dense_slab_policy; mod workspaces; use workspaces::Workspaces; -mod dense_weight_cache_methods; +mod dense_cache_ops; use dense_slab_policy::dense_slab_policy; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use dense_slab_policy::startup_step; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops.rs similarity index 91% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops.rs index 32e39404..2c3691d4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops.rs @@ -12,10 +12,10 @@ use super::{ SlabAllocator, SlabPolicy, Workspaces, binding_error, dense_slab_policy, driver_error, startup_step, }; -mod dense_cache_buffers_and_close; mod dense_cache_eager_layer_load; mod dense_cache_gdn_qsa_workspaces; mod dense_cache_matrix_registration; -mod dense_cache_ple_and_verify_weights; -mod dense_cache_prompt_and_gdn_scratch; +mod dense_cache_prompt_capacity; +mod dense_cache_teardown; +mod dense_cache_weight_views; mod dense_weight_cache_constructors; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_eager_layer_load.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_eager_layer_load.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_eager_layer_load.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_eager_layer_load.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_gdn_qsa_workspaces.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_gdn_qsa_workspaces.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_matrix_registration.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_matrix_registration.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_prompt_capacity.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_prompt_capacity.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_buffers_and_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_teardown.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_buffers_and_close.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_teardown.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_weight_views.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_cache_weight_views.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_weight_cache_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_weight_cache_constructors.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_weight_cache_constructors.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_cache_ops/dense_weight_cache_constructors.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs index 54d43a73..0c16ee16 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs @@ -16,7 +16,7 @@ use super::{ qsa_index::{QsaIndexStage, QsaPrepareRequest}, session::{QwenSession, QwenStepTxn, TargetStepOrigin}, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, BoundLayerKind, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, BoundLayerKind, ModelBinding}; type StepCoreResult = (Option, Option>); @@ -51,7 +51,7 @@ pub(crate) struct PrefillStepProduct { /// All helpers disappear from serving builds. No tensor words enter logs or /// assertion formatting; only equality and bounded counts are reported. #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -mod reset_replay_sdet; +mod reset_replay_proof; /// Fixed operator labels only; diagnostics never contain request/model data. #[derive(Debug)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt.rs index 7908febc..a8bc38de 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt.rs @@ -126,7 +126,13 @@ pub(in crate::qwen_forward) struct NoPromptHooks; /// [`PromptPlan`](crate::backend::original_prompt::PromptPlan) is walked by `drive`; every `Batched` action is one /// real `OriginalPromptExecutor::forward` + `publish` transaction on the shared arena/session/draft, so the chunk loop /// of `Prefill::run` is the action sequence. This is an unselected source owner: nothing in `backend` constructs it. -pub(in crate::qwen_forward) struct OriginalPromptComposer<'a, 'arena, 'ctx> { +pub(in crate::qwen_forward) struct OriginalPromptComposer< + 'a, + 'arena, + 'ctx, + C: FnMut() -> bool, + H: OriginalPromptHooks + ?Sized, +> { pub executor: &'a mut OriginalPromptExecutor<'ctx>, pub binding: &'a ModelBinding, pub dense: &'a DenseWeightCache<'ctx>, @@ -139,8 +145,8 @@ pub(in crate::qwen_forward) struct OriginalPromptComposer<'a, 'arena, 'ctx> { pub embedding: &'a OriginalPromptEmbedding<'ctx>, pub policy: &'a OriginalMtpScalarPolicy, /// `should_stop` of the Original; also forwarded into every chunk's draft-KV recording. - pub cancel: &'a mut dyn FnMut() -> bool, - pub hooks: &'a mut dyn OriginalPromptHooks, + pub cancel: &'a mut C, + pub hooks: &'a mut H, /// The last chunk's publication (new origin and the known-next sample), for the caller's first decode window. pub last_published: Option<(TargetStepOrigin, Option)>, } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs index bef1d479..96e9dd5c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs @@ -16,6 +16,6 @@ use super::{ SpanExport, Stage, StagedInput, TokenId, driver_error, prof, staged_input_enabled, }; -mod construction_and_parking; -mod prompt_executor_forward_and_close; +mod chunk_run; +mod executor_lifecycle; mod prompt_executor_retire_owners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_draft.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_draft.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_final.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_final.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_input.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_input.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_layers.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_layers.rs index 7558d188..0f802178 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_chunk_forward/forward_layers.rs @@ -5,7 +5,7 @@ use super::{ OriginalPromptExecutor, OriginalPromptTxn, PStage, PromptDeviceNormedRows, PromptDeviceRows, PromptWeights, QsaLayerDevices, Result, prof, }; -use crate::model_binding::qwen4exp_input::BoundLayer; +use crate::model_binding::weight_binding::BoundLayer; use crate::qwen_forward::gr::GrRole; use crate::qwen_forward::prompt_device_rows::PromptDeviceRead; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_executor_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_executor_close.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_executor_close.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/chunk_run/prompt_executor_close.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle.rs index 29946253..ddec4d1c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle.rs @@ -11,4 +11,4 @@ use super::{ }; mod executor_construction; -mod session_park_and_qsa_owners; +mod session_handoff; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle/executor_construction.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle/executor_construction.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle/session_handoff.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/executor_lifecycle/session_handoff.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs index 5397dbbd..bc64ddac 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs @@ -41,7 +41,9 @@ impl Drop for OriginalPromptPending<'_, '_, '_> { } } impl OriginalPromptHooks for NoPromptHooks {} -impl crate::backend::original_prompt::PromptRunner for OriginalPromptComposer<'_, '_, '_> { +impl bool, H: OriginalPromptHooks + ?Sized> crate::backend::original_prompt::PromptRunner + for OriginalPromptComposer<'_, '_, '_, C, H> +{ type Error = Error; fn cancelled(&mut self) -> bool { (self.cancel)() @@ -75,10 +77,10 @@ impl crate::backend::original_prompt::PromptRunner for OriginalPromptComposer<'_ } /// Runs `plan` to its final seed through `composer`. `admitted_capacity` is the capacity the executor, arena and cache /// were built for. Cancellation maps to the same refusal `forward` returns when its draft recording is cancelled. -pub(in crate::qwen_forward) fn run_original_prompt( +pub(in crate::qwen_forward) fn run_original_prompt bool, H: OriginalPromptHooks + ?Sized>( plan: crate::backend::original_prompt::PromptPlan<'_>, admitted_capacity: usize, - composer: &mut OriginalPromptComposer<'_, '_, '_>, + composer: &mut OriginalPromptComposer<'_, '_, '_, C, H>, ) -> Result { use crate::backend::original_prompt::{DriveError, drive}; drive(plan, admitted_capacity, composer).map_err(|e| match e { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs index 32fcda05..c368c5ed 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs @@ -2,7 +2,7 @@ //! Q6K matrices (GDN or QSA roles), giving the projected columns per row for the retained GR bank. use super::{BoundLayerKind, DenseWeightCache, Error, LayerId, ModelBinding, QwenChunkTxn, Result}; -use crate::model_binding::qwen4exp_input::{GdnMatrixKind, GdnMatrixRole, QsaMatrixKind, QsaMatrixRole}; +use crate::model_binding::weight_binding::{GdnMatrixKind, GdnMatrixRole, QsaMatrixKind, QsaMatrixRole}; use crate::qwen_forward::gr::ResidualReady; use crate::qwen_forward::prompt_device_rows::PromptWeights; use crate::qwen_forward::q6_attention_columns::{self, ColumnKey, ColumnTarget, ProjectionRow, Role}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_proof.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_proof.rs index f3bc82c3..44415ef3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_proof.rs @@ -86,7 +86,7 @@ fn assert_topology(binding: &ModelBinding) -> usize { fn fixed_dimensions(binding: &ModelBinding) -> Fixed { // The verified closed artifact/binder fixes the main vocabulary; PLE // hash-table vocabularies are separate and must not be used here. - let vocabulary = Dimension::new(u64::from(crate::model_binding::qwen4exp_input::VOCABULARY)) + let vocabulary = Dimension::new(u64::from(crate::model_binding::weight_binding::VOCABULARY)) .expect("verified vocabulary refused"); assert_eq!(vocabulary.get(), VOCABULARY as u32); let context_length = diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs index 04ea33bd..9c710fe7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs @@ -33,7 +33,7 @@ fn topology_validation_requires_the_exact_contiguous_closed_sequence() { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod pinned { use super::*; - use crate::model_binding::qwen4exp_input::ModelBinding; + use crate::model_binding::weight_binding::ModelBinding; use leleka_model_format::{gguf::VerifiedGgufFile, qwen4exp::Qwen4ExpArtifact}; use std::{env, path::PathBuf}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs index 86897271..7f4a46ff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs @@ -5,7 +5,7 @@ use super::contract::{Dimension, Error, LayerId, Result, Stage, TokenLayer}; use super::dense_weight_cache::DenseWeightCache; use super::gr::ResidualReady; use super::session::QwenStepTxn; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, BoundLayerKind, GdnMatrixKind, GdnMatrixRole, GdnWeights, GrRole, InputBindingError, ModelBinding, }; use leleka_cuda_driver::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs index 3b13793e..e5e398f0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs @@ -8,7 +8,7 @@ use super::{ allocate, dispatch_projection, download, driver_error, normalize_retained_qk, validate_values, }; -mod chain_construction_and_buffers; mod chain_projection_convolution; -mod chain_readout_and_finish; mod chain_row_queue; +mod chain_slots; +mod readout_drain; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_construction_and_buffers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_slots.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_construction_and_buffers.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_slots.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_readout_and_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/readout_drain.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_readout_and_finish.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/readout_drain.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device.rs index 953c6c11..df3e4167 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device.rs @@ -60,5 +60,5 @@ mod mirror_reuse_enabled; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use mirror_reuse_enabled::micro_rows; use mirror_reuse_enabled::mirror_reuse_enabled; -mod gdn_chunk_device_methods; +mod chunk_device_phases; mod native_fused_step; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_batch_compute.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases/chunk_device_batch_compute.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_batch_compute.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases/chunk_device_batch_compute.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_construction.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases/chunk_device_construction.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_construction.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases/chunk_device_construction.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases/chunk_device_finish_cleanup.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/chunk_device_phases/chunk_device_finish_cleanup.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror.rs index 8f928b7d..dfb0164c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror.rs @@ -71,7 +71,7 @@ pub(super) struct MirrorReadout<'ctx> { #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod gpu_tests; -mod gdn_state_mirror_methods; mod mirror_readout; +mod state_mirror_phases; mod upload_checked; use upload_checked::upload_checked; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases.rs similarity index 87% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases.rs index 1dbca0e2..f87aecb9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases.rs @@ -7,5 +7,5 @@ use super::{ upload_checked, validate_values, }; -mod state_mirror_compute_and_admit; -mod state_mirror_publish_and_close; +mod mirror_compute; +mod mirror_publish; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases/mirror_compute.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases/mirror_compute.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_publish_and_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases/mirror_publish.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_publish_and_close.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/state_mirror_phases/mirror_publish.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/state.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/state.rs index a2ce2ab9..07890f37 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/state.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/state.rs @@ -1,7 +1,7 @@ //! Immutable, owner-bound recurrent candidates. Session is the sole publisher. use super::super::contract::{Error, LayerId, Position, Result, TokenLayer}; use super::{HISTORY_ELEMENTS, STATE_ELEMENTS, validate_values}; -use crate::model_binding::qwen4exp_input::BindingIdentity; +use crate::model_binding::weight_binding::BindingIdentity; use std::rc::{Rc, Weak}; #[derive(Clone)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs index 42d9a2e4..030f209e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs @@ -8,7 +8,7 @@ use super::{ Workspace, allocate, chain, download, driver_error, validate_values, }; -mod verified_row_compute_and_lease; -pub(in super::super) use verified_row_compute_and_lease::compute_row; +mod verified_row; +pub(in super::super) use verified_row::compute_row; mod workspace; mod workspace_replay; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row_compute_and_lease.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row_compute_and_lease.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/numeric_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/numeric_gpu.rs index 533f41da..a20ddbbf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/numeric_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/numeric_gpu.rs @@ -1,4 +1,4 @@ -//! Numerical transport proof of the MTP verification journal (test-only; moved out of the parent file by STRA-338). +//! Numerical transport proof of the MTP verification journal (test-only). use super::{ COUNTS, CandidatePair, Context, DeviceBuffer, Error, GdnStateFiniteGuard, Result, STATE_ELEMENTS, VALUES, VerifiedRowBuffers, allocate, compute_row, download, driver_error, upload, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs index 014e2fde..dad4eb15 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs @@ -6,8 +6,8 @@ use super::contract::{Dimension, Error, LayerId, Result, Stage, TokenLayer}; use super::dense_weight_cache::DenseWeightCache; use super::input::PleReady; use super::session::QwenStepTxn; -pub(crate) use crate::model_binding::qwen4exp_input::GrRole; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrWeights, InputBindingError, ModelBinding}; +pub(crate) use crate::model_binding::weight_binding::GrRole; +use crate::model_binding::weight_binding::{BindingIdentity, GrWeights, InputBindingError, ModelBinding}; use leleka_cuda_driver::{Context, DeviceBuffer, Error as DriverError}; use std::{ cell::{Cell, RefCell, RefMut}, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/checks.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/checks.rs index 8926b7cb..e4655c57 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/checks.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/checks.rs @@ -1,5 +1,4 @@ -//! Admission checks and the scratch lease of the retained attention -> FFN handoff (moved out of the parent file by -//! STRA-338). +//! Admission checks and the scratch lease of the retained attention -> FFN handoff. use super::{ Cell, Context, DenseWeightCache, DetachedGrRead, Error, GrPhase, GrRole, GrScratch, InjectedResidual, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs index f69e9d6f..44fd2ed1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs @@ -7,7 +7,7 @@ use super::contract::{Dimension, Error, Position, Result, Stage, TokenId}; use super::dense_weight_cache::{DenseWeightCache, PleResident}; use super::session::QwenStepTxn; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, EMBEDDING_VALUES, InputBindingError, ModelBinding, PLE_ROW_VALUES, VOCABULARY, }; @@ -52,7 +52,7 @@ pub(crate) struct InputStage; #[cfg(test)] mod tests { use super::*; - use crate::model_binding::qwen4exp_input::{InputConstants, PLE_ROWS}; + use crate::model_binding::weight_binding::{InputConstants, PLE_ROWS}; #[test] fn head_major_gather_keeps_all_sixteen_read_ranges_in_order() { let rows = std::array::from_fn(|head| 1000 + 7 * head as u64); @@ -130,7 +130,7 @@ mod tests { // layer one, before its GR read. Session owns the eventual atomic publication. use super::contract::{LayerId, TokenLayer}; use super::gr::InjectedResidual; -use crate::model_binding::qwen4exp_input::{GrRole, PleMatrixRole, PleWeights}; +use crate::model_binding::weight_binding::{GrRole, PleMatrixRole, PleWeights}; use leleka_cuda_driver::{Bf16ProjectionShape, Context, DeviceBuffer, Error as DriverError}; use std::rc::Rc; mod ple_transport; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs index 7fae45e2..8c9034b3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs @@ -13,9 +13,9 @@ use super::{InputReady, ResidualStreams, TokenId}; pub(super) fn gather_rows( rows: &[u64; 16], - mut read: impl FnMut(u64) -> crate::model_binding::qwen4exp_input::InputResult>, + mut read: impl FnMut(u64) -> crate::model_binding::weight_binding::InputResult>, ) -> std::result::Result, InputError> { - if rows.iter().any(|&row| row >= crate::model_binding::qwen4exp_input::PLE_ROWS) { + if rows.iter().any(|&row| row >= crate::model_binding::weight_binding::PLE_ROWS) { return Err(InputError::Binding(InputBindingError::Range)); } let mut output = Vec::new(); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs index 1eb2ece0..b440ebd1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs @@ -2,7 +2,7 @@ //! (with the EOS rule), identical per head to the Original, and bounded to the token and row domains. use super::super::contract::{Error, Result}; -use crate::model_binding::qwen4exp_input::{InputConstants, PLE_ROWS, VOCABULARY}; +use crate::model_binding::weight_binding::{InputConstants, PLE_ROWS, VOCABULARY}; pub(super) fn rows(token: u32, predecessors: [i32; 2], constants: &InputConstants) -> Result<[u64; 16]> { if token >= VOCABULARY || predecessors.iter().any(|&v| v < -1 || v >= VOCABULARY as i32) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs index ed3d11f1..48376a2d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs @@ -178,7 +178,7 @@ fn admit_kar_input<'b>( token: TokenId, pos: Position, txn: &QwenStepTxn, -) -> Result<(&'b crate::model_binding::qwen4exp_kar_ple::KarPleBinding, [u64; 16])> { +) -> Result<(&'b crate::model_binding::kar_ple_source::KarPleBinding, [u64; 16])> { let kar = binding.kar_ple_binding().ok_or(Error::IdentityMismatch)?; if !kar.matches(&binding.identity()) || !cache.context_matches(txn.cuda_context()?) { return Err(Error::IdentityMismatch); @@ -251,7 +251,7 @@ pub(super) fn trace_ple() -> bool { crate::settings::process().diagnostics.trace_ple } pub(super) fn validate_ids( - constants: &crate::model_binding::qwen4exp_input::InputConstants, + constants: &crate::model_binding::weight_binding::InputConstants, token: TokenId, pos: Position, ) -> Result<()> { @@ -265,7 +265,7 @@ pub(super) fn validate_ids( pub(super) fn gather_ple( binding: &ModelBinding, rows: &[u64; 16], - pending: crate::model_binding::qwen4exp_input::PlePending, + pending: crate::model_binding::weight_binding::PlePending, ) -> std::result::Result, InputError> { let decoded = binding.ple_collect(pending).map_err(InputError::Binding)?; let mut decoded = decoded.into_iter(); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache.rs index 85a14fca..dc3f0dbf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache.rs @@ -2,8 +2,8 @@ //! Cache mappings publish only after synchronized scatter + decode + finite readback. #![allow(dead_code)] use super::contract::{Error, Result}; -use crate::model_binding::qwen4exp_input::{BindingIdentity, PLE_ROWS}; -use crate::model_binding::qwen4exp_kar_ple::{KarPleBinding, KarRowPacket, KarRowReader}; +use crate::model_binding::kar_ple_source::{KarPleBinding, KarRowPacket, KarRowReader}; +use crate::model_binding::weight_binding::{BindingIdentity, PLE_ROWS}; use leleka_cuda_driver::{Context, DeviceBuffer}; use std::collections::{HashMap, VecDeque}; use std::hash::{BuildHasherDefault, Hasher}; @@ -142,4 +142,4 @@ mod publish_gather; use publish_gather::ahead_enabled; use publish_gather::publish_gather; mod ahead_rows; -mod kar_ple_cache_methods; +mod kar_ple_cache_lifecycle; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_lifecycle.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_lifecycle.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs index ff609710..2b6ef91b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs @@ -3,7 +3,7 @@ //! through the same verification as production. use super::{BindingIdentity, KarPleBinding, KarPleCache, PLE_ROWS}; -use crate::model_binding::qwen4exp_kar_ple::pinned_profile; +use crate::model_binding::kar_ple_source::pinned_profile; use leleka_cuda_driver::Driver; use leleka_model_format::kar::{KarInspection, VerifiedKarPleArtifact}; use std::io::Write; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/loaded_target_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/loaded_target_owners.rs index 1182dd62..b3a81fa8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/loaded_target_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/loaded_target_owners.rs @@ -3,7 +3,7 @@ use super::{ dense_weight_cache::DenseWeightCache, kar_ple_cache::KarPleCache, moe_weight_cache::MoeWeightCache, output::OutputStage, session::QwenSession, }; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; /// The loaded target model and every cache one on-loaded observation borrows; it exists so a phase takes one /// argument instead of six owners that always travel together. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert.rs index 45246230..224ec75a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert.rs @@ -10,7 +10,7 @@ use super::moe_weight_cache::{CachedMoeMatrix, MoeWeightCache}; use super::moe_weight_cache::{MmqChunkRequest, SharedTailRow}; use super::session::QwenStepTxn; use crate::model_binding::kar_expert_source::{KarExpertSource, KarSourceError}; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, GrRole, InputBindingError, ModelBinding, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs index ee97474a..11a70b4e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs @@ -93,7 +93,7 @@ fn upload_raw_matrix<'ctx>( weights, selection, role, - crate::model_binding::qwen4exp_input::MoeRows { first: 0, count: dims.rows }, + crate::model_binding::weight_binding::MoeRows { first: 0, count: dims.rows }, ) .map_err(binding_error)?; if block.kind() != dims.kind || block.columns() != dims.columns || block.rows() != dims.rows { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive.rs index d558793b..b167a47f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive.rs @@ -6,7 +6,7 @@ use super::{ Stage, binding_error, project_group, }; mod adaptive_wave; -use crate::model_binding::qwen4exp_input::{MoeRoutedSourceScope, MoeWeightDescriptor}; +use crate::model_binding::weight_binding::{MoeRoutedSourceScope, MoeWeightDescriptor}; use crate::qwen_forward::cpu_expert_miss::{CpuMissRows, CpuMissWorkspace, PreparedCpuMiss, runtime_error}; pub(super) use adaptive_wave::{AdaptiveWave, WaveState}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive/adaptive_wave.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive/adaptive_wave.rs index 0949206d..af729b58 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive/adaptive_wave.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive/adaptive_wave.rs @@ -1,4 +1,4 @@ -//! The adaptive wave: resident GPU groups beside owned CPU miss batches (STRA-338 size: extract-method only). +//! The adaptive wave: resident GPU groups beside owned CPU miss batches. use super::{ ActualDown, ChunkFfnRow, Context, DownOrigin, DownScope, Error, ExpertGroup, K, ModelBinding, MoeWeightCache, Pair, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_plan.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_plan.rs index 40a94fd1..b8f63fc3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_plan.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_plan.rs @@ -1,4 +1,4 @@ -//! Expert-group plan of one adaptive packet wave (STRA-338 size: extract-method only). +//! Expert-group plan of one adaptive packet wave. use super::super::direct_packets_fns::PacketRun; use super::packet_wave::PacketWave; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave.rs index cdcacae6..d9ab5e99 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave.rs @@ -1,4 +1,4 @@ -//! GPU queue and CPU miss batches of one adaptive packet wave (STRA-338 size: extract-method only). +//! GPU queue and CPU miss batches of one adaptive packet wave. use super::super::adaptive::{miss_batch_end, prepare_cpu_jobs, source_keys}; use super::super::packet_run_project_group_direct::DirectRun; @@ -7,7 +7,7 @@ use super::{ MoeWeightCache, N, Pair, QwenChunkTxn, Rc, Result, RoutedGateUpQ8, Stage, binding_error, driver_error, resident_queue, runtime_error, }; -use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; +use crate::model_binding::weight_binding::MoeWeightDescriptor; use crate::qwen_forward::cpu_expert_miss::{CpuMissRows, CpuMissWorkspace}; /// The GPU miss queue state: the shared miss list, the next miss to stage and the occupied ephemeral slots, plus the diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/bound_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/bound_rows.rs index 1c3d2d5c..44a252e4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/bound_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/bound_rows.rs @@ -1,4 +1,4 @@ -//! The uploaded rows of one chunk and their ungrouped/grouped execution (STRA-338 size: extract-method only). +//! The uploaded rows of one chunk and their ungrouped/grouped execution. #[cfg(all(test, target_arch = "x86_64"))] use super::direct_gpu; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_packets_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_packets_fns.rs index 8d843f83..525bb080 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_packets_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_packets_fns.rs @@ -1,4 +1,4 @@ -//! Phases of the direct-packet layer batch (STRA-338 size: extract-method only). +//! Phases of the direct-packet layer batch. #[cfg(all(test, target_arch = "x86_64"))] use super::direct_gpu; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_shared_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_shared_fns.rs index c5921b7b..e49a8c15 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_shared_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_shared_fns.rs @@ -1,4 +1,4 @@ -//! Helpers shared by the resident, direct and source Down groups (STRA-338 size: extract-method only). +//! Helpers shared by the resident, direct and source Down groups. use super::{ ActualSlotPacket, CachedMoeMatrix, ChunkFfnRow, Context, DeviceBuffer, DownColumns, DownScope, DriverError, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs index cbb20df1..e219a97d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs @@ -19,7 +19,7 @@ use super::{ download_f32, driver_error, dual_routed_format, ordered_down_refusal, validate_packet_pairs, }; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use crate::model_binding::qwen4exp_input::MoeRoutedSourceScope; +use crate::model_binding::weight_binding::MoeRoutedSourceScope; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::moe_weight_cache::RoutedSourceHealth; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/admission_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/admission_fns.rs index 30008f40..e1a20c2f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/admission_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/admission_fns.rs @@ -1,10 +1,10 @@ -//! Support and descriptor admission of one MMQ chunk (STRA-338 size: extract-method only). +//! Support and descriptor admission of one MMQ chunk. use super::{ ChunkFfnRow, Error, K, LayerId, ModelBinding, MoeExpertSelection, MoeMatrixKind, MoeMatrixRole, QwenChunkTxn, Result, binding_error, }; -use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; +use crate::model_binding::weight_binding::MoeWeightDescriptor; /// Whether every routed slot of every row has an MMQ-capable Gate/Up/Down kind. `supported` is the starting verdict. pub(super) fn rows_supported( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive.rs index 9f4e03f6..430de1f9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive.rs @@ -4,7 +4,7 @@ use super::{ Cell, ChunkFfnRow, Context, DeviceBuffer, Error, K, LayerId, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, Pair, QwenChunkTxn, Result, SlotPacks, Stage, binding_error, mmq_error, }; -use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; +use crate::model_binding::weight_binding::MoeWeightDescriptor; use crate::qwen_forward::moe_weight_cache::original_dual_layout; use leleka_cuda_driver::{MmqWorkspace, OriginalMmqLayer}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/expert_gather.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/expert_gather.rs index 99ee650f..33449542 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/expert_gather.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/expert_gather.rs @@ -1,4 +1,4 @@ -//! Gather of one expert's matrices into the admitted bank (STRA-338 size: extract-method only). +//! Gather of one expert's matrices into the admitted bank. use super::layer_walk::{ExpertGroup, Walk, WalkOwners}; use super::{ @@ -41,7 +41,7 @@ impl<'ctx> Walk<'_, '_, 'ctx> { fn gather_source bool>( &self, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>, gathered: GatheredExpert<'_>, owners: &mut WalkOwners<'_, '_, 'ctx, '_, '_, F>, ) -> Result<()> { @@ -53,7 +53,7 @@ impl<'ctx> Walk<'_, '_, 'ctx> { let consume = |raw: [&DeviceBuffer<'ctx>; 3], health: &crate::qwen_forward::moe_weight_cache::RoutedSourceHealth<'_, '_>, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>| { + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>| { self.stage_gathered(activation, formats, raw, &mut observed_cancel)?; self.confirm_gather(health, source, &mut observed_cancel, pairs) }; @@ -86,7 +86,7 @@ impl<'ctx> Walk<'_, '_, 'ctx> { fn confirm_gather( &self, health: &crate::qwen_forward::moe_weight_cache::RoutedSourceHealth<'_, '_>, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>, observed_cancel: &mut impl FnMut() -> bool, pairs: &[Pair], ) -> Result<()> { @@ -124,7 +124,7 @@ pub(super) fn gather_layouts(binding: &ModelBinding, row: &ChunkFfnRow, first: & /// Every grouped member must name the expected whole expert triplet. pub(super) fn check_expert_keys( - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>, keys: &[MoeWeightDescriptor; 3], members: usize, ) -> Result<()> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/layer_walk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/layer_walk.rs index cc91aede..cb8c4bf1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/layer_walk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/original_adaptive/layer_walk.rs @@ -1,4 +1,4 @@ -//! The adaptive prompt layer walk over staged and resident experts (STRA-338 size: extract-method only). +//! The adaptive prompt layer walk over staged and resident experts. use super::{ ChunkFfnRow, Context, DeviceBuffer, Error, LayerId, ModelBinding, MoeExpertSelection, MoeMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/resident_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/resident_layer.rs index 4ce4ac08..0684df33 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/resident_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident/resident_layer.rs @@ -1,4 +1,4 @@ -//! The resident MMQ chunk execution (STRA-338 size: extract-method only). +//! The resident MMQ chunk execution. use super::{ BoundExpert, Cell, ChunkFfnRow, Context, DEVICE_PEAK, DeviceBuffer, DownScope, Error, ExpertReady, K, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident_queue.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident_queue.rs index a7a8f56d..99aad99e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident_queue.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/resident_queue.rs @@ -9,7 +9,7 @@ use super::{ binding_error, download_f32, driver_error, ordered_down_refusal, use_direct_packets, uses_adaptive, validate_packet_pairs, }; -use crate::model_binding::qwen4exp_input::MoeRoutedSourceScope; +use crate::model_binding::weight_binding::MoeRoutedSourceScope; use crate::qwen_forward::moe_weight_cache::{RoutedResidentOwner, RoutedSourceHealth, TripletLoanRequest}; use leleka_cuda_driver::{RoutedResidentOutputs, RoutedResidentQueue, RoutedResidentRefusal, RoutedResidentWeights}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down.rs index b8d88bca..3c3d2452 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down.rs @@ -13,7 +13,7 @@ pub(super) enum DownSelection { /// row's index among them. #[derive(Clone, Copy)] pub(super) struct CompletedCpuRow<'a> { - pub(super) keys: &'a [crate::model_binding::qwen4exp_input::MoeWeightDescriptor; 3], + pub(super) keys: &'a [crate::model_binding::weight_binding::MoeWeightDescriptor; 3], pub(super) values: &'a super::super::cpu_expert_miss::CpuMissRows, pub(super) row_index: usize, } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs index 99d20c2a..dc91e6d2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs @@ -137,7 +137,7 @@ impl<'ctx> DownScope<'ctx> { /// admit the destination to the original ordered packet consumer. pub(in super::super) fn upload_cpu_completed_row( &self, - binding: &crate::model_binding::qwen4exp_input::ModelBinding, + binding: &crate::model_binding::weight_binding::ModelBinding, selection: DownSelection, completed: CompletedCpuRow<'_>, ) -> Result> { @@ -323,8 +323,8 @@ fn check_grouped_selections(selections: &[DownSelection]) -> Result<()> { } fn completed_row_source<'a>( - binding: &crate::model_binding::qwen4exp_input::ModelBinding, - keys: &[crate::model_binding::qwen4exp_input::MoeWeightDescriptor; 3], + binding: &crate::model_binding::weight_binding::ModelBinding, + keys: &[crate::model_binding::weight_binding::MoeWeightDescriptor; 3], selection: DownSelection, completed: &'a super::super::super::cpu_expert_miss::CpuMissRows, row: usize, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch.rs index 042fdf14..4efe8cab 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch.rs @@ -15,7 +15,7 @@ use super::contract::{Dimension, Error, LayerId, Result, TokenLayer}; use super::gr::ResidualReady; use super::qsa_index::driver_error; use super::shared_expert_workspace::validate_descriptors; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole, ModelBinding, MoeWeightDescriptor}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole, ModelBinding, MoeWeightDescriptor}; use leleka_cuda_driver::{ Context, DeviceBuffer, GdnGemm, GdnNativeFormat, MOE_BATCH_MAX_TOKENS, MOE_BATCH_SCRATCH_BYTES, MoePrefillBatch, MoeRouteBatch, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/route_micro.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/route_micro.rs index 935ed66e..8024786a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/route_micro.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/route_micro.rs @@ -1,4 +1,4 @@ -//! Validation and device phases of `MoePrefillStage::route_shared_micro` (STRA-338 size: extract-method only). +//! Validation and device phases of `MoePrefillStage::route_shared_micro`. use super::{ Buffers, CombineInput, DeviceBuffer, Dimension, EXPERTS, Error, GdnNativeFormat, GemmRef, GrRole, LayerId, MIXED, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route.rs index 3a33ab2c..cb60288e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route.rs @@ -5,7 +5,7 @@ use super::contract::{Dimension, Error, ExpertId, FiniteF32, LayerId, Position, use super::dense_weight_cache::DenseWeightCache; use super::gr::ResidualReady; use super::session::QwenStepTxn; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole, InputBindingError, ModelBinding, MoeRouteWeights}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole, InputBindingError, ModelBinding, MoeRouteWeights}; use leleka_cuda_driver::{Bf16ProjectionShape, Context, Error as DriverError}; const EXPERTS: usize = 512; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs index c38846c9..c9ae7352 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache.rs @@ -1,7 +1,7 @@ //! Actor-owned immutable encoded weights. Recurrence/checkpoints never own this cache. use super::contract::{Error, Result}; use super::qsa_index::{binding_error, driver_error}; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightDescriptor, MtpKind, MtpRole, }; @@ -358,7 +358,7 @@ use validate_ranked_profile::original_mmq_triplet; pub(super) use validate_ranked_profile::room_fits; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(crate) use validate_ranked_profile::validate_ranked_profile; +mod moe_cache_ops; mod moe_cache_routed_owners; -mod moe_weight_cache_methods; mod routed_source_health; mod routed_workspace_owner; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed.rs index 7d388dda..e871ba1b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed.rs @@ -1,6 +1,6 @@ //! Two temporary, source-bound whole expert triplets. No cache-hit or row proof. //! Root alone supplies the scheduler/current-transaction checks and registration. -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, ModelBinding, MoeExpertBlock, MoeMatrixRole, MoeRoutedSourceScope, MoeWeightDescriptor, }; use crate::qwen_forward::contract::{Error, Result, Stage}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs index a0fb07d2..65147962 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs @@ -9,5 +9,5 @@ use super::{ }; mod ephemeral_owner_allocation; -mod ephemeral_owner_loans_and_drain; +mod ephemeral_owner_lending; mod ephemeral_owner_stage_transfer; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_loans_and_drain.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_lending.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_loans_and_drain.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_lending.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs index 29bfd194..8870ea7f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs @@ -172,7 +172,7 @@ impl<'ctx> MoeWeightCache<'ctx> { fn expert_source_spans( binding: &ModelBinding, bank: &leleka_cuda_driver::MappedExpertBank<'ctx>, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>, layer: u32, expert: u32, ) -> Result<[ResidentExpertBankSpan; 3]> { @@ -257,7 +257,7 @@ fn shared_bytes( weights, MoeExpertSelection::Shared, roles[index], - crate::model_binding::qwen4exp_input::MoeRows { first: 0, count: key.rows }, + crate::model_binding::weight_binding::MoeRows { first: 0, count: key.rows }, ) .map_err(binding_error)? .into_bytes()) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_layer_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_layer_fns.rs index 5d45e196..7d13c550 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_layer_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_layer_fns.rs @@ -1,11 +1,11 @@ -//! One original-prompt MoE layer: expert spans, copy ring and finish (STRA-338 size: extract-method only). +//! One original-prompt MoE layer: expert spans, copy ring and finish. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GdnNativeFormat, LayerId, ModelBinding, MoeExpertWeights, MoeMatrixRole, MoeWeightDescriptor, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, PStage, Rc, ResidentExpertBankSpan, Result, binding_error, driver_error, original_dual_layout, prof, prompt_stream_settings, }; -use crate::model_binding::qwen4exp_input::MoeRoutedSourceScope; +use crate::model_binding::weight_binding::MoeRoutedSourceScope; use leleka_cuda_driver::{ MappedExpertBank, MmqFormat, MmqWorkspace, OriginalMmqCopySchedule, OriginalMoePromptDevice, OriginalMoePromptLayer, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile.rs index fe770862..c119ba8b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile.rs @@ -72,7 +72,7 @@ pub(crate) struct ProfileWitness { mod sdet; // Genuine descriptor list supplied only by the separate bound constructor. -use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; +use crate::model_binding::weight_binding::MoeWeightDescriptor; pub(super) const SHARED_MAX_BYTES: usize = 212_828_160; #[derive(Default, Clone, Copy, Debug, PartialEq, Eq)] pub(crate) struct RoleTraffic { @@ -106,7 +106,7 @@ pub(super) struct SharedPermanentPool { pub(super) baseline: [u64; 5], } #[cfg(test)] -mod shared_permanent_sdet; +mod shared_permanent_pool_tests; #[derive(Clone, Copy)] pub(crate) struct LearnedMainWitness { pub(crate) routed_matrices: usize, @@ -122,7 +122,7 @@ pub(crate) struct LearnedMainWitness { } #[cfg(test)] -mod learned_main_sdet; +mod learned_main_seed_tests; mod ranked_profile; mod shared_permanent_pool; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_seed_tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_sdet.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_seed_tests.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool_tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_sdet.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool_tests.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs index 37e4e154..472f3c9b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs @@ -10,4 +10,4 @@ use super::{ }; mod pinned_triplet_preload; -mod profile_ranked_fill_and_pool; +mod ranked_profile_fill; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/ranked_profile_fill.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/ranked_profile_fill.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_requests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_requests.rs index 3bb0f684..6d6921eb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_requests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_requests.rs @@ -1,5 +1,5 @@ //! The request objects the encoded-weight cache serves: which MTP step, which shared tail, which source matrix. -use crate::model_binding::qwen4exp_input::{ModelBinding, MoeExpertWeights, MoeWeightDescriptor}; +use crate::model_binding::weight_binding::{ModelBinding, MoeExpertWeights, MoeWeightDescriptor}; use crate::qwen_forward::contract::TokenLayer; use crate::qwen_forward::mtp::{DenseKv, MtpFrame}; use crate::qwen_forward::session::QwenSession; @@ -60,7 +60,7 @@ pub(in crate::qwen_forward) struct MmqChunkRequest<'a> { #[derive(Clone, Copy)] pub(in crate::qwen_forward) struct SourceMatrix { pub(in crate::qwen_forward) member: usize, - pub(in crate::qwen_forward) role: crate::model_binding::qwen4exp_input::MoeMatrixRole, + pub(in crate::qwen_forward) role: crate::model_binding::weight_binding::MoeMatrixRole, } /// Which layer's shared weights are lent and how many transient bytes must still fit while they are lent. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_routed_outputs.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_routed_outputs.rs index 4e0617ae..1238915a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_routed_outputs.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_routed_outputs.rs @@ -1,6 +1,6 @@ //! Exact whole-output owners for the private adaptive resident producer. //! Storage and successful callback counts are not row or finite certificates. -use crate::model_binding::qwen4exp_input::BindingIdentity; +use crate::model_binding::weight_binding::BindingIdentity; use crate::qwen_forward::contract::{Error, Result}; use crate::qwen_forward::qsa_index::driver_error; use leleka_cuda_driver::{Context, DeviceBuffer}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive.rs index fe0e91c5..c8aae58f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive.rs @@ -2,7 +2,7 @@ //! Provenance: attested generate.cpp 14cf46dc (serve adapt/apply_pending). use super::cache_profile::{HOST_CAP, PrefixPlan, ProfileLimits, RankedProfile}; use super::{CachedMoeMatrix, Error, Result, WORKING_RESERVE, binding_error, driver_error}; -use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; +use crate::model_binding::weight_binding::MoeWeightDescriptor; pub(super) const LAYERS: usize = 48; pub(super) const EXPERTS: usize = 512; @@ -51,7 +51,7 @@ pub(super) struct AdaptivePolicy { #[cfg(test)] mod tests; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, }; use leleka_cuda_driver::{CompletedOwnedCopy, Context, DeviceBuffer, OwnedCopyPoll, PendingOwnedCopy}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops.rs similarity index 94% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops.rs index d9364c9a..1e4f1908 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops.rs @@ -13,12 +13,12 @@ use super::{ }; mod moe_cache_close_owners; -mod moe_cache_compose_shared_and_mtp; +mod moe_cache_lookups; mod moe_cache_lru_updates; mod moe_cache_main_entry_routed_source; -mod moe_cache_matrix_and_mtp_lookup; mod moe_cache_mmq_chunk_admission; mod moe_cache_mmq_constructors; +mod moe_cache_producer_composition; mod moe_cache_shared_tail_constructors; mod moe_cache_triplet_plan_upload; mod moe_cache_validate_prepare_step; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_close_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_close_owners.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_close_owners.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_close_owners.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lookups.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lookups.rs index e1beb533..320d6d02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lookups.rs @@ -32,7 +32,7 @@ impl<'ctx> MoeWeightCache<'ctx> { weights, selection, role, - crate::model_binding::qwen4exp_input::MoeRows { first: 0, count: key.rows }, + crate::model_binding::weight_binding::MoeRows { first: 0, count: key.rows }, ) .map_err(binding_error)?; Ok(block.into_bytes()) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lru_updates.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lru_updates.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lru_updates/shared_keys.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lru_updates/shared_keys.rs index 452f782d..098227c0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_lru_updates/shared_keys.rs @@ -38,7 +38,7 @@ fn shared_bytes( weights, MoeExpertSelection::Shared, SHARED_ROLES[index], - crate::model_binding::qwen4exp_input::MoeRows { first: 0, count: key.rows }, + crate::model_binding::weight_binding::MoeRows { first: 0, count: key.rows }, ) .map_err(binding_error)? .into_bytes()) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_main_entry_routed_source.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_main_entry_routed_source.rs index 22bfbc74..e5e359af 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_main_entry_routed_source.rs @@ -34,12 +34,12 @@ impl<'ctx> MoeWeightCache<'ctx> { pub(in super::super::super) fn with_matrix_routed_source<'source, 'group, T>( &mut self, binding: &ModelBinding, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'source, 'group>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'source, 'group>, matrix: SourceMatrix, consume: impl FnOnce( CachedMoeMatrix<'_, 'ctx>, &RoutedSourceHealth<'_, 'ctx>, - &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'source, 'group>, + &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'source, 'group>, ) -> Result, ) -> Result { let SourceMatrix { member, role } = matrix; @@ -84,7 +84,7 @@ impl<'ctx> MoeWeightCache<'ctx> { key: MoeWeightDescriptor, member: usize, role: MoeMatrixRole, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>, ) -> Result<()> { let read = || Ok(source.block(member, role).map_err(binding_error)?.into_bytes()); let _ = if key.expert.is_some() && matches!(key.role, 0 | 1) && matches!(key.raw_kind, 18 | 22) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_main_entry_routed_source/fill_fns.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_main_entry_routed_source/fill_fns.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_chunk_admission.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_mmq_chunk_admission.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_chunk_admission.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_mmq_chunk_admission.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_mmq_constructors.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_mmq_constructors.rs index 038742ff..29c63ba9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_mmq_constructors.rs @@ -82,7 +82,7 @@ macro_rules! blank_cache { }; } -use crate::model_binding::qwen4exp_input::MtpWeights; +use crate::model_binding::weight_binding::MtpWeights; /// F32 dense rows keep a host copy of their words; every other kind keeps none. fn dense_f32_words(kind: MtpKind, bytes: &[u8]) -> Result>> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_producer_composition.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_producer_composition.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_shared_tail_constructors.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_shared_tail_constructors.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_triplet_plan_upload.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_triplet_plan_upload.rs index 7aaaadea..fbb21b76 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_triplet_plan_upload.rs @@ -234,7 +234,7 @@ impl<'ctx> MoeWeightCache<'ctx> { weights, selection, role, - crate::model_binding::qwen4exp_input::MoeRows { first: 0, count: key.rows }, + crate::model_binding::weight_binding::MoeRows { first: 0, count: key.rows }, ) .map_err(binding_error)?; Ok(block.into_bytes()) @@ -317,7 +317,7 @@ fn read_triplet( weights, selection, role, - crate::model_binding::qwen4exp_input::MoeRows { first: 0, count: key.rows }, + crate::model_binding::weight_binding::MoeRows { first: 0, count: key.rows }, ) .map_err(binding_error)?; if block.bytes().len() != key.bytes { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_validate_prepare_step.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_ops/moe_cache_validate_prepare_step.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs index 95b7d66c..a1badc8e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs @@ -10,7 +10,7 @@ use super::{ /// The Gate/Up/Down descriptors of one group member, in role order. fn triplet_keys( - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'_, '_>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'_, '_>, member: usize, ) -> Result<[MoeWeightDescriptor; 3]> { Ok([ @@ -77,12 +77,12 @@ impl<'ctx> MoeWeightCache<'ctx> { pub(in super::super) fn with_adaptive_triplet_routed_source<'source, 'group, T>( &self, binding: &ModelBinding, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'source, 'group>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'source, 'group>, member: usize, consume: impl FnOnce( [&DeviceBuffer<'ctx>; 3], &RoutedSourceHealth<'_, 'ctx>, - &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'source, 'group>, + &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'source, 'group>, ) -> Result, ) -> Result { self.validate(binding, self.context)?; @@ -100,12 +100,12 @@ impl<'ctx> MoeWeightCache<'ctx> { pub(in super::super) fn with_ephemeral_triplet_routed_source<'source, 'group, T>( &self, request: cache_ephemeral_routed::TripletLoanRequest<'_>, - source: &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'source, 'group>, + source: &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'source, 'group>, cancel_observed: &std::cell::Cell, consume: impl FnOnce( [&DeviceBuffer<'ctx>; 3], &RoutedSourceHealth<'_, 'ctx>, - &mut crate::model_binding::qwen4exp_input::MoeRoutedSourceScope<'source, 'group>, + &mut crate::model_binding::weight_binding::MoeRoutedSourceScope<'source, 'group>, ) -> Result, ) -> Result { let cache_ephemeral_routed::TripletLoanRequest { binding, member, .. } = request; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/mtp_kv_resident.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/mtp_kv_resident.rs index 671b3cbb..69d450ce 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/mtp_kv_resident.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/mtp_kv_resident.rs @@ -4,7 +4,7 @@ use super::super::{ mtp::{DenseKv, MtpFrame}, qsa_index::driver_error, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding}; use leleka_cuda_driver::{Context, DeviceBuffer, MtpDenseKvRing}; use std::rc::Rc; const RING_BYTES: usize = 128 * 1024 * 1024; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights.rs index e374c61c..e5e0cc2e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights.rs @@ -5,7 +5,7 @@ use super::{ BindingIdentity, Cell, Context, Dense, DeviceBuffer, Error, ModelBinding, MoeWeightCache, MtpKind, MtpRole, Rc, Result, binding_error, driver_error, }; -use crate::model_binding::qwen4exp_input::{pinned_dense_bytes, rt_dense_name, rt_dense_roles, rt_dense_shape}; +use crate::model_binding::weight_binding::{pinned_dense_bytes, rt_dense_name, rt_dense_roles, rt_dense_shape}; #[derive(Clone)] struct RetainedDense<'ctx> { role: MtpRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs index edc56c6f..581aaab1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs @@ -7,7 +7,7 @@ use super::{ qsa_index::{allocate, binding_error, download, driver_error, release, upload, validate_values}, session::{QwenSession, TargetStepOrigin}, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding, MtpKind, MtpRole}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding, MtpKind, MtpRole}; use leleka_cuda_driver::{Bf16ProjectionShape, Context, DenseFormat, DeviceBuffer, ProjectionKind, ProjectionSpec}; use std::{cell::Cell, rc::Rc}; mod kv_only; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk.rs index f9eea1af..31f5eb5a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk.rs @@ -2,7 +2,7 @@ //! The current target prefix remains unchanged until joint publication. //! No checkpoint rewind, target position mutation, or prediction is fabricated. use super::{Error, MtpSession, Rc, Result, TargetStepOrigin}; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; use crate::qwen_forward::{ contract::Position, session::{QwenSession, chunk::QwenChunkTxn}, @@ -24,7 +24,7 @@ struct ValidatedWarmEnd(u64); #[cfg(test)] mod tests { use super::*; - use crate::model_binding::qwen4exp_input::BindingIdentity; + use crate::model_binding::weight_binding::BindingIdentity; use crate::qwen_forward::{ contract::{Dimension, TokenId}, mtp::MtpFrame, @@ -174,7 +174,7 @@ mod tests { /// Immutable numerical observation only; never a checkpoint/restore/source. #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(in crate::qwen_forward) struct MtpChunkNumericSnapshot { - binding: crate::model_binding::qwen4exp_input::BindingIdentity, + binding: crate::model_binding::weight_binding::BindingIdentity, next_position: u64, cells: Rc>>, residual: Option>>, @@ -184,7 +184,7 @@ pub(in crate::qwen_forward) struct MtpChunkNumericSnapshot { mod branch_refusal { use super::super::{Cell, DenseKv}; use super::*; - use crate::model_binding::qwen4exp_input::BindingIdentity; + use crate::model_binding::weight_binding::BindingIdentity; #[test] fn chunk_stale_target_generation_refuses_even_at_same_numeric_start() { let binding = BindingIdentity::test_identity(); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/warming.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/warming.rs index 29177b03..ae61a8d7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/warming.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/warming.rs @@ -1,7 +1,7 @@ //! Fresh-prefill-only authenticated tail coverage. No intermediate draft Ready. //! Every retired target row is authenticated; only canonical tail cells persist. use super::{CellPair, DenseKv, Error, MtpSession, Rc, Result, WINDOW}; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding}; use crate::qwen_forward::{ contract::{Dimension, Stage, TokenId}, moe_weight_cache::MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention.rs index 62e74d52..10e1b46b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention.rs @@ -10,7 +10,7 @@ use super::{ }, session::QwenSession, }; -use crate::model_binding::qwen4exp_input::{ModelBinding, MtpKind, MtpRole}; +use crate::model_binding::weight_binding::{ModelBinding, MtpKind, MtpRole}; use leleka_cuda_driver::{Context, DeviceBuffer}; use std::{cell::Cell, rc::Rc}; const N: usize = 2560; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode.rs index 6ca94e7f..30fd5619 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode.rs @@ -12,7 +12,7 @@ use super::{ session::QwenSession, }; use super::{dense_weight_cache::DenseWeightCache, moe_weight_cache::MoeWeightCache}; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; pub(crate) struct MtpWindowSpec { depth: usize, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu.rs index 6d4005a3..64675498 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu.rs @@ -4,7 +4,7 @@ use super::{ DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, MtpDecoder, MtpWindowError, MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, Result, TargetStepProduct, TokenId, mtp, }; -use crate::model_binding::qwen4exp_kar_ple::InheritedKarArchive; +use crate::model_binding::kar_ple_source::InheritedKarArchive; use crate::qwen_forward::contract::Stage; use crate::qwen_forward::session::ResetReplaySnapshot; use leleka_cuda_driver::Driver; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs index 199031fd..02db8d65 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs @@ -18,8 +18,8 @@ pub(super) fn admit_binding(binding: &ModelBinding) { assert!(ROW_CAP.checked_mul(10).unwrap() + TRANSACTION_CAP + 4 * 1024 * 1024 <= SNAPSHOT_CAP); assert_eq!(binding.layer_count(), 48); let disposition = binding.ordered_layers().iter().fold((0, 0), |(g, q), d| match d.kind() { - crate::model_binding::qwen4exp_input::BoundLayerKind::Gdn => (g + 1, q), - crate::model_binding::qwen4exp_input::BoundLayerKind::Qsa => (g, q + 1), + crate::model_binding::weight_binding::BoundLayerKind::Gdn => (g + 1, q), + crate::model_binding::weight_binding::BoundLayerKind::Qsa => (g, q + 1), }); assert_eq!(disposition, (36, 12)); } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder.rs index 54ebfb97..901bd320 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder.rs @@ -13,5 +13,5 @@ use super::{ mod batched_window; mod batched_window_plan; -mod draft_warm_and_window; +mod decoder_entry; mod scalar_window; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/draft_warm_and_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/decoder_entry.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/draft_warm_and_window.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/decoder_entry.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts.rs index 30b7654c..d2be1fc9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts.rs @@ -8,7 +8,7 @@ use super::{ qsa_index::{allocate, binding_error, download, download_bytes, driver_error, release, upload, validate_values}, session::QwenSession, }; -use crate::model_binding::qwen4exp_input::{ModelBinding, MtpKind, MtpRole}; +use crate::model_binding::weight_binding::{ModelBinding, MtpKind, MtpRole}; use leleka_cuda_driver::{Context, DeviceBuffer}; use std::{cell::Cell, rc::Rc}; pub(super) mod fixed_workspace; @@ -44,11 +44,11 @@ mod tests; mod mtp_block; use mtp_block::moe_driver_error; use mtp_block::validate_route; -mod routed_and_shared_experts; +mod expert_math; #[cfg(test)] -use routed_and_shared_experts::down_tile; +use expert_math::down_tile; #[cfg(test)] -use routed_and_shared_experts::gate_up_tile; -use routed_and_shared_experts::route; +use expert_math::gate_up_tile; +use expert_math::route; mod append_row; use append_row::append_row; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/routed_and_shared_experts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/expert_math.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/routed_and_shared_experts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/expert_math.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace.rs index 0dcaef85..b0dc9545 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace.rs @@ -54,7 +54,7 @@ struct Packed { } use super::super::{mtp::MtpFrame, session::QwenSession}; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding}; const CHARGES: [usize; 17] = [10240, 102400, 2720, 320, 5120, 2560, 680, 80, 10240, 2560, 2560, 2560, 10240, 4, 10240, 40, 10240]; pub(in crate::qwen_forward) const ALLOCATED_BYTES: usize = 172804; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr.rs index d570d6cd..770ee54a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr.rs @@ -13,7 +13,7 @@ use super::{ }, session::QwenSession, }; -use crate::model_binding::qwen4exp_input::{ModelBinding, MtpKind, MtpRole}; +use crate::model_binding::weight_binding::{ModelBinding, MtpKind, MtpRole}; use leleka_cuda_driver::Context; use std::{cell::Cell, rc::Rc}; mod mtp_final_transport; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/oracle_capture.rs b/crates/engine-qwen35-cuda/src/qwen_forward/oracle_capture.rs index befb8739..b0a8dff7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/oracle_capture.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/oracle_capture.rs @@ -9,7 +9,7 @@ use super::{ output::OutputStage, session::QwenSession, }; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; use std::{ cell::RefCell, collections::BTreeMap, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs index 0e428814..66797c03 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs @@ -1,7 +1,7 @@ //! Literal generate.cpp expert-cache sizing/retry and STRP profile reader. //! Counts are planning metadata; only the returned physical cache owns slots. use super::contract::{Error, Result}; -use crate::model_binding::qwen4exp_input::{ModelBinding, MoeMatrixRole}; +use crate::model_binding::weight_binding::{ModelBinding, MoeMatrixRole}; use leleka_cuda_driver::{Context, OriginalExpertCache}; use std::{fs::File, io::Read, path::Path}; @@ -227,21 +227,21 @@ pub(crate) fn open<'ctx>( let reserve = options.reserve_mib.checked_mul(1 << 20).ok_or(Error::Overflow)?; let free = usable_room(context.memory_info().map_err(driver)?.0, context.budget_bytes(), context.allocated_bytes()); let sizing = (free, reserve, pending_mtp_bind_bytes); - let slots = slot_sizing_and_open_retry::initial_slots(&options, &geometry, sizing, profile)?; - let plan = slot_sizing_and_open_retry::size_plan(context, &options, profile, (geometry, slots, reserve))?; + let slots = slot_sizing::initial_slots(&options, &geometry, sizing, profile)?; + let plan = slot_sizing::size_plan(context, &options, profile, (geometry, slots, reserve))?; if plan.slots == 0 { return Ok(None); } - let retry = slot_sizing_and_open_retry::Retry { + let retry = slot_sizing::Retry { auto: options.slots < 0, per_layer: options.per_layer, reserve, max_blob: geometry.max_blob, }; - slot_sizing_and_open_retry::open_with_retry(context, &retry, plan) + slot_sizing::open_with_retry(context, &retry, plan) } -mod slot_sizing_and_open_retry; +mod slot_sizing; #[cfg(test)] mod budget_room_tests { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing_and_open_retry.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing_and_open_retry.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_file_cache_source.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_file_cache_source.rs index a2c0f585..fc10f129 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_file_cache_source.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_file_cache_source.rs @@ -4,7 +4,7 @@ use super::{ contract::{Error, Result}, original_cache_startup::OriginalRankedExperts, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding}; use leleka_cuda_driver::{ Context, OriginalExpertCache, OriginalExpertStager, OriginalFileExpertBlob, OriginalStagerOptions, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner.rs index a6da3fbe..d763a37f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner.rs @@ -14,7 +14,7 @@ use super::{ output_native::{OriginalMtpNativeHead, OriginalNativeOutput}, session::{QwenSession, original_prompt::draft::OriginalDraftSession}, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding}; use leleka_cuda_driver::{ Context, MtpOriginalInt8, OriginalMtpActor, OriginalMtpCapture, OriginalMtpDraftHead, OriginalMtpDrafter, OriginalMtpKvStartup, OriginalMtpLoadFailure, OriginalMtpLoadMeter, OriginalMtpLoadPlan, OriginalMtpPlanError, @@ -128,6 +128,6 @@ mod tests { mod original_mtp_request; use original_mtp_request::capture_of; use original_mtp_request::plan_error; +mod full_owner_assembly; mod mtp_full_owner_actor_close; -mod original_mtp_full_owner_methods; use mtp_full_owner_actor_close::driver_error; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_full_owner_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/full_owner_assembly.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_full_owner_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/full_owner_assembly.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter.rs index 024f2d3d..00d241a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter.rs @@ -11,7 +11,7 @@ use super::{ original_prompt::draft::{OriginalDraftSession, WindowOrigins}, }, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding}; use leleka_cuda_driver::{ AcceptedWindow, CompletedOriginalMtpDraft, Context, DraftTarget, NativeHeadSelection, OriginalGpuEvent, OriginalMtpFullPolicy, OriginalVerifyWindow, RepeatRowWindow, SamplerParams, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs index 9d02e2c9..4ebb8397 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config.rs @@ -2,7 +2,7 @@ //! context. Everything here is configuration, never a certificate: each value names the line of the //! Original it mirrors, so a hardware run can diff them against the CLI it is compared with. use super::contract::{Error, Result}; -use crate::model_binding::qwen4exp_input::{ModelBinding, MoeMatrixRole}; +use crate::model_binding::weight_binding::{ModelBinding, MoeMatrixRole}; use crate::settings::EnvSource; use leleka_cuda_driver::{ DraftKvPolicy, OriginalMtpFullPolicy, OriginalMtpGrVariant, OriginalMtpScalarPolicy, OriginalVerifyExpertLayout, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs index 2b61a4f7..d9e11b41 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host.rs @@ -37,7 +37,7 @@ use super::{ original_prompt::draft::{OriginalDraftCheckpoint, OriginalDraftSession}, }, }; -use crate::model_binding::qwen4exp_input::{BoundLayerKind, ModelBinding}; +use crate::model_binding::weight_binding::{BoundLayerKind, ModelBinding}; use leleka_cuda_driver::{ AcceptedWindow, Context, DeviceBuffer, OriginalGpuEvent, OriginalMtpFullPolicy, OriginalNativeHeadGraphResources, OriginalVerifier, OriginalVerifyGraphResources, OriginalVerifyQsaJournal, OriginalVerifyWindowResult, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool.rs index a408da2e..b96bf1f8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool.rs @@ -18,7 +18,7 @@ use super::{ cpu_expert_miss::{CpuMissWorkspace, runtime_error, validate_triplet}, input::binding_error, }; -use crate::model_binding::qwen4exp_input::{ModelBinding, MoeExpertWeights, MoeMatrixRole, MoeRoutedSourceScope}; +use crate::model_binding::weight_binding::{ModelBinding, MoeExpertWeights, MoeMatrixRole, MoeRoutedSourceScope}; use leleka_cuda_driver::{OriginalGpuStream, OriginalVerifyCpuRows, OriginalVerifyCpuSink}; use leleka_model_format::qwen4exp::ResidentExpertBankSpan; use leleka_native_cpu_expert::{BorrowedExpert, BorrowedGroup, DirectCpuPool, DownFormat, GateUpFormat}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs index 9c22108b..5a5e6b65 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs @@ -119,7 +119,7 @@ pub(super) fn open_job( } fn job_descriptors( source: &mut MoeRoutedSourceScope<'_, '_>, -) -> Result<[crate::model_binding::qwen4exp_input::MoeWeightDescriptor; 3]> { +) -> Result<[crate::model_binding::weight_binding::MoeWeightDescriptor; 3]> { Ok([ source.descriptor(0, MoeMatrixRole::Gate).map_err(binding_error)?, source.descriptor(0, MoeMatrixRole::Up).map_err(binding_error)?, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request.rs index 07c84687..ba86a3b8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request.rs @@ -93,14 +93,14 @@ pub(in crate::qwen_forward) trait RequestOwners { &mut self, request: &ServeRequest, resume: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> Result<(), SpecError>; /// Run the verified-window decode of the request; `emit` receives each committed round. fn decode( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<(), Error>, + cancel: &mut impl FnMut() -> bool, ) -> Result; /// The request that `resume` placed is over (`Ok`, or how it ended); the conversation bookkeeping for the /// next one. @@ -186,8 +186,8 @@ pub(in crate::qwen_forward) fn run_request( owners: &mut O, request: &ServeRequest, max_context: i64, - emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<(), Error>, + cancel: &mut impl FnMut() -> bool, ) -> Result { // sized closures over the caller's trait objects: the core is generic, so no trait object is added to the lifecycle let mut emit = |tokens: &[i32]| emit(tokens); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs index 64e81f0b..72d22c88 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs @@ -57,7 +57,7 @@ impl RequestOwners for Fake { self.fresh = false; Some(resume) } - fn prefill(&mut self, _: &ServeRequest, resume: usize, cancel: &mut dyn FnMut() -> bool) -> Result<(), SpecError> { + fn prefill(&mut self, _: &ServeRequest, resume: usize, cancel: &mut impl FnMut() -> bool) -> Result<(), SpecError> { self.log.push("prefill"); self.prefilled_from = Some(resume); self.fresh = false; @@ -72,8 +72,8 @@ impl RequestOwners for Fake { fn decode( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, - _: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<(), Error>, + _: &mut impl FnMut() -> bool, ) -> Result { self.log.push("decode"); if let Some(error) = self.decode { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency.rs index f4515ec8..bf728384 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency.rs @@ -29,7 +29,7 @@ use super::{ original_serve_seed::SwapSources, original_serve_verifier::driver_error, }; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; use crate::settings::EnvSource; use leleka_cuda_driver::{ Context, MappedExpertBank, ORIGINAL_VERIFY_MAX_PCIE_FETCHES, OriginalExpertCache, OriginalGpuStream, @@ -298,10 +298,10 @@ pub(in crate::qwen_forward) use swap_tie_order::TieOrder; mod strata_pcie_auto; use strata_pcie_auto::StrataPcieAuto; mod pcie_auto_on_window_pool; -mod span_cache_and_pcie_lag; +mod pcie_share_controllers; #[cfg(test)] mod strata_pcie_auto_tests; -use span_cache_and_pcie_lag::span_cache_enabled; +use pcie_share_controllers::span_cache_enabled; mod source_spans; pub(super) use source_spans::source_spans; mod open_tier; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs index 4293ca74..bed8f46e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/open_tier.rs @@ -140,7 +140,7 @@ pub(super) fn pin_resident_complement( let room = crate::memory_governor::complement_room(available); let budget = ((budget_gib * GIB) as u64).min(room); let ranked = ranked_complement(cache, profile); - let started = std::time::Instant::now(); + let started = leleka_obs::time::Clock::now(&leleka_obs::time::SystemClock); match bank.pin_resident(&ranked, budget) { Ok((held, bytes)) => eprintln!( "leleka-serve: resident RAM budget {:.2} GiB (asked {budget_gib:.2}, {:.2} GiB available): \ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/span_cache_and_pcie_lag.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/pcie_share_controllers.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/span_cache_and_pcie_lag.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/pcie_share_controllers.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_seed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_seed.rs index 0f680072..e2f08f51 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_seed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_seed.rs @@ -21,7 +21,7 @@ use super::{ original_serve_residency::{SpanCache, Swap, choose_swaps, source_spans}, original_serve_verifier::driver_error, }; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; use leleka_cuda_driver::OriginalExpertCache; use leleka_model_format::qwen4exp::ResidentExpertBankSpan; use std::rc::Rc; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs index 13d245e7..42cb9ae9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack.rs @@ -56,7 +56,7 @@ use super::{ }, }; use crate::backend::original_prompt::{PlanError, PlanLimits, PromptOptions, PromptPath, PromptPlan, ResumePoint}; -use crate::model_binding::qwen4exp_input::ModelBinding; +use crate::model_binding::weight_binding::ModelBinding; use leleka_context::memory_plan::KvFormat; use leleka_cuda_driver::{ Context, DeviceBuffer, DeviceRef, NativeHeadDispatch, OriginalExpertCache, OriginalMtpFullPolicy, @@ -241,14 +241,14 @@ pub(crate) mod decode_graph_reuse; use decode_graph_reuse::{Began, DecodeGraphKey, Ended, GraphReuse, Why}; mod stack_groups; use stack_groups::{RequestState, ServePolicy, TierState}; -mod stack_config_and_ttft_marks; -use stack_config_and_ttft_marks::at; -use stack_config_and_ttft_marks::failure; -use stack_config_and_ttft_marks::plan_error; -use stack_config_and_ttft_marks::prefill_bytes; -use stack_config_and_ttft_marks::tier_for; -mod original_serve_stack_methods; +mod stack_config; +use stack_config::at; +use stack_config::failure; +use stack_config::plan_error; +use stack_config::prefill_bytes; +use stack_config::tier_for; mod prompt_chunk; +mod stack_phases; pub(crate) use prompt_chunk::dbg_el; use prompt_chunk::operator_line; use prompt_chunk::operator_note; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs index 1bd8d67b..c57ae8e1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake/stack.rs @@ -141,7 +141,7 @@ impl FakeStack { &mut self, request: &ServeRequest, resume: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> Result<(), SpecError> { let n = request.prompt.len(); if n < 2 { @@ -178,7 +178,7 @@ impl FakeStack { &mut self, prompt: &[i32], action: &PromptAction, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> Result<(), SpecError> { let PromptPath::Batched { .. } = action.path else { return Err(Error::IdentityMismatch.into()); @@ -216,8 +216,8 @@ impl FakeStack { fn serve_rounds( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<(), Error>, + cancel: &mut impl FnMut() -> bool, ) -> Result { self.dev.begin_decode(&request.prompt)?; if self.controller.is_failed() { @@ -241,8 +241,8 @@ impl FakeStack { fn decode_over_graphs( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<(), Error>, + cancel: &mut impl FnMut() -> bool, ) -> Result { let (key, seed) = (self.graph_key, self.dev.digest()); let owners = self.owners.take().ok_or(Error::IdentityMismatch)?; @@ -301,7 +301,7 @@ impl RequestOwners for FakeStack { &mut self, request: &ServeRequest, resume: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> Result<(), SpecError> { let started = self.clock.now(); self.timing = (0.0, 0.0); @@ -315,8 +315,8 @@ impl RequestOwners for FakeStack { fn decode( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<(), Error>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<(), Error>, + cancel: &mut impl FnMut() -> bool, ) -> Result { let started = self.clock.now(); let result = self.decode_over_graphs(request, emit, cancel); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs index ad4b52a8..5ad70b4f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs @@ -128,7 +128,7 @@ impl<'a, 'ctx> RequestOwners for OriginalServeStack<'a, 'ctx> { &mut self, request: &ServeRequest, resume: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result<(), SpecError> { let started = self.config.clock.now(); self.state.timing = (0.0, 0.0); @@ -144,8 +144,8 @@ impl<'a, 'ctx> RequestOwners for OriginalServeStack<'a, 'ctx> { fn decode( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<()>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<()>, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result { let started = self.config.clock.now(); let tier0 = self.tier.residency.stats; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs index ed353f1a..ff3f8249 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs @@ -8,4 +8,4 @@ use super::{ }; mod prefix_serve_after_phase_parking; -mod prefix_serve_store_and_shedding; +mod store_control; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_store_and_shedding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/store_control.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_store_and_shedding.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/store_control.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs index 9a58c1fe..a31d10f5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs @@ -12,7 +12,7 @@ impl<'ctx> PromptChunk<'_, 'ctx> { &mut self, count: usize, arena: &mut OriginalPrefillArena<'_, 'ctx>, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result<(), SpecError> { let target = PromptChunkTarget { weights: PromptWeights::new(self.binding, self.dense), @@ -31,7 +31,7 @@ impl<'ctx> PromptChunk<'_, 'ctx> { } } /// The forward's result: a failure after a cancel request is the cancel, any other is the forward's own error. -fn forward_outcome

(pending: Result

, cancel: &mut dyn FnMut() -> bool) -> std::result::Result { +fn forward_outcome

(pending: Result

, cancel: &mut impl FnMut() -> bool) -> std::result::Result { if let Err(e) = &pending { crate::bringup_trace!("DBG[{:.0}s] executor.forward err {e:?}", dbg_el()); } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config_and_ttft_marks.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config_and_ttft_marks.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_phase_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/decode_phase_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_phase_steps.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/decode_phase_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/decode_teardown.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/decode_teardown.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/executor_opening.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/executor_opening.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/executor_opening.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/executor_opening.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_cache_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/open_cache_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_cache_steps.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/open_cache_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_phase_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/open_phase_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_phase_steps.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/open_phase_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase.rs index ec4ba579..9f75f6ac 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase.rs @@ -22,8 +22,8 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { pub(in super::super) fn decode_phase( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<()>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<()>, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result { let (sampling, staged) = self.decode_stage(request)?; let mut view = self.decode_view(&staged.shared); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase/decode_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase/decode_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase/decode_view.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_decode_phase/decode_view.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_memory_classes.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_memory_classes.rs index 0365def4..c68275e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_memory_classes.rs @@ -33,8 +33,8 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { pub(crate) fn serve( &mut self, request: &ServeRequest, - emit: &mut dyn FnMut(&[i32]) -> Result<()>, - cancel: &mut dyn FnMut() -> bool, + emit: &mut impl FnMut(&[i32]) -> Result<()>, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result { self.apply_memory_directive(); self.state.marks = TtftMarks::start(&self.config.clock); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_metrics_close.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_metrics_close.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open/assemble.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open/assemble.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open/open_phases.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_open/open_phases.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_chunk.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_chunk.rs index 3396e3c5..9794d664 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_chunk.rs @@ -15,7 +15,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { &mut self, source: &Rc, count: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result<(), SpecError> { let mut chunk = PromptChunk { binding: self.binding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_phase.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_phase.rs index c8818d05..27b2dd32 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/original_serve_stack_prefill_phase.rs @@ -20,7 +20,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { &mut self, request: &ServeRequest, resume: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result<(), SpecError> { let seeding = self.begin_prefill()?; let p = profile::span("prefill.read"); @@ -162,7 +162,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { &mut self, request: &ServeRequest, resume: usize, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result<(), SpecError> { let binding: &ModelBinding = self.binding; let n = request.prompt.len(); @@ -255,7 +255,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> { request: &ServeRequest, source: &Rc, action: crate::backend::original_prompt::PromptAction, - cancel: &mut dyn FnMut() -> bool, + cancel: &mut impl FnMut() -> bool, ) -> std::result::Result, SpecError> { trace_action(&action); if action.path == PromptPath::FinalSeed { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_request_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/serve_request_step.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_request_step.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_phases/serve_request_step.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs index 38f25e9a..3c90a8c9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs @@ -18,7 +18,7 @@ use super::{ output_native::OriginalNativeOutput, session::original_verified::OriginalVerifiedBase, }; -use crate::model_binding::qwen4exp_input::{BoundLayerKind, ModelBinding}; +use crate::model_binding::weight_binding::{BoundLayerKind, ModelBinding}; use leleka_cuda_driver::{ Context, DeviceBuffer, DeviceRef, OriginalQsaMappedJournal, OriginalQsaResidentIndex, OriginalVerifier, OriginalVerifyExpertFormats, OriginalVerifyQsaJournal, OriginalVerifyResources, OriginalVerifyWindowPolicy, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller.rs index 086cd7cb..8d83ed9f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller.rs @@ -155,4 +155,4 @@ mod trace_enabled; pub(crate) use trace_enabled::stats_enabled; pub(crate) use trace_enabled::trace_enabled; mod original_spec_controller_finish; -mod original_spec_controller_methods; +mod round_steps; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_round_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/commit_round_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_round_steps.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/commit_round_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_start_request.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/original_spec_controller_start_request.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_start_request.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/original_spec_controller_start_request.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_verify_commit.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/original_spec_controller_verify_commit.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_verify_commit.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/original_spec_controller_verify_commit.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_round_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/verify_round_steps.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_round_steps.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/round_steps/verify_round_steps.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output.rs index 55306bf0..acbde788 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output.rs @@ -4,7 +4,7 @@ use super::contract::{Dimension, Error, FiniteF32, LayerId, Position, Result, Stage, TokenId}; use super::gr::{GrStage, InjectedResidual}; use super::session::QwenStepTxn; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding, OutputBindingError, OutputWeights}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding, OutputBindingError, OutputWeights}; use leleka_cuda_driver::{ Context, DeviceBuffer, HEAD_GREEDY_WORKSPACE_BYTES, HeadGreedySelection, HeadGreedyWorkspace, Q6KProjectionShape, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs index 2cef1f5a..c3d68fa3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs @@ -9,5 +9,5 @@ use super::{ driver_error, encode_activation, greedy, selected_token, validate_weight_owner, }; -mod output_stage_load_and_logits; +mod head_load_and_logits; mod output_stage_sampling_projection; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_load_and_logits.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/head_load_and_logits.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_load_and_logits.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/head_load_and_logits.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output_native.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output_native.rs index f374b6df..51e39423 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output_native.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output_native.rs @@ -1,7 +1,7 @@ //! Model-affine literal NativeHead bank. Actual row/epoch/accepted-prefix authority //! stays with the existing actor transaction; this module never mints it. use super::contract::{Error, Result, Stage}; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding, NativeOutputRole}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding, NativeOutputRole}; use leleka_cuda_driver::{ Context, DeviceBuffer, NativeHeadDispatch, NativeHeadPayload, NativeHeadSampling, NativeHeadSelection, OriginalGpuGraph, OriginalGpuStream, OriginalNativeEmbed, OriginalNativeHead, OriginalNativeHeadGraphResources, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows.rs index 73ce8e84..a92c2cee 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows.rs @@ -10,7 +10,7 @@ use super::{ input::{InputReady, PlePrior}, session::QwenStepTxn, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole, ModelBinding}; use leleka_cuda_driver::{ Context, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalDeviceNormedResidual, OriginalDeviceResidual, OriginalPleHistory, OriginalPromptDevice, OriginalPromptRows, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/mtp_prefill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/mtp_prefill.rs index 4f37c9a5..d5d7df45 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/mtp_prefill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/mtp_prefill.rs @@ -8,7 +8,7 @@ use super::{ PromptDeviceFinal, PromptDeviceRows, PromptWeights, Rc, Result, ScalarDraftKvRequest, ScalarPromptSources, SourceInput, TokenId, micro_driver_error, }; -use crate::model_binding::qwen4exp_input::{MtpKind, MtpRole}; +use crate::model_binding::weight_binding::{MtpKind, MtpRole}; use leleka_cuda_driver::{ CompletedDraftKv, DraftKvOutcome, DraftKvPolicy, DraftKvSources, MtpInt8Snapshot, MtpOriginalInt8, OriginalMtpEmbedding, OriginalMtpPrefill, OriginalMtpPrefillWeights, PrefillRows, RecordRun, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns.rs index bb6cb126..35d2052e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns.rs @@ -11,7 +11,7 @@ use super::{ qsa_index::validate_values, session::{QwenStepTxn, TargetStepOrigin, chunk::QwenChunkTxn}, }; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, GdnMatrixKind, GdnMatrixRole, GdnWeights, GrRole, ModelBinding, QsaMatrixKind, QsaMatrixRole, QsaWeights, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs index 6a0580b1..5a1737ff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs @@ -7,7 +7,7 @@ use super::qsa_index::{ project_cached_out, release, upload, upload_bytes, validate_values, }; use super::session::QwenStepTxn; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding, QsaMatrixRole}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding, QsaMatrixRole}; use leleka_cuda_driver::{Context, DeviceBuffer}; use std::{cell::Cell, rc::Rc}; const Q: usize = 6144; @@ -81,7 +81,7 @@ pub(in crate::qwen_forward) mod attention_scratch; pub(super) struct NativeAttended<'source, 'ctx> { identity: TokenLayer, binding: BindingIdentity, - provider: Rc, + provider: Rc, source: &'source super::gr::ResidualReady, context: &'ctx Context<'ctx>, origin: super::session::TargetStepOrigin, @@ -97,7 +97,7 @@ pub(super) struct NativePromptAttentionBatch<'source, 'lease, 'ctx> { layer: LayerId, context: &'ctx Context<'ctx>, origin: super::session::TargetStepOrigin, - provider: Rc, + provider: Rc, } mod decode_selected_cached; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch.rs index b5da2426..c9bc461b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch.rs @@ -249,7 +249,7 @@ impl<'ctx> QsaAttentionLease<'_, '_, 'ctx> { &'a mut self, binding: &ModelBinding, context: &Context<'_>, - weights: &crate::model_binding::qwen4exp_input::QsaWeights, + weights: &crate::model_binding::weight_binding::QsaWeights, ) -> Result<(&'a DeviceBuffer<'ctx>, &'a mut DeviceBuffer<'ctx>)> { self.validate(binding, context)?; if !std::ptr::eq(weights, self.prepared.weights()) || weights.layer() != self.identity.layer().get() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch/gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch/gpu.rs index bfef4f74..868d7bda 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch/gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/attention_scratch/gpu.rs @@ -3,7 +3,7 @@ use super::{ Cell, Context, DeviceBuffer, Error, Q, Rc, RefCell, Result, SCRATCH_BYTES, SIZES, ScratchBuffers, SelectedKvBytes, attend_retained, attention_driver_error, gate_retained, release, upload_bytes, validate_values, }; -use crate::model_binding::qwen4exp_input::QsaMatrixKind; +use crate::model_binding::weight_binding::QsaMatrixKind; use leleka_cuda_driver::Driver; use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs index 1dba59a8..8f945a42 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs @@ -63,7 +63,7 @@ impl NativeAttended<'_, '_> { fn validate_source_values(&self, binding: &ModelBinding, layer: LayerId) -> Result<()> { self.source.validate_origin( &binding.identity(), - crate::model_binding::qwen4exp_input::GrRole::Attention(layer.get()), + crate::model_binding::weight_binding::GrRole::Attention(layer.get()), )?; validate_values(&self.values, Q)?; validate_values(&self.gate, Q) @@ -85,7 +85,7 @@ impl NativeAttended<'_, '_> { } self.source.validate_origin( &binding.identity(), - crate::model_binding::qwen4exp_input::GrRole::Attention(layer.get()), + crate::model_binding::weight_binding::GrRole::Attention(layer.get()), )?; validate_values(&self.values, Q)?; validate_values(&self.gate, Q) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/retained_gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/retained_gpu_tests.rs index 39812674..d9976ad3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/retained_gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/retained_gpu_tests.rs @@ -4,7 +4,7 @@ use super::{ Cell, Context, DeviceBuffer, Error, Q, QsaAttended, QsaGated, Rc, Result, SelectedKvBytes, allocate, attend_retained, download, gate_retained, release, upload, upload_bytes, }; -use crate::model_binding::qwen4exp_input::QsaMatrixKind; +use crate::model_binding::weight_binding::QsaMatrixKind; use leleka_cuda_driver::{Bf16ProjectionShape, Driver}; fn exact(left: &[f32], right: &[f32]) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_attention.rs index 36db7dd6..b21cc2d6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_attention.rs @@ -8,7 +8,7 @@ use super::{ QsaPending, QsaPrior, allocate, download, driver_error, project_scratch_out_numeric, upload, validate_values, }, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole, QsaMatrixKind, QsaMatrixRole, QsaWeights}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole, QsaMatrixKind, QsaMatrixRole, QsaWeights}; use leleka_cuda_driver::{ CompletedQsaKvAppend, Context, DeviceBuffer, NativeBatchWorkspace, QsaAttentionInputs, QsaKvInputs, QsaNativeDecode, QsaNativeGate, QsaPromptKv, QsaPromptStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_index.rs index ab861b5a..250064df 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_decode_index.rs @@ -8,7 +8,7 @@ use super::{ qsa_prompt_index::PromptIndexDevices, session::QwenStepTxn, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole, ModelBinding, QsaMatrixRole, QsaWeights}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole, ModelBinding, QsaMatrixRole, QsaWeights}; use leleka_cuda_driver::{ Context, DeviceBuffer, QsaChunkRows, QsaIndexPrior, QsaPromptIndexPrefix, QsaPromptSelection, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs index 7860c6b6..64044f65 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs @@ -5,7 +5,7 @@ use super::dense_weight_cache::{DenseWeightCache, QsaSelectionRequest}; use super::gr::ResidualReady; use super::qsa_attention::QsaGated; use super::session::QwenStepTxn; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, GrRole, InputBindingError, ModelBinding, QsaMatrixKind, QsaMatrixRole, QsaWeights, }; use leleka_cuda_driver::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory.rs index 766f4c6e..2e904dd6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory.rs @@ -151,4 +151,4 @@ impl Index for Directory { } #[cfg(test)] -mod qsa_directory_sdet; +mod directory_limit_tests; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/qsa_directory_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/directory_limit_tests.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/qsa_directory_sdet.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/directory_limit_tests.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device.rs index f5788a65..57835e67 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device.rs @@ -131,4 +131,4 @@ mod resident_qsa_completed; pub(in crate::qwen_forward) use resident_qsa_completed::ResidentSealOwners; mod resident_qsa_layer; mod resident_qsa_prior; -mod resident_qsa_span_export_and_seal; +mod span_transfer; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/span_transfer.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/span_transfer.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch.rs index 2b21587f..41da216b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch.rs @@ -9,7 +9,7 @@ use super::{ qsa_index::validate_values, session::{QwenStepTxn, TargetStepOrigin, chunk::QwenChunkTxn}, }; -use crate::model_binding::qwen4exp_input::{ +use crate::model_binding::weight_binding::{ BindingIdentity, GrRole, ModelBinding, QsaMatrixKind, QsaMatrixRole, QsaWeights, }; use leleka_cuda_driver::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prompt_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prompt_index.rs index dc8d1f4c..46df1b9d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prompt_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prompt_index.rs @@ -12,7 +12,7 @@ use super::{ chunk::{PreparedLayerRow, QwenChunkTxn}, }, }; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole, ModelBinding, QsaMatrixRole, QsaWeights}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole, ModelBinding, QsaMatrixRole, QsaWeights}; use leleka_cuda_driver::{ Context, DeviceBuffer, NativeBatchWorkspace, QsaChunkRows, QsaIndexPrior, QsaPromptIndexPrefix, QsaPromptIndexState, QsaPromptIndexWorkspace, QsaPromptSelection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch.rs index b7ed83ac..d2ea407b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch.rs @@ -2,7 +2,7 @@ use super::contract::{Error, Result, TokenLayer}; use super::gr::ResidualReady; use super::moe_route::{map_driver_error, validate_activation, validate_logits}; -use crate::model_binding::qwen4exp_input::{BindingIdentity, GrRole}; +use crate::model_binding::weight_binding::{BindingIdentity, GrRole}; use leleka_cuda_driver::{Bf16ProjectionShape, Context, DeviceBuffer}; use std::{ cell::{Cell, RefMut}, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session.rs index 7cd3d2fd..96748e02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session.rs @@ -10,7 +10,7 @@ use super::input::{InputReady, PleOwner, PlePending, PlePrior}; use super::output::{FiniteLogits, greedy}; pub(super) use super::qsa_index::QsaPrior as QsaIndexPrior; use super::qsa_index::{QsaOwner, QsaPending}; -use crate::model_binding::qwen4exp_input::{BindingIdentity, BoundLayerKind, GrRole, ModelBinding}; +use crate::model_binding::weight_binding::{BindingIdentity, BoundLayerKind, GrRole, ModelBinding}; use leleka_cuda_driver::Context; use std::{rc::Rc, thread::ThreadId}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/checkpoint.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/checkpoint.rs index 1aa87178..2dcf772f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/checkpoint.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/checkpoint.rs @@ -1,7 +1,7 @@ //! Complete immutable target state snapshots for a bounded verification window. //! This capability never clears a CUDA failure or survives session reset. use super::{Error, GdnPrior, PlePrior, QsaIndexPrior, QwenSession, Result, STATE_CAPACITY}; -use crate::model_binding::qwen4exp_input::BindingIdentity; +use crate::model_binding::weight_binding::BindingIdentity; use std::rc::Rc; /// Captured only by the successful target executor. Reset or rewind invalidates diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs index 1fca2742..c1f214cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs @@ -19,4 +19,4 @@ mod qwen_chunk_txn_gdn_micro; mod qwen_chunk_txn_layer_batch; mod qwen_chunk_txn_micro_inputs; mod qwen_chunk_txn_micro_window; -mod qwen_chunk_txn_rows_and_witness; +mod row_witnesses; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/row_witnesses.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/row_witnesses.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs index ab4401cc..3615e73f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs @@ -154,7 +154,7 @@ fn break_authority(txn: &mut Txn<'_>, refusal: u32, layer: LayerId, position: Po } fn refuse_with(refusal: u32) { - use crate::model_binding::qwen4exp_input::BindingIdentity; + use crate::model_binding::weight_binding::BindingIdentity; let (layer, position) = (layer_of(1), row_position()); let mut session = QwenSession::test_session(BindingIdentity::test_identity()); let mut txn = ple_gdn_fixture(&mut session); @@ -180,7 +180,7 @@ fn refuse_with(refusal: u32) { #[test] fn ple_journal_admits_only_current_layer_one_gdn_attention_phase() { - use crate::model_binding::qwen4exp_input::BindingIdentity; + use crate::model_binding::weight_binding::BindingIdentity; use crate::qwen_forward::input::PlePending; let (layer, position) = (layer_of(1), row_position()); for refusal in 0..16 { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs index c6bbdf5b..9d436922 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs @@ -9,5 +9,5 @@ use super::{ }; mod original_prompt_txn_begin; -mod original_prompt_txn_prior_and_abort; mod original_prompt_txn_publish; +mod prior_rollback; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_prior_and_abort.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/prior_rollback.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_prior_and_abort.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/prior_rollback.rs diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs index 1093ce3f..3fe2ad81 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs @@ -3,7 +3,7 @@ //! refused. use super::{Error, GdnPrior, OriginalVerifiedLineage, PlePrior, QwenSession, STATE_CAPACITY, predecessors_after}; -use crate::model_binding::qwen4exp_input::BindingIdentity; +use crate::model_binding::weight_binding::BindingIdentity; fn session(gdn: &[usize], ple: bool) -> QwenSession<'static> { let mut session = QwenSession::test_session(BindingIdentity::test_identity()); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs index 56ff33ff..cbc66c3b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs @@ -5,7 +5,7 @@ use super::{ Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, QsaOwner, QwenSession, Rc, Stage, TokenId, TokenLayer, }; -use crate::model_binding::qwen4exp_input::BindingIdentity; +use crate::model_binding::weight_binding::BindingIdentity; use crate::qwen_forward::contract::Dimension; fn token(value: u64) -> TokenId { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/shared_expert_workspace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/shared_expert_workspace.rs index 91e0f544..8f44b7d7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/shared_expert_workspace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/shared_expert_workspace.rs @@ -1,7 +1,7 @@ //! Explicit target shared-tail owner. No weights or output certificates are fabricated. use super::contract::{Error, Result, TokenLayer}; use super::qsa_index::driver_error; -use crate::model_binding::qwen4exp_input::{BindingIdentity, ModelBinding, MoeWeightDescriptor}; +use crate::model_binding::weight_binding::{BindingIdentity, ModelBinding, MoeWeightDescriptor}; use leleka_cuda_driver::{ Context, DeviceBuffer, SharedDownKind, SharedExpertWeights, SharedExpertWorkspace, SharedGuKind, SharedTailRefusal, }; diff --git a/docs/architecture/tech-debt.md b/docs/architecture/tech-debt.md index ca702cef..5343f141 100644 --- a/docs/architecture/tech-debt.md +++ b/docs/architecture/tech-debt.md @@ -260,11 +260,61 @@ Crates: `leleka-control-plane`, `leleka-engine-host`, `leleka-deploy`, `leleka-g | Old | New | Where | |---|---|---| -| binary `leleka-api` | `leleka-api` | `control-plane/Cargo.toml` (`[[bin]]`, `default-run`), the usage texts, the service unit names (`leleka-api.service`, `leleka-api-NAME.service`), `leleka up`/`leleka run` calls (`leleka-api model ...`, `api-key init`), the installed file list and MANIFEST, `install.sh`, the Windows scripts (`leleka-api.exe`), the release and runtime-image build scripts, the CI workflows, the e2e harness scripts, the fake runtime double (`leleka-api` symlink) and the docs | -| crate `leleka-control-plane` | `leleka-control-plane` (identifier `leleka_control_plane`) | `Cargo.toml` of the workspace and of every dependent, `Cargo.lock`, `use` paths, `-p` arguments of scripts and CI, `architecture.json` and the baselines | -| crate `leleka-engine-host` | `leleka-engine-host` (identifier `leleka_engine_host`) | the same; the crate hosts the engine process `leleka-inference` (and `leleka-daemon`, `leleka-cli`, `leleka-seal-exec`) with the node, pool, managed worker and gateway services around it, so the name says what it hosts; the `strata-desktop` binary keeps its name (not part of the order) | +| binary `strata-next` | `leleka-api` | `control-plane/Cargo.toml` (`[[bin]]`, `default-run`), the usage texts, the service unit names (`leleka-api.service`, `leleka-api-NAME.service`), `leleka up`/`leleka run` calls (`leleka-api model ...`, `api-key init`), the installed file list and MANIFEST, `install.sh`, the Windows scripts (`leleka-api.exe`), the release and runtime-image build scripts, the CI workflows, the e2e harness scripts, the fake runtime double (`leleka-api` symlink) and the docs | +| crate `strata-control` | `leleka-control-plane` (identifier `leleka_control_plane`) | `Cargo.toml` of the workspace and of every dependent, `Cargo.lock`, `use` paths, `-p` arguments of scripts and CI, `architecture.json` and the baselines | +| crate `strata-desktop-core` | `leleka-engine-host` (identifier `leleka_engine_host`) | the same; the crate hosts the engine process `leleka-inference` (and `leleka-daemon`, `leleka-cli`, `leleka-seal-exec`) with the node, pool, managed worker and gateway services around it, so the name says what it hosts; the `strata-desktop` binary keeps its name (not part of the order) | Done by `scripts/dev/rename_strata_names.py` (a plain text replacement over the tracked files, rerunnable, which also catches what a branch merged later adds). `STRATA_*` environment variables stay. Not touched: `engine/strata` (the Original, including its Python package `strata_control`), `docs/experiments/` and `docs/e2e-data/` (records of what was run, with the names of that day), `docs/ledger*`, `docs/upstream/` and every `*.patch` (diffs against the Original). **Compatibility:** no `leleka-api` alias is shipped, because nothing outside the repository calls the binary by that name; a prefix installed by an older `leleka` is complete in itself (its `leleka`, its MANIFEST and its `leleka-api`), and a new `leleka up` takes the binaries from the package it was built in, which carries `leleka-api`; mixing a new `leleka` with an old package directory is not supported (the MANIFEST lists different files). The owner's running service (`leleka.service` on rnr5090) runs a package built before the rename and was not touched. +### (c3) Stage 10 pass over the engine crates (owner order 2026-11-14, branch `claude/debt-engine`) + +The order: the debt of the engine is brought to zero in the code, or listed as a named exception in `architecture.json` +(`exceptions`: crate, file, ratchet, reason; an entry that excuses nothing is an error). Crates: `leleka-engine-qwen35-cuda`, +`leleka-engine-core`, `leleka-engine-fake`, `leleka-runtime`. + +| Ratchet (production code) | before | after, in the code | named exceptions | +|---|---|---|---| +| `glob-super-import` | 70 (193 files with the glob, tests and GPU proofs included) | 0 | none | +| `allow-unused-imports` | engine 224, engine-core 18 | 0 | none (re-exports nobody used are deleted, names only the tests need are `#[cfg(test)]`, names only another platform needs sit under their `cfg`) | +| `path-include` | 100 | 0 (420 files moved to the place their module name gives) | none; five `#[path]` remain in test-only modules: two files of the crate's `tests/` directory, the file two proofs share (`native_down_pair_io.rs`, one copy of its state each) | +| `env-read` | 1 | 0 | `settings/source.rs`: the one reader of the process environment | +| `instant-now` | 16 | 0 | 8 files of measurement timers in hot loops (round, miss, kernel; each one a log line or counter); load laps and the resident-RAM log line read `SystemClock` | +| `dyn-trait` | engine-core 18, engine-fake 1, engine 53 | engine-core 0, engine-fake 0, engine 9 | `Box` of the five factory files, `EngineFamily::spawn` and the fake family (process boundary); two stored host callbacks (measurement sink, GPU probe). The 9 left are on the hot branch, see below | +| `process-global` | 59 | 0 | 37 files, in three groups: reads of the serving context that is fixed at start-up (`serving_cells()`), `Governor::global()` (the S13/S14 injection of a governor handle is not done), and the settings capture, one tuning cache, one trace epoch, four per-instance `OnceCell` fields | + +What was done, with the tools that did it (all under `scripts/dev/`, offline aids): + +* **Imports.** `unglob_by_errors.py` replaced every `use super::*;` by the names the file uses. It seeds the list from the module + tree, builds the crate, adds what rustc says is missing, removes what no build uses, and gives a name only the tests need + `#[cfg(test)]`; it also handled the 12 files under a platform `cfg` (the names the other platform needs sit under + `#[cfg(not(target_os = "linux"))]`) and the test modules. `drop_allow_unused.py` removed `#[allow(unused_imports)]` and what it hid + (about 170 re-exports). The size gate caught three files that the lists pushed over 400 lines; `open_cache_steps.rs` was split off + `open_phase_steps.rs` and the other two lost a comment line. +* **Modules without `#[path]`.** `path_to_modules.py` moved each `#[path]` module to the file its name gives and its children with it (a + file loaded through `#[path]` owns its directory like a `mod.rs`, so the children move too); 420 files, no code changed. The GPU proofs + now sit beside the code they prove (`backend/native_down_*`), and they compile against `leleka-gateway-text` (a dev-dependency) instead of + including its `prompt.rs` as a module, which also stops its 33 tests from running twice. A `cfg(feature = "preview-path")` attribute had been + read as a `#[path]` attribute by `rust_modtree.py`, which hid two modules from every earlier tool; fixed there and in the low-level copy. + Gates that quote source paths follow: `smoke-groups.json` (directory patterns), the `docs/gpu-bringup.md` table, the oracle pin path, the + source scan of `tests/bringup_prints_gated.rs`. +* **Names.** 50 modules renamed with `rename_module.py` for what they hold: the `*_methods` groups (`moe_cache_ops`, `stack_phases`, + `round_steps`, ...), the `*_and_*` files (`dense_cache_teardown`, `chunk_run`, `mirror_compute`, ...), the `*_sdet` test targets + (`reset_replay_proof`, `directory_limit_tests`, ...), the `*_types` files and `qwen4exp_input` / `qwen4exp_kar_ple` (`weight_binding`, + `kar_ple_source`). The test ids of the renamed test modules changed with their path. Not renamed: 50 more `*_and_*` / repeated-prefix names + that six readers proposed (the list is in the commit `claude/debt-docs`); each needs its callers read. +* **Docs.** 449 generated headers (`Methods of ...`, `Functions: ...`, `Split out of ... to keep its files under the line limit`) are real + descriptions of what the file is and why it is separate; six readers wrote them from the code, the diff is comment lines only. +* **`dyn`.** `&mut dyn StateMemory` / `dyn SessionEngine` of `engine-core` are generics; the `cancel` / `emit` callbacks of the request + layer (`RequestOwners`, the stack's prefill and decode entry points) are `impl FnMut`; the prompt composer is generic over its callback and + hooks. + +Left, with the reason: + +| What | Why | Next step | +|---|---|---| +| `Governor::global()` (22 sites in 12 files) | the handle has to travel through `StackConfig`, the request environment and `PrefixServe`; each site is cold, but the plumbing touches the load path | one `MemoryHandle` built from what `memory_governor::startup` returns and carried in `StackConfig`; then `memory_governor`'s free functions become its methods | +| `serving_cells()` (33 sites in 27 files) | the bound is an immutable process constant after start-up; the call sites are position and prompt-length checks on the decode and prefill paths | a `ServingBound` handle on the session and the request, with the identity gate | +| 9 `dyn` of the hot path: `OriginalServePool` (host), `GdnGemm` (prefill batch), `Drain` (prefill profile) | per-round and per-layer calls; the change is semantics-neutral but touches the decode loop and the prefill ring | branch `claude/debt-hot-engine`, not merged before the laptop identity run | +| `settings::process()` | leaf code that cannot take a parameter | S13/S14 | ### (d) Other open items of this file (unchanged by the pass; the owner's order for them) diff --git a/docs/experiments/async-park-compression-and-orchestrator-bench.md b/docs/experiments/async-park-compression-and-orchestrator-bench.md index 908f5269..6ee961f7 100644 --- a/docs/experiments/async-park-compression-and-orchestrator-bench.md +++ b/docs/experiments/async-park-compression-and-orchestrator-bench.md @@ -22,7 +22,7 @@ Labels: **M** = measured, source named; **C** = read from code; **E** = estimate ### A.1 What is parked, and in which format (C unless marked) -Code path: `QwenSession` park -> `ResidentQsaLayer::export_span` (`crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs`) +Code path: `QwenSession` park -> `ResidentQsaLayer::export_span` (`crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/span_transfer.rs`) fills one `ParkedLayerSpan { first_token, tokens, kv: Vec, index: Vec }` per QSA layer; a `ParkedBlock` (`session_original_prompt.rs`) is 12 spans; a `ParkedSession` (node) holds the GDN and PLE priors, the index checkpoint tails and the draft-ring snapshot. The store (`engine-core::prefix_cache`) is model-free and keeps them as plain host heap bytes. diff --git a/docs/gpu-bringup.md b/docs/gpu-bringup.md index ead83d92..dcef1337 100644 --- a/docs/gpu-bringup.md +++ b/docs/gpu-bringup.md @@ -280,26 +280,57 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | driver-basic | cuda-driver --test gpu_driver | `installed_driver_fixed_kernels` | device | LELEKA_CUDA_REAL_GPU=1 | - | | driver-basic | cuda-driver --test q5_gpu | `installed_driver_q5_numeric_refusals` | device | LELEKA_CUDA_REAL_GPU=1 | - | | driver-basic | cuda-driver --test q6_gpu | `installed_driver_q6_numeric_refusals` | device | LELEKA_CUDA_REAL_GPU=1 | - | -| gdn | cuda-driver lib | `original_fused_t1_gdn_program_runs_in_order_refuses_earliest_and_cleans_up` | device | LELEKA_STRA169_RUN_GDN_FUSED_T1=yes | - | -| gdn | cuda-driver lib | `strata_prefill_gdn_program_runs_in_order_refuses_earliest_and_cleans_up` | device | LELEKA_STRA169_RUN_GDN_BATCH=yes | - | -| gdn | cuda-driver lib | `queued_gdn_row_matches_scalar_calls_orders_refusals_and_cleans_up` | device | LELEKA_STRA169_RUN_GDN_ROW_QUEUE=yes | - | | gr | cuda-driver lib | `installed_gr_read_guard_matches_all_stage_bits_and_first_nonfinite` | device | LELEKA_STRA169_RUN_GR_DEVICE_GUARD=yes | - | -| gr | cuda-driver lib | `original_first_t1_t2_t3_gr_batch_injection_overwrite_refusal_and_cleanup` | device | LELEKA_STRA172_RUN_GR_BATCH_INJECT_WORKSPACE=yes | - | | gr | cuda-driver lib | `original_first_microbank_read_inject_ffn_all_rows_bits_and_cleanup` | device | LELEKA_STRA169_RUN_GR_MICROBATCH=yes | - | +| misc-device | cuda-driver lib | `original_three_copies_first_owned_event_triplet_bytes_guards_and_cleanup` | device | LELEKA_STRA169_RUN_OWNED_ASYNC_COPY=yes | - | +| misc-device | cuda-driver lib | `poison_while_pending_retains_registered_owners_and_preserves_the_primary_error` | device | LELEKA_STRA169_RUN_OWNED_ASYNC_COPY=yes | - | +| misc-device | cuda-driver lib | `deferred_status_equals_the_immediate_evaluation_and_poisons` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | | misc-device | cuda-driver lib | `a_released_owner_leaves_the_memory_to_the_last_holder` | device | LELEKA_VERIFY_WINDOW_GPU=yes | - | | misc-device | cuda-driver lib | `a_handle_to_a_slab_range_keeps_the_slab_alive_after_the_allocator_released_it` | device | LELEKA_VERIFY_WINDOW_GPU=yes | - | +| misc-device | cuda-driver lib | `original_first_complete_greedy_ties_finite_reset_guards_and_cleanup` | device | LELEKA_STRA172_RUN_HEAD_GREEDY=yes | - | +| misc-device | cuda-driver lib | `original_group_stream_k_stress` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `fixed_down_pack_matches_original_upload_and_refuses_before_copy` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `duplicated_ring_same_attention_reload_append_wrap` | device | LELEKA_STRA169_RUN_MTP_KV_RING_PROOF=yes | - | | misc-device | cuda-driver lib | `the_batched_guard_leaves_the_status_words_of_the_separate_launches` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `short_prompts_record_on_the_drafters_own_scalar_owner_not_on_a_standalone_one` | device | LELEKA_MTP_SCALAR_SHORT_GPU=yes | - | | misc-device | cuda-driver lib | `mapped_table_alias_reads_the_host_bytes_and_costs_no_device_memory` | device | (ignore only) | - | | misc-device | cuda-driver lib | `native_embed_table_alias_reads_the_same_bytes_and_costs_no_device_memory` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `staged_input_equals_the_per_token_kernels_bit_for_bit` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | +| misc-device | cuda-driver lib | `gr_fused_guards_equal_the_separate_guard_kernels_bit_for_bit` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | +| misc-device | cuda-driver lib | `gr_kernels_run_near_their_traffic_floor_at_chunk_size` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | +| misc-device | cuda-driver lib | `rt_bank_places_every_tensor_and_the_expert_chunks_exactly` | device | LELEKA_MTP_RT_BANK_GPU=yes | - | +| misc-device | cuda-driver lib | `draft_head_gather_matches_a_host_gather_for_each_kernel_width` | device | LELEKA_MTP_RT_BANK_GPU=yes | - | +| misc-device | cuda-driver lib | `pcie_copy_gpu_raw_loop_pageable` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `pcie_copy_gpu_raw_loop_page_locked` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `pcie_copy_gpu_raw_batch_pageable` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `pcie_copy_gpu_raw_batch_page_locked` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `pcie_copy_gpu_raw_batch_mixed` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `pcie_copy_gpu_bandwidth` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `sealed_window_assets_load_on_the_device_and_export_every_named_entry` | device | LELEKA_VERIFY_WINDOW_GPU=yes | - | +| misc-device | cuda-driver lib | `the_pcie_span_copy_stages_gate_up_down_like_the_dma_path` | device | LELEKA_VERIFY_WINDOW_GPU=yes | - | +| misc-device | cuda-driver lib | `whole_value_matches_original_40_tiles_and_refuses_closed_shapes` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `selection_kernels_equal_the_originals_at_long_positions` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `topk_variants_equal_the_original_and_are_timed` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `decode_scores_are_timed_next_to_the_topk` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `original_first_selected_kv_bytes_attention_reorder_refusals_cleanup` | device | LELEKA_STRA172_RUN_QSA_SELECTED_KV=yes | - | +| misc-device | cuda-driver lib | `queued_gdn_row_matches_scalar_calls_orders_refusals_and_cleans_up` | device | LELEKA_STRA169_RUN_GDN_ROW_QUEUE=yes | - | +| misc-device | cuda-driver lib | `original_fused_t1_gdn_program_runs_in_order_refuses_earliest_and_cleans_up` | device | LELEKA_STRA169_RUN_GDN_FUSED_T1=yes | - | +| misc-device | cuda-driver lib | `strata_prefill_gdn_program_runs_in_order_refuses_earliest_and_cleans_up` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | | misc-device | cuda-driver lib | `gdn_recurrence_equals_the_original_bit_for_bit` | device | (ignore only) | - | | misc-device | cuda-driver lib | `gdn_recurrence_kh_equals_the_original_bit_for_bit` | device | (ignore only) | - | | misc-device | cuda-driver lib | `gdn_stage_kernels_equal_the_originals_bit_for_bit` | device | (ignore only) | - | | misc-device | cuda-driver lib | `gdn_tensor_core_scan_stays_within_the_gate_of_the_sequential_recurrence` | device | (ignore only) | - | | misc-device | cuda-driver lib | `gdn_tensor_core_scan_timing_against_the_kh_recurrence` | device | (ignore only) | - | -| misc-device | cuda-driver lib | `gr_fused_guards_equal_the_separate_guard_kernels_bit_for_bit` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | -| misc-device | cuda-driver lib | `gr_kernels_run_near_their_traffic_floor_at_chunk_size` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | -| misc-device | cuda-driver lib | `original_first_selected_kv_bytes_attention_reorder_refusals_cleanup` | device | LELEKA_STRA172_RUN_QSA_SELECTED_KV=yes | - | +| misc-device | cuda-driver lib | `original_first_t1_t2_t3_gr_batch_injection_overwrite_refusal_and_cleanup` | device | LELEKA_STRA172_RUN_GR_BATCH_INJECT_WORKSPACE=yes | - | +| misc-device | cuda-driver lib | `strata_prefill_moe_program_runs_in_order_refuses_earliest_and_cleans_up` | device | LELEKA_STRA169_RUN_MOE_PREFILL_BATCH=yes | - | +| misc-device | cuda-driver lib | `original_first_mtp_input_prefix_products_status_order_and_cleanup` | device | LELEKA_STRA172_RUN_MTP_INPUT_PREFIX=yes | - | +| misc-device | cuda-driver lib | `original_first_whole_ple_queue_causal_history_status_reset_and_cleanup` | device | LELEKA_STRA169_RUN_PLE_CLOSED_QUEUE=yes | - | +| misc-device | cuda-driver lib | `original_first_shared_tail_all_products_status_reset_and_cleanup` | device | LELEKA_STRA172_RUN_SHARED_TAIL=yes | - | | misc-device | cuda-driver lib | `refill_batch_copy_gpu_slots_equal_per_copy` | device | (ignore only) | - | +| misc-device | cuda-driver lib | `original_first_group_workspace_all_products_active_spans_reset_and_cleanup` | device | LELEKA_STRA172_RUN_ROUTED_COLUMNS_LOAN=yes | - | +| misc-device | cuda-driver lib | `original_first_columns_loan_gate_up_fresh_order_guards_and_cleanup` | device | LELEKA_STRA172_RUN_ROUTED_COLUMNS_LOAN=yes | - | +| misc-device | cuda-driver lib | `original_first_routed_resident_pipeline_all_products_refusals_reset_and_cleanup` | device | LELEKA_STRA169_RUN_ROUTED_RESIDENT_QUEUE=yes | - | +| misc-device | cuda-driver lib | `original_first_complete_routed_finite_stages_reset_and_cleanup` | device | LELEKA_STRA172_RUN_ROUTED_FINITE_GUARD=yes | - | | misc-device | cuda-driver --test preflight_00_sealed_asset_report | `preflight_00_sealed_asset_report` | device | (ignore only) | - | | misc-device | cuda-driver --test preflight_00_sealed_asset_report | `preflight_01_device_limits` | device | (ignore only) | - | | misc-device | cuda-driver --test preflight_00_sealed_asset_report | `preflight_10_lazy_constructors` | device | (ignore only) | - | @@ -307,16 +338,6 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | misc-device | cuda-driver --test preflight_00_sealed_asset_report | `preflight_30_synthetic_mtp_full_owner` | device | (ignore only) | - | | misc-device | cuda-driver --test preflight_00_sealed_asset_report | `preflight_40_synthetic_verifier_record_all` | device | (ignore only) | - | | misc-device | deploy lib | `pinned_sources_serve_the_pinned_table` | device | (ignore only) | - | -| misc-device | engine-qwen35-cuda lib | `pinned_combined_kar_mtp_retained_three_plus_two_matches_full_reference_five` | device | LELEKA_STRA169_RUN_COMBINED_REUSE=yes | - | -| misc-device | engine-qwen35-cuda lib | `pinned_new_slowpaths_match_completed_public_output` | device | (ignore only) | - | -| misc-device | engine-qwen35-cuda lib | `pinned_five_public_cases_one_loaded_owner` | device | (ignore only) | - | -| misc-device | engine-qwen35-cuda lib | `pinned_five_public_cases_retained_qk_qsa_owner` | device | (ignore only) | - | -| misc-device | engine-qwen35-cuda lib | `pinned_five_public_cases_resident_owners` | device | (ignore only) | - | -| misc-device | engine-qwen35-cuda lib | `pinned_single_load_public_native_vs_native_down_outer256_pair` | device | (ignore only) | - | -| misc-device | engine-qwen35-cuda lib | `pinned_single_load_native_resident_mmq_model_numeric` | device | LELEKA_STRA169_RUN_NATIVE_RESIDENT_MMQ_MODEL=yes | - | -| misc-device | engine-qwen35-cuda lib | `pinned_single_load_resident_mmq_model_numeric` | device | LELEKA_STRA169_RUN_RESIDENT_MMQ_MODEL=yes | - | -| misc-device | engine-qwen35-cuda lib | `pinned_single_load_capture_two_combined_reuse_and_chunk_numeric` | device | LELEKA_STRA169_RUN_SINGLELOAD_PROOF=yes | - | -| misc-device | engine-qwen35-cuda lib | `pinned_single_load_grouped_certified_chunk_numeric` | device | LELEKA_STRA169_RUN_GROUPED_CHUNK_PROOF=yes | - | | misc-device | engine-qwen35-cuda lib | `scan_against_queue_on_a_full_cache` | device | (ignore only) | - | | mock-only | cuda-driver lib | `family_quantizer_transport_child` | mock | LELEKA_CUDA_MOCK_HARNESS=1 | - | | mock-only | cuda-driver --test isolated_cpu_elf_matrix | `isolated_cpu_elf_matrix` | mock | LELEKA_CUDA_MOCK_HARNESS=1 | - | @@ -326,10 +347,17 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | mock-only | cuda-driver --test q5_mock | `q5_fixture_child` | mock | LELEKA_CUDA_MOCK_HARNESS=1 | - | | mock-only | cuda-driver --test isolated_q6_protocol_matrix | `isolated_q6_protocol_matrix` | mock | LELEKA_CUDA_MOCK_HARNESS=1 | - | | mock-only | cuda-driver --test q6_fixture_child | `q6_fixture_child` | mock | LELEKA_CUDA_MOCK_HARNESS=1 | - | -| model-assets | cuda-driver lib | `actual_expert215_native_resident_gu_and_same_source_down_diagnostic` | assets | LELEKA_RUN_REAL_NATIVE_D4=yes | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `original_three_uploads_first_triplet_exact_padding_refusals_cleanup` | assets | LELEKA_STRA172_RUN_MMQ_TRIPLET=yes | (fixture files read via a helper; inspect before running) | | model-assets | cuda-driver lib | `original_first_mmq_adaptive_and_distinct_fixed_profiles_exact` | assets | LELEKA_STRA169_RUN_MMQ_NUMERIC=yes | LELEKA_STRA169_MMQ_REFERENCE_DIR, LELEKA_STRA169_MMQ_REFERENCE_MANIFEST_SHA | +| model-assets | cuda-driver lib | `original_first_owned_gate_up_bytes_products_refusals_and_cleanup` | assets | LELEKA_STRA172_RUN_OWNED_GATE_UP_UPLOAD=yes | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `actual_expert215_native_resident_gu_and_same_source_down_diagnostic` | assets | LELEKA_RUN_REAL_NATIVE_D4=yes | (fixture files read via a helper; inspect before running) | | model-assets | cuda-driver lib | `original_references_resident_chain_gather_dual_native_and_guards_exact` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | cuda-driver lib | `queued_finite_chain_and_bulk_down_packets_exact` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `pcie_copy_gpu_production_pageable` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `pcie_copy_gpu_production_page_locked` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `pcie_copy_gpu_production_mixed` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `a_fresh_journal_needs_the_resolver_before_the_window_and_ensure_keeps_the_epoch` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | cuda-driver lib | `parked_pages_and_index_rows_round_trip_through_the_owners` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | cuda-driver --test projection_family_gpu | `installed_driver_public_family_parity` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | cuda-driver --test family_public_q8_child | `family_public_q8_child` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | cuda-driver --test q5_gpu | `installed_driver_q5_native_parity` | assets | LELEKA_CUDA_REAL_GPU=1 | LELEKA_Q5_EVIDENCE, LELEKA_Q5_NATIVE_ORACLE, LELEKA_Q5_TRUSTED_PTX | @@ -337,6 +365,15 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | model-assets | cuda-driver --test q6_gpu | `installed_driver_q6_native_parity` | assets | LELEKA_CUDA_REAL_GPU=1 | LELEKA_Q6_EVIDENCE, LELEKA_Q6_NATIVE_ORACLE, LELEKA_Q6_TRUSTED_PTX | | model-assets | cuda-driver --test q6_gpu | `installed_driver_q6_real_tensor_component` | assets | LELEKA_CUDA_REAL_GPU=1 | (fixture files read via a helper; inspect before running) | | model-assets | deploy lib | `provisions_the_pinned_table_from_upstream` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_layer0_and_window_boundaries` | assets | LELEKA_STRA169_RUN_COMBINED_BOUNDARIES=yes | LELEKA_STRA169_LAYER0_DIR | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_layer0_native_first_mmq_diagnostic` | assets | LELEKA_STRA169_RUN_LAYER0_MMQ_DIAGNOSTIC=yes | LELEKA_STRA169_LAYER0_DIR | +| model-assets | engine-qwen35-cuda lib | `pinned_new_slowpaths_match_completed_public_output` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_five_public_cases_one_loaded_owner` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_five_public_cases_retained_qk_qsa_owner` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_five_public_cases_resident_owners` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_five_public_cases_strata_adaptive_slots` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_public_native_vs_native_down_outer256_pair` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_native_resident_mmq_model_numeric` | assets | LELEKA_STRA169_RUN_NATIVE_RESIDENT_MMQ_MODEL=yes | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `original_serve_laptop_bench` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `original_serve_memory_smoke` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `memory_archive_guard_probe` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | @@ -347,9 +384,10 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | model-assets | engine-qwen35-cuda lib | `original_serve_conversation_smoke_resume_matches_a_full_read` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `original_serve_conversation_coverage_smoke` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `original_serve_ttft_sweep` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | -| model-assets | engine-qwen35-cuda lib | `pinned_single_load_layer0_and_window_boundaries` | assets | LELEKA_STRA169_RUN_COMBINED_BOUNDARIES=yes | LELEKA_STRA169_LAYER0_DIR | -| model-assets | engine-qwen35-cuda lib | `pinned_single_load_layer0_native_first_mmq_diagnostic` | assets | LELEKA_STRA169_RUN_LAYER0_MMQ_DIAGNOSTIC=yes | LELEKA_STRA169_LAYER0_DIR | -| model-assets | engine-qwen35-cuda lib | `pinned_five_public_cases_strata_adaptive_slots` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_combined_kar_mtp_retained_three_plus_two_matches_full_reference_five` | assets | LELEKA_STRA169_RUN_COMBINED_REUSE=yes | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_resident_mmq_model_numeric` | assets | LELEKA_STRA169_RUN_RESIDENT_MMQ_MODEL=yes | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_capture_two_combined_reuse_and_chunk_numeric` | assets | LELEKA_STRA169_RUN_SINGLELOAD_PROOF=yes | (fixture files read via a helper; inspect before running) | +| model-assets | engine-qwen35-cuda lib | `pinned_single_load_grouped_certified_chunk_numeric` | assets | LELEKA_STRA169_RUN_GROUPED_CHUNK_PROOF=yes | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `pinned_kar_cached_vs_legacy_same_session_reset_replays_all_logits_and_numeric_state` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `pinned_artifact_refuses_missing_output_before_layers_without_state_commit` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda lib | `pinned_artifact_two_tokens_finish_all_layers_and_commit_state` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | @@ -360,21 +398,10 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | model-assets | engine-qwen35-cuda --test stra168_full_vocabulary | `prepare_independent_full_vocabulary_fixture` | assets | (ignore only) | (fixture files read via a helper; inspect before running) | | model-assets | engine-qwen35-cuda --test stra168_full_vocabulary | `installed_driver_full_vocabulary_matches_original_and_literal_words` | assets | LELEKA_CUDA_REAL_GPU=1 | (fixture files read via a helper; inspect before running) | | model-assets | model-format --test builder_makes_archives | `write_a_synthetic_archive_for_the_census_example` | assets | (ignore only) | LELEKA_SYNTH_KAR | -| moe-mmq | cuda-driver lib | `strata_prefill_moe_program_runs_in_order_refuses_earliest_and_cleans_up` | device | LELEKA_STRA169_RUN_MOE_PREFILL_BATCH=yes | - | | moe-mmq | cuda-driver lib | `installed_grouped_native_gu18_gu22_matches_actual_scalar_columns` | device | LELEKA_STRA169_RUN_MOE_GROUP=yes | - | | moe-mmq | cuda-driver lib | `scalar_first_grouped_swiglu_down_columns_exact_and_closed_guards` | device | LELEKA_STRA169_RUN_GROUPED_DOWN=yes | - | | moe-mmq | cuda-driver lib | `original_first_gu21_gu23_full_products_refusals_reset_and_cleanup` | device | LELEKA_STRA172_RUN_GROUPED_GU21_GU23=yes | - | | moe-mmq | cuda-driver lib | `original_first_gu21_gu23_nc4_full_products_tails_refusals_reset_and_cleanup` | device | LELEKA_STRA172_RUN_GROUPED_GU21_GU23_NC4=yes | - | -| moe-mmq | cuda-driver lib | `original_first_columns_loan_gate_up_fresh_order_guards_and_cleanup` | device | LELEKA_STRA172_RUN_ROUTED_COLUMNS_LOAN=yes | - | -| moe-mmq | cuda-driver lib | `original_first_group_workspace_all_products_active_spans_reset_and_cleanup` | device | LELEKA_STRA172_RUN_ROUTED_GROUP_WORKSPACE=yes | - | -| moe-mmq | cuda-driver lib | `original_first_routed_resident_pipeline_all_products_refusals_reset_and_cleanup` | device | LELEKA_STRA169_RUN_ROUTED_RESIDENT_QUEUE=yes | - | -| moe-mmq | cuda-driver lib | `original_first_complete_routed_finite_stages_reset_and_cleanup` | device | LELEKA_STRA172_RUN_ROUTED_FINITE_GUARD=yes | - | -| moe-mmq | cuda-driver lib | `original_group_stream_k_stress` | device | (ignore only) | - | -| moe-mmq | cuda-driver lib | `original_first_complete_greedy_ties_finite_reset_guards_and_cleanup` | device | LELEKA_STRA172_RUN_HEAD_GREEDY=yes | - | -| moe-mmq | cuda-driver lib | `original_first_shared_tail_all_products_status_reset_and_cleanup` | device | LELEKA_STRA172_RUN_SHARED_TAIL=yes | - | -| mtp | cuda-driver lib | `duplicated_ring_same_attention_reload_append_wrap` | device | LELEKA_STRA169_RUN_MTP_KV_RING_PROOF=yes | - | -| mtp | cuda-driver lib | `original_first_mtp_input_prefix_products_status_order_and_cleanup` | device | LELEKA_STRA172_RUN_MTP_INPUT_PREFIX=yes | - | -| mtp | cuda-driver lib | `short_prompts_record_on_the_drafters_own_scalar_owner_not_on_a_standalone_one` | device | LELEKA_MTP_SCALAR_SHORT_GPU=yes | - | | new-pins | cuda-driver lib | `experimental_gpu_fwht256_matches_cpu` | device | (ignore only) | - | | new-pins | cuda-driver lib | `experimental_gpu_q4_append_and_gather_match_cpu` | device | (ignore only) | - | | new-pins | cuda-driver lib | `experimental_gpu_keyless_route_matches_cpu` | device | (ignore only) | - | @@ -385,26 +412,8 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | new-pins | cuda-driver lib | `closed_gpu_poison_fills_the_nan_pattern_and_nothing_else` | device | (ignore only) | - | | new-pins | cuda-driver lib | `closed_gpu_native_flash_attn_matches_the_fp64_specification` | device | (ignore only) | - | | new-pins | cuda-driver lib | `closed_gpu_s_gemv_matches_the_shim_executed_golden` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_production_pageable` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_production_page_locked` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_production_mixed` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_raw_loop_pageable` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_raw_loop_page_locked` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_raw_batch_pageable` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_raw_batch_page_locked` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_raw_batch_mixed` | device | (ignore only) | - | -| pcie-copy | cuda-driver lib | `pcie_copy_gpu_bandwidth` | device | (ignore only) | - | -| ple | cuda-driver lib | `original_first_whole_ple_queue_causal_history_status_reset_and_cleanup` | device | LELEKA_STRA169_RUN_PLE_CLOSED_QUEUE=yes | - | -| ple | cuda-driver lib | `whole_value_matches_original_40_tiles_and_refuses_closed_shapes` | device | (ignore only) | - | -| prefill-stage | cuda-driver lib | `staged_input_equals_the_per_token_kernels_bit_for_bit` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | -| prefill-stage | cuda-driver lib | `deferred_status_equals_the_immediate_evaluation_and_poisons` | device | LELEKA_PREFILL_STAGE_GPU=yes | - | | qsa | cuda-driver lib | `int8_kv_append_kernels_match_the_original_host_reference_bit_exactly` | device | (ignore only) | - | | qsa | cuda-driver lib | `streamed_attention_equals_fully_resident_attention_with_a_20480_cell_window` | device | (ignore only) | - | -| qsa | cuda-driver lib | `selection_kernels_equal_the_originals_at_long_positions` | device | (ignore only) | - | -| qsa | cuda-driver lib | `topk_variants_equal_the_original_and_are_timed` | device | (ignore only) | - | -| qsa | cuda-driver lib | `decode_scores_are_timed_next_to_the_topk` | device | (ignore only) | - | -| qsa | cuda-driver lib | `a_fresh_journal_needs_the_resolver_before_the_window_and_ensure_keeps_the_epoch` | device | (ignore only) | - | -| qsa | cuda-driver lib | `parked_pages_and_index_rows_round_trip_through_the_owners` | device | (ignore only) | - | | runtime-gdn | engine-qwen35-cuda lib | `original_first_retained_whole_qk_repeat_tail_reset_guards_cleanup` | device | LELEKA_STRA169_RUN_GDN_QK_SLOT=yes | - | | runtime-gdn | engine-qwen35-cuda lib | `retained_gdn_chain_matches_legacy_intermediates_and_fences_products` | device | (ignore only) | - | | runtime-gdn | engine-qwen35-cuda lib | `queued_gdn_chain_matches_scalar_oracles_refuses_and_cleans_up` | device | (ignore only) | - | @@ -430,20 +439,11 @@ variables); **mock**: isolated CPU harness protocol tests, not GPU smokes. | runtime-qsa | engine-qwen35-cuda lib | `retained_attention_gate_out_matches_legacy_transfers_and_cleans_refusals` | device | (ignore only) | - | | runtime-qsa | engine-qwen35-cuda lib | `resident_index_transport_matches_uncached_at_190k_and_reset` | device | (ignore only) | - | | runtime-qsa | engine-qwen35-cuda lib | `one_input_upload_matches_five_legacy_projections_and_preserves_lease_guards` | device | (ignore only) | - | -| seal-loads | cuda-driver lib | `sealed_window_assets_load_on_the_device_and_export_every_named_entry` | device | LELEKA_VERIFY_WINDOW_GPU=yes | - | -| seal-loads | cuda-driver lib | `the_pcie_span_copy_stages_gate_up_down_like_the_dma_path` | device | LELEKA_VERIFY_WINDOW_GPU=yes | - | -| seal-loads | cuda-driver lib | `rt_bank_places_every_tensor_and_the_expert_chunks_exactly` | device | LELEKA_MTP_RT_BANK_GPU=yes | - | -| seal-loads | cuda-driver lib | `draft_head_gather_matches_a_host_gather_for_each_kernel_width` | device | LELEKA_MTP_RT_BANK_GPU=yes | - | | serve-probes | cuda-driver --test original_arena_probe | `arena_probe` | device | (ignore only) | - | | serve-probes | cuda-driver --test original_executor_probe | `executor_probe` | device | (ignore only) | - | -| transport | cuda-driver lib | `original_three_copies_first_owned_event_triplet_bytes_guards_and_cleanup` | device | LELEKA_STRA169_RUN_OWNED_ASYNC_COPY=yes | - | -| transport | cuda-driver lib | `poison_while_pending_retains_registered_owners_and_preserves_the_primary_error` | device | LELEKA_STRA169_RUN_OWNED_ASYNC_COPY=yes | - | -| transport | cuda-driver lib | `original_first_owned_gate_up_bytes_products_refusals_and_cleanup` | device | LELEKA_STRA172_RUN_OWNED_GATE_UP_UPLOAD=yes | - | | transport | cuda-driver --test full_matrix_transport_gpu | `complete_selected_matrices_match_legacy_64_row_bits` | device | (ignore only) | - | -| transport | cuda-driver lib | `fixed_down_pack_matches_original_upload_and_refuses_before_copy` | device | (ignore only) | - | | transport | cuda-driver --test prepared_routed_gate_up_gpu | `prepared_routed_gate_up_reuses_exact_native_q8_and_refuses_invalid_owners` | device | (ignore only) | - | | transport | cuda-driver --test ple_key_bulk_gpu | `ple_key_full_matrix_matches_160_legacy_tiles_and_exposes_late_nonfinite` | device | (ignore only) | - | -| transport | cuda-driver lib | `original_three_uploads_first_triplet_exact_padding_refusals_cleanup` | device | LELEKA_STRA172_RUN_MMQ_TRIPLET=yes | - | | transport | cuda-driver lib | `owned_readback_original_first_preserves_gdn_extents_and_raw_words` | device | (ignore only) | - | | transport | cuda-driver lib | `checked_subspan_real_copy_preserves_untouched_bytes` | device | (ignore only) | - | | transport | cuda-driver lib | `device_slab_views_keep_their_bytes_apart_and_charge_only_the_slab` | device | (ignore only) | - | diff --git a/scripts/cuda-qsa-oracle/source.sha256 b/scripts/cuda-qsa-oracle/source.sha256 index d0daba2f..f42cc172 100644 --- a/scripts/cuda-qsa-oracle/source.sha256 +++ b/scripts/cuda-qsa-oracle/source.sha256 @@ -1,4 +1,4 @@ -101eec0eba8c5afff046d5040c6d5044f7aaf82ceae5c19832925e070a1c8e01 crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/qsa.rs +101eec0eba8c5afff046d5040c6d5044f7aaf82ceae5c19832925e070a1c8e01 crates/engine-qwen35-cuda/src/model_binding/weight_binding/qsa.rs ed281c74a39e07f58d23a22be195fffce4a8840840dc767a0bef2ff0b7683b6c crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs cc996a7f1a0f56adbbcd6d514fe6ba4a4d06c3ce5c244f24b4acc11bf0a0214c crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs 78ab8d9240963876e2a1578f845894cd38af148a37242a2dfc9a8668afeb1bc6 crates/cuda-driver/assets/qwen_qsa_attention.cu diff --git a/scripts/dev/rename_strata_names.py b/scripts/dev/rename_strata_names.py index 8214b053..8f0e442f 100644 --- a/scripts/dev/rename_strata_names.py +++ b/scripts/dev/rename_strata_names.py @@ -24,6 +24,18 @@ HYPHEN = (("strata-next", "leleka-api"), ("strata-control", "leleka-control-plan UNDERSCORE = (("strata_control", "leleka_control_plane"), ("strata_desktop_core", "leleka_engine_host")) +KEEP = "" # a line that documents the old names (the table in tech-debt.md) is left as it is + + +def rename(line, name): + for old, to in HYPHEN: + line = line.replace(old, to) + if name.endswith((".rs", ".toml")): + for old, to in UNDERSCORE: + line = line.replace(old, to) + return line + + def main(): dry = "--dry-run" in sys.argv root = pathlib.Path(__file__).resolve().parents[2] @@ -38,12 +50,7 @@ def main(): text = raw.decode("utf-8") except (UnicodeDecodeError, OSError): continue - new = text - for old, to in HYPHEN: - new = new.replace(old, to) - if name.endswith((".rs", ".toml")): - for old, to in UNDERSCORE: - new = new.replace(old, to) + new = "\n".join(line if KEEP in line else rename(line, name) for line in text.split("\n")) if new != text: changed += 1 if not dry: diff --git a/scripts/dev/rust_modtree_lowlevel.py b/scripts/dev/rust_modtree_lowlevel.py index 7b4251c3..28643ed8 100644 --- a/scripts/dev/rust_modtree_lowlevel.py +++ b/scripts/dev/rust_modtree_lowlevel.py @@ -332,7 +332,7 @@ class Crate: m = re.match(rf"(?:pub(?:\s*\([^)]*\))?\s+)?mod\s+({IDENT})\s*;", t) if m: child_name = m.group(1) - path_attr = next((re.search(r'path\s*=\s*"([^"]+)"', a) for a in attrs if "path" in a), None) + path_attr = next((m for m in (re.match(r'#\[path\s*=\s*"([^"]+)"', a) for a in attrs) if m), None) if path_attr: cand = [(file.parent / path_attr.group(1)).resolve()] else: diff --git a/scripts/dev/unglob_by_errors.py b/scripts/dev/unglob_by_errors.py index 14e694ae..f2d2aa4c 100644 --- a/scripts/dev/unglob_by_errors.py +++ b/scripts/dev/unglob_by_errors.py @@ -100,11 +100,11 @@ def collect(msgs): PLATFORM_FILES = { "backend/original_serve/runner/owner_run_steps.rs", "memory_governor/page_cache.rs", - "model_binding/qwen4exp_input/mtp/backing.rs", "model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs", - "model_binding/qwen4exp_input/mtp/read_expert_rows.rs", "model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs", - "model_binding/qwen4exp_kar_ple/private_copy/inode.rs", "model_binding/qwen4exp_kar_ple/private_copy/checked_reader.rs", - "model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs", "model_binding/qwen4exp_kar_ple/load_pinned_inherited_archive.rs", - "model_binding/qwen4exp_kar_ple/pinned_profile.rs", "qwen_forward/original_serve_residency/open_tier.rs", + "model_binding/weight_binding/mtp/backing.rs", "model_binding/weight_binding/mtp/mtp_weight_reads.rs", + "model_binding/weight_binding/mtp/read_expert_rows.rs", "model_binding/kar_ple_source/pinned_profile_tests.rs", + "model_binding/kar_ple_source/private_copy/inode.rs", "model_binding/kar_ple_source/private_copy/checked_reader.rs", + "model_binding/kar_ple_source/inherited_kar_archive.rs", "model_binding/kar_ple_source/load_pinned_inherited_archive.rs", + "model_binding/kar_ple_source/pinned_profile.rs", "qwen_forward/original_serve_residency/open_tier.rs", }