From b66ed637ffe997fa7645deb649250dc599f3cb46 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 20:19:50 +0100 Subject: [PATCH 1/7] engine-qwen35-cuda: the GPU proofs use leleka-gateway-text instead of compiling its prompt.rs as a module; 23 more #[path] modules become ordinary; orphan renderer copy to garbage rust_modtree.py: a cfg(feature = "preview-path") attribute was taken for a #[path] attribute (two modules were invisible to the tools). path_to_modules.py keeps a file that two parents declare (native_down_pair_io.rs, one copy of the state each). Co-Authored-By: Claude Sonnet 5.5 --- Cargo.lock | 1 + crates/engine-qwen35-cuda/Cargo.toml | 2 + crates/engine-qwen35-cuda/src/backend.rs | 9 - .../combined_changed_boundary_proof.rs | 1 - .../combined_changed_boundary_proof/rig.rs | 0 .../combined_prefix_numeric.rs | 0 .../combined_prefix_numeric_sdet.rs | 0 .../layer0_native_mmq_proof.rs | 0 .../native_down_candidate_only.rs | 12 +- .../adaptive_slots.rs} | 4 +- .../adaptive_slots}/cleanup.rs | 0 .../adaptive_slots}/observe.rs | 0 .../fivecase_frames.rs | 2 +- .../fivecase_runtime.rs | 2 +- .../native_down_candidate_only/pair_arm.rs} | 0 .../pair_checks.rs} | 0 .../native_down_candidate_only/pair_owner.rs} | 2 +- .../pair_proofs.rs} | 0 .../native_down_candidate_only/pair_run.rs} | 0 .../native_down_pair_io.rs | 0 .../native_down_public_pair.rs | 7 +- .../long_public_preflight.rs} | 6 +- .../native_down_public_pair/pair_arm.rs} | 0 .../native_down_public_pair/pair_run.rs} | 2 +- .../native_resident_mmq_model_proof.rs | 0 .../resident_mmq_model_proof.rs | 0 .../singleload_proof.rs | 0 .../long_public_preflight/public_renderer.rs | 355 ------------------ scripts/dev/drop_allow_unused.py | 150 ++++++++ scripts/dev/path_to_modules.py | 7 +- scripts/dev/rust_modtree.py | 2 +- scripts/dev/unglob_by_errors.py | 247 ++++++++++++ 32 files changed, 415 insertions(+), 396 deletions(-) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/combined_changed_boundary_proof.rs (98%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/combined_changed_boundary_proof/rig.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/combined_prefix_numeric.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/combined_prefix_numeric_sdet.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/layer0_native_mmq_proof.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/native_down_candidate_only.rs (90%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_adaptive_candidate_only.rs => backend/native_down_candidate_only/adaptive_slots.rs} (98%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_adaptive_candidate_only => backend/native_down_candidate_only/adaptive_slots}/cleanup.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_adaptive_candidate_only => backend/native_down_candidate_only/adaptive_slots}/observe.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend/native_down_candidate_only}/fivecase_frames.rs (98%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend/native_down_candidate_only}/fivecase_runtime.rs (99%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_pair_arm.rs => backend/native_down_candidate_only/pair_arm.rs} (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_pair_checks.rs => backend/native_down_candidate_only/pair_checks.rs} (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_pair_owner.rs => backend/native_down_candidate_only/pair_owner.rs} (99%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_pair_proofs.rs => backend/native_down_candidate_only/pair_proofs.rs} (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_pair_run.rs => backend/native_down_candidate_only/pair_run.rs} (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/native_down_pair_io.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/native_down_public_pair.rs (78%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/long_public_preflight/long_public_request.rs => backend/native_down_public_pair/long_public_preflight.rs} (98%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_public_pair_arm.rs => backend/native_down_public_pair/pair_arm.rs} (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs/native_down_public_pair_run.rs => backend/native_down_public_pair/pair_run.rs} (99%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/native_resident_mmq_model_proof.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/resident_mmq_model_proof.rs (100%) rename crates/engine-qwen35-cuda/src/{gpu_proofs => backend}/singleload_proof.rs (100%) delete mode 100644 crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/public_renderer.rs create mode 100644 scripts/dev/drop_allow_unused.py create mode 100644 scripts/dev/unglob_by_errors.py diff --git a/Cargo.lock b/Cargo.lock index f9a785eb..bc2f898a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1350,6 +1350,7 @@ dependencies = [ "leleka-cuda-driver", "leleka-engine-core", "leleka-experimental-ref", + "leleka-gateway-text", "leleka-memory", "leleka-memory-os", "leleka-model-format", diff --git a/crates/engine-qwen35-cuda/Cargo.toml b/crates/engine-qwen35-cuda/Cargo.toml index f9b23eba..fd53aa05 100644 --- a/crates/engine-qwen35-cuda/Cargo.toml +++ b/crates/engine-qwen35-cuda/Cargo.toml @@ -46,5 +46,7 @@ workspace = true [dev-dependencies] serde_json = "1" leleka-engine-core = { path = "../engine-core", features = ["testing"] } +# The GPU proofs render prompts with the gateway renderer itself (they used to compile its source file as a module). +leleka-gateway-text = { path = "../gateway-text" } # Model-free device probe of the VRAM expert tier (test builds only). leleka-cuda-driver = { path = "../cuda-driver", features = ["cuda-driver", "expert-tier-probe"] } diff --git a/crates/engine-qwen35-cuda/src/backend.rs b/crates/engine-qwen35-cuda/src/backend.rs index 5494c795..c2deffa2 100644 --- a/crates/engine-qwen35-cuda/src/backend.rs +++ b/crates/engine-qwen35-cuda/src/backend.rs @@ -157,11 +157,9 @@ mod backend_measurement_sdet; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/combined_prefix_numeric.rs"] mod combined_prefix_numeric; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/combined_prefix_numeric_sdet.rs"] mod combined_prefix_numeric_sdet; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod original_serve_arms; @@ -179,37 +177,30 @@ mod original_serve_smoke; mod original_serve_ttft; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/singleload_proof.rs"] mod singleload_proof; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/resident_mmq_model_proof.rs"] mod resident_mmq_model_proof; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/native_resident_mmq_model_proof.rs"] mod native_resident_mmq_model_proof; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/layer0_native_mmq_proof.rs"] mod layer0_native_mmq_proof; #[cfg(feature = "preview-path")] #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[path = "gpu_proofs/combined_changed_boundary_proof.rs"] mod combined_changed_boundary_proof; #[cfg(feature = "preview-path")] #[cfg(all(test, target_os = "linux", target_arch = "x86_64"))] -#[path = "gpu_proofs/native_down_public_pair.rs"] mod native_down_public_pair; #[cfg(feature = "preview-path")] #[cfg(all(test, target_os = "linux", target_arch = "x86_64"))] -#[path = "gpu_proofs/native_down_candidate_only.rs"] mod native_down_candidate_only; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/combined_changed_boundary_proof.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/gpu_proofs/combined_changed_boundary_proof.rs rename to crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs index 7dbff742..7a40b905 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/combined_changed_boundary_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs @@ -2,7 +2,6 @@ use super::*; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners as LoadedTarget; use std::env; -#[path = "combined_changed_boundary_proof/rig.rs"] pub(super) mod rig; use rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in, unwrap_phase}; diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/combined_changed_boundary_proof/rig.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/combined_changed_boundary_proof/rig.rs rename to crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/combined_prefix_numeric.rs b/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/combined_prefix_numeric.rs rename to crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/combined_prefix_numeric_sdet.rs b/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/combined_prefix_numeric_sdet.rs rename to crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/layer0_native_mmq_proof.rs b/crates/engine-qwen35-cuda/src/backend/layer0_native_mmq_proof.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/layer0_native_mmq_proof.rs rename to crates/engine-qwen35-cuda/src/backend/layer0_native_mmq_proof.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_candidate_only.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs similarity index 90% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_candidate_only.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs index 9e04ab32..68134a23 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_candidate_only.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs @@ -10,29 +10,22 @@ use std::{ panic::{AssertUnwindSafe, catch_unwind, resume_unwind}, }; // EXACT existing daemon pure renderer, Effort::None. No hand-built ChatML. -#[path = "../../../../crates/gateway-text/src/prompt.rs"] -#[allow(dead_code)] -mod public_renderer; +use leleka_gateway_text::prompt as public_renderer; // Files, request framing and counters shared with the one-load pair (native_down_public_pair.rs). #[path = "native_down_pair_io.rs"] mod pair_io; use pair_io::*; // The retained completed Native arm and the checks of the MTP window witnesses. -#[path = "native_down_pair_checks.rs"] mod pair_checks; use pair_checks::*; // One actual owner generation on a fresh target/draft state. -#[path = "native_down_pair_arm.rs"] mod pair_arm; use pair_arm::*; // The one loaded owner, its ordered teardown and the run of a proof on it. -#[path = "native_down_pair_owner.rs"] mod pair_owner; use pair_owner::*; -#[path = "native_down_pair_run.rs"] mod pair_run; use pair_run::*; -#[path = "native_down_pair_proofs.rs"] mod pair_proofs; use pair_proofs::*; #[test] @@ -90,7 +83,6 @@ fn pinned_five_public_cases_resident_owners() { } // Private framing only; Root owns the unchanged five-case consumer/caller. -#[path = "fivecase_frames.rs"] mod fivecase_frames; impl Inputs<'_, '_, '_> { fn prepare_five_public_frames(&self) -> (PathBuf, String) { @@ -99,7 +91,6 @@ impl Inputs<'_, '_, '_> { } // Private loaded-owner helper; Root supplies sealed genuine tokenizer frames. -#[path = "fivecase_runtime.rs"] mod fivecase_runtime; impl Inputs<'_, '_, '_> { fn arm_five_public_cases( @@ -111,5 +102,4 @@ impl Inputs<'_, '_, '_> { } } -#[path = "native_down_adaptive_candidate_only.rs"] mod adaptive_slots; diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs index f11117c5..2f954f2b 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs @@ -5,10 +5,8 @@ use super::*; use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport}; use std::path::Path; -#[path = "native_down_adaptive_candidate_only/observe.rs"] mod observe; use observe::*; -#[path = "native_down_adaptive_candidate_only/cleanup.rs"] mod cleanup; use cleanup::*; @@ -30,7 +28,7 @@ fn save_public_admission(root: &Path, baseline: &Baseline, tokenizer: &Tokenizer let (req, ids, canonical) = request(tokenizer); assert_eq!(ids, baseline.input_ids); assert_eq!(ids.len(), 202); - let renderer = sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs")); + let renderer = sha(include_bytes!("../../../../gateway-text/src/prompt.rs")); save( root, "BASELINE-ADMISSION.json", diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only/cleanup.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/cleanup.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only/cleanup.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/cleanup.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only/observe.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/observe.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_adaptive_candidate_only/observe.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/observe.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/fivecase_frames.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/gpu_proofs/fivecase_frames.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs index 1c44a9a4..3cb28b56 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/fivecase_frames.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs @@ -142,7 +142,7 @@ fn write_frame( pub(super) fn prepare(inputs: &Inputs<'_, '_, '_>) -> (PathBuf, String) { let (root, uid) = fresh_frames_root(); let requests = build_requests(inputs); - let renderer = sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs")); + let renderer = sha(include_bytes!("../../../../gateway-text/src/prompt.rs")); check_requests(&requests); let entries: Vec = requests .iter() diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/fivecase_runtime.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/gpu_proofs/fivecase_runtime.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs index 87464cf6..5211d602 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/fivecase_runtime.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs @@ -94,7 +94,7 @@ fn admit_manifest_header(manifest: &Value) -> String { assert_eq!(number(manifest, "case_count"), CASE_COUNT as u64); assert_eq!(text(manifest, "baseline_frame_sha256"), BASE_FRAME_SHA); assert_eq!(text(manifest, "model_digest"), MODEL_DIGEST); - let renderer = sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs")); + let renderer = sha(include_bytes!("../../../../gateway-text/src/prompt.rs")); assert_eq!(text(manifest, "renderer_source_sha256"), renderer); renderer } diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_arm.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_arm.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_arm.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_arm.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_checks.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_checks.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_checks.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_checks.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_owner.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_owner.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs index 7b4a072c..66a7dc9f 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_owner.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs @@ -105,7 +105,7 @@ fn pinned_tokenizer(artifact: &Qwen4ExpArtifact) -> (Tokenizer, u32) { (tokenizer, eos) } fn renderer_sha() -> String { - sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs")) + sha(include_bytes!("../../../../gateway-text/src/prompt.rs")) } fn baseline_admission_json() -> Value { json!({"baseline_sha256":BASELINE_SHA,"retained_run":"24993ad2-9c7c-4a90-bfac-3e6e0b5685c1", diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_proofs.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_proofs.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_proofs.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_proofs.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_run.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_run.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_run.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_run.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_io.rs b/crates/engine-qwen35-cuda/src/backend/native_down_pair_io.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_pair_io.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_pair_io.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs similarity index 78% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs index 6207a32d..fbe75e3e 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs @@ -9,20 +9,15 @@ use std::{ panic::{AssertUnwindSafe, catch_unwind, resume_unwind}, }; // EXACT existing daemon pure renderer, Effort::None. No hand-built ChatML. -#[path = "long_public_preflight/long_public_request.rs"] mod long_public_preflight; -#[path = "../../../../crates/gateway-text/src/prompt.rs"] -#[allow(dead_code)] -mod public_renderer; +use leleka_gateway_text::prompt as public_renderer; // Files, request framing and counters shared with the candidate-only proofs (native_down_candidate_only.rs). #[path = "native_down_pair_io.rs"] mod pair_io; use pair_io::*; // One actual owner generation, and the run of the pair on the one loaded owner. -#[path = "native_down_public_pair_arm.rs"] mod pair_arm; use pair_arm::*; -#[path = "native_down_public_pair_run.rs"] mod pair_run; #[test] diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/long_public_request.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/long_public_request.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs index 1943880d..eb3e3e64 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/long_public_request.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs @@ -9,9 +9,7 @@ use std::{ os::unix::fs::OpenOptionsExt, path::Path, }; -#[path = "../../../../../crates/gateway-text/src/prompt.rs"] -#[allow(dead_code)] -mod public_renderer; +use leleka_gateway_text::prompt as public_renderer; const BYTE_CAP: usize = 1024 * 1024; const ARTIFACT_CAP: usize = 16 * 1024 * 1024; const CONTEXT: usize = 262144; @@ -176,7 +174,7 @@ fn push_frame_summary( bound_model_digest: &str, artifacts: &mut Vec, ) -> io::Result { - let renderer = digest(include_bytes!("../../../../../crates/gateway-text/src/prompt.rs")); + let renderer = digest(include_bytes!("../../../../gateway-text/src/prompt.rs")); let frame = json!({ "schema":"public-long-preflight-v1","model_digest":bound_model_digest, "renderer_source_sha256":renderer, diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair_arm.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_arm.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair_arm.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_arm.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair_run.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs similarity index 99% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair_run.rs rename to crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs index 64239028..6100c2e5 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/native_down_public_pair_run.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs @@ -69,7 +69,7 @@ fn pinned_tokenizer(artifact: &Qwen4ExpArtifact) -> (Tokenizer, u32) { (tokenizer, eos) } fn frame_json(case: &Case) -> Value { - json!({"renderer_source_sha256":sha(include_bytes!("../../../../crates/gateway-text/src/prompt.rs")), + json!({"renderer_source_sha256":sha(include_bytes!("../../../../gateway-text/src/prompt.rs")), "framed_prompt":case.req.prompt,"framed_prompt_sha256":sha(case.req.prompt.as_bytes()), "input_token_ids":case.ids,"framed_count":case.ids.len(),"model_digest":MODEL_DIGEST, "max_output_tokens":CAP,"temperature_milli":0}) diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/native_resident_mmq_model_proof.rs b/crates/engine-qwen35-cuda/src/backend/native_resident_mmq_model_proof.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/native_resident_mmq_model_proof.rs rename to crates/engine-qwen35-cuda/src/backend/native_resident_mmq_model_proof.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/resident_mmq_model_proof.rs b/crates/engine-qwen35-cuda/src/backend/resident_mmq_model_proof.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/resident_mmq_model_proof.rs rename to crates/engine-qwen35-cuda/src/backend/resident_mmq_model_proof.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/singleload_proof.rs b/crates/engine-qwen35-cuda/src/backend/singleload_proof.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/gpu_proofs/singleload_proof.rs rename to crates/engine-qwen35-cuda/src/backend/singleload_proof.rs diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/public_renderer.rs b/crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/public_renderer.rs deleted file mode 100644 index 24b72b5a..00000000 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/long_public_preflight/public_renderer.rs +++ /dev/null @@ -1,355 +0,0 @@ -//! Supported text subset of the pinned Strata Qwen chat template. -//! The no-tool path and a representative tool continuation are byte-for-byte -//! checked against upstream golden cases. Tool definitions are adapted from -//! Responses function objects. -use serde_json::Value; - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum Role { - System, - Developer, - User, - Assistant, -} - -#[derive(Clone, Copy, Debug)] -pub struct Message<'a> { - pub role: Role, - pub content: &'a str, - pub reasoning: Option<&'a str>, -} - -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] -pub enum Effort { - None, - Low, - Medium, - High, - #[default] - XHigh, -} - -const XHIGH: &str = "Reasoning effort is set to xhigh. Please think carefully through the task, validate key \ - assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final \ - answer."; -const LOW: &str = "Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the \ - conclusion without unnecessary elaboration."; - -pub fn render(messages: &[Message<'_>], effort: Effort) -> Result { - render_with_tools(messages, effort, &[]) -} - -const TOOLS_FOOTER: &str = "\ -\n\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\ -\n\n\n\nvalue_1\n\ -\n\nThis is the value for the second parameter\nthat can \ -span\nmultiple lines\n\n\n\n\n\nReminder:\n- Function \ -calls MUST follow the specified format: an inner block must be nested \ -within XML tags\n- Required parameters MUST be specified\n- You may provide \ -optional reasoning for your function call in natural language BEFORE the function call, but NOT \ -after\n- If there is no function call available, answer the question like normal with your current \ -knowledge and do not tell the user about function calls\n"; - -/// The index of the first message that is not system or developer; those must all come first and a user message -/// must come last. -fn first_non_system(messages: &[Message<'_>]) -> Result { - if messages.is_empty() { - return Err("prompt needs a message"); - } - let first_non_system = messages - .iter() - .position(|message| !matches!(message.role, Role::System | Role::Developer)) - .unwrap_or(messages.len()); - if first_non_system == messages.len() - || messages[first_non_system..] - .iter() - .any(|message| matches!(message.role, Role::System | Role::Developer)) - { - return Err("system and developer messages must be at the beginning"); - } - if messages - .last() - .is_none_or(|message| message.role != Role::User) - { - return Err("generation needs a final user message"); - } - Ok(first_non_system) -} - -/// One tool definition as the template prints it. -fn push_tool(prompt: &mut String, tool: &Value) -> Result<(), &'static str> { - let name = tool - .get("name") - .and_then(Value::as_str) - .ok_or("tool needs a name")?; - prompt.push('\n'); - prompt.push_str("{\"type\": \"function\", \"function\": {\"name\": "); - prompt.push_str(&serde_json::to_string(name).expect("string JSON")); - if let Some(description) = tool.get("description").and_then(Value::as_str) { - prompt.push_str(", \"description\": "); - prompt.push_str(&serde_json::to_string(description).expect("string JSON")); - } - if let Some(parameters) = tool.get("parameters") { - prompt.push_str(", \"parameters\": "); - write_template_json(parameters, prompt); - } - if let Some(strict) = tool.get("strict") { - prompt.push_str(", \"strict\": "); - write_template_json(strict, prompt); - } - prompt.push_str("}}"); - Ok(()) -} - -/// The `# Tools` section of the system block. -fn push_tools(prompt: &mut String, instruction: &str, tools: &[Value]) -> Result<(), &'static str> { - if !instruction.is_empty() { - prompt.push_str("\n\n"); - } - prompt.push_str("# Tools\n\nYou have access to the following functions:\n\n"); - for tool in tools { - push_tool(prompt, tool)?; - } - prompt.push_str(TOOLS_FOOTER); - Ok(()) -} - -/// The system block: effort instruction, tool section and the joined system messages. -fn push_system_block( - prompt: &mut String, - instruction: &str, - system: &str, - tools: &[Value], -) -> Result<(), &'static str> { - if instruction.is_empty() && system.is_empty() && tools.is_empty() { - return Ok(()); - } - prompt.push_str("<|im_start|>system\n"); - prompt.push_str(instruction); - if !tools.is_empty() { - push_tools(prompt, instruction, tools)?; - } - if !system.is_empty() && (!instruction.is_empty() || !tools.is_empty()) { - prompt.push_str("\n\n"); - } - prompt.push_str(system); - prompt.push_str("<|im_end|>\n"); - Ok(()) -} - -/// The user and assistant turns after the system block. -fn push_turns(prompt: &mut String, turns: &[Message<'_>]) { - for message in turns { - match message.role { - Role::User => { - prompt.push_str("<|im_start|>user\n"); - prompt.push_str(message.content.trim()); - prompt.push_str("<|im_end|>\n"); - } - Role::Assistant => { - prompt.push_str("<|im_start|>assistant\n\n"); - prompt.push_str(message.reasoning.unwrap_or("").trim()); - prompt.push_str("\n\n\n"); - prompt.push_str(message.content.trim()); - prompt.push_str("<|im_end|>\n"); - } - Role::System | Role::Developer => unreachable!(), - } - } -} - -pub fn render_with_tools( - messages: &[Message<'_>], - effort: Effort, - tools: &[Value], -) -> Result { - let first_non_system = first_non_system(messages)?; - let system = messages[..first_non_system] - .iter() - .map(|message| message.content.trim()) - .filter(|content| !content.is_empty()) - .collect::>() - .join("\n"); - let instruction = match effort { - Effort::None | Effort::Medium => "", - Effort::Low => LOW, - Effort::High | Effort::XHigh => XHIGH, - }; - let mut prompt = String::new(); - push_system_block(&mut prompt, instruction, &system, tools)?; - push_turns(&mut prompt, &messages[first_non_system..]); - prompt.push_str("<|im_start|>assistant\n\n"); - if effort == Effort::None { - prompt.push_str("\n\n\n"); - } - Ok(prompt) -} - -/// The keys of a JSON-schema-like object in template order: `type` first when the object has one. -fn template_keys(fields: &serde_json::Map) -> Vec<&String> { - let mut keys = fields.keys().collect::>(); - if fields.contains_key("type") { - let priority = |key: &str| match key { - "type" => 0, - "properties" => 1, - "required" => 2, - "items" => 3, - "enum" => 4, - "description" => 5, - "additionalProperties" => 6, - _ => 7, - }; - keys.sort_by_key(|key| (priority(key), key.as_str())); - } - keys -} - -fn write_template_json(value: &Value, output: &mut String) { - match value { - Value::Object(fields) => { - output.push('{'); - for (index, key) in template_keys(fields).into_iter().enumerate() { - if index > 0 { - output.push_str(", "); - } - output.push_str(&serde_json::to_string(key).expect("object key JSON")); - output.push_str(": "); - write_template_json(&fields[key], output); - } - output.push('}'); - } - Value::Array(items) => { - output.push('['); - for (index, item) in items.iter().enumerate() { - if index > 0 { - output.push_str(", "); - } - write_template_json(item, output); - } - output.push(']'); - } - _ => output.push_str(&value.to_string()), - } -} - -#[cfg(test)] -mod tests { - use super::*; - use serde_json::{Value, json}; - - fn golden_cases() -> Vec { - serde_json::from_str(include_str!("../../../engine/strata/serve/chat_golden.json")).unwrap() - } - - fn golden_messages(case: &Value) -> Vec> { - case["messages"] - .as_array() - .unwrap() - .iter() - .map(|message| Message { - role: match message["role"].as_str().unwrap() { - "system" => Role::System, - "developer" => Role::Developer, - "user" => Role::User, - "assistant" => Role::Assistant, - role => panic!("unsupported role: {role}"), - }, - content: message["content"].as_str().unwrap(), - reasoning: message["reasoning_content"].as_str(), - }) - .collect::>() - } - - fn assert_text_case_matches(golden: &[Value], name: &str) { - let case = golden.iter().find(|case| case["name"] == name).unwrap(); - let messages = golden_messages(case); - let effort = if name == "thinking disabled" { - Effort::None - } else { - Effort::XHigh - }; - assert_eq!( - render(&messages, effort).unwrap(), - case["rendered"], - "{name}" - ); - } - - #[test] - fn text_prompt_matches_upstream_golden_bytes() { - let golden = golden_cases(); - for name in [ - "single user", - "system + user", - "multi-turn", - "assistant with thinking", - "unicode content", - "empty user", - "whitespace and newlines", - "thinking disabled", - ] { - assert_text_case_matches(&golden, name); - } - } - - fn weather_messages() -> [Message<'static>; 4] { - [ - Message { - role: Role::User, - content: "Weather in Oslo?", - reasoning: None, - }, - Message { - role: Role::Assistant, - content: "\n\n\nOslo\n\n\ - \n", - reasoning: None, - }, - Message { - role: Role::User, - content: "\n{\"temp\": 3}\n", - reasoning: None, - }, - Message { - role: Role::User, - content: "And in Bergen?", - reasoning: None, - }, - ] - } - - #[test] - fn representative_tool_prompt_matches_upstream_golden_bytes() { - let golden = golden_cases(); - let case = golden - .iter() - .find(|case| case["name"] == "tool call and response") - .unwrap(); - let function = &case["tools"][0]["function"]; - let tools = [json!({ - "type":"function", "name":function["name"], "description":function["description"], - "parameters":function["parameters"] - })]; - let messages = weather_messages(); - assert_eq!( - render_with_tools(&messages, Effort::XHigh, &tools).unwrap(), - case["rendered"] - ); - } - - #[test] - fn rejects_unrepresentable_message_order() { - let system = Message { - role: Role::System, - content: "rules", - reasoning: None, - }; - let user = Message { - role: Role::User, - content: "question", - reasoning: None, - }; - assert!(render(&[user, system], Effort::XHigh).is_err()); - assert!(render(&[system], Effort::XHigh).is_err()); - } -} diff --git a/scripts/dev/drop_allow_unused.py b/scripts/dev/drop_allow_unused.py new file mode 100644 index 00000000..a64d8417 --- /dev/null +++ b/scripts/dev/drop_allow_unused.py @@ -0,0 +1,150 @@ +"""Remove `#[allow(unused_imports)]` and what it hid (STRA-338 stage 10, ratchet `allow-unused-imports`). + +Usage: python scripts/dev/drop_allow_unused.py WORKTREE CRATE_DIR PACKAGE [--keep-test-only] + +The attribute sat on re-exports (`pub use child::name;`) that the splits kept so the old paths still resolve. Without it the compiler +says which of them nobody uses: + + * a name unused in the unit-test build is unused everywhere (that build compiles all code and the tests): it is deleted from its + `use` statement, the statement goes when nothing is left; + * a name used by the test build only is kept as `#[cfg(test)] use ..;` (the statement is split when it names others too). + +One round is `cargo check --lib --bins` and `--tests`; the loop repeats because deleting a re-export can make another one unused. +Offline refactoring aid, not part of the product. +""" +import collections +import json +import pathlib +import re +import sys + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) +import explicit_imports as ei # noqa: E402 +from unglob_by_errors import PLATFORM_FILES # noqa: E402 + +ALLOW = re.compile(r"^[ \t]*#\[allow\(unused_imports\)\][ \t]*\n", re.M) +USE_STATEMENT = re.compile(r"(?ms)^(?P(?:[ \t]*(?:#\[[^\n]*\]|///[^\n]*)\n)*)(?P[ \t]*(?:pub(?:\([^)]*\))?[ \t]+)?use[ \t]+)" + r"(?P[^;]*?);[ \t]*\n") +NL = chr(10) +NAME = re.compile(rf"(?:\bas\s+)?({ei.IDENT})\s*$") + + +def bound(item): + """The name an import item binds (`a::B` -> B, `a::b as c` -> c); None for globs and `as _`.""" + m = NAME.search(item) + return m.group(1) if m and not item.rstrip().endswith("as _") else None + + +def statement_names(body): + """[(name as it is bound, source text of the item)] of `a::b::{c, d as e}` or `a::b::c` (one level of braces).""" + body = body.strip() + brace = body.find("{") + if brace < 0: + return [(bound(body), body)], body, None + prefix, inner = body[:brace], body[brace + 1 : body.rindex("}")] + items = [i.strip() for i in inner.split(",") if i.strip()] + return [(bound(i), i) for i in items], prefix, items + + +def build(attrs, head, prefix, items): + """One `use` statement for `items` below `prefix`, wrapped at 120 columns like rustfmt does.""" + indent = head[: len(head) - len(head.lstrip())] + if len(items) == 1 and not items[0].startswith("self"): + return f"{attrs}{head}{prefix}{items[0]};{NL}" + one = f"{head}{prefix}{{{', '.join(items)}}};" + if len(one) <= 120: + return f"{attrs}{one}{NL}" + lines, cur = [], indent + " " + for item in items: + if len(cur) + len(item) + 1 > 120: + lines.append(cur.rstrip()) + cur = indent + " " + cur += item + ", " + lines.append(cur.rstrip()) + return f"{attrs}{head}{prefix}{{{NL}{NL.join(lines)}{NL}{indent}}};{NL}" + + +def rewrite(text, drop, test_only): + """The text with `drop` names deleted and `test_only` names moved under `#[cfg(test)]`.""" + def fix(m): + if "{" in m.group("body").split("{", 1)[-1]: # nested braces: left for a person + return m.group(0) + names, prefix, items = statement_names(m.group("body")) + gone = [i for n, i in names if n in drop] + moved = [i for n, i in names if n in test_only] + if not gone and not moved: + return m.group(0) + attrs, head = m.group("attrs"), m.group("head") + if items is None: # a single path + return f"{attrs}#[cfg(test)]{NL}{head}{m.group('body').strip()};{NL}" if moved else "" + left = [i for n, i in names if n not in drop and n not in test_only] + out = build(attrs, head, prefix, left) if left else "" + if moved: + out += build("" if left else attrs, head, prefix, moved).replace(head, "#[cfg(test)]" + NL + head, 1) + return out + + return USE_STATEMENT.sub(fix, text) + + +def write(path, text): + with open(path, "w", encoding="utf-8", newline=chr(10)) as handle: + handle.write(text) + + +def flagged_counts(msgs): + """Counter {(file, name): messages} of the unused-import warnings (a name flagged by two units counts twice).""" + counts = collections.Counter() + for m in msgs: + for r, names in ei.flagged([m], "unused").items(): + counts.update((r, n) for n in names) + return counts + + +def classify(counts_a, counts_b): + """({file: names unused everywhere}, {file: names used by the test build only}) from the two builds. + `--tests` builds the library once more as a dependency of the integration tests, so it repeats the first build's + warnings; what it says on top of that comes from the unit-test build.""" + drop, test_only = collections.defaultdict(set), collections.defaultdict(set) + for (r, name), n_a in counts_a.items(): + if counts_b.get((r, name), 0) > n_a: + drop[r].add(name) + else: + test_only[r].add(name) + for (r, name), n_b in counts_b.items(): + if (r, name) not in counts_a: # a file only the test build compiles + drop[r].add(name) + return drop, test_only + + +def main(): + wt, crate_dir, package = sys.argv[1:4] + wtp = pathlib.Path(wt).resolve() + rel = lambda f: f.resolve().relative_to(wtp).as_posix() # noqa: E731 + crate = pathlib.Path(crate_dir).resolve() + files = {f: f.read_text(encoding="utf-8") for f in (crate / "src").rglob("*.rs")} + for f, text in files.items(): + if ALLOW.search(text) and "--keep-allow" not in sys.argv: + files[f] = ALLOW.sub("", text) + write(f, files[f]) + for round_no in range(1, 8): + a = ei.run_cargo(wt, f"-p {package} --lib --bins", "da-a.json") + b = ei.run_cargo(wt, f"-p {package} --tests", "da-b.json") + drop_by_file, test_by_file = classify(flagged_counts(a), flagged_counts(b)) + touched = 0 + by_rel = {rel(f): f for f in files} + for r in set(drop_by_file) | set(test_by_file): + f = by_rel.get(r) + if f is None or r.split("/src/", 1)[-1] in PLATFORM_FILES: # their other-platform code is not built here + continue + new = rewrite(files[f], drop_by_file.get(r, set()), test_by_file.get(r, set())) + if new != files[f]: + files[f] = new + write(f, new) + touched += 1 + print(f"round {round_no}: {touched} files edited", flush=True) + if not touched: + break + + +if __name__ == "__main__": + main() diff --git a/scripts/dev/path_to_modules.py b/scripts/dev/path_to_modules.py index a7c92041..ff581275 100644 --- a/scripts/dev/path_to_modules.py +++ b/scripts/dev/path_to_modules.py @@ -9,6 +9,7 @@ a moved module are moved the same way (their `#[path]` or their place next to th paths of `include_str!`/`include_bytes!` in a moved file are rewritten. Without --apply the plan is printed. Offline refactoring aid, not part of the product. """ +import collections import os import pathlib import re @@ -33,6 +34,7 @@ def canonical_base(new_file, keeps_attr): def plan(crate, every): src = crate.root_dir.resolve() / "src" + declared_by = collections.Counter(child.file for mod in crate.by_file.values() for child in mod.children.values()) """(moves {old file: new file}, dropped [(parent file, module name)], problems [str]).""" moves, dropped, problems = {}, [], [] new_file = {crate.root.file: crate.root.file} @@ -51,7 +53,8 @@ def plan(crate, every): current = child.file is_modrs = current.name == "mod.rs" canonical = base / name / "mod.rs" if is_modrs else base / f"{name}.rs" - if not current.is_relative_to(src): # a file of the crate's `tests/` directory stays where it is + shared = declared_by[current] > 1 # a file two parents declare (each owns a copy of its state) cannot be moved + if shared or not current.is_relative_to(src): # a file of the crate's `tests/` directory stays where it is new_file[current], keeps[current], changed[current] = current, True, False queue.append(child) continue @@ -82,7 +85,7 @@ def rewrite_includes(text, old, new): """Fix the relative path of include_str!/include_bytes! in a file that moves from `old` to `new`.""" def fix(m): target = (old.parent / m.group(2)).resolve() - return f'{m.group(1)}"{pathlib.PurePosixPath(os.path.relpath(target, new.parent)).as_posix()}"' + return f'{m.group(1)}"{os.path.relpath(target, new.parent).replace(os.sep, "/")}"' return re.sub(r'(include_(?:str|bytes)!\()"([^"]+)"', fix, text) diff --git a/scripts/dev/rust_modtree.py b/scripts/dev/rust_modtree.py index f12e3acb..c69c20df 100644 --- a/scripts/dev/rust_modtree.py +++ b/scripts/dev/rust_modtree.py @@ -343,7 +343,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 new file mode 100644 index 00000000..14e694ae --- /dev/null +++ b/scripts/dev/unglob_by_errors.py @@ -0,0 +1,247 @@ +"""Replace `use super::*;` by explicit imports, guided by the compiler's errors (STRA-338 stage 10, `glob-super-import`). + +Usage: python scripts/dev/unglob_by_errors.py WORKTREE CRATE_DIR PACKAGE [--include-tests] [--max-rounds N] + +`explicit_imports.py` expands every glob file at once and gives a file back its glob when the build fails. This driver keeps +the expansion and repairs it from the compiler's messages instead, so the files that tool could not close (GPU proofs, test +modules, names behind an inner cfg) become explicit too: + + * a name the file uses but does not have (`cannot find type/value/function/trait/macro X`, an `enum Result takes 2 generic + arguments` from the prelude instead of the crate alias) is added as `use super::X;`; + * `unresolved import super::X` adds X to the parent's own imports when the parent is also expanded here; + * a trait whose methods are called but is not in scope is added with the path rustc suggests; + * a name that only the test build needs gets `#[cfg(test)]`; a name no build uses is removed. + +Each round is one `cargo check --lib --bins` and one `--tests` (through scripts/dev/wsl-cargo.sh on Windows). The Plan, the module +tree and the rendering are those of explicit_imports.py. Offline refactoring aid, not part of the product. +""" +import collections +import json +import pathlib +import posixpath +import re +import sys + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) +import explicit_imports as ei # noqa: E402 + +IDENT = ei.IDENT +MISSING = [ + re.compile(rf"cannot find (?:type|value|function|trait|macro|struct, variant or union type|tuple struct or tuple variant|" + rf"unit struct, unit variant or constant|derive macro|attribute macro|function, tuple struct or tuple variant|" + rf"value, found) `({IDENT})` in this scope"), + re.compile(rf"failed to resolve: use of undeclared (?:type|module|crate or module) `({IDENT})`"), + re.compile(rf"failed to resolve: use of unresolved module or unlinked crate `({IDENT})`"), + re.compile(rf"failed to resolve: use of undeclared type or module `({IDENT})`"), + re.compile(rf"(?:enum|struct|type alias|trait) `({IDENT})` takes \d+ generic argument"), + re.compile(rf"cannot find .*? `({IDENT})` in module"), +] +BAD_IMPORT = re.compile(r"unresolved imports? (.*)") +SUPER_NAME = re.compile(rf"`super::({IDENT})`") +TRAIT_HELP = re.compile(r"(?:trait|traits).*(?:not in scope|perhaps you want to import)") + + +def messages(wt, package, args, out_name): + """compiler-message dicts of `cargo check --message-format=json` over `args`.""" + return ei.run_cargo(wt, f"-p {package} {args}", out_name) + + +def span_file(message): + for span in message.get("spans", []): + if span.get("is_primary"): + return posixpath.normpath(span["file_name"]) + return None + + +def missing_names(message): + text = message["message"] + for rx in MISSING: + m = rx.search(text) + if m: + return [m.group(1)] + return [] + + +def trait_paths(message): + """`crate::a::Trait` paths rustc suggests importing for a method call (children of an E0599).""" + found = [] + for child in message.get("children", []): + if not TRAIT_HELP.search(child.get("message", "")): + continue + for span in child.get("spans", []): + replacement = span.get("suggested_replacement") or "" + for m in re.finditer(r"use ([\w:]+);", replacement): + found.append(m.group(1)) + return found + + +def collect(msgs): + """({file: {name}}, {file: {bad super name}}, {file: {trait path}}, {file: other error text}) of one build.""" + missing, bad, traits, other = (collections.defaultdict(set) for _ in range(4)) + for m in msgs: + if m["level"] != "error": + continue + f = span_file(m) + if f is None: + continue + names = missing_names(m) + paths = trait_paths(m) + bad_import = BAD_IMPORT.match(m["message"]) + if names: + missing[f].update(names) + elif bad_import: + bad[f].update(SUPER_NAME.findall(bad_import.group(1))) + elif paths: + traits[f].update(paths) + else: + other[f].add(m["message"][:100]) + return missing, bad, traits, other + + +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", +} + + +def prune_existing(plan, rel): + """Files that already carry explicit `use super::{..}` lists: their names become the seed of the prune.""" + plan.prune = True + todo = [] + for f, text in plan.texts.items(): + names = {} + for m in ei.USE_SUPER_RE.finditer(text): + block = m.group(0) + cfg_lines = [ln for ln in block.splitlines() if ln.startswith("#[cfg(")] + cfg = chr(10).join(cfg_lines) + kind = "test" if cfg == "#[cfg(test)]" else "normal" + if cfg == "#[cfg(test)]": + cfg = "" + for name in re.findall(IDENT, block.split("use super::", 1)[1]): + names[name] = kind + if cfg: + plan.cfgs.setdefault(f, {})[name] = cfg + if names: + plan.imports[f] = names + todo.append(f) + return todo + + +def select(plan, rel): + """(todo, skipped, keep_all) of the glob files, by the skip rules and the --include-tests/--platform/--opaque flags.""" + only = [a for a in sys.argv[4:] if not a.startswith("--") and not a.isdigit()] + todo, skipped, keep_all = [], {}, set() + for f in plan.candidates(): + reason = plan.skip_reason(f) + if reason == "test module" and "--include-tests" in sys.argv: + reason = None + if reason == "platform cfg" and "--platform" in sys.argv: + reason = None + keep_all.add(f) # the other platform's code is not compiled here: unused names are reported, not removed + if reason == "opaque glob in the parent chain" and "--opaque" in sys.argv: + reason = None + if only and not any(o in rel(f) for o in only): + continue + (skipped.__setitem__(f, reason) if reason else todo.append(f)) + return todo, skipped, keep_all + + +def main(): + wt, crate_dir, package = sys.argv[1:4] + max_rounds = int(sys.argv[sys.argv.index("--max-rounds") + 1]) if "--max-rounds" in sys.argv else 12 + plan = ei.Plan(wt, crate_dir) + wtp = pathlib.Path(wt).resolve() + rel = lambda f: f.resolve().relative_to(wtp).as_posix() # noqa: E731 + by_rel = {rel(f): f for f in plan.crate.by_file} + only = [a for a in sys.argv[4:] if not a.startswith("--") and not a.isdigit()] + todo, skipped, keep_all = [], {}, set() + if "--prune-existing" in sys.argv: + todo = prune_existing(plan, rel) + keep_all = {f for f in todo if rel(f).split("/src/", 1)[1] in PLATFORM_FILES} + todo = [f for f in todo if f not in keep_all] + for f in keep_all: + plan.imports.pop(f, None) + else: + todo, skipped, keep_all = select(plan, rel) + needs = plan.compute_needs(todo) + plan.blocked = {f for f in plan.blocked if f in todo} # a conditional name is repaired by the build below + plan.apply(todo, needs) + for f, conditional in plan.cfgs.items(): # a name declared twice under complementary platform cfgs is always there + for n in [n for n, c in conditional.items() if "not(true)" in c or c.strip() in ("", "true")]: + del conditional[n] + print(f"{package}: {len(todo)} files to expand, {len(skipped)} skipped", flush=True) + for reason, n in collections.Counter(skipped.values()).items(): + print(f" skipped {n}: {reason}", flush=True) + for round_no in range(1, max_rounds + 1): + plan.write() + a = messages(wt, package, "--lib --bins", "ug-a.json") + b = messages(wt, package, "--tests", "ug-b.json") + am, ab, at, ao = collect(a) + bm, bb, bt, bo = collect(b) + changed = 0 + for f in todo: + r, imp = rel(f), plan.imports.setdefault(f, {}) + wanted = (am[r], "normal"), (bm[r] - am[r], "test") + for names, kind in wanted: + for n in names: + if n not in imp: + imp[n] = kind + changed += 1 + elif plan.cfgs.get(f, {}).pop(n, None) is not None: # the name is there but its cfg hides it + changed += 1 + for path in at[r] | bt[r]: + key = "@anon:" + path + if key not in imp: + imp[key] = "normal" if path in at[r] else "test" + changed += 1 + for n in ab[r] | bb[r]: + parent = plan.crate.by_file[f].parent + if parent is not None and parent.file in todo: + kind = "normal" if n in ab[r] else "test" + if plan.imports.setdefault(parent.file, {}).get(n) != "normal": + plan.imports[parent.file][n] = kind + changed += 1 + elif n in imp: + del imp[n] # the name is not in the parent: another path is needed (listed below) + changed += 1 + other = {r: v for r, v in {**ao, **bo}.items() if r in {rel(f) for f in todo}} + print(f"round {round_no}: {changed} imports added, {sum(len(v) for v in other.values())} other errors in " + f"{len(other)} files", flush=True) + if changed: + continue + if other: + for r, v in sorted(other.items())[:20]: + print(" ", r, sorted(v)[:2]) + break + unused_a, unused_b = ei.flagged(a, "unused"), ei.flagged(b, "unused") + pruned = 0 + for f in todo: + r, imp = rel(f), plan.imports[f] + if f in keep_all: + print(" unused here, kept:", r, sorted(set(unused_a.get(r, ())) & set(unused_b.get(r, ()))), flush=True) + continue + for name in list(imp): + a_unused = name in unused_a.get(r, ()) + b_unused = name in unused_b.get(r, ()) + if b_unused: + del imp[name] + pruned += 1 + elif a_unused and imp[name] == "normal": + imp[name] = "test" + pruned += 1 + print(f" pruned or moved to cfg(test): {pruned}", flush=True) + if not pruned: + break + plan.write() + left = [rel(f) for f in plan.texts if ei.GLOB_RE.search(open(f, encoding="utf-8").read())] + print(f"{len(left)} files still carry the glob") + ei.WORK.mkdir(parents=True, exist_ok=True) + (ei.WORK / f"unglob_{package}.json").write_text(json.dumps(left, indent=0)) + + +if __name__ == "__main__": + main() From c0d34a6648fc6e8bdf535615a6e51837c5540aa4 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 20:35:20 +0100 Subject: [PATCH 2/7] engine-qwen35-cuda: explicit imports instead of use super::* in all 193 files (test modules, GPU proofs and platform-cfg files included) Co-Authored-By: Claude Sonnet 5.5 --- .../src/backend/clock_tests.rs | 6 ++++- .../combined_changed_boundary_proof.rs | 18 ++++++++++++++- .../combined_changed_boundary_proof/rig.rs | 6 ++++- .../src/backend/combined_prefix_numeric.rs | 10 ++++++++- .../backend/combined_prefix_numeric_sdet.rs | 4 +++- .../src/backend/generate.rs | 8 ++++++- .../src/backend/layer0_native_mmq_proof.rs | 4 +++- .../src/backend/lifecycle_tests.rs | 5 ++++- crates/engine-qwen35-cuda/src/backend/load.rs | 8 ++++++- .../src/backend/load_cuda.rs | 6 ++++- .../src/backend/load_tests.rs | 5 ++++- .../src/backend/load_weights.rs | 5 ++++- .../src/backend/native_down_candidate_only.rs | 17 +++++++++++++- .../adaptive_slots.rs | 21 +++++++++++++++++- .../adaptive_slots/cleanup.rs | 5 ++++- .../adaptive_slots/observe.rs | 4 +++- .../fivecase_frames.rs | 5 ++++- .../fivecase_runtime.rs | 5 ++++- .../native_down_candidate_only/pair_arm.rs | 9 +++++++- .../native_down_candidate_only/pair_checks.rs | 2 +- .../native_down_candidate_only/pair_owner.rs | 7 +++++- .../native_down_candidate_only/pair_proofs.rs | 6 ++++- .../native_down_candidate_only/pair_run.rs | 5 ++++- .../src/backend/native_down_pair_io.rs | 5 ++++- .../src/backend/native_down_public_pair.rs | 22 ++++++++++++++++++- .../native_down_public_pair/pair_arm.rs | 9 +++++++- .../native_down_public_pair/pair_run.rs | 10 ++++++++- .../native_resident_mmq_model_proof.rs | 4 +++- .../original_serve/runner/owner_run_steps.rs | 12 ++++++++-- .../src/backend/original_serve/tests.rs | 2 +- .../backend/original_serve_memory_smoke.rs | 18 ++++++++++++++- .../original_serve_memory_smoke/leak.rs | 2 +- .../original_serve_memory_smoke/load.rs | 6 ++++- .../original_serve_memory_smoke/probe.rs | 2 +- .../original_serve_memory_smoke/reader.rs | 2 +- .../original_serve_memory_smoke/shed.rs | 2 +- .../original_serve_memory_smoke/soak.rs | 2 +- .../original_serve_memory_smoke/traffic.rs | 2 +- .../backend/original_serve_prefix_smoke.rs | 18 ++++++++++++++- .../original_serve_prefix_smoke/extras.rs | 2 +- .../original_serve_prefix_smoke/run.rs | 6 ++++- .../src/backend/original_serve_smoke.rs | 20 ++++++++++++++++- .../original_serve_smoke/smoke_conv.rs | 5 ++++- .../original_serve_smoke/smoke_coverage.rs | 5 ++++- .../original_serve_smoke/smoke_long.rs | 7 +++++- .../original_serve_smoke/smoke_main.rs | 21 +++++++++++++++++- .../original_serve_smoke/smoke_main/corpus.rs | 4 +++- .../original_serve_smoke/smoke_stack.rs | 5 ++++- .../src/backend/profile_tests.rs | 5 ++++- .../src/backend/resident_mmq_model_proof.rs | 4 +++- .../src/backend/serve_run.rs | 6 ++++- .../src/backend/singleload_proof.rs | 4 +++- .../engine-qwen35-cuda/src/backend/tests.rs | 13 ++++++++++- .../src/conversation/resident/tests.rs | 2 +- .../src/experimental/tests.rs | 5 ++++- .../src/memory_governor/page_cache.rs | 5 ++++- .../model_binding/qwen4exp_input/gdn/tests.rs | 2 +- .../model_binding/qwen4exp_input/gr/tests.rs | 2 +- .../qwen4exp_input/mtp/backing.rs | 6 ++++- .../qwen4exp_input/mtp/mtp_weight_reads.rs | 8 +++++-- .../qwen4exp_input/mtp/read_expert_rows.rs | 7 ++++-- .../model_binding/qwen4exp_input/mtp/tests.rs | 5 ++++- .../qwen4exp_input/validate_ple_descriptor.rs | 8 +++++-- .../qwen4exp_kar_ple/inherited_kar_archive.rs | 7 ++++-- .../load_pinned_inherited_archive.rs | 8 +++++-- .../qwen4exp_kar_ple/pinned_profile.rs | 8 +++++-- .../qwen4exp_kar_ple/pinned_profile_tests.rs | 6 ++++- .../private_copy/checked_reader.rs | 6 +++-- .../qwen4exp_kar_ple/private_copy/inode.rs | 6 +++-- .../dense_weight_cache/workspaces.rs | 8 +++++-- .../qwen_forward/executor/prefill_chunk.rs | 9 +++++++- .../prefill_chunk/check_chunk_on_loaded.rs | 6 +++-- .../executor/prefill_chunk/mmq_evaluation.rs | 6 ++++- .../prefill_chunk/native_mmq_evaluation.rs | 2 +- .../executor/prefill_chunk/qwen_forward.rs | 13 +++++++++-- .../qwen_forward/prefill_chunk_planned.rs | 14 ++++++++++-- .../prefill_chunk_planned/chunk_layer.rs | 8 +++++-- .../prefill_chunk_planned/chunk_setup.rs | 9 ++++++-- .../prefill_chunk_planned/window_attention.rs | 10 +++++++-- .../prefill_chunk_planned/window_experts.rs | 6 +++-- .../prefill_chunk_planned/window_ffn.rs | 8 +++++-- .../prefill_chunk/read_chunk_attention_ffn.rs | 8 +++++-- .../executor/prefill_chunk/window_numeric.rs | 9 +++++++- .../prefill_chunk/window_numeric/proof.rs | 7 ++++-- .../executor/reset_replay_sdet.rs | 5 ++++- .../src/qwen_forward/executor/step_layers.rs | 8 +++++-- .../src/qwen_forward/executor/tests.rs | 5 ++++- .../src/qwen_forward/gdn/chain/gpu_tests.rs | 5 ++++- .../gdn/chain/row_queue_gpu_tests.rs | 6 ++++- .../src/qwen_forward/gdn/chunk_device.rs | 14 +++++++++++- .../chunk_device/gdn_chunk_device_methods.rs | 15 +++++++++++-- .../chunk_device_batch_compute.rs | 8 +++++-- .../gdn/chunk_device/numeric_gpu.rs | 13 ++++++++++- .../numeric_gpu/batch_adoption.rs | 6 +++-- .../gdn/chunk_device/numeric_gpu/exercise.rs | 8 +++++-- .../src/qwen_forward/gdn/driver_error.rs | 7 ++++-- .../src/qwen_forward/gdn/four_borrow_gpu.rs | 5 ++++- .../gdn/input_scratch_gpu_tests.rs | 5 ++++- .../src/qwen_forward/gdn/mirror/gpu_tests.rs | 2 +- .../src/qwen_forward/gdn/prefill_batch.rs | 6 ++++- .../src/qwen_forward/gdn/prefill_batch/gpu.rs | 2 +- .../src/qwen_forward/gdn/verification.rs | 7 +++++- .../gdn/verification/numeric_gpu.rs | 5 ++++- .../qwen_forward/gr/gr_residual_reuse_gpu.rs | 5 ++++- .../qwen_forward/gr/output_workspace_gpu.rs | 8 ++++++- .../output_workspace_proof_stages.rs | 6 ++++- .../src/qwen_forward/gr/retained_handoff.rs | 10 ++++++++- .../gr/retained_handoff/installed.rs | 5 ++++- .../src/qwen_forward/gr/tests.rs | 4 +++- .../src/qwen_forward/input/gather_rows.rs | 10 +++++++-- .../qwen_forward/kar_ple_cache/lru_tests.rs | 2 +- .../kar_ple_cache/row_parity_probe.rs | 2 +- .../qwen_forward/kar_ple_cache/slot_tests.rs | 2 +- .../moe_expert/expert_matrix_projection.rs | 12 ++++++++-- .../src/qwen_forward/moe_expert/grouped.rs | 15 ++++++++++++- .../moe_expert/grouped/direct_gpu.rs | 12 +++++++++- .../moe_expert/grouped/direct_gpu/arm.rs | 6 +++-- .../grouped/direct_gpu/loaded_arms.rs | 6 +++-- .../moe_expert/grouped/direct_gpu/policy.rs | 8 +++++-- .../moe_expert/grouped/direct_gpu/probe.rs | 6 +++-- .../moe_expert/grouped/layer0_pair.rs | 5 ++++- .../src/qwen_forward/moe_expert/tests.rs | 4 +++- .../qwen_forward/moe_prefill_batch/tests.rs | 5 ++++- .../src/qwen_forward/moe_route/tests.rs | 5 ++++- .../cache_lru_index/lru_index.rs | 6 +++-- .../moe_weight_cache/cache_profile_fill.rs | 13 ++++++++++- .../cache_profile_fill/moe_weight_cache.rs | 15 +++++++++++-- .../pinned_triplet_preload.rs | 10 +++++++-- .../cache_profile_fill/profile_build.rs | 7 ++++-- .../shared_quartet_preload.rs | 7 +++++- .../src/qwen_forward/mtp/kv_only.rs | 4 +++- .../mtp/state/chunk/mtp_session.rs | 6 +++-- .../mtp/state/prefix_draft_snapshot.rs | 7 ++++-- .../src/qwen_forward/mtp/state/tests.rs | 5 ++++- .../src/qwen_forward/mtp_attention/tests.rs | 2 +- .../src/qwen_forward/mtp_decode/batch_gpu.rs | 7 +++++- .../src/qwen_forward/mtp_decode/chunk.rs | 2 +- .../qwen_forward/mtp_decode/mtp_decoder.rs | 11 ++++++++-- .../mtp_decoder/draft_warm_and_window.rs | 7 ++++-- .../mtp_experts/fixed_workspace/role.rs | 8 +++++-- .../fixed_workspace/transport_drop.rs | 9 ++++++-- .../mtp_expert_transport/shared_project.rs | 12 ++++++++-- .../src/qwen_forward/mtp_experts/tests.rs | 2 +- .../original_serve_config/tests.rs | 8 ++++++- .../original_serve_engine/env_tests.rs | 2 +- .../original_serve_engine/tests.rs | 7 +++++- .../original_serve_host/ple_on_chain/tests.rs | 2 +- .../qwen_forward/original_serve_host/tests.rs | 2 +- .../qwen_forward/original_serve_pool/tests.rs | 4 +++- .../original_serve_request/tests.rs | 5 ++++- .../original_serve_residency/open_tier.rs | 10 +++++++-- .../original_serve_residency/tests.rs | 9 +++++--- .../tier_env_tests.rs | 2 +- .../conversation/tests.rs | 2 +- .../open_phase_steps.rs | 11 ++++++++-- .../prefix/clock_tests.rs | 2 +- .../original_serve_stack/prefix/tests.rs | 6 ++++- .../original_serve_stack/tests.rs | 5 ++++- .../original_serve_verifier/tests.rs | 4 +++- .../original_spec_controller/tests.rs | 6 ++++- .../output/output_stage_test_replay.rs | 9 ++++++-- .../src/qwen_forward/output/tests.rs | 5 ++++- .../qsa_attention/attention_scratch.rs | 8 ++++++- .../qsa_attention/attention_scratch/gpu.rs | 5 ++++- .../src/qwen_forward/qsa_index/context.rs | 10 +++++++-- .../qwen_forward/qsa_index/index_resident.rs | 13 ++++++++++- .../index_resident/synthetic_late_prior.rs | 4 ++-- .../qsa_index/input_reuse_gpu_tests.rs | 5 ++++- .../qwen_forward/qsa_index/prompt_device.rs | 10 ++++++++- .../prompt_device/resident_device.rs | 14 +++++++++++- .../prompt_device/resident_device/scalar.rs | 9 +++++++- .../resident_device/scalar/scalar_row_run.rs | 3 ++- .../qwen_forward/qsa_index/selected_cache.rs | 7 +++++- .../qsa_index/selected_cache/tests.rs | 5 ++++- .../src/qwen_forward/session/chunk.rs | 7 +++++- .../session/chunk/qwen_chunk_txn.rs | 12 ++++++++-- .../qwen_chunk_txn_micro_window.rs | 8 +++++-- .../session/chunk/test_gdn_component_rows.rs | 9 ++++++-- .../src/qwen_forward/session/chunk/verify.rs | 8 ++++++- .../session/chunk/verify/tests.rs | 6 ++++- .../qwen_forward/session/original_prompt.rs | 7 +++++- .../session/original_prompt/draft.rs | 5 ++++- .../qwen_forward/session/original_verified.rs | 4 +++- .../session/original_verified/tests.rs | 2 +- .../session/reset_replay_snapshot.rs | 6 +++-- .../src/qwen_forward/session/tests.rs | 6 ++++- .../src/serve_meta/tests.rs | 5 ++++- .../src/serve_tuning/tests.rs | 2 +- .../src/settings/capture_tests.rs | 2 +- .../src/settings/decode_tests.rs | 2 +- .../src/settings/diagnostics_tests.rs | 2 +- .../src/settings/kv_tests.rs | 2 +- .../src/settings/memory_tests.rs | 2 +- .../src/settings/serve_tests.rs | 2 +- 194 files changed, 1065 insertions(+), 248 deletions(-) diff --git a/crates/engine-qwen35-cuda/src/backend/clock_tests.rs b/crates/engine-qwen35-cuda/src/backend/clock_tests.rs index ebdce422..4b520367 100644 --- a/crates/engine-qwen35-cuda/src/backend/clock_tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/clock_tests.rs @@ -1,7 +1,11 @@ //! The request clocks of the backend on a manual clock (STRA-338 S14): the terminal publication deadline, the //! prefill/decode accounting of the measurement recorder and the clock reads of the source verification. -use super::*; +use super::{ + BACKPRESSURE_TIMEOUT, Clock, ContractError, Duration, EvaluationMeasurement, FinishReason, GenerationEvent, + GenerationFailure, GenerationSink, GenerationTerminal, NativeBackendConfig, Usage, emit_event, emit_terminal, + measurement, verify_sources_parallel, +}; use leleka_obs::time::ManualClock; fn completed() -> GenerationTerminal { diff --git a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs index 7a40b905..b51e95ba 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs @@ -1,5 +1,21 @@ //! Private sole new changed-path model gate; actual source identity/load preserved. -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationExecution, + EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, + GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, + InputBindingError, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, + LoadedModel, MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, + OriginalServeMode, OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, + Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, + SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, close_context, load, thread, +}; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, +}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners as LoadedTarget; use std::env; pub(super) mod rig; diff --git a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs index fe7ab3b1..e09f59d2 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs @@ -1,7 +1,11 @@ //! The loaded real owners the single-load GPU proofs share: the pinned binding over the inherited sealed archive, //! the device owners built on one bounded Context, a phase run on a fresh target owner, and the teardown whose //! results are asserted only after every attempt was made. Opening and scheduling stay with each proof. -use super::*; +use super::{ + InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile, +}; +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; use std::{ env, panic::{AssertUnwindSafe, catch_unwind}, diff --git a/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric.rs b/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric.rs index 6d44f03f..b0325b46 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric.rs @@ -1,7 +1,15 @@ //! Disposable, real-owner numerical observation. Never an actor publication gate. //! Forced inputs are public IDs; no expected model tensors or invented state. use super::combined_changed_boundary_proof::rig::Owners; -use super::*; +use super::{ + AtomicBool, EvaluationExecution, FinishReason, Generation, GenerationSink, ModelBinding, MtpContinuation, Mutex, + Shared, SystemClock, Tokenizer, generate_mtp_resume, +}; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, KarPleCache, MoeWeightCache, MtpDecoder, OutputStage, QwenSession, TargetStepProduct, + TokenId, +}; use crate::qwen_forward::mtp::KnownNext; use crate::qwen_forward::mtp_decode::DraftHeadOwners; use crate::qwen_forward::{mtp::PrefixDraftSnapshot, session::ResetReplaySnapshot}; diff --git a/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs b/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs index eb30f0cf..64727086 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_prefix_numeric_sdet.rs @@ -3,7 +3,9 @@ use super::combined_changed_boundary_proof::rig::{ DEVICE_BUDGET, MOE_REFUSAL, Owners, PinnedTokenizer, bind_pinned_with_tokenizer, require_opt_in, }; -use super::*; +use super::{Driver, ModelBinding, PathBuf, Rc, Tokenizer}; +#[cfg(feature = "preview-path")] +use super::{MoeWeightCache, QwenSession}; use std::{ env, panic::{AssertUnwindSafe, catch_unwind, resume_unwind}, diff --git a/crates/engine-qwen35-cuda/src/backend/generate.rs b/crates/engine-qwen35-cuda/src/backend/generate.rs index e9d6a2da..523b2ba7 100644 --- a/crates/engine-qwen35-cuda/src/backend/generate.rs +++ b/crates/engine-qwen35-cuda/src/backend/generate.rs @@ -1,5 +1,11 @@ //! The single-token generation step loop. -use super::*; +use super::{ + AtomicBool, BackendError, Clock, DenseWeightCache, Dimension, ErrorCode, EvaluationExecution, FinishReason, + GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationSink, Instant, KarPleCache, ModelBinding, + MoeWeightCache, MtpDecoder, Ordering, OutputStage, Position, QwenForward, QwenSession, Shared, SystemClock, + TargetStepProduct, TokenId, Tokenizer, Usage, Utf8Pending, emit_event, error, exhausted, generate_mtp, invalid, + measurement, native_position, unavailable, unsupported, +}; use crate::qwen_forward::executor::{PrefillChunkInputs, StepCaches, StepRequest}; pub(super) struct Generation<'a, 'context, 'driver, C: Clock = SystemClock> { diff --git a/crates/engine-qwen35-cuda/src/backend/layer0_native_mmq_proof.rs b/crates/engine-qwen35-cuda/src/backend/layer0_native_mmq_proof.rs index aa664e39..7f19143b 100644 --- a/crates/engine-qwen35-cuda/src/backend/layer0_native_mmq_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/layer0_native_mmq_proof.rs @@ -1,6 +1,8 @@ //! Private sole new changed-path model gate; actual source identity/load preserved. use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in}; -use super::*; +use super::{Driver, EvaluationExecution, ModelBinding, PathBuf, Rc}; +#[cfg(feature = "preview-path")] +use super::{MoeWeightCache, QwenForward}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use std::{env, panic::resume_unwind}; diff --git a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs index 35ef7acd..c500e7b0 100644 --- a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests.rs @@ -5,7 +5,10 @@ //! `FakeDevice` (no GPU). Time is a `ManualClock` that the device moves by the scripted cost of a chunk or a round, so //! the deadline and the prefill/decode accounting are exact. Normal completion, stop, length, acceptance and timing //! are here; `ends` holds the cancel, deadline and error exits, `prefix` the cross-session cache. -use super::*; +use super::{ + Arc, AtomicBool, ErrorCode, FinishReason, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, + GenerationStream, GenerationTerminal, Mutex, Ordering, Shared, Tokenizer, Usage, original_serve, +}; use crate::qwen_forward::original_serve_engine::{ServeOutcome, ServeStop}; use crate::qwen_forward::original_serve_request::{ServeDevice, ServeError, ServeRequest}; use crate::qwen_forward::original_serve_stack::lifecycle_fake::{FakeDevice, FakeStack, Script, greedy_continuation}; diff --git a/crates/engine-qwen35-cuda/src/backend/load.rs b/crates/engine-qwen35-cuda/src/backend/load.rs index 07e9c6d9..79637a8a 100644 --- a/crates/engine-qwen35-cuda/src/backend/load.rs +++ b/crates/engine-qwen35-cuda/src/backend/load.rs @@ -1,6 +1,12 @@ //! The owner-side Load: bind the sources, open CUDA, build the caches, then serve generations until Unload. //! The phases live in `load_*.rs`; this file fixes the order they run in. -use super::*; +use super::{ + Announcement, BackendError, Bound, Closed, Command, EvaluationExecution, EvaluationObserver, Identity, LoadedModel, + ModelDescriptor, NativeBackendConfig, OptimizedBackendConfig, Ordering, QwenSession, Rc, Receiver, Reply, + RuntimeConfig, Serving, Shared, SystemClock, admit_load, bind_model, build_loaded, check_not_cancelled, + close_context, close_weights, experimental_modes, launch_original, load_weights, new_conversations, + open_checked_context, open_driver, original_serve, probe_experimental_plan, serve_commands, start_governor, +}; use leleka_cuda_driver::Context; /// Everything one Load needs from its owner thread. diff --git a/crates/engine-qwen35-cuda/src/backend/load_cuda.rs b/crates/engine-qwen35-cuda/src/backend/load_cuda.rs index 73eee9e1..2ae66141 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_cuda.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_cuda.rs @@ -1,5 +1,9 @@ //! The CUDA half of a Load: driver, device context, load-time probes and the hand-over to the Original serve stack. -use super::*; +use super::{ + Announcement, BackendError, Bound, Driver, Governed, LoadEnv, LoadPhase, ModelBinding, NativeBackendConfig, Rc, + build_loaded, exhausted, experimental_modes, load_failure, original_serve, probe_experimental, + probe_kar_level_decode, unavailable, +}; use leleka_cuda_driver::Context; pub(super) fn open_driver() -> Result { diff --git a/crates/engine-qwen35-cuda/src/backend/load_tests.rs b/crates/engine-qwen35-cuda/src/backend/load_tests.rs index 54a084cc..abcf50c8 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_tests.rs @@ -1,6 +1,9 @@ //! What the phase functions of the Load (STRA-338 S5b) must keep from the code they replaced: the policy flags, the //! execution gates and the weight-cache log line, each compared with the expressions of the former `serve_load`. -use super::*; +use super::{ + Counters, EvaluationExecution, OptimizedBackendConfig, OptimizedOwnerPolicy, PolicyFlags, execution_gate_message, + generation_cache_line, +}; #[cfg(feature = "preview-path")] use crate::qwen_forward::dense_weight_cache::DenseCacheCounters; #[cfg(feature = "preview-path")] diff --git a/crates/engine-qwen35-cuda/src/backend/load_weights.rs b/crates/engine-qwen35-cuda/src/backend/load_weights.rs index f097cc36..092a73bf 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_weights.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_weights.rs @@ -1,5 +1,8 @@ //! The weight caches a native Load builds on the CUDA context: output head, KAR PLE cache, dense and MoE weights. -use super::*; +use super::{ + BackendError, Bound, DenseWeightCache, KarPleCache, LoadEnv, LoadPhase, ModelBinding, MoeWeightCache, OutputStage, + PolicyFlags, exhausted, invalid, load_failure, load_forward_failure, load_moe, +}; use leleka_cuda_driver::Context; type ForwardResult = Result; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs index 68134a23..cb8f8217 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs @@ -1,6 +1,21 @@ //! Candidate-only PUBLIC quality proof against one retained actual Native arm. //! Historical wall time is never used as an A/B measurement. -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, DenseWeightCache, Digest, Dimension, Driver, Duration, ErrorCode, + EvaluationExecution, EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FRAME_LIMIT, + FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, + GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, InputConstants, Instant, + KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, KarPleCache, + LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, ModelBinding, ModelDescriptor, MoeWeightCache, + MtpContinuation, MtpDecoder, MtpWindowError, MtpWindowSpec, Mutex, Ordering, OriginalServeChoice, + OriginalServeMode, OriginalServeOptions, OutputStage, PathBuf, Position, PrefixCacheOptions, PrefixTail, QUEUE, + Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, QwenForward, QwenSession, Rc, Receiver, RecentIds, + ResidentConversations, ResidentPolicy, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, SupportedModelTuple, + SyncSender, SystemClock, TargetStepProduct, TokenId, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, + combined_changed_boundary_proof, emit_terminal, error, generate, generate_mtp_resume, load, measurement, owner, + prepare_prompt, request, session, spawn, thread, +}; use serde_json::{Value, json}; use std::{ env, diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs index 2f954f2b..97fa3cfb 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs @@ -1,7 +1,26 @@ //! Configured five PUBLIC cases on one actual Strata adaptive cache owner. //! No Native inference replay; original paired quality/timing remains separately required. use super::super::combined_changed_boundary_proof::rig::close_context_flags; -use super::*; +use super::{ + Arc, AssertUnwindSafe, AtomicBool, AtomicU64, BACKEND_API_VERSION, BASELINE_SHA, Backend, BackendCapabilities, + BackendError, BackendIdentity, Baseline, CAP, CacheCounts, Clock, ContractError, DEVICE_BUDGET, DeferredTail, + Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, + FinishReason, GenerationEvent, GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, + InferenceMode, InheritedKarArchive, InputBindingError, Inputs, KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, + KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, + ModelBinding, ModelDescriptor, Mutex, OpenOptions, OpenOptionsExt, Ordering, OriginalServeChoice, + OriginalServeMode, OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Proof, Qwen4ExpArtifact, + Qwen35Cuda, Qwen35CudaStart, Rc, Read, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, + SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, Value, VerifiedGgufFile, WindowWitness, Write, + baseline, catch_unwind, env, error, fivecase_runtime, json, metadata, path, request, resume_unwind, save, sha, + thread, token_ids, +}; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, +}; use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport}; use std::path::Path; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/cleanup.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/cleanup.rs index 35ccf97f..6f50c2e7 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/cleanup.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/cleanup.rs @@ -1,5 +1,8 @@ //! The cleanup documents of the adaptive proof and the assertions made once every teardown attempt was done. -use super::*; +use super::{ + AdaptiveClosed, AssertUnwindSafe, Baseline, InheritedKarArchive, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, Path, + Value, bank_copies_json, catch_unwind, fivecase_runtime, json, resume_unwind, save, token_ids, +}; /// The owner wall profile as the artifacts record it. pub(super) struct OwnerWall { diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/observe.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/observe.rs index 50f938fa..4558ed4c 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/observe.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots/observe.rs @@ -1,5 +1,7 @@ //! What the adaptive owners reported before and during their ordered teardown. -use super::*; +use super::{AdaptiveOwners, ModelBinding, Value, bank_report_json, json}; +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, MoeWeightCache}; /// A completion counter as the artifacts record it, and whether it is positive. pub(super) struct Count { diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs index 3cb28b56..714d4d46 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_frames.rs @@ -1,6 +1,9 @@ //! Private CPU-only framing on the caller's already admitted tokenizer. //! No model load, generation, expected outputs or state/capability publication. -use super::*; +use super::{ + CAP, GenerationRequest, Inputs, MODEL_DIGEST, OpenOptions, OpenOptionsExt, PathBuf, Read, Tokenizer, Value, env, + json, path, prepare_prompt, public_renderer, request, save, sha, +}; use std::os::unix::fs::{MetadataExt, PermissionsExt}; const BASE_FRAME_SHA: &str = "9512d4883fca31282206c3a03c8d4d3f3085b5c1dfedd998c8957061e01514e4"; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs index 5211d602..a9326ff1 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/fivecase_runtime.rs @@ -1,6 +1,9 @@ //! Private five fresh public requests on the caller's one admitted model owner. //! This helper neither loads weights nor supplies an output oracle. -use super::*; +use super::{ + Arm, CAP, EvaluationExecution, FinishReason, GenerationRequest, Inputs, KAR_MTP_PROFILE, MODEL_DIGEST, OpenOptions, + OpenOptionsExt, Read, Tokenizer, Value, candidate_windows, env, json, path, prepare_prompt, save, sha, token_ids, +}; use std::os::unix::fs::MetadataExt; const CASE_COUNT: usize = 5; const BASE_FRAME_SHA: &str = "9512d4883fca31282206c3a03c8d4d3f3085b5c1dfedd998c8957061e01514e4"; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_arm.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_arm.rs index 6e45880b..2eae83bb 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_arm.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_arm.rs @@ -1,6 +1,13 @@ //! One actual owner generation on a fresh target/draft state: bounded stream consumer, failure artifact and the //! measurement record of a completed arm. -use super::*; +use super::{ + AtomicBool, CacheCounts, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason, + Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, + GenerationTerminal, ModelBinding, MtpContinuation, Ordering, QUEUE, Rc, Shared, SystemClock, Tokenizer, Usage, + Value, WindowWitness, cache, cache_json, emit_terminal, generate_mtp_resume, json, measurement, path, save, thread, +}; +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, Instant, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; const WALL_BOUNDARY: &str = "immediately before generate_mtp_resume through terminal, actual channel EOF and \ consumer join; excludes session teardown and helpers"; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_checks.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_checks.rs index e5544a4a..cd3840f7 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_checks.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_checks.rs @@ -1,5 +1,5 @@ //! The retained completed Native arm and the checks of the MTP window witnesses of a candidate arm. -use super::*; +use super::{Arm, FRAME_LIMIT, Value, WindowWitness, json, sealed_bytes, sha}; pub(super) const BASELINE_SHA: &str = "4d61ee949d37a738500c889f23f07310b6d75c7c8dfe5f50173eceafe1882fbe"; pub(super) struct Baseline { diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs index 66a7dc9f..401ea479 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_owner.rs @@ -1,6 +1,11 @@ //! The one loaded owner of the PUBLIC candidate proofs: admission of the sealed inputs, the load, the ordered //! teardown and the artifacts of it. The proofs differ only in the `Proof` hooks (`native_down_pair_proofs.rs`). -use super::*; +use super::{ + AtomicBool, BASELINE_SHA, Baseline, CAP, DenseWeightCache, GenerationRequest, InheritedKarArchive, Inputs, Instant, + KAR_MTP_PROFILE, KarPleCache, MODEL_DIGEST, ModelBinding, MoeWeightCache, Mutex, OpenOptions, OpenOptionsExt, + OutputStage, PathBuf, Qwen4ExpArtifact, Rc, Read, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile, + baseline, env, json, metadata, path, request, save, sha, +}; use crate::qwen_forward::owner_wall_profile::{self, Sample}; use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport}; use std::os::unix::fs::PermissionsExt; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_proofs.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_proofs.rs index f7306d30..fb7337b8 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_proofs.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_proofs.rs @@ -1,6 +1,10 @@ //! The four PUBLIC candidate proofs: they differ in the caches they load, in what they generate and in what //! they conclude; the owner, the teardown and the artifacts are shared (`native_down_pair_run.rs`). -use super::*; +use super::{ + Arm, BASELINE_SHA, Baseline, CAP, Check, DenseWeightCache, EvaluationExecution, Finish, FinishReason, + KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, MoeFacts, MoeWeightCache, Owner, Proof, QwenForward, QwenSession, Rc, + RunCtx, Value, cache_json, candidate_windows, fivecase_runtime, json, merged, save, token_ids, with_counters, +}; use crate::qwen_forward::moe_expert::LoadedArms; use crate::qwen_forward::moe_weight_cache::LearnedMainWitness; use fivecase_runtime::FiveCaseReport; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_run.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_run.rs index be19b50e..59481686 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_run.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/pair_run.rs @@ -1,6 +1,9 @@ //! Runs a `Proof` on the one loaded owner: generation, ordered teardown, the cleanup artifacts that survive a //! failed generation, and the assertions that follow every attempted teardown. -use super::*; +use super::{ + AssertUnwindSafe, DEVICE_BUDGET, Driver, Finish, Host, InheritedKarArchive, ModelBinding, Owner, OwnerCounters, + Proof, Rc, RunCtx, Teardown, Value, Witnessed, bank_json, catch_unwind, json, merged, resume_unwind, save, +}; use crate::qwen_forward::owner_wall_profile::{self, Sample}; const SCOPE: &str = diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_pair_io.rs b/crates/engine-qwen35-cuda/src/backend/native_down_pair_io.rs index 519f7159..d2cee6ef 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_pair_io.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_pair_io.rs @@ -1,6 +1,9 @@ //! Files, environment, request framing and counters shared by the PUBLIC pair proofs. //! Included by `native_down_candidate_only.rs` and `native_down_public_pair.rs` (each owns its copy of the state). -use super::*; +use super::{ + CacheCounts, Digest, GenerationRequest, OpenOptions, OpenOptionsExt, Ordering, PathBuf, Read, Sha256, Tokenizer, + Value, Write, env, json, prepare_prompt, public_renderer, +}; pub(super) const ARTIFACT_CAP: usize = 16 * 1024 * 1024; pub(super) static ARTIFACT_BYTES: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs index fbe75e3e..7bb955cc 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs @@ -1,5 +1,25 @@ //! One-load private PUBLIC generation pair; actual owner timings, never HTTP timings. -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationExecution, + EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FRAME_LIMIT, FinishReason, Generation, + GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, + InferenceMode, InheritedKarArchive, InputBindingError, KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, + KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, + ModelBinding, ModelDescriptor, MtpContinuation, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, + OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, QUEUE, Qwen4ExpArtifact, Qwen35Cuda, + Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, SupportedModelTuple, + SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, emit_terminal, error, + generate_mtp_resume, load, measurement, owner, request, spawn, thread, +}; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, session, +}; +#[cfg(test)] +use super::prepare_prompt; use serde_json::{Value, json}; use std::{ env, diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_arm.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_arm.rs index 7f8bd020..adfd81fd 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_arm.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_arm.rs @@ -1,6 +1,13 @@ //! One actual owner generation of the one-load PUBLIC pair on a fresh target/draft state: bounded stream //! consumer, failure artifact and the measurement record of a completed arm. -use super::*; +use super::{ + AtomicBool, CacheCounts, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason, + Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, + GenerationTerminal, ModelBinding, MtpContinuation, QUEUE, Rc, Shared, SystemClock, Tokenizer, Usage, Value, + WindowWitness, cache, cache_json, emit_terminal, generate_mtp_resume, json, measurement, path, save, thread, +}; +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; pub(super) struct Arm { pub(super) measurement: EvaluationMeasurement, diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs index 6100c2e5..f11c8353 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/pair_run.rs @@ -1,5 +1,13 @@ //! The one-load PUBLIC pair: sealed inputs, one owner load, four arms (two warm, two measured) and the artifacts. -use super::*; +use super::{ + ARTIFACT_BYTES, ARTIFACT_CAP, Arm, AssertUnwindSafe, AtomicBool, CAP, DEVICE_BUDGET, Driver, Duration, + EvaluationExecution, GenerationRequest, InheritedKarArchive, Inputs, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, + Mutex, Ordering, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile, + catch_unwind, env, json, long_public_preflight, merged, metadata, ns, path, request, reserve_artifacts, + resume_unwind, save, sha, +}; +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage}; use std::os::unix::fs::PermissionsExt; const NATIVE_POLICY: &str = "native64-same-dual-cache-retained-mtp-kv"; diff --git a/crates/engine-qwen35-cuda/src/backend/native_resident_mmq_model_proof.rs b/crates/engine-qwen35-cuda/src/backend/native_resident_mmq_model_proof.rs index d407e2ea..a58466d1 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_resident_mmq_model_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_resident_mmq_model_proof.rs @@ -1,6 +1,8 @@ //! Private sole new changed-path model gate; actual source identity/load preserved. use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in}; -use super::*; +use super::{Driver, EvaluationExecution, ModelBinding, PathBuf, Rc}; +#[cfg(feature = "preview-path")] +use super::{MoeWeightCache, QwenForward}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use std::{env, panic::resume_unwind}; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs index 6312395b..1bb36299 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs @@ -1,8 +1,16 @@ //! The steps of the Original owner loop `run`: open and report the stack, admit and serve a generate command, //! sweep idle sessions and close everything; early exits stay in `run`. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveGuard, Admission, AtomicBool, BackendError, CapturedIds, ClientLink, Clock, Command, DeferredTail, Duration, + ErrorCode, FinishReason, ForwardError, GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationRequest, + GenerationSink, GenerationTerminal, IdleSweep, Live, LoadPhase, LoadedModel, LoopCtx, ModelBinding, Ordering, + OriginalServeOptions, OriginalServeStack, PREFIX_SUMMARY, PathBuf, PhaseDurations, PrefixTail, QUEUE, Rc, Receiver, + ReopenEnv, Reply, RequestToServe, ServeDevice, ServeError, ServeFailure, ServeRequest, ServeStop, Shared, + StackConfig, SystemClock, TokenVocabulary, Tokenizer, Usage, Utf8Pending, context_fits, emit_terminal, exhausted, + generate, invalid, load_failure, meta_facts, open_error, prepare_prompt, publish_prefix_summary, stack_config, + unavailable, +}; use leleka_backend_api::GenerationStream; use leleka_cuda_driver::Context; use std::sync::Arc; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs index b54f0e21..7fa58caa 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of `original_serve`. -use super::*; +use super::{ConfigFacts, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, PathBuf, choose, context_fits}; fn facts() -> ConfigFacts { ConfigFacts { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs index e3e93465..6c37b5c1 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs @@ -23,7 +23,23 @@ //! //! Output lines: `MEM-REPORT ` (the governor's full report), `MEM-CENSUS `, `MEM-SOAK ...`, `MEM-SHED //! ...`, `MEM-RESULT`. -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, + EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, + GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, + KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, + MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, + OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, + Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, + Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, probes, spawn, thread, +}; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, session, +}; use crate::qwen_forward::original_serve_stack::dbg_el; use crate::qwen_forward::{ original_serve_request::{ServeError, ServeRequest}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/leak.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/leak.rs index 5c6904fc..f7b0b69c 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/leak.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/leak.rs @@ -3,7 +3,7 @@ //! prefix store and the glibc heap, then fits the slope of each series against the request count after the //! warm-up and prints it with its confidence interval. use super::traffic::{Tally, TrafficRequest}; -use super::*; +use super::{Census, Mem, PathBuf, env, list, number, print_report}; const TSV_HEADER: &str = "t_s\treq\trss\trss_anon\trss_file\trss_shmem\tswap\tavail\tcached\tshmem_sys\t\ active_file\tinactive_file\tvram_used\tvram_acct\tprefix_store\tmalloc_arena\tmalloc_in_use\tmalloc_free\t\ diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/load.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/load.rs index 559e3017..cac55044 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/load.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/load.rs @@ -1,6 +1,10 @@ //! Loads the pinned model under the memory governor, opens the serve stack as production starts it and runs the //! scenario of `LELEKA_MEM_SCENARIO` on it. -use super::*; +use super::{ + CancelAt, Census, Driver, Governor, InheritedKarArchive, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget, + PrefixConfig, Qwen4ExpArtifact, Rc, Rng, SHARD0, SHARD1, ServeError, StackConfig, Tokenizer, VerifiedGgufFile, + census, dbg_el, env, filler, guard, number, print_report, required_path, serve_one, text, +}; /// What the operator asked for. struct Plan { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/probe.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/probe.rs index 7af75310..927c0a5f 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/probe.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/probe.rs @@ -1,5 +1,5 @@ //! Model-free probe of the sealed KAR memfd under the governor's residency guard. -use super::*; +use super::{Governor, InheritedKarArchive, env, guard, number, required_path}; /// One second of the probe: the memfd's swapped bytes, the cost of looking, and the swap counters since the last. fn probe_second(governor: &Governor, t: u64, last_in: &mut Option<(u64, u64)>) { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/reader.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/reader.rs index 3a439ca3..4eee1020 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/reader.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/reader.rs @@ -1,7 +1,7 @@ //! The reader scenario: decode speed and the memfd's residency while a competing reader streams a big file //! through the page cache (what the Original did when it read the KAR file next to the memfd): phase A without the //! reader, B with it, C after. -use super::*; +use super::{Mem, NO_STOP, PathBuf, number, print_report, text}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/shed.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/shed.rs index 6860327a..9932c0d2 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/shed.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/shed.rs @@ -1,6 +1,6 @@ //! The shed scenario: the prefix cache evicted, requests refused and the budget restored, driven by floors moved //! next to the memory the host has now, so the real limit is never approached. -use super::*; +use super::{Admission, Level, Mem, RequestShape, number, print_report}; use std::time::Duration; fn available() -> u64 { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/soak.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/soak.rs index 60803b4b..1df06f3f 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/soak.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/soak.rs @@ -1,6 +1,6 @@ //! The soak scenario: mixed requests (cancels, refusals, long prompts, prefix-cache churn) judged flat after warm-up. use super::traffic::{Tally, TrafficRequest}; -use super::*; +use super::{Census, Mem, Tolerances, check_flat, list, number, print_report}; /// The knobs of the soak. struct Soak { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/traffic.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/traffic.rs index 6c6fed19..f9a98683 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/traffic.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/traffic.rs @@ -1,6 +1,6 @@ //! The mixed traffic of the soak and the leak scenarios: sessions that grow by tool turns, big prompts, //! unshared prompts, cancels and requests the governor must refuse. -use super::*; +use super::{Admission, Mem, RequestShape, ServeError}; /// What the traffic has done so far. #[derive(Default)] diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs index c056b168..c706a7de 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs @@ -33,7 +33,23 @@ //! //! Run: `cargo test -p leleka-engine-qwen35-cuda -- --ignored --exact //! backend::original_serve_prefix_smoke::original_serve_prefix_cache_smoke`. -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, + EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, + GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, + KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, + MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, + OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, + Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, + Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, probes, request, +}; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, session, +}; use crate::qwen_forward::original_serve_stack::dbg_el; use crate::qwen_forward::{ original_serve_request::{ServeError, ServeRequest}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/extras.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/extras.rs index a5c81bbd..f946e8fa 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/extras.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/extras.rs @@ -1,7 +1,7 @@ //! What the prefix-cache smoke does around the served requests: the per-request accounting, the verification //! against a full read, the summary, the pool protocol on the live cache and the cancellation checks. use super::run::Pfx; -use super::*; +use super::{CancelAt, ServeError, Served, env, filler, ids, mem_available_mib, rss_mib, serve_one}; /// What the served requests added up to. #[derive(Default)] diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/run.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/run.rs index e897abef..7d30d4cf 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/run.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/run.rs @@ -1,7 +1,11 @@ //! Loads the pinned model, opens the stack in the mode asked for and serves the scripted workload. use super::extras::{RequestAt, Tally}; use super::workload::{Plan, Workload}; -use super::*; +use super::{ + CancelAt, Driver, InheritedKarArchive, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget, PrefixConfig, + Qwen4ExpArtifact, Rc, SHARD0, SHARD1, ServeError, Served, StackConfig, Tokenizer, VerifiedGgufFile, dbg_el, env, + filler, mem_available_mib, number, required_path, rss_mib, serve_one, text, workload, +}; /// The pinned tokenizer and EOS, the KAR archive and the binding with its expert source. struct Pinned { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs index e290b7b6..c46585b2 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs @@ -25,7 +25,25 @@ //! While the verifier window producers listed in `UNBOUND_PRODUCERS` are unbound the stack refuses to open //! with the first missing producer's name; that refusal is the expected result of this smoke until they land. use super::super::qwen_forward::original_serve_stack::dbg_el; -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, + EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, + GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, + KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, + MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, + OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, + Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, + Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, load, original_prompt, probes, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, +}; use crate::qwen_forward::{ original_serve_request::{RequestSampling, ServeError, ServeRequest}, original_serve_stack::{OriginalServeStack, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_conv.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_conv.rs index 79d5369e..247525d6 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_conv.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_conv.rs @@ -1,6 +1,9 @@ //! The conversation cache on the real model: the resume smoke, and the requests, the timing and the chunk //! comparison the coverage smoke shares. -use super::*; +use super::{ + OriginalServeStack, PROMPT, PathBuf, ServeError, StackConfig, Tokenizer, dbg_el, env, env_or, open_pinned, + open_stack, optin, request, with_context, +}; /// What one request of the conversation smokes returned. pub(super) struct Served { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_coverage.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_coverage.rs index 2532fc21..3c3c22b8 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_coverage.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_coverage.rs @@ -1,7 +1,10 @@ //! Coverage of the conversation cache on the real model (documented on //! `original_serve_conversation_coverage_smoke`): every resumed request is compared token for token with the //! same request read from the empty prompt; every check prints a `CONV-CHECK name ok|FAIL` line. -use super::*; +use super::{ + CancelAfter, OriginalServeStack, PROMPT, PathBuf, PromptRequest, ServeError, Served, StackConfig, Tokenizer, + agent_sampler, dbg_el, env, env_or, ids, open_pinned, open_stack, optin, same_chunks, serve_once, with_context, +}; /// The knobs of the coverage smoke. struct Knobs { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs index dfbc1f2c..5e2c4335 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs @@ -1,6 +1,11 @@ //! Long-context smoke of the streamed INT8 KV: one greedy request over a prompt far longer than the resident //! window (documented on `original_serve_long_context_streamed_kv_smoke`). -use super::*; +use super::{ + OriginalServeStack, PathBuf, ServeRequest, StackConfig, Tokenizer, collect, dbg_el, env, env_or, ids, number, + open_pinned, open_stack, request, with_context, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; use std::time::Instant; const COLORS: [&str; 8] = ["amber", "blue", "crimson", "green", "grey", "ivory", "orange", "violet"]; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs index 2488c776..8c067990 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs @@ -1,6 +1,25 @@ //! The main smoke: greedy twice across a reset, a sampled request, a cancellation, the optional parity corpus //! and a short prompt on the scalar draft-KV path. -use super::*; +use super::{ + Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, + CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, + EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, + GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, + KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, + MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, + OriginalServeOptions, OriginalServeStack, PROMPT, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, + Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeRequest, Sha256, StackConfig, + SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, agent_sampler, + collect, dbg_el, env, env_or, ids, open_pinned, open_stack, optin, report_timing, request, with_context, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; +#[cfg(feature = "preview-path")] +use super::{ + DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, + MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, + TargetStepProduct, TokenId, +}; mod corpus; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs index 64f46d14..7219897f 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs @@ -1,7 +1,9 @@ //! The parity corpus of the main smoke: every line of `LELEKA_SMOKE_PROMPTS` is tokenized with the verified //! tokenizer, served greedily for `LELEKA_SMOKE_MAX_NEW` tokens (default 64) and printed as ids so the Original //! can be run on the same ids. -use super::*; +use super::{ServeError, ServeRequest, Smoke, Tokenizer, agent_sampler, env, env_or, report_timing}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; use crate::qwen_forward::{ original_serve_engine::ServeOutcome, original_serve_request::{RequestSampling, original_stop_tokens}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_stack.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_stack.rs index e57c7c39..4b6a3cc2 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_stack.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_stack.rs @@ -1,6 +1,9 @@ //! The pinned model, the Context and the Original serve stack the smokes of `backend_original_serve_smoke.rs` //! run on, and the helpers they share. -use super::*; +use super::{ + Driver, InheritedKarArchive, ModelBinding, OriginalServeStack, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, ServeError, + ServeRequest, StackConfig, Tokenizer, VerifiedGgufFile, dbg_el, env, required_path, +}; use crate::qwen_forward::original_serve_engine::ServeOutcome; use std::str::FromStr; diff --git a/crates/engine-qwen35-cuda/src/backend/profile_tests.rs b/crates/engine-qwen35-cuda/src/backend/profile_tests.rs index e942643a..1986d684 100644 --- a/crates/engine-qwen35-cuda/src/backend/profile_tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/profile_tests.rs @@ -1,7 +1,10 @@ //! The ranked expert profile read through the WeightSource port: the refusals and their order are the ones of the //! former file read, and the double of the port stands in for the file. use super::sources::{read_pinned_profile, read_ranked_expert_profile}; -use super::*; +use super::{ + BackendError, Digest, ErrorCode, RANKED_EXPERT_PROFILE_BYTES, RANKED_EXPERT_PROFILE_SHA, RankedExpertProfileSource, + Sha256, +}; use leleka_model_format::weight_source::MemWeightSource; fn hex(bytes: &[u8]) -> String { diff --git a/crates/engine-qwen35-cuda/src/backend/resident_mmq_model_proof.rs b/crates/engine-qwen35-cuda/src/backend/resident_mmq_model_proof.rs index 6d2f00d9..83887271 100644 --- a/crates/engine-qwen35-cuda/src/backend/resident_mmq_model_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/resident_mmq_model_proof.rs @@ -1,6 +1,8 @@ //! Private sole new changed-path model gate; actual source identity/load preserved. use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, MOE_REFUSAL, Owners, bind_pinned, require_opt_in}; -use super::*; +use super::{Driver, PathBuf, Rc}; +#[cfg(feature = "preview-path")] +use super::{MoeWeightCache, QwenForward}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use std::{env, panic::resume_unwind}; diff --git a/crates/engine-qwen35-cuda/src/backend/serve_run.rs b/crates/engine-qwen35-cuda/src/backend/serve_run.rs index 5b432cc8..68efa4f5 100644 --- a/crates/engine-qwen35-cuda/src/backend/serve_run.rs +++ b/crates/engine-qwen35-cuda/src/backend/serve_run.rs @@ -1,5 +1,9 @@ //! Running one admitted generation: the Generation step context and the choice of the generation loop. -use super::*; +use super::{ + Admitted, Exchange, FinishReason, Generation, GenerationFailure, InferenceMode, Job, MtpContinuation, Ordering, + QwenSession, Serving, Usage, clock_seed, generate, generate_mtp_resume, invalid, measurement, request_sampler, + unavailable, unsupported, +}; use std::cell::RefCell; pub(super) type Sampler = Result, leleka_sampler_ref::SamplingError>; diff --git a/crates/engine-qwen35-cuda/src/backend/singleload_proof.rs b/crates/engine-qwen35-cuda/src/backend/singleload_proof.rs index 32ef4c6a..55c99dcc 100644 --- a/crates/engine-qwen35-cuda/src/backend/singleload_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/singleload_proof.rs @@ -4,7 +4,9 @@ use super::combined_changed_boundary_proof::rig::{ DEVICE_BUDGET, MOE_REFUSAL, Owners, PinnedTokenizer, bind_pinned, bind_pinned_with_tokenizer, require_opt_in, }; -use super::*; +use super::{Driver, ModelBinding, PathBuf, Rc, Tokenizer}; +#[cfg(feature = "preview-path")] +use super::{MoeWeightCache, QwenForward, QwenSession}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use std::{ env, diff --git a/crates/engine-qwen35-cuda/src/backend/tests.rs b/crates/engine-qwen35-cuda/src/backend/tests.rs index 33cd5052..1477b82b 100644 --- a/crates/engine-qwen35-cuda/src/backend/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/tests.rs @@ -1,4 +1,15 @@ -use super::*; +use super::{ + Active, ActiveGuard, Arc, AtomicBool, Backend, BackendError, Command, DeferredTail, Digest, ErrorCode, + EvaluationExecution, FRAME_LIMIT, GenerationRequest, InferenceMode, KAR_LOAD_REPLY_TIMEOUT, KAR_PROFILE, + LOAD_CONFIG_VERSION, LoadedModel, MODE_DIGEST, MODEL_DIGEST, ModelDescriptor, Mutex, OPTIMIZED_EXECUTION, + OUTPUT_LIMIT, Ordering, PROMPT_LIMIT, Proxy, QUEUE, QUEUED_OWNERS_EXECUTION, RANKED_EXPERT_PROFILE_SHA, + REPLY_TIMEOUT, RecentIds, RuntimeConfig, SHARD0, Sha256, Shared, SyncSender, Tokenizer, Utf8Pending, + kar_expert_mode_digest, kar_mode_digest, load_reply_timeout, mpsc, optimized_execution_digest, + pinned_model_descriptor, prepare_prompt, queued_owners_execution_digest, request_sampler, validate_handle, + validate_kar_selection, validate_load, validate_request, +}; +#[cfg(feature = "preview-path")] +use super::{Dimension, InputConstants, Position, native_position}; #[test] fn queued_owner_identity_is_distinct_and_binds_profile_and_actual_bound_mode() { let old_fields = [ diff --git a/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs b/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs index 05b42faf..7bf82d4c 100644 --- a/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs +++ b/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ResidentConversations, ResidentPolicy, ResumeSource}; fn policy(budget_gib: usize, slots: usize) -> ResidentPolicy { ResidentPolicy { budget_bytes: budget_gib << 30, slots, fixed_bytes: 100 << 20, bytes_per_token: 20_000 } diff --git a/crates/engine-qwen35-cuda/src/experimental/tests.rs b/crates/engine-qwen35-cuda/src/experimental/tests.rs index 0a52a15e..0cfc2d99 100644 --- a/crates/engine-qwen35-cuda/src/experimental/tests.rs +++ b/crates/engine-qwen35-cuda/src/experimental/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + ExperimentalConfig, ExperimentalError, KvFormat, Mode, OptIn, PathBuf, Program, ensure_consumed, + load_control_vector_tables, mode_digest, plan, pool_bytes, +}; fn cfg(modes: &[Mode], resident: i64) -> ExperimentalConfig { let mut opt_in = OptIn::default(); 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 0f087edc..bbe73443 100644 --- a/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs +++ b/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs @@ -1,6 +1,9 @@ //! Page-cache release after the load (`drop_file_cache`), moved out of `memory_governor` by STRA-338 (size). -use super::*; +use super::{ + BackendError, CacheWish, DeviceSample, Entry, EnvSource, FixedItem, Governor, GovernorConfig, HostFacts, HostProc, + KarForm, Mutex, OpenStage, PlanInput, SamplerGuard, Settings, Space, VramFacts, When, +}; /// Give back the page cache the load created: the shards were read once to verify and to copy the resident bank, and /// nothing reads those pages again (the bank is a RAM copy). Left in place they are the cache pressure that pushed the diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs index 1f0f5546..152e1f18 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{E, NATIVE_EPSILON, TensorSignature, block_range, descriptor, exact_bf16, kind}; #[test] fn epsilon_is_exact_original_layer_operand() { assert_eq!(NATIVE_EPSILON.to_bits(), 0x358637bd); diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs index f8c3d7b7..7b1c8b58 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{GrRole, InputBindingError, TensorSignature, exact_bf16, role_set, validate_descriptor}; #[test] fn gr_binding_accepts_only_exact_finite_bf16_containers() { for bits in [0, 0x80000000, 0x3f800000, 0x00010000, 0x7f7f0000] { diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs index 144d6228..628f694c 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs @@ -1,7 +1,11 @@ //! 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. -use super::*; +use super::{ + BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File, + INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix, + MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, read_exact_range, read_expert_rows, +}; use sha2::{Digest, Sha256}; use std::io::Read; use std::os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt, PermissionsExt}; 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/qwen4exp_input/mtp/mtp_weight_reads.rs index ad60e93f..fe25a4b9 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs @@ -1,7 +1,11 @@ //! The reads of the MTP weights: dense rows, expert rows and the binding identity check. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File, + INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix, + MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing, descriptor, read_exact_range, + read_expert_rows, row_range, validate_numeric, +}; impl MtpWeights { /// Operator-only fixed profile. The copy owns an unnamed read-only inode for 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/qwen4exp_input/mtp/read_expert_rows.rs index 47521e8b..74665dbd 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs @@ -1,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File, + INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix, + MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing, +}; pub(super) fn read_expert_rows( experts: &File, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs index ba1425e8..0eecf459 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + BindingIdentity, DESCRIPTORS, INDEX_LIMIT, InputBindingError, MtpIndex, MtpKind, MtpRole, interleave_q2, row_range, + rt_dense_name, rt_dense_roles, rt_dense_shape, validate_identity, validate_numeric, +}; fn index() -> String { DESCRIPTORS .iter() diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs index f9e30568..fde7c92c 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs @@ -1,8 +1,12 @@ //! Methods of `InputConstants`: `test_fixture`. Methods of `BindingIdentity`: `test_identity`. //! Functions: `validate_ple_descriptor`, `bind_layers`, `bind_layer`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayer, BoundLayerKind, GlobalRole, InputBindingError, InputResult, LayerRole, PLE_ROWS, Qwen4ExpArtifact, + TensorRole, +}; +#[cfg(test)] +use super::{BindingIdentity, InputConstants, Rc}; pub(super) fn validate_ple_descriptor(artifact: &Qwen4ExpArtifact) -> InputResult<()> { let ple = artifact 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/qwen4exp_kar_ple/inherited_kar_archive.rs index d2b5d9e6..16ee32f6 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs @@ -1,8 +1,11 @@ //! 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... -#[allow(unused_imports)] -use super::*; +use super::{ + ARCHIVE_DIGEST, BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, + KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, + PathBuf, RefCell, SparseArchive, VerifiedKarPleArtifact, private_copy, +}; use leleka_model_format::weight_source::{BackingKind, FileWeightSource, Verification, WeightIdentity}; #[cfg(test)] 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/qwen4exp_kar_ple/load_pinned_inherited_archive.rs index 9d2540d3..5be59a2a 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/qwen4exp_kar_ple/load_pinned_inherited_archive.rs @@ -1,8 +1,12 @@ //! 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... -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPleBinding, + KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, KarRowPacket, KarRowReader, LoadPhase, NATIVE_DIGESTS, + PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, VerifiedKarPleArtifact, + open_sealed_archive_fd, pinned_profile, reopen_read_only_archive, verify_open_provenance, +}; /// The read handle of the inherited archive: a read-only reopen of the file, or the sealed memfd itself. #[cfg(target_os = "linux")] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs index 54a64455..eb2263ce 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs @@ -1,8 +1,12 @@ //! Methods of `InheritedKarArchive`: `expert_capture_observation`. //! Functions: `pinned_profile`, `pinned_parts`, `pinned_profile_spec`, `load_pinned_archive` and 3 more. -#[allow(unused_imports)] -use super::*; +use super::{ + ARCHIVE_DIGEST, BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, + KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PART0_F32_DIGEST, + PART1_F32_DIGEST, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, VIRTUAL_F32_DIGEST, VerifiedKarPleArtifact, + error, input_failure, kar_failure, private_copy, +}; /// Candidate expectations from independently verified v4 conversion receipts /// d51353be and 0d8a4a52. Construction reads no archive and grants no serving 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/qwen4exp_kar_ple/pinned_profile_tests.rs index e7c24590..765a889f 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs @@ -1,7 +1,11 @@ //! Implements `Write for BrokenSink`. //! Functions: `diagnostic_cases`, `assert_kar_diagnostic_redacts`, `assert_input_diagnostic_survives_broken_sink`, `... -use super::*; +use super::{ + BindingIdentity, File, InputBindingError, InputResult, KarError, KarPlePartProvenance, KarPleProfile, + KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PLE_ROWS, Path, PathBuf, RefCell, VerifiedKarPleArtifact, error, + input_diagnostic, kar_diagnostic, pinned_profile, pinned_profile_spec, +}; #[cfg(not(target_os = "windows"))] struct BrokenSink; 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/qwen4exp_kar_ple/private_copy/checked_reader.rs index 15ca77af..c38b579c 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/qwen4exp_kar_ple/private_copy/checked_reader.rs @@ -1,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + COPY_BUFFER, File, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions, + OpenOptionsExt, Path, Read, SOURCE_FLAGS, Seek, Write, inode, input_failure, phase_error, report_io, +}; #[cfg(target_os = "macos")] pub(super) fn checked_reader(own: &OwnedCopy, bytes: u64) -> InputResult { 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/qwen4exp_kar_ple/private_copy/inode.rs index c08842b8..2a04e19b 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs @@ -1,8 +1,10 @@ //! Methods of `OwnedCopy`: `create`, `created`, `writer`, `detach` and 2 more. Implements `Drop for OwnedCopy`. //! Functions: `inode`, `diagnostic`, `report_io`, `phase_error` and 8 more. -#[allow(unused_imports)] -use super::*; +use super::{ + File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions, + OpenOptionsExt, Path, Read, SOURCE_FLAGS, Seek, Write, checked_reader, copy_exact, input_failure, +}; pub(super) fn inode(meta: &Metadata) -> Inode { (meta.dev(), meta.ino()) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs index 8de5cecf..e6ac1bf0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs @@ -1,8 +1,12 @@ //! The lazily created workspaces of the dense weight cache, moved out of it by STRA-338 (size): consecutive owners, //! declared in the order the cache dropped them, so the drop order is unchanged. -#[allow(unused_imports)] -use super::*; +use super::{ + DeviceBuffer, GdnInputScratch, GrBatchInjectWorkspace, GrScratch, QkScratch, QsaAttentionScratch, QsaIndexKeyCache, + QsaInputScratch, QsaSelectedCache, Rc, RefCell, RouterScratch, +}; +#[cfg(test)] +use super::Cell; /// Every scratch owner of the cache that starts empty (`None` or an empty list) and is filled on first use. #[derive(Default)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs index 81d4e73a..095553e6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs @@ -3,7 +3,14 @@ //! attention, then completes the whole FFN GR bank. Qualification is pending. #![allow(dead_code)] use super::super::session::chunk::QwenChunkTxn; -use super::*; +use super::{ + BindingIdentity, BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage, + InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage, + MoeWeightCache, OutputStage, Position, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenForward, + QwenSession, QwenStepTxn, Result, Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, + TokenId, VerificationChunk, VerificationSource, WindowCaches, diagnose, prefill_chunk, + prepare_layer_attention_micro, read_layer_attention, validate_layer_plan, +}; #[derive(Clone, Copy)] enum ChunkMoePolicy { Native, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs index 98430e36..cc2806e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs @@ -2,8 +2,10 @@ //! Methods of `Rig`: `snapshot`, `prefill`, `step_final`, `prefill_chunk` and 7 more. #![cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] -use super::*; +use super::{ + DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, Position, + PrefillChunkInputs, QwenForward, QwenSession, Result, Stage, TokenId, +}; use crate::qwen_forward::executor::{PrefillStepProduct, StepCaches, StepRequest, TargetStepProduct}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use crate::qwen_forward::mtp::KnownNext; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/mmq_evaluation.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/mmq_evaluation.rs index 18b11396..fa276bda 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/mmq_evaluation.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/mmq_evaluation.rs @@ -1,5 +1,9 @@ //! Only the explicitly selected new full-model MMQ gate. Old observers unchanged. -use super::*; +use super::{ + ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, + Position, PrefillChunkInputs, QwenForward, QwenSession, Result, Stage, StepCaches, StepRequest, TargetStepProduct, + TokenId, +}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use crate::qwen_forward::mtp::KnownNext; use crate::qwen_forward::mtp::MtpChunkNumericSnapshot; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/native_mmq_evaluation.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/native_mmq_evaluation.rs index d454697f..d363b188 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/native_mmq_evaluation.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/native_mmq_evaluation.rs @@ -1,6 +1,6 @@ //! Separate native-certified activation model observer. Original failed observer unchanged. use super::mmq_evaluation::{ChunkExact, ChunkRun, MmqRun, Observation, pos}; -use super::*; +use super::{QwenForward, TokenId}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use crate::qwen_forward::mtp_decode::MtpDecoder; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs index 99137de5..be175d50 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs @@ -1,8 +1,17 @@ //! Groups the submodules `joint_chunk`, `prefill_chunk_cached_windowed`, `prefill_chunk_native_windowed` and 1 more. //! Split out of `prefill_chunk` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, + ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, + ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, QsaAttentionStage, + QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, Stage, StepCaches, + StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, TokenId, VerificationChunk, VerificationSource, + WindowCaches, chunk_diagnostic, diagnose, prefill_chunk, prepare_layer_attention_micro, prepare_micro_ffn_rows, + prepare_q6_layer_columns, qwen_forward, read_chunk_attention_ffn, read_layer_attention, validate_layer_plan, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::{check_chunk_on_loaded, window_numeric}; mod joint_chunk; #[allow(unused_imports)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs index f7314c4c..4db0ebcc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs @@ -1,8 +1,18 @@ //! Methods of `ChunkEnv`: `new`, `with_boundary`, `native_prompt`. Methods of `ChunkRun`: `window`. //! Defines `MicroBank`, `MicroBank`, `NativeMoe` and 6 more. -#[allow(unused_imports)] -use super::*; +use super::{ + AllocationTrace, AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, + Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, + MicroEnv, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, + PrefillChunkPlan, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, + QwenStepTxn, Result, Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TokenId, VerificationChunk, + VerificationSource, WindowCaches, chunk_diagnostic, diagnose, prepare_layer_attention_micro, + prepare_micro_ffn_rows, prepare_q6_layer_columns, qwen_forward, read_chunk_attention_ffn, read_layer_attention, + validate_layer_plan, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use leleka_cuda_driver::Context; mod chunk_layer; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs index 6cfc359b..ce89ceca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs @@ -2,8 +2,12 @@ use super::window_experts::ExpertRun; use super::window_ffn::WindowOwners; -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, ChunkEnv, ChunkRun, Context, Dimension, Error, GdnPlan, InjectedResidual, LayerId, MoeWeightCache, + NativeMoe, QwenChunkTxn, QwenForward, Result, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use crate::qwen_forward::gdn::chunk_device::GdnChunkDevice; use crate::qwen_forward::moe_expert::ChunkFfnLayer; use crate::qwen_forward::session::chunk::{ChunkFfnRow, ChunkMicroWindow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs index d1bcf062..496b946d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs @@ -1,7 +1,12 @@ //! STRA-338 size: admission, transaction begin, input rows and output head of one prefill chunk. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkEnv, ChunkMoePolicy, ChunkOpening, Context, DenseWeightCache, Error, InjectedResidual, InputStage, + KarPleCache, ModelBinding, MoeWeightCache, OutputStage, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, + QwenForward, QwenSession, QwenStepTxn, Result, Stage, chunk_diagnostic, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; /// The MMQ actor context, and the contexts of the recurrence and verification GDN owners when they are in use. type ChunkContexts<'ctx, 'driver> = diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs index f79636b3..65062021 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs @@ -1,7 +1,13 @@ //! STRA-338 size: the attention reads of one window of a prefill layer. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkEnv, ChunkRun, Error, GrStage, InjectedResidual, InputStage, LayerEntry, LayerId, MicroBank, QwenChunkTxn, + QwenForward, Result, Stage, chunk_diagnostic, prepare_layer_attention_micro, read_layer_attention, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; +#[cfg(test)] +use super::QwenStepTxn; use crate::qwen_forward::session::chunk::ChunkAttentionRow; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs index 733eebc6..82248e3f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs @@ -1,7 +1,9 @@ //! STRA-338 size: the expert execution and the batched FFN injection of one window of a prefill layer. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkEnv, ChunkMoePolicy, ChunkRun, Error, GrStage, InjectedResidual, LayerId, MoeExpertStage, MoeWeightCache, + NativeMoe, QwenChunkTxn, QwenForward, Result, Stage, chunk_diagnostic, +}; use crate::qwen_forward::gr::GrBatchRow; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::moe_expert::NativePromptFinish; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs index 8da4ecfa..7606f215 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs @@ -1,7 +1,11 @@ //! STRA-338 size: the projected columns and the prepared FFN rows of one window of a prefill layer. -#[allow(unused_imports)] -use super::*; +use super::{ + AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkRun, Error, ForwardPhase, GdnStage, InjectedResidual, LayerId, + MicroBank, MicroEnv, MoeExpertStage, MoeRouteStage, NativeMoe, Position, QwenChunkTxn, QwenForward, QwenStepTxn, + Result, Stage, TokenId, chunk_diagnostic, diagnose, prepare_micro_ffn_rows, prepare_q6_layer_columns, + read_chunk_attention_ffn, +}; use crate::qwen_forward::gdn::chunk_device::{ChunkEdge, GdnChunkDevice}; use crate::qwen_forward::gdn::{DeviceChunkRow, GdnLayerInput}; use crate::qwen_forward::gr::DetachedGrRead; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs index 20f5e318..ea40d3bf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs @@ -1,8 +1,12 @@ //! Methods of `AttentionHandoff`: `new`. //! Methods of `QwenForward`: `test_layer0_pair_on_loaded`, `run_layer0_diagnostic`. -#[allow(unused_imports)] -use super::*; +use super::{DenseWeightCache, ForwardPhase, GrStage, ModelBinding, Result, diagnose}; +#[cfg(test)] +use super::{ + ChunkMoePolicy, Dimension, Error, KarPleCache, MoeWeightCache, OutputStage, PrefillChunkInputs, QwenForward, + QwenSession, Stage, TokenId, +}; use crate::qwen_forward::gr::AttentionBlockOutput; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs index bbf01b2d..6f76e6a6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs @@ -1,7 +1,14 @@ //! Changed MicroWindow boundary observer. No model loading or serving switch. //! The returned report owns only counts/booleans; its assertions belong AFTER //! the caller has closed all actual GPU owners and checked allocated_bytes=0. -use super::*; +use super::{ + AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, GdnStage, + GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, ModelBinding, + MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, PrefillChunkPlan, + QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, + Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, TokenId, VerificationChunk, + VerificationSource, WindowCaches, qwen_forward, +}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use crate::qwen_forward::mtp_decode::MtpDecoder; use std::{cell::Cell, rc::Rc}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs index f99ae017..dc9ae9c8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs @@ -1,7 +1,10 @@ //! The proof phases of the window boundary observer (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + BoundaryPlan, Cell, ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, + MtpDecoder, OutputStage, PartialReport, Position, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, + QwenSession, Rc, Result, Stage, StepCaches, StepRequest, TargetStepProduct, TokenId, owned_journal, tokens, +}; use crate::qwen_forward::mtp::KnownNext; use crate::qwen_forward::mtp::MtpChunkNumericSnapshot; use crate::qwen_forward::session::ResetReplaySnapshot; 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_sdet.rs index c175ee24..f5111017 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_sdet.rs @@ -1,6 +1,9 @@ //! Cache-reset-replay numerical proof, moved out of `executor.rs` by STRA-338 (size); same module path as before. -use super::*; +use super::{ + BoundLayerKind, DenseWeightCache, Dimension, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, Position, + QwenForward, QwenSession, Result, StepCaches, StepRequest, TokenId, validate_layer_plan, +}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use crate::qwen_forward::{ dense_weight_cache::DenseCacheCounters, moe_weight_cache::WeightCacheCounters, session::ResetReplaySnapshot, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs index 07ee9b6a..7a5576a4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs @@ -1,7 +1,11 @@ //! Phases of `QwenForward::step_core` (STRA-338 size: extract-method only, same order of operations). -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, + InputStage, KarPleCache, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, + Position, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenStepTxn, Result, TokenId, diagnose, + read_layer_attention, validate_layer_plan, +}; use crate::qwen_forward::gdn::GdnLayerInput; use crate::qwen_forward::moe_expert::ExpertRowRequest; use crate::qwen_forward::qsa_attention::QsaReady; 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 7b82ed9b..33c2ff59 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + BoundLayerKind, Dimension, Error, LayerId, OutputStage, Position, QwenForward, QwenSession, QwenStepTxn, Result, + Stage, TokenId, validate_descriptors, +}; #[test] fn topology_validation_requires_the_exact_contiguous_closed_sequence() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/gpu_tests.rs index 9640d90e..63086880 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/gpu_tests.rs @@ -5,7 +5,10 @@ use super::super::{ GateHostOperands, GdnOwner, GdnPrior, GdnStateMirror, OutNormScale, RecurrenceOperands, convolve, gates, normalize_qk, out_norm, recur, release, upload, }; -use super::*; +use super::{ + BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, Error, GdnMatrixKind, HISTORY_ELEMENTS, Product, Rc, + Role, TokenLayer, VALUES, allocate, download, +}; use crate::qwen_forward::contract::{Dimension, LayerId, Position, TokenId}; use leleka_cuda_driver::{Bf16ProjectionShape, Driver}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/row_queue_gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/row_queue_gpu_tests.rs index 1b510138..3f0492dd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/row_queue_gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/row_queue_gpu_tests.rs @@ -7,7 +7,11 @@ use super::super::{ GateHostOperands, OutNormScale, RecurrenceOperands, STATE_ELEMENTS, convolve, gates, normalize_qk, out_norm, recur, release, upload, }; -use super::*; +use super::{ + BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, DeviceOperand, Error, GdnMatrixKind, GdnRowQueue, + HISTORY_ELEMENTS, QkScratch, QkvInput, QueueInputs, QueuedRow, Rc, Result, Role, TokenLayer, VALUES, allocate, + download, +}; use crate::qwen_forward::contract::{Dimension, LayerId, Position, TokenId}; use leleka_cuda_driver::{Bf16ProjectionShape, Driver}; 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 1e6560b8..757f9fa4 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 @@ -2,7 +2,19 @@ #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::session::chunk::GdnChunkMicro; use super::super::session::chunk::{GdnChunkRow, GdnChunkSeal, GdnChunkStart}; -use super::*; +use super::{ + ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, Context, DenseFormat, DenseWeightCache, + DeviceBuffer, DeviceChunkRow, Dimension, DriverError, Error, GateHostOperands, GdnInputLease, GdnInputScratch, + GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, GdnStateKey, + GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, InputBindingError, LayerId, LeaseClaim, LeasedProjection, + MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, ProjectedQkvSource, ProjectionKind, ProjectionOperands, + ProjectionSpec, PromptLayer, PromptProgram, PromptSource, Q5KProjectionShape, Q6KProjectionShape, QkScratch, + QwenStepTxn, ReadoutClaim, RecurrenceOperands, ResidualReady, Result, STATE_ELEMENTS, Stage, TokenLayer, VALUES, + allocate, chain, download, download_unchecked, driver_error, pool_enabled, preflight_budget, release, state, + upload, validate_values, verification, +}; +#[cfg(test)] +use super::CHANNELS; use leleka_cuda_driver::{GdnRowQueue, GdnStateFiniteGuard}; use std::{cell::Cell, rc::Rc}; pub(in crate::qwen_forward) const CHUNK_DEVICE_CHARGE: usize = 2 * STATE_ELEMENTS * 4 + 4; 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/gdn_chunk_device_methods.rs index fbb9e73b..ebcd590f 100644 --- 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/gdn_chunk_device_methods.rs @@ -1,8 +1,19 @@ //! Groups the submodules `chunk_device_batch_compute`, `chunk_device_construction`, `chunk_device_finish_cleanup`. //! Split out of `chunk_device` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, + ChunkReadout, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, Dimension, DriverError, Error, + GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease, + GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, + GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, + InputBindingError, LayerId, LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, + ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource, + Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, Rc, ReadoutClaim, ReadoutDownload, + RecurrenceOperands, ResidualReady, Result, STATE_ELEMENTS, Stage, TokenLayer, VALUES, allocate, chain, download, + download_unchecked, driver_error, micro_rows, mirror_reuse_enabled, pool_enabled, preflight_budget, release, state, + upload, validate_values, verification, +}; mod chunk_device_batch_compute; mod chunk_device_construction; 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/gdn_chunk_device_methods/chunk_device_batch_compute.rs index 4969f312..460d22fb 100644 --- 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/gdn_chunk_device_methods/chunk_device_batch_compute.rs @@ -1,8 +1,12 @@ //! Methods of `GdnChunkDevice`: `finish_batch`, `history`, `step_source`, `read_checked` and 13 more. //! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkEdge, ChunkReadout, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, HISTORY_ELEMENTS, Rc, ReadoutDownload, + Result, VALUES, allocate, download, driver_error, preflight_budget, validate_values, +}; +#[cfg(test)] +use super::upload; impl<'ctx> GdnChunkDevice<'ctx> { /// Adopt the final state of a batch that drained clean: the separate `next` diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs index ea1b657f..346878c5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs @@ -3,7 +3,18 @@ use super::super::super::contract::{Dimension, LayerId}; use super::super::super::session::chunk::TestGdnComponentRows; use super::super::{RecurrenceOperands, convolve, recur}; -use super::*; +use super::{ + ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHANNELS, CHUNK_DEVICE_CHARGE, Cell, + ChunkReadout, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, DriverError, Error, + GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease, + GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, + GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, + InputBindingError, LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, + ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource, + Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, Rc, ReadoutClaim, ResidualReady, Result, + STATE_ELEMENTS, Stage, TokenLayer, allocate, chain, download, driver_error, preflight_budget, release, state, + upload, validate_values, +}; use leleka_cuda_driver::Driver; const ROWS: usize = 65; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs index 54cff189..87950278 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs @@ -1,8 +1,10 @@ //! Functions: `batch_adoption`, `adoption_rows`, `adoption_phase`, `batch_operand_guards` and 6 more. //! Split out of `numeric_gpu` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Context, Dimension, Error, GdnChunkDevice, GdnChunkRow, GdnPrior, HISTORY_ELEMENTS, LayerId, + Result, STATE_ELEMENTS, TestGdnComponentRows, component_owner, difference, download, driver_error, require, +}; // Batch adoption of the Strata-prefill step. Pure ownership/identity: no kernel // runs here, the final state is a recognisable pattern written into `next`. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs index fe326ba3..81e5f18f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs @@ -1,8 +1,12 @@ //! Methods of `Fixture`: `new`, `row_guards`, `run_rows`, `compute_row` and 12 more. //! Functions: `require_rejected_clean`, `exercise`, `run_gdn_chunk_numeric`. Defines `Fixture`, `ComputedRow`. -#[allow(unused_imports)] -use super::*; +use super::{ + BUDGET, BindingIdentity, CHUNK_DEVICE_CHARGE, ChunkReadout, Context, Counts, DeviceBuffer, Dimension, Driver, + Error, GdnChunkDevice, GdnChunkRow, GdnChunkSeal, GdnPrior, GdnStateFiniteGuard, LayerId, Operands, Rc, Reference, + Result, STATE_ELEMENTS, TestGdnComponentRows, component_owner, convolution_input, convolution_weights, convolve, + difference, download, driver_error, operands, reference, require, upload, +}; // The prior, the same-PTX reference and the row sources every stage of the component proof uses. struct Fixture { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs index af9719f4..aa103a5f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs @@ -1,8 +1,11 @@ //! Functions: `driver_error`, `validate_candidates`, `state_index`, `key_head`. //! Split out of `gdn` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{DriverError, Error, KEY_HEADS, Result, Stage, VALUE_HEADS, WIDTH}; +#[cfg(test)] +use super::CandidateFixture; +#[cfg(test)] +use super::{HISTORY_ELEMENTS, STATE_ELEMENTS, TokenLayer, validate_values}; pub(in super::super) fn driver_error(error: DriverError) -> Error { if crate::driver_errors_traced() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/four_borrow_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/four_borrow_gpu.rs index 49b09a85..3f23f160 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/four_borrow_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/four_borrow_gpu.rs @@ -1,6 +1,9 @@ //! ONE binding-loaded layer0 transport proof; no synthetic ModelBinding, //! fabricated session advancement or all48/full-model qualification. -use super::*; +use super::{ + Context, DenseWeightCache, Dimension, Error, FOUR_BORROW_BYTES, GdnPrior, GdnStage, HISTORY_ELEMENTS, LayerId, + ModelBinding, QwenStepTxn, ResidualReady, Result, STATE_ELEMENTS, Stage, VALUES, validate_values, +}; use crate::qwen_forward::gdn::GdnLayerInput; use crate::qwen_forward::{ contract::{Position, TokenId}, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/input_scratch_gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/input_scratch_gpu_tests.rs index 3bd12d48..67bfa62e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/input_scratch_gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/input_scratch_gpu_tests.rs @@ -1,6 +1,9 @@ //! New per-layer input lease parity; synthetic component, never ModelBinding. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use super::*; +use super::{ + BindingIdentity, Context, DeviceBuffer, Error, GdnInputLease, GdnInputScratch, GdnMatrixKind, GdnMatrixLayout, + GdnMatrixRole, LeaseClaim, allocate, dispatch_projection, download, input_scratch, project_retained, upload, +}; use input_scratch::INPUT_BYTES; use leleka_cuda_driver::Driver; use std::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gpu_tests.rs index 3e05d547..1775b1ce 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gpu_tests.rs @@ -1,7 +1,7 @@ //! New device mirror against the actual uncached recurrence, not a model oracle. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{GdnOwner, HISTORY_ELEMENTS, RecurrenceOperands, recur}; -use super::*; +use super::{BindingIdentity, Cell, Context, Error, GdnPrior, GdnStateMirror, MIRROR_BYTES, MirrorNext, Rc, VALUES}; use crate::qwen_forward::contract::{Dimension, LayerId, Position, TokenId, TokenLayer}; use leleka_cuda_driver::Driver; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs index 50cd289e..a2bac559 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs @@ -13,7 +13,11 @@ use super::super::session::chunk::GdnChunkMicro; use super::chunk_device::GdnChunkDevice; use super::chunk_producer::ChunkReady; -use super::*; +use super::{ + BoundLayerKind, CHANNELS, Context, DenseWeightCache, DeviceBuffer, Dimension, Error, GdnMatrixKind, GdnMatrixRole, + GdnStage, HISTORY_ELEMENTS, LayerId, ModelBinding, PromptLayer, Result, Stage, TokenLayer, VALUE_HEADS, VALUES, + download, driver_error, validate_values, +}; use leleka_cuda_driver::{GDN_BATCH_EPSILON, GDN_BATCH_MAX_TOKENS, GdnGemm, GdnNativeFormat, GdnPrefillBatch}; const MIXED: usize = 2560; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gpu.rs index 356249ef..e4014c8c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gpu.rs @@ -3,7 +3,7 @@ //! and the chunk adoption in `gdn_chunk_numeric_gpu.rs`; the full model step //! needs a bound `ModelBinding`, a loaded `DenseWeightCache` and a real //! adapter, so its qualification is Root's Original17 prefill gate. -use super::*; +use super::{BATCH_SCRATCH_BYTES, Bf16Profile, EAGER_TOKENS, GdnBatchResources, batch_device_bytes}; use leleka_cuda_driver::Driver; #[test] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs index ca7c5254..42607b35 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs @@ -3,7 +3,12 @@ use super::super::session::{ TargetStepOrigin, chunk::{GdnChunkRow, GdnChunkStart}, }; -use super::*; +use super::{ + BindingIdentity, CHANNELS, Context, DeviceBuffer, Error, GdnPrior, HISTORY_ELEMENTS, LayerId, Result, + STATE_ELEMENTS, Stage, TokenLayer, VALUES, allocate, chain, download, driver_error, validate_values, +}; +#[cfg(test)] +use super::{CandidatePair, upload}; use leleka_cuda_driver::GdnStateFiniteGuard; use std::{ cell::{Cell, RefCell}, 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 d5e3ca4f..533f41da 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,5 +1,8 @@ //! Numerical transport proof of the MTP verification journal (test-only; moved out of the parent file by STRA-338). -use super::*; +use super::{ + COUNTS, CandidatePair, Context, DeviceBuffer, Error, GdnStateFiniteGuard, Result, STATE_ELEMENTS, VALUES, + VerifiedRowBuffers, allocate, compute_row, download, driver_error, upload, +}; use leleka_cuda_driver::Driver; struct Numerical<'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_residual_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_residual_reuse_gpu.rs index 81f76219..faa380f6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_residual_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_residual_reuse_gpu.rs @@ -1,6 +1,9 @@ //! New GR residual transport parity through actual private serving helpers. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use super::*; +use super::{ + BindingIdentity, Cell, Context, DeviceBuffer, Error, GrScratch, Rc, download_f32, inject_cached_cuda, + read_cached_cuda, upload_bf16, upload_f32, +}; use leleka_cuda_driver::Driver; use std::cell::RefCell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs index 0c79ccd4..407ea719 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs @@ -1,7 +1,13 @@ //! Functions: `run_proof`, `compare_outputs`, `release_owners`, `original_first_fixed_outputs_repeat_overwrite_abort... //! Defines `Tally`. -use super::*; +use super::{ + AttentionBlockOutput, BindingIdentity, Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Dimension, + DriverError, Error, GR_OUTPUT_BYTES, GR_OUTPUT_DEVICE_BYTES, GrBatchRow, GrMicroAttention, GrMicroAttentionBank, + GrMicroAttentionBlock, GrMicroBlock, GrMicroInput, GrRole, GrScratch, GrWeights, InputBindingError, LayerId, + MicroBlockRequest, ModelBinding, PleReady, QwenStepTxn, Rc, ReadCandidate, RefCell, RefMut, Result, TokenLayer, + download_f32, driver_error, inject_cached_cuda, read_cached_cuda, retained_handoff, upload_bf16, upload_f32, +}; use leleka_cuda_driver::Driver; #[derive(Default)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/output_workspace_proof_stages.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/output_workspace_proof_stages.rs index 215f17a5..585ce05f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/output_workspace_proof_stages.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/output_workspace_proof_stages.rs @@ -1,5 +1,9 @@ //! The stages of the output workspace proof; the parent owns the tally, the proof driver and the test. -use super::*; +use super::{ + BindingIdentity, Cell, Context, DeviceBuffer, Error, GrScratch, Rc, ReadCandidate, RefCell, Result, Tally, block, + check_handoff, coefficients, compare_outputs, download_f32, driver_error, fresh_inject, fresh_read, + inject_cached_cuda, poison_all, read_cached_cuda, retained_handoff, streams, upload_bf16, upload_f32, +}; type Weights<'m, 'c> = &'m [DeviceBuffer<'c>; 4]; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs index 02970e42..b3621bc8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs @@ -2,7 +2,15 @@ //! The actual finite host witness remains canonical; only its duplicate H2D //! is removed. No device-only host proof or changed arithmetic is introduced. use super::read_cached_cuda::borrow_injection; -use super::*; +use super::{ + Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Error, GrMicroAttentionBank, GrMicroAttentionBlock, + GrPhase, GrRead, GrRole, GrScratch, GrStage, InjectedResidual, LayerId, ModelBinding, QwenStepTxn, + READ_DEVICE_BYTES, Rc, ReadCandidate, RefMut, ResidualReady, Result, TokenLayer, admit_budget, batch_chunk, + copy_cached_f32, diagnose, download_f32, driver_error, read_cached_cuda, validate_layer, validate_streams, + validate_values, +}; +#[cfg(test)] +use super::{BindingIdentity, inject_cached_cuda, upload_bf16, upload_f32}; /// The attention block output an attention residual is injected with, and the token and layer it was computed for. #[derive(Clone, Copy)] pub(in crate::qwen_forward) struct AttentionBlockOutput<'a> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/installed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/installed.rs index bd793c6a..8b83f4cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/installed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff/installed.rs @@ -1,6 +1,9 @@ //! Only the new actual attention-injection -> FFN GR ownership/transport seam. //! Scalar host-roundtrip executes FIRST. No fabricated model/session proof. -use super::*; +use super::{ + BindingIdentity, Cell, Context, DeviceBuffer, Error, GrScratch, Rc, download_f32, inject_cached_cuda, + inject_replace_residual, read_cached_cuda, replace_residual_buffer, upload_bf16, upload_f32, +}; use leleka_cuda_driver::Driver; use std::cell::RefCell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs index c1c260cd..6375eba7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs @@ -1,6 +1,8 @@ //! Unit tests of `gr`. -use super::*; +use super::{ + BindingIdentity, Dimension, Error, GrRole, InjectedResidual, LayerId, TokenLayer, validate_layer, validate_streams, +}; #[test] fn gr_preflight_keeps_all_inputs_unchanged_on_shape_or_numeric_refusal() { 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 3dfa1c29..53c5d647 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 @@ -1,8 +1,14 @@ //! Methods of `InputReady`: `test_fixture`. Methods of `PleOwner`: `new`, `matches`. //! Functions: `gather_rows`, `binding_error`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Dimension, EMBEDDING_VALUES, Error, GrRole, InjectedResidual, InputBindingError, InputError, + LayerId, ModelBinding, PLE_HC, PLE_HISTORY, PLE_ROW_VALUES, PleMicroBatchReady, PleMicroInput, PleOwner, + PlePending, PlePrior, PleReady, PleState, Position, QwenStepTxn, Rc, Result, Stage, TokenLayer, ple_values, + ple_zeros, +}; +#[cfg(test)] +use super::{InputReady, ResidualStreams, TokenId}; pub(super) fn gather_rows( rows: &[u64; 16], diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs index ebd71eda..8fad61f9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs @@ -1,7 +1,7 @@ //! Methods of `Rng`: `next`, `row`. Methods of `Scan`: `new`, `victim`, `plan`, `gather`. //! Functions: `token`, `gather_equals_the_full_scan_on_random_sequences`, `chunks_and_gathers_interleaved_keep_every... -use super::*; +use super::{Lookup, Residents, SLOTS, assign_slots, lookup_rows, plan_gather, publish_gather}; use std::collections::HashMap; struct Rng(u64); 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 55c269cf..9b8ab142 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 @@ -1,7 +1,7 @@ //! Functions: `fnv`, `probe_binding`, `probe_rows`, `dump_decoded_rows_for_original_comparison` and 2 more. //! Split out of `kar_ple_cache` to keep its files under the line limit. -use super::*; +use super::{BindingIdentity, KarPleBinding, KarPleCache, PLE_ROWS}; use crate::model_binding::qwen4exp_kar_ple::pinned_profile; use leleka_cuda_driver::Driver; use leleka_model_format::kar::{KarInspection, VerifiedKarPleArtifact}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs index ecf1b60b..3d6dca7d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs @@ -1,7 +1,7 @@ //! Functions: `apply`, `the_scatter_staging_buffers_match_the_update_records`, `chunk`, `consistent` and 9 more. //! Defines `Given`. -use super::*; +use super::{Error, Lookup, MAX_MISSES, Residents, UPDATE_RECORD_BYTES, assign_slots, lookup_rows, scratch_bytes}; /// What `KarPleCache::commit` does to the map, over the pure parts. fn apply(entries: &mut Residents, lookup: &Lookup, miss_slot: &[u32], victims: &[Option], stamp: u64) { 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 5eb0486b..4e89fa25 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 @@ -1,8 +1,16 @@ //! Functions: `matrix_dims`, `gate_up_dims`, `prepared_routed_format`, `gate_up_prepared_format` and 15 more. //! Defines `MatrixDims`, `ExpertMatrix`, `ExpertActivation` and 2 more. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, CachedMoeMatrix, Context, DEVICE_PEAK, DenseFormat, DeviceBuffer, Error, FF, ModelBinding, + MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, N, + ProjectionKind, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, Result, RoutedFormat, RoutedGateUpQ8, + Stage, binding_error, download_f32, driver_error, upload_bytes, +}; +#[cfg(test)] +use super::TILE; +#[cfg(test)] +use super::validate_values; /// Shape and format of one expert matrix as the binding declares it. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs index be0af4c0..02a2cccb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs @@ -2,7 +2,20 @@ //! Exact scalar Q8_1 arithmetic; this is not the tensorcore MMQ numerical profile. use super::super::gr::{DetachedGrRead, GrStage}; use super::super::session::chunk::{ChunkFfnRow, QwenChunkTxn}; -use super::*; +use super::{ + ActualDown, ActualSlotPacket, BindingIdentity, BoundExpert, CachedMoeMatrix, Cell, CompletedCpuRow, Context, + DEVICE_PEAK, DeviceBuffer, DownOrigin, DownProvenance, DownScope, DownSelection, DriverError, Error, + ExpertActivation, ExpertReady, FF, GrRole, K, LayerId, MatrixDims, MmqChunkRequest, ModelBinding, + MoeExpertSelection, MoeExpertStage, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, N, PackedDown, + QwenStepTxn, Rc, Result, RetainedDown, RoutedExperts, RoutedFormat, RoutedGateUpQ8, SharedTailRow, SourceMatrix, + Stage, StepCuda, TokenLayer, TransportBuffer, admit_budget, binding_error, cached_mlp_down, download_f32, + driver_error, dual_routed_format, execute_cuda_cached, launch_cached_projection, moe_down, validate_values, +}; +#[cfg(test)] +use super::{ + DeclaredMatrix, DenseFormat, ExpertMatrix, ExpertRowRequest, InputBindingError, KarExpertSource, KarSourceError, + MoeExpertBlock, ProjectionKind, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, ResidualReady, +}; use leleka_cuda_driver::DownColumns; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod adaptive_packets; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs index 36075ad2..7adfe339 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs @@ -1,6 +1,16 @@ //! ONE loaded actual-row transport proof. No source admission, ModelBinding, //! session advancement, standalone Load or full-model qualification is minted. -use super::*; +use super::{ + BindingIdentity, BoundExpert, CachedMoeMatrix, ChunkFfnLayer, ChunkFfnRow, CompletedCpuRow, Context, DEVICE_PEAK, + DeclaredMatrix, DenseFormat, DeviceBuffer, DownColumns, DownProvenance, DownScope, DownSelection, DriverError, + Error, ExpertActivation, ExpertGroup, ExpertMatrix, ExpertReady, ExpertRowRequest, FF, GrRole, GrStage, + InputBindingError, K, KarExpertSource, KarSourceError, LayerId, MatrixDims, MmqChunkRequest, ModelBinding, + MoeExpertBlock, MoeExpertSelection, MoeExpertStage, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, + N, NativePromptFinish, PackedDown, PacketGroupMembers, PreparedMoeRow, ProjectionKind, ProjectionSpec, + Q5KProjectionShape, Q6KProjectionShape, QwenChunkTxn, Rc, ResidualReady, Result, RetainedDown, RoutedExperts, + RoutedFormat, RoutedGateUpQ8, RowTail, SharedTailRow, SourceMatrix, Stage, StepCuda, TokenLayer, TransportBuffer, + download_f32, driver_error, moe_down, validate_values, +}; use crate::qwen_forward::gr::DetachedGrRead; use crate::qwen_forward::session::{QwenStepTxn, ResetReplaySnapshot, chunk::ChunkAttentionRow}; use crate::qwen_forward::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs index b83ac0a6..bf231305 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs @@ -1,8 +1,10 @@ //! Functions: `arm`, `probe_payload`, `preflight_copy`, `corrupted_bytes` and 1 more. //! Split out of `direct_gpu` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, ChunkFfnLayer, DEVICE_PEAK, DownScope, Error, FF, K, LoadedArms, MoeExpertStage, N, Observation, ObservedArm, + QwenChunkTxn, Result, SLOTS, arm_chunk_rows, arm_tokens, cancel_probe, +}; pub(super) fn arm<'ctx>( arms: &mut LoadedArms<'_, '_, 'ctx>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs index b71abf35..8d458a04 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs @@ -1,8 +1,10 @@ //! Methods of `LoadedArms`: `arm`, `matches_snapshot`, `precheck`, `reference_and_candidate` and 2 more. //! Methods of `QwenForward`: `test_direct_down_on_loaded`. -#[allow(unused_imports)] -use super::*; +use super::{ + CANCELLED_ON_COPY, DirectDownReport, DirectRun, Error, K, LoadedArms, N, ObservedArm, QwenForward, + ResetReplaySnapshot, Result, Stage, arm, compare, output_differences, same_outputs, transport_probe, +}; impl LoadedArms<'_, '_, '_> { pub(super) fn arm(&mut self, old: bool, cancel_after_copy: bool) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs index 9538e1a9..3d9b7147 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs @@ -1,8 +1,12 @@ //! Methods of `Observation`: `begin`, `take`. Methods of `DirectDownReport`: `assert_after_teardown`. //! Implements `Drop for Observation`. Functions: `policy`, `copy_completed`, `observe_packet`, `compare` and 7 more. -#[allow(unused_imports)] -use super::*; +use super::{ + CANCELLED_ON_COPY, COPIED, ChunkAttentionRow, ChunkFfnRow, DenseWeightCache, DetachedGrRead, DeviceBuffer, + Dimension, DirectDownReport, Error, GdnStage, GrStage, InputStage, K, KarPleCache, LayerId, ModelBinding, + MoeExpertStage, MoeRouteStage, N, OLD, Observation, PACKETS, PreparedMoeRow, QwenChunkTxn, QwenStepTxn, Result, + TokenId, download_f32, validate_values, +}; use crate::qwen_forward::gdn::GdnLayerInput; pub(in super::super) fn policy(actual: bool) -> bool { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs index f3354031..1c468146 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs @@ -1,8 +1,10 @@ //! Methods of `Probe`: `run`, `fill_sentinels`, `split_and_pack_old`, `copy_direct` and 7 more. //! Functions: `transport_probe`, `output_differences`, `same_outputs`. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DownScope, DownSelection, DriverError, Error, ExpertReady, K, N, Probe, Rc, Result, SLOTS, + corrupted_bytes, download_f32, driver_error, preflight_copy, probe_payload, refuse_alien_scope, validate_values, +}; impl<'ctx> Probe<'_, 'ctx> { pub(super) fn run(&mut self) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/layer0_pair.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/layer0_pair.rs index aaebea33..bef7bdba 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/layer0_pair.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/layer0_pair.rs @@ -1,5 +1,8 @@ //! Same actual sealed rows and transaction, native first, no publication. -use super::*; +use super::{ + ChunkFfnLayer, ChunkFfnRow, Error, ExpertReady, K, LayerId, ModelBinding, MoeExpertStage, MoeWeightCache, + QwenChunkTxn, Result, +}; use crate::qwen_forward::layer0_mmq_observation as observation; fn counters(cache: &MoeWeightCache<'_>) -> [u64; 5] { let c = cache.counters(); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs index 9ad5e2c9..dfb7a46c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs @@ -1,6 +1,8 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{DEVICE_PEAK, Error, FF, N, admit_budget}; +#[cfg(test)] +use super::collect_rows; #[test] fn completed_tiles_keep_all_rows_and_late_failure_withholds_candidate() { let values = collect_rows(N, |first, count| { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs index e0470d6f..c042c301 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + EXPERTS, Error, FF, GdnNativeFormat, MIXED, MoeBf16Profile, MoeWeightDescriptor, SELECTED, device_bytes, + down_format, f32_bytes, gate_up_format, validate_route_row, +}; fn descending() -> ([i32; SELECTED], [f32; SELECTED]) { (std::array::from_fn(|i| (i * 7) as i32), std::array::from_fn(|i| 0.2 - i as f32 * 0.01)) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs index d64817fb..a6ecbfca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs @@ -1,4 +1,7 @@ -use super::*; +use super::{ + BindingIdentity, DriverError, EXPERTS, Error, ExpertId, LOGITS_BYTES, LayerId, Result, RoutedExperts, RouterLogits, + SELECTED, Stage, TokenId, TokenLayer, map_driver_error, route_with, +}; use crate::qwen_forward::contract::{Dimension, Position}; // The oracle's explicit lane-index loops preserve the fixed warp traversal. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs index 65b517d9..864d8cd7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs @@ -1,8 +1,10 @@ //! Methods of `LruIndex`: `new`, `with_capacity`, `metadata_bytes`, `len` and 15 more. //! Split out of `cache_lru_index` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ABSENT, Error, HOST_LIMIT, LruIndex, MAX_KEYS, MAX_PROTECTED, MoeWeightDescriptor, Node, PER_LAYER, + PreparedUpdates, Result, slot, +}; impl LruIndex { #[cfg(any(test, all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64")))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs index 6e8f58e2..644c1ba9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs @@ -1,5 +1,16 @@ //! Binding-authenticated constructor; metadata alone cannot produce weights. -use super::*; +use super::{ + AdaptiveWitness, BindingIdentity, BoundExpert, Cell, Context, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, + FixedMtpWeights, HashMap, LearnedMainWitness, LruIndex, MAIN_LIMIT, MmqChunkRequest, MmqFormat, MmqWeights, + MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, + MoeWeightDescriptor, MtpExpertPicks, MtpHeadSources, MtpInputWorkspace, MtpKind, MtpKvClaim, MtpKvResident, + MtpRole, MtpStepSite, PREFILL_STREAM_OVERRIDE, PendingMtpKv, PreparedUpdates, PromptWeightOwners, Rc, RefCell, + Result, RetainedOriginalMtpWeights, RoutedFiniteStage, RoutedGroupWorkspace, RoutedStageFiniteGuard, SharedKeys, + SharedPermanentWitness, SharedTailRow, SharedWeightsRequest, SourceMatrix, TripletLoanRequest, WORKING_RESERVE, + WeightCacheCounters, binding_error, cache_profile, cache_strata_adaptive, driver_error, +}; +#[cfg(test)] +use super::room_fits; #[cfg(test)] use cache_profile::ProfileWitness; use cache_profile::{HOST_CAP, PROFILE_SHA, PinnedPool, PrefixPlan, ProfileLimits, RankedProfile}; 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 36d9fda3..7786e9cd 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 @@ -1,8 +1,19 @@ //! Groups the submodules `pinned_triplet_preload`, `profile_ranked_fill_and_pool`. //! Split out of `cache_profile_fill` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + AdaptiveWitness, BindingIdentity, BoundExpert, Cell, Context, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, + FixedMtpWeights, HOST_CAP, HashMap, LearnedMainWitness, LruIndex, MAIN_LIMIT, MmqChunkRequest, MmqFormat, + MmqWeights, MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, + MoeWeightDescriptor, MtpExpertPicks, MtpHeadSources, MtpInputWorkspace, MtpKind, MtpKvClaim, MtpKvResident, + MtpRole, MtpStepSite, PREFILL_STREAM_OVERRIDE, PROFILE_SHA, PendingMtpKv, PinnedPool, PrefixPlan, PreparedUpdates, + ProfileLimits, PromptWeightOwners, RankedProfile, Rc, RefCell, Result, RetainedOriginalMtpWeights, + RoutedFiniteStage, RoutedGroupWorkspace, RoutedStageFiniteGuard, SharedKeys, SharedPermanentWitness, SharedTailRow, + SharedWeightsRequest, SourceMatrix, TripletLoanRequest, WORKING_RESERVE, binding_error, driver_error, + profile_window_spill_with_floor, +}; +#[cfg(test)] +use super::ProfileWitness; mod pinned_triplet_preload; mod profile_ranked_fill_and_pool; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs index c1976144..76872ac1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs @@ -1,8 +1,14 @@ //! Methods of `MoeWeightCache`: `preload_pinned_triplet`, `admit_pinned_triplet`, `pinned_layouts`, `check_pinned_ro... //! Defines `PinnedLayouts`, `PinnedSource`, `PinnedAdmission`. -#[allow(unused_imports)] -use super::*; +use super::{ + DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, + WORKING_RESERVE, binding_error, driver_error, +}; +#[cfg(test)] +use super::ProfileWitness; +#[cfg(test)] +use super::PinnedPool; /// Layouts, charges and the checked next counters of one pinned triplet upload. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs index 7a3b772c..5d90efa4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs @@ -2,8 +2,11 @@ //! extract-method only). // Stays a glob on purpose: the file is at the 400-line limit and the explicit list would put it over. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, + MoeWeightDescriptor, PinnedPool, PrefixPlan, ProfileLimits, RankedProfile, Result, WORKING_RESERVE, + WeightCacheCounters, binding_error, cache_profile, driver_error, profile_window_spill_with_floor, +}; /// Which sizing and seeding the profile build uses. #[allow(dead_code)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs index be970cc5..9120d462 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs @@ -4,7 +4,12 @@ #[allow(unused_imports)] #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::profile_build::{ProfileFile, ProfileKind, ProfileRequest}; -use super::*; +use super::{ + DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, + WORKING_RESERVE, binding_error, cache_profile, driver_error, +}; +#[cfg(test)] +use super::{Context, PROFILE_SHA, RankedProfile}; /// The room a shared quartet upload must leave free: the spill allowance and the main pool size once the quartet is /// inserted. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs index 3d4effe1..7f659162 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs @@ -1,5 +1,7 @@ //! Private canonical cell producer. It never represents a ready draft/residual. -use super::*; +use super::{Error, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, QwenSession, Result}; +#[cfg(test)] +use super::{Cell, MtpSession, Rc}; use crate::qwen_forward::session::chunk::{ChunkRowResidual, QwenChunkTxn}; // The same validated frame and canonical packed K/V tuple. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs index 72626b18..238c23cf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs @@ -1,8 +1,10 @@ //! Methods of `MtpSession`: `test_chunk_snapshot`, `test_chunk_eq`. //! Split out of `chunk` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +#[cfg(all(test, target_arch = "x86_64"))] +use super::MtpChunkNumericSnapshot; +#[cfg(test)] +use super::{MtpSession, Rc}; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl MtpSession { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs index ae8d78aa..2ebf9e07 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs @@ -1,8 +1,11 @@ //! Methods of `PrefixDraftSnapshot`: `has_prefix`, `numeric_eq`, `retained_bytes`. //! Methods of `MtpSession`: `test_prefix_snapshot`, `admit_snapshot_owner`, `admit_snapshot_frame`. -#[allow(unused_imports)] -use super::*; +use super::{CellPair, Error, HALF_ROW, MtpCheckpoint, MtpFrame, Rc, Result}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::PrefixDraftSnapshot; +#[cfg(test)] +use super::{ModelBinding, MtpSession}; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl PrefixDraftSnapshot { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs index c7de3c36..510c1d5e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + BindingIdentity, Cell, CellPair, DenseKv, Dimension, Error, HALF_ROW, MtpCheckpoint, MtpFrame, MtpSession, + Position, Rc, TokenId, Weak, first_seed_retained_charge, validate_half, +}; use crate::qwen_forward::session::QwenSession; fn draft() -> (MtpSession, MtpFrame) { let binding = BindingIdentity::test_identity(); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs index f5788120..282b5669 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{Error, geometry, validate_window}; #[test] fn mtp_attention_new_causal_geometry_and_budget_boundaries() { for (position, width, half_bytes, scratch) in [ 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 8edf3483..14c39eb8 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 @@ -1,6 +1,11 @@ //! ONE authentic changed MTP boundary. Root schedules this ignored entry only. //! Full heads/state stay private; output contains counts and predicates only. -use super::*; +use super::{ + DenseWeightCache, Dimension, DraftHeadOwners, Error, KarPleCache, KnownNext, ModelBinding, MoeWeightCache, + MtpDecoder, MtpInput, MtpSession, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, Position, + PrefillStepProduct, QwenForward, QwenSession, ReadyMtpChunk, Result, StepSessions, TargetStepProduct, TokenId, + VerificationChunk, VerificationSource, WindowCaches, WindowOwners, mtp, +}; use crate::model_binding::qwen4exp_kar_ple::InheritedKarArchive; use crate::qwen_forward::contract::Stage; use crate::qwen_forward::session::ResetReplaySnapshot; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/chunk.rs index 4d551d2e..8536a674 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/chunk.rs @@ -1,5 +1,5 @@ //! Real ordered MTP warm edges with a jointly published target chunk. -use super::*; +use super::{Error, ModelBinding, MoeWeightCache, MtpDecoder, Result, mtp, reserve}; use crate::qwen_forward::{ mtp::MtpChunkStage, session::chunk::{ChunkDraftPublication, QwenChunkTxn}, 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 d275798c..26821682 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 @@ -1,8 +1,15 @@ //! The methods of `MtpDecoder` that run a window: the batched window (with its plan), the scalar window and the //! draft warm-up. Separate from `mtp_decode`, which holds the decoder itself. -#[allow(unused_imports)] -use super::*; +use super::{ + DenseWeightCache, Dimension, DraftHeadOwners, Error, KarPleCache, KnownNext, ModelBinding, MoeWeightCache, + MtpDecoder, MtpInput, MtpSession, MtpVerifiedWindow, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, + Position, PrefillStepProduct, QwenForward, QwenSession, ReadyMtpChunk, Result, StepSessions, TargetStepProduct, + TokenId, VerificationChunk, VerificationSource, WindowCaches, WindowOwners, first_seed_reuse_enabled, + kv_prefill_host_charge, mtp, needed_draft_predictions, reserve, window_limit, window_stage_error, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::batch_gpu; mod batched_window_plan; mod batched_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/draft_warm_and_window.rs index 9bd966e5..63900082 100644 --- 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/draft_warm_and_window.rs @@ -1,7 +1,10 @@ //! MtpDecoder: draft warming along known-next edges, and the window entry that picks the batched or scalar window. -#[allow(unused_imports)] -use super::*; +use super::{ + Dimension, DraftHeadOwners, Error, KnownNext, ModelBinding, MoeWeightCache, MtpDecoder, MtpInput, MtpSession, + MtpVerifiedWindow, MtpWindowError, MtpWindowRequest, PrefillStepProduct, QwenSession, Result, StepSessions, + TargetStepProduct, TokenId, WindowOwners, kv_prefill_host_charge, mtp, reserve, +}; impl MtpDecoder { pub(crate) fn new(binding: &ModelBinding) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs index b1813f4d..d2b727b2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs @@ -1,8 +1,12 @@ //! Methods of `Role`: `slot`, `output_slot`, `count`. //! Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 11 more. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, DEVICE_PEAK, DeviceBuffer, Error, FF, Finite, FixedBuffers, N, Rc, Result, Role, Slot, Transport, at, + download, moe_driver_error, preflight, validate_values, +}; +#[cfg(test)] +use super::K; impl Role { pub(super) fn slot(self) -> Slot { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs index f7588007..aca3f382 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs @@ -1,8 +1,13 @@ //! Methods of `Packed`: `new`, `pack`, `observe_packed`, `combine`. Methods of `Slot`: `bytes`. //! Implements `Drop for Transport`. Functions: `at`, `routed_hidden`, `routed_down`, `routed` and 8 more. -#[allow(unused_imports)] -use super::*; +use super::{ + CHARGES, Cell, DenseFormat, DeviceBuffer, Error, ExpertInputs, FF, Finite, FixedBuffers, K, N, Packed, + ProjectionKind, ProjectionSpec, QuantizedIndices, Rc, Result, Role, RouteSlot, Slot, Transport, moe_driver_error, + preflight, validate_route, validate_values, +}; +#[cfg(test)] +use super::download; impl Drop for Transport<'_, '_> { fn drop(&mut self) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs index f4b5cb04..fe6cff1e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs @@ -1,8 +1,16 @@ //! Methods of `Packed`: `new`, `pack`, `observe_packed`, `combine`. //! Functions: `shared_project`, `shared_hidden`, `shared_down`, `shared_scaled` and 6 more. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DenseFormat, DeviceBuffer, Error, FF, Finite, K, N, Packed, ProjectionKind, ProjectionSpec, Rc, + Result, Role, RoutedExpert, Transport, at, moe_driver_error, preflight, routed, validate_route, validate_values, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::FixedReference; +#[cfg(test)] +use super::ObservedOutput; +#[cfg(test)] +use super::download; pub(super) fn shared_project( transport: &mut Transport<'_>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs index e2ef6ee9..efae8aa1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{Error, K, down_tile, gate_up_tile, validate_route}; fn fixture(rows: usize, blocks: usize, salt: u8) -> Vec { let mut bytes = vec![0; rows * blocks * 18]; for row in 0..rows { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs index b259f621..e2ecd974 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs @@ -1,6 +1,12 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + Error, ExpertBlobSizes, OriginalMtpGrVariant, RopeConstants, SamplerPath, driver_sampler_params, greedy_params, + legacy_footprint, mtp_full_policy, mtp_pack_experts_needed, mtp_scalar_policy, prefill_layout_options, + sampler_path, verify_geometry, +}; +#[cfg(test)] +use super::legacy_footprint_from; #[test] fn the_pack_expert_bank_is_needed_only_without_an_rt_directory() { // pack-driven draft (no RT directory): the pack's experts are the draft layer's experts diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/env_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/env_tests.rs index b0a9626d..2eed6bf0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/env_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/env_tests.rs @@ -3,7 +3,7 @@ //! `NanGuard::from_environment`): what each spelling selects, and which malformed values are ignored. use super::super::original_spec_adaptive::{AdaptiveConfig, FLOOR_CEILING_LEGACY}; use super::super::original_spec_controller::NanGuard; -use super::*; +use super::{MAX_T, OriginalServeSettings}; use crate::settings::MapEnv; const VOCAB: u32 = 1000; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs index 7b78292a..4763a638 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs @@ -2,7 +2,12 @@ use super::super::original_spec_controller::{NanGuard, OriginalSpecController, SpecConfig, SpecError, SpecWindow}; use super::super::original_spec_draft::{DraftPreparation, DraftSampling, VerifiedWindow}; -use super::*; +use super::{ + ADAPTIVE_DEFAULT, AdaptiveConfig, CommittedWindow, DraftCompletion, DraftLimits, DraftPick, EnvSource, Error, + FirstDraftSeed, MAX_T, OriginalDraftEngine, OriginalFirstDraftEngine, OriginalServeEngine, OriginalServePort, + OriginalServeSettings, OriginalSpecEngine, Rc, Result, ServeCallbacks, ServeOutcome, ServeStop, ServedWindow, + SpeculativeRequest, TargetSeedRow, serve_request, +}; use std::cell::RefCell; const VOCAB: u32 = 1000; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/ple_on_chain/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/ple_on_chain/tests.rs index 7300c7f1..6e76dcd7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/ple_on_chain/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/ple_on_chain/tests.rs @@ -1,6 +1,6 @@ //! The ahead gather asks for exactly the rows the window's own fold asks for. -use super::*; +use super::{PleOnChain, WindowStart, enabled, window_before, window_input}; /// `InputStage::original_window_ple`'s fold: row `i` sees the last two tokens of `predecessors ++ tokens[..i]`. fn folded_before(predecessors: [i32; 2], tokens: &[i32]) -> Vec<[i32; 2]> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs index f6c8f7b8..10f5d4b7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{HostOutcome, RequestSampling, SamplerParams, SamplerPath}; fn greedy() -> SamplerParams { crate::qwen_forward::original_serve_config::greedy_params(1) diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs index 34203e95..790b9fd9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs @@ -1,6 +1,8 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{Error, ExpertJob, HIDDEN, TOP_K, output_offset, plan_experts_where, scatter, selection}; +#[cfg(test)] +use super::plan_experts; fn ids(rows: &[[i32; TOP_K]]) -> Vec { rows.iter().flatten().copied().collect() 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 833a3add..e0b02ba8 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 @@ -1,7 +1,10 @@ //! Unit tests of `original_serve_request`. use super::super::original_serve_engine::ServeStop; -use super::*; +use super::{ + Admission, ENDOFTEXT_TOKEN, Error, RequestOwners, ServeError, ServeOutcome, ServeRequest, SpecError, admit, + original_stop_tokens, run_request, +}; use leleka_cuda_driver::SamplerPath; fn request(prompt: usize, max_new: usize) -> ServeRequest { 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 ee346b0c..04c4d0bf 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 @@ -1,8 +1,14 @@ //! Functions: `open_tier`, `fill_and_pin`, `read_profile`, `warn_decode_headroom` and 15 more. //! Split out of `original_serve_residency` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + AtomicU32, Context, CpuExpertPool, EnvSource, Error, ExpertTierConfig, LOAN_FLOOR, MappedExpertBank, ModelBinding, + MoeWeightCache, ORIGINAL_VERIFY_MAX_PCIE_FETCHES, Ordering, OriginalCacheOptions, OriginalExpertCache, + OriginalGpuStream, OriginalRankedExperts, OriginalServePool, OriginalVerifyCpuRows, OriginalVerifyCpuSink, + OriginalVerifyGpuPlan, OriginalVerifyPcieSource, PathBuf, PcieSplitPolicy, Rc, ResidentExpertBankSpan, Result, + RoutedGroup, SpanCache, StrataPcieAuto, SwapSources, TieOrder, VANILLA_FREE_FLOOR_MIB, VERIFIER_ASSEMBLY_MIB, + driver_error, original_cache_startup, span_cache_enabled, +}; use leleka_cuda_driver::RefillBatchOptions; /// generate.cpp startup of the tier for the serve stack: size and open the cache after every other owner, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs index 7e693e81..0fc54c52 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs @@ -1,6 +1,11 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + EXPERTS, ExpertTierConfig, GroupSplit, LAYERS, PcieLag, PcieMode, PcieSplitPolicy, ResidencyState, RoutedGroup, + VANILLA_FREE_FLOOR_MIB, VERIFIER_ASSEMBLY_MIB, adapt_decay, choose_swaps, split_group_pcie, split_group_tail, +}; +#[cfg(test)] +use super::{choose_swaps_reference, split_group}; #[test] fn adapt_decay_outside_zero_to_one_falls_back_to_the_default_with_a_line() { @@ -107,8 +112,6 @@ fn choose_swaps_timing() { eprintln!("choose_swaps: new {fast:.0} us, reference {slow:.0} us per call ({a} {b})"); } -use super::*; - fn row(ids: [i32; 10]) -> Vec { ids.to_vec() } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tier_env_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tier_env_tests.rs index e7172287..975b24d8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tier_env_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tier_env_tests.rs @@ -1,6 +1,6 @@ //! Golden cases of `ExpertTierConfig::from_source`, the strict parser of the `LELEKA_ORIGINAL_SERVE_*` tier //! switches: a value that does not parse (or fails `validate`) is refused, never ignored. -use super::*; +use super::{ExpertTierConfig, PathBuf, PcieMode, ResidencyState, Result}; use crate::settings::MapEnv; const P: &str = "LELEKA_ORIGINAL_SERVE_"; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs index 21c64c68..20f401d6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ConversationConfig, Error, PromptOptions, RequestStart, ResumeDevice, ServeConversation, TURN_TOKEN}; use crate::backend::original_prompt::{PlanLimits, PromptPath, PromptPlan, ResumePoint}; /// A device whose state is the token list it holds; points are copies of it. A restore is only possible 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/original_serve_stack_methods/open_phase_steps.rs index 3a2a3bf0..48b42a19 100644 --- 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/original_serve_stack_methods/open_phase_steps.rs @@ -2,8 +2,15 @@ //! embedding), in the order `open` runs them. Each step keeps its stage marks, notes and error context. // Stays a glob on purpose: the file is at the 400-line limit and the explicit list would put it over. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, DraftAttachmentTables, DraftAttachmentTarget, Error, ExecutorOpening, ExecutorSizing, + ExecutorTarget, KarPleCache, LOAN_TIER_ROWS, LoanTier, ModelBinding, MoeWeightCache, NativeHeadDispatch, + OriginalExpertCache, OriginalMtpFullOwner, OriginalNativeOutput, OriginalPromptEmbedding, OriginalPromptExecutor, + OriginalServeSettings, OriginalSpecController, PARKED_BYTES_PER_TOKEN, PARKED_STATE_ESTIMATE, PINNED_MODEL, + PrefillLayoutOptions, PrefixServe, PromptWeights, QwenSession, Rc, RtMtpLoad, ServeFailure, StackBlock, + StackConfig, StackState, VOCABULARY, at, dbg_el, failure, operator_note, original_serve_residency, prefill_bytes, + vram_note, +}; use crate::qwen_forward::session::original_prompt::draft::OriginalDraftSession; /// The window policies of the environment: the live one, the parked arms and the widest window any of them needs. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/clock_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/clock_tests.rs index 0574c43a..c8c2a308 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/clock_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/clock_tests.rs @@ -1,7 +1,7 @@ //! The retention clock of the prefix cache on a manual clock (STRA-338 S14). use super::tests::{Fake, G, cfg, request}; -use super::*; +use super::{AnyClock, PrefixServe}; use leleka_obs::time::ManualClock; /// The retention clock is the one the cache was built with (STRA-338 S14): a session survives exactly its retention. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs index 5d3c55a7..e0fd1b35 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs @@ -1,6 +1,10 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + AnyClock, ByteSize, ChunkOutcome, Clock, Consider, Error, PolicyParams, PrefixBudget, PrefixConfig, PrefixDevice, + PrefixMatch, PrefixServe, PrefixStore, PrefixSummary, Reject, Start, Stats, Stopwatch, StoreConfig, TailMode, + budget, +}; use crate::backend::original_prompt::{PlanLimits, PromptOptions, PromptPath, PromptPlan, ResumePoint}; pub(super) const G: usize = 256; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs index 69b63281..f2a4bbe0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + ADMITTED_CAPACITIES, Error, ExpertBlobSizes, KvFormat, LoanTier, PlanError, PrefillLayoutOptions, StackConfig, + TURN_TOKEN, plan_error, prefill_bytes, prefill_layout_options, tier_for, +}; #[test] fn a_chunk_borrows_the_smallest_rung_that_holds_it() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs index c7cbf21c..cba5d972 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs @@ -1,6 +1,8 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + Error, PLE_HISTORY_BYTES, PLE_HISTORY_VALUES, ServeFailure, Stage, assemble_with_window_fallback, window_cap_after, +}; use leleka_cuda_driver::Error as D; #[test] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs index 82dc4af6..354051af 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs @@ -1,7 +1,11 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). use super::super::original_spec_draft::{DraftPick, FirstSeedPoint, OriginalFirstDraftEngine, TargetSeedRow}; -use super::*; +use super::{ + AdaptiveConfig, AdaptivePolicy, Choice, DraftBatch, DraftPlan, DraftPolicy, DraftPreparation, DraftSampling, Error, + MAX_T, NanGuard, Offer, Origin, OriginalDraftEngine, OriginalSpecController, OriginalSpecEngine, PrefixMemo, Rc, + Result, RoundFacts, SpecConfig, SpecError, SpecStats, SpecWindow, SuffixDrafter, VerifiedWindow, +}; mod golden; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs index 0ca188c4..c4f9ece8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs @@ -1,8 +1,13 @@ //! Methods of `OutputStage`: `test_prefix_begin_target`, `test_reset_replay_record`, `test_reset_replay_capture`, `s... //! Functions: `greedy`, `selected_token`, `validate_weight_owner`, `encode_activation` and 4 more. -#[allow(unused_imports)] -use super::*; +use super::{ + ACTIVATION_BYTES, BindingIdentity, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, HeadGreedySelection, + LOGIT_BYTES, LogitValues, OUTPUT_WEIGHT_BYTES, OutputBindingError, OutputWeights, Result, Stage, TokenId, + VOCABULARY, +}; +#[cfg(test)] +use super::OutputStage; // The real ignored reset test opts in explicitly. Other test callers retain // no extra values; production builds have neither this storage nor a reader. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs index e221415b..d7cb62f7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + BindingIdentity, Dimension, Error, FiniteF32, FiniteLogits, LOGIT_BYTES, LogitValues, OutputWeights, Position, + TokenId, VOCABULARY, combine, decode_logits, greedy, validate_weight_owner, +}; fn finite_values(fill: f32) -> Vec { vec![FiniteF32::new(fill).expect("finite fixture"); VOCABULARY] 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 a77d305c..b5da2426 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 @@ -1,5 +1,11 @@ //! Exclusive current-row storage only; no checkpoint or cross-row finite proof. -use super::*; +use super::{ + BindingIdentity, Cell, Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, Q, QsaAttendBuffers, + QsaAttentionStage, QsaPrepared, QsaReady, QsaSelectedCache, QwenStepTxn, Rc, Result, TokenLayer, admit_budget, + attention_driver_error, download, release_retained, validate_values, +}; +#[cfg(test)] +use super::{SelectedKvBytes, attend_retained, gate_retained, release, upload_bytes}; use std::cell::{RefCell, RefMut}; pub(in crate::qwen_forward) const SCRATCH_BYTES: usize = 108_544; 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 887bd046..c8354765 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 @@ -1,5 +1,8 @@ //! Numeric whole-owner test only; never fabricates a model or prepared row. -use super::*; +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 leleka_cuda_driver::{Bf16ProjectionShape, Driver}; use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs index 22db4250..54fe6a15 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs @@ -1,8 +1,14 @@ //! Methods of `QsaOwner`: `new`, `matches`. //! Methods of `QsaPrior`: `oracle_capture_parts`, `test_reset_replay_numeric_eq`, `same_native_kv`, `same_pages` and... -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Directory, Error, KV, LayerId, PackedKv, Position, QsaOwner, QsaPrior, Rc, Result, Stage, State, + reserve, validate_half, validate_ids, validate_values, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::OracleQsaParts; +#[cfg(test)] +use super::PAGE; /// The serving context in cells (262144 unless configured; see `contract::serving_cells`). pub(super) fn context() -> usize { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs index 2c9e6762..f0a66c49 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs @@ -1,6 +1,17 @@ //! Actor-owned bounded index-key mirror; host QsaPrior remains canonical. //! Only exact immutable parent identity permits incremental device publication. -use super::*; +use super::{ + Bf16ProjectionShape, BindingIdentity, BlockQuery, Context, DenseFormat, DenseWeightCache, DeviceBuffer, Directory, + DriverError, Error, GrRole, InputBindingError, KvPage, LayerId, ModelBinding, PAGE, Position, ProjectionKind, + ProjectionSources, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, QsaAttendBuffers, QsaGated, + QsaInputLease, QsaInputScratch, QsaLayerProjection, QsaMatrixKind, QsaMatrixLayout, QsaMatrixRole, QsaOwner, + QsaPrior, QsaSelectedCache, QsaSelectionRequest, QsaWeights, QwenStepTxn, Rc, ResidualReady, Result, Stage, State, + TokenLayer, admit_budget, context, device_peak, driver_error, reserve, select_with_keys, validate_values, +}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::combined_qsa_observer; +#[cfg(test)] +use super::{KV, QsaPending, select}; use std::cell::Cell; const ROW_BYTES: usize = 128 * 4; #[derive(Debug, PartialEq, Eq)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs index ed005940..436d28fd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs @@ -1,8 +1,8 @@ //! Functions: `synthetic_late_prior`, `synthetic_late_prior_for`. //! Split out of `index_resident` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +#[cfg(test)] +use super::{BindingIdentity, Directory, KvPage, LayerId, PAGE, QsaOwner, QsaPrior, Rc, State}; #[cfg(test)] pub(super) fn synthetic_late_prior(position: u64) -> QsaPrior { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/input_reuse_gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/input_reuse_gpu_tests.rs index 36d00af4..bd710af3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/input_reuse_gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/input_reuse_gpu_tests.rs @@ -1,6 +1,9 @@ //! New QSA current-source lease parity; synthetic component, never ModelBinding. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use super::*; +use super::{ + BindingIdentity, Context, DeviceBuffer, Error, QsaInputLease, QsaInputScratch, QsaMatrixKind, QsaMatrixLayout, + QsaMatrixRole, allocate, dispatch_projection, download, input_scratch, project_input_numeric, upload, +}; use crate::qwen_forward::gdn::LeaseClaim; use input_scratch::INPUT_BYTES; use leleka_cuda_driver::Driver; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs index cd80e1c8..1ba96826 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs @@ -5,7 +5,15 @@ use super::super::dense_weight_cache::QsaResident; use super::super::qsa_attention::PromptDevices; use super::super::qsa_prompt_index::PromptChunkOwners; use super::super::session::{TargetStepOrigin, chunk::QwenChunkTxn}; -use super::*; +use super::{ + Bf16ProjectionShape, BindingIdentity, BlockQuery, Cell, Context, DenseFormat, DenseWeightCache, DeviceBuffer, + Directory, DriverError, Error, GrRole, InputBindingError, LayerId, ModelBinding, Position, ProjectionKind, + ProjectionSources, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, QsaAttendBuffers, QsaGated, + QsaIndexKeyCache, QsaInputLease, QsaInputScratch, QsaLayerProjection, QsaMatrixKind, QsaMatrixLayout, + QsaMatrixRole, QsaOwner, QsaPending, QsaPrior, QsaSelectedCache, QsaSelectionRequest, QsaWeights, QwenStepTxn, Rc, + ResidualReady, Result, Stage, TokenLayer, allocate, context, download, driver_error, project, + project_scratch_out_numeric, upload, validate_values, +}; use crate::qwen_forward::prompt_device_rows::PromptWeights; use leleka_cuda_driver::{ CompletedQsaKvAppend, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalQsaDeviceSelection, 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 59b90426..61b07083 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 @@ -3,7 +3,19 @@ //! Root session adapter validates the actual Attention(layer) physical read and //! stores all twelve actual seals before joint target/draft publication. use super::super::super::{input::InputReady, session::QwenSession}; -use super::*; +use super::{ + Bf16ProjectionShape, BindingIdentity, BlockQuery, CompletedQsaKvAppend, Context, DenseFormat, DenseWeightCache, + DeviceBuffer, Directory, DriverError, Error, GrRole, InputBindingError, LayerId, ModelBinding, + NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalQsaDeviceSelection, + OriginalQsaPromptDevice, OriginalQsaPromptWeights, Position, ProjectionKind, ProjectionSources, ProjectionSpec, + PromptChunkOwners, PromptDevices, PromptWeights, Q5KProjectionShape, Q6KProjectionShape, QsaAttendBuffers, + QsaChunkPrior, QsaGated, QsaIndexKeyCache, QsaIndexPrior, QsaInputLease, QsaInputScratch, QsaKvAppendTarget, + QsaLayerProjection, QsaMatrixKind, QsaMatrixLayout, QsaMatrixRole, QsaNativeKind, QsaOwner, QsaPrior, + QsaPromptIndexState, QsaPromptKv, QsaResident, QsaSelectedCache, QsaSelectionRequest, QsaWeights, QwenChunkTxn, + QwenStepTxn, Rc, ResidualReady, Result, Stage, TargetStepOrigin, TokenLayer, allocate, check_prompt_shapes, + context, device_error, download, native, project, project_scratch_out_numeric, prompt_projections, upload, + validate_values, +}; use leleka_cuda_driver::{ OriginalQsaIndexBatch, OriginalQsaIndexCheckpoint, OriginalQsaResidentAppendTarget, OriginalQsaResidentIndex, QsaNativeWeight, ResidentContinuation, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs index bcb2ba60..c179be2c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs @@ -1,7 +1,14 @@ //! Genuine current scalar target/MTP continuation of the same live resident //! layer. Old scalar projection/gate/Out math is retained; no index/page image. use super::resident_qsa_layer::mint; -use super::*; +use super::{ + BindingIdentity, Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, + NativeBatchWorkspace, OriginalQsaIndexCheckpoint, OriginalQsaMappedAppend, OriginalQsaMappedJournal, + OriginalQsaResidentIndex, OriginalQsaResidentTransport, QsaMatrixKind, QsaMatrixRole, QsaResident, QsaWeights, + QwenStepTxn, Rc, ResidentQsaLayer, ResidentQsaPrior, ResidentQsaSeal, ResidualReady, Result, Stage, + TargetStepOrigin, TokenLayer, allocate, device_error, download, project, project_scratch_out_numeric, upload, + validate_values, +}; use leleka_cuda_driver::{ OriginalQsaResidentScalarIndex, OriginalQsaResidentScalarSelection, QsaAttentionInputs, QsaNativeDecode, QsaNativeGate, ResidentContinuation, ScalarStepRows, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs index e1c89836..75d8fa5d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs @@ -8,6 +8,7 @@ use super::{ ScalarOwners, ScalarStep, TargetStepOrigin, TokenLayer, allocate, driver, gate_and_out, mint, upload, validate_values, }; +use crate::qwen_forward::qsa_index::admit_budget; /// The transaction, the input row and the projection branch agree with the layer before any lineage is looked at. fn validate_scalar_row( @@ -90,7 +91,7 @@ impl<'source, 'lease, 'index, 'weights, 'ctx> ResidentQsaScalar<'source, 'lease, let ScalarStep { binding, cache, txn, input } = step; let ScalarOwners { attention, stage, gate_owner } = owners; self.validate(binding, cache, txn, input)?; - super::super::super::admit_budget(self.context)?; + admit_budget(self.context)?; let append = self.kv.append_resident_decode(workspace, stage, &self.prior.0.kv, &self.selected).map_err(driver)?; let attended = self.attend(workspace, attention, &append)?; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache.rs index 6bc7a2a4..3f9127d2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache.rs @@ -1,6 +1,11 @@ //! Lossless selected-cell residency. The immutable host pages remain canonical. //! A lookup address is only an index: every hit also proves a live identical Rc page. -use super::*; +use super::{ + BindingIdentity, Cell, Context, DeviceBuffer, Error, KV, KvPage, QsaOwner, QsaPrepared, QsaPrior, Rc, Result, + device_peak, driver_error, reserve, validate_half, validate_ids, +}; +#[cfg(test)] +use super::{LayerId, Position, QsaPending, TokenLayer}; use leleka_cuda_driver::QsaSelectedKvWorkspace; use std::{collections::HashMap, rc::Weak}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs index 739c075a..f3e52a4e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of the selected-cell cache (moved out of the file by STRA-338; the test ids are unchanged). -use super::*; +use super::{ + BindingIdentity, Error, KV, LayerDirectory, LayerId, Plan, Position, QsaOwner, QsaPending, QsaPrior, Rc, Result, + TokenLayer, plan, +}; use crate::qwen_forward::contract::{Dimension, TokenId}; fn append(prior: &QsaPrior, word: u16) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs index a4d70f47..29121f58 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs @@ -1,6 +1,11 @@ //! Private layer-major staging. Original committed owner never advances here. #![allow(dead_code)] -use super::*; +use super::{ + BindingIdentity, BoundLayerKind, Context, Dimension, Error, FiniteLogits, GdnOwner, GdnPending, GdnPrior, GrRole, + InjectedResidual, InputReady, LayerId, ModelBinding, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, + QsaOwner, QsaPending, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, ThreadId, + TokenId, TokenLayer, chunk, +}; mod txn_groups; mod verify; 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 5d0e640b..9ccf55b9 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 @@ -1,8 +1,16 @@ //! Groups the submodules `qwen_chunk_txn_attention_sources`, `qwen_chunk_txn_begin`, `qwen_chunk_txn_ffn_after_atten... //! Split out of `chunk` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveMicroWindow, AttentionProgress, AttentionSource, BatchProgress, BindingIdentity, BoundLayerKind, + ChunkAttentionRow, ChunkCommit, ChunkDraftPublication, ChunkFfnRow, ChunkMicroWindow, ChunkRowResidual, Context, + Dimension, Error, FfnInjectionRow, FiniteLogits, GdnChunkAnchor, GdnChunkJournal, GdnChunkMicro, GdnChunkRow, + GdnChunkSeal, GdnChunkStart, GdnOwner, GdnPending, GdnPrior, GrRole, InjectedResidual, InputReady, LayerId, + MicroProgress, ModelBinding, PleOwner, PlePending, PlePrior, Position, PreparedLayerRow, PromptInit, QsaIndexPrior, + QsaOwner, QsaPending, QwenChunkTxn, QwenSession, QwenStepTxn, Rc, Result, Row, STATE_CAPACITY, Stage, + TargetStepOrigin, ThreadId, TokenId, TokenLayer, VerifiedDraftPublication, VerifiedTargetPrefix, chunk, + host_charge, host_charge_bounded, +}; mod qwen_chunk_txn_attention_sources; mod qwen_chunk_txn_begin; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs index c287cfb7..53f727f2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs @@ -1,8 +1,12 @@ //! Methods of `QwenChunkTxn`: `check_micro_open`, `micro_misaligned`, `phase_in_flight`, `micro_width` and 19 more. //! Split out of `qwen_chunk_txn` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveMicroWindow, ChunkMicroWindow, Context, Error, LayerId, Position, QsaIndexPrior, QwenChunkTxn, Rc, Result, + STATE_CAPACITY, +}; +#[cfg(test)] +use super::{Dimension, GrRole, InjectedResidual, Stage}; impl<'session, 'driver> QwenChunkTxn<'session, 'driver> { /// A micro window opens only on an idle windowed transaction, at the cursor, for the current layer. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs index f72f2015..45411d88 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs @@ -1,8 +1,13 @@ //! Methods of `TestGdnComponentRows`: `new`, `start`, `row`, `seal`. //! Split out of `chunk` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +#[cfg(all(test, target_arch = "x86_64"))] +use super::TestGdnComponentRows; +#[cfg(test)] +use super::{ + BindingIdentity, Dimension, Error, GdnChunkAnchor, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnPrior, Position, + Rc, Result, TokenId, TokenLayer, +}; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl TestGdnComponentRows { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs index 30a32d38..ed07c9db 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs @@ -1,6 +1,12 @@ //! Private complete-state journal for a bounded target verification window. //! No provisional row is a committed TargetStepProduct or an origin. -use super::*; +use super::{ + ChunkCommit, ChunkRowResidual, Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, GrRole, + InjectedResidual, LayerId, ModelBinding, PlePrior, Position, QsaIndexPrior, QwenChunkTxn, QwenSession, QwenStepTxn, + Rc, Result, Row, STATE_CAPACITY, Stage, TargetStepOrigin, TokenId, TokenLayer, host_charge_bounded, +}; +#[cfg(test)] +use super::{GdnChunkStart, PromptInit}; use crate::qwen_forward::executor::TargetStepProduct; const HOST_LIMIT: usize = 512 * 1024 * 1024; 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 7a32c319..09432b25 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 @@ -1,6 +1,10 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + Dimension, Error, GdnChunkAnchor, GdnChunkStart, HOST_LIMIT, LayerId, PlePrior, Position, PrefixState, PromptInit, + QwenChunkTxn, QwenSession, Rc, Row, Stage, TokenId, TokenLayer, VerificationJournal, greedy_prefix, + host_charge_bounded, verification_extra_charge, +}; fn token(value: u64) -> TokenId { TokenId::new(value, Dimension::new(248320).unwrap()).unwrap() } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs index 6eeff8fb..222fe1a9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs @@ -6,7 +6,12 @@ use super::super::prompt_device_rows::PromptWeights; use super::super::qsa_index::prompt_device::resident_device::{ ParkedLayerSpan, ParkedPrefix, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, ResidentQsaSeal, SpanExport, }; -use super::*; +use super::{ + BindingIdentity, BoundLayerKind, Context, Dimension, Error, FiniteLogits, GdnOwner, GdnPending, GdnPrior, GrRole, + InjectedResidual, InputReady, LayerId, ModelBinding, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, + QsaOwner, QsaPending, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, ThreadId, + TokenId, TokenLayer, chunk, +}; use std::cell::{Cell, RefCell}; pub(in crate::qwen_forward) mod draft; mod prompt_txn_owners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs index 1a74d2fa..f02c4e78 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs @@ -1,6 +1,9 @@ //! Canonical Original INT8 draft owner. Actual immutable driver snapshots are //! bound to the real target branch; end metadata never invents older KV cells. -use super::*; +use super::{ + BindingIdentity, DenseWeightCache, Error, ModelBinding, OriginalPromptTxn, QwenSession, Result, Stage, + TargetStepOrigin, +}; use leleka_cuda_driver::{CompletedDraftKv, CompletedOriginalMtpDraft, Context, MtpInt8Snapshot, MtpOriginalInt8}; pub(in crate::qwen_forward) struct OriginalDraftSession<'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified.rs index 00df7299..d1ea21e8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified.rs @@ -19,7 +19,9 @@ //! describe a position the session does not hold); a checkpoint restore replaces every prior and ends it. use super::super::qsa_index::prompt_device::resident_device::ResidentQsaPrior; use super::checkpoint::{committed_origin, origin_at}; -use super::*; +use super::{ + Dimension, Error, GdnPrior, LayerId, PlePrior, Position, QwenSession, Result, STATE_CAPACITY, TargetStepOrigin, +}; /// Largest verified window (`kVerifyMaxT`). pub(in crate::qwen_forward) const MAX_WINDOW_ROWS: usize = 8; 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 b037c6cf..fbeff6cb 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 @@ -1,6 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{Error, GdnPrior, OriginalVerifiedLineage, PlePrior, QwenSession, STATE_CAPACITY, predecessors_after}; use crate::model_binding::qwen4exp_input::BindingIdentity; fn session(gdn: &[usize], ple: bool) -> QwenSession<'static> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs index 2a5751ed..006c184a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs @@ -1,8 +1,10 @@ //! Methods of `ResetReplaySnapshot`: `has_prefix`, `numeric_eq`, `same_shape`, `retained_bytes`. //! Methods of `QwenSession`: `oracle_capture_committed`, `validate_reset_states`, `validate_reset_ple`, `validate_re... -#[allow(unused_imports)] -use super::*; +#[cfg(all(test, target_arch = "x86_64"))] +use super::ResetReplaySnapshot; +#[cfg(test)] +use super::{Dimension, Error, LayerId, ModelBinding, Position, QwenSession, Result, STATE_CAPACITY}; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl ResetReplaySnapshot { 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 83b03773..000eec53 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs @@ -1,6 +1,10 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + BoundLayerKind, Context, Error, FiniteLogits, GdnOwner, GdnPending, GdnPrior, GrRole, InjectedResidual, InputReady, + LayerId, ModelBinding, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, QsaOwner, QsaPending, QwenSession, + Rc, Result, Stage, TargetStepOrigin, ThreadId, TokenId, TokenLayer, +}; use crate::model_binding::qwen4exp_input::BindingIdentity; use crate::qwen_forward::contract::Dimension; diff --git a/crates/engine-qwen35-cuda/src/serve_meta/tests.rs b/crates/engine-qwen35-cuda/src/serve_meta/tests.rs index eb12cea2..7dcb9731 100644 --- a/crates/engine-qwen35-cuda/src/serve_meta/tests.rs +++ b/crates/engine-qwen35-cuda/src/serve_meta/tests.rs @@ -1,6 +1,9 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::*; +use super::{ + BuildInfo, CacheFacts, ConfigFacts, MODEL_DIGEST_MAPPING, ModelFile, ModelInfo, Path, ProfileInfo, cache_line, + startup_lines, token, +}; const DIGEST: &str = "sha256:80d5e3333801cedbca81a5c19c24ed6bb48fd56977acd190318f66b23a1766a3"; const PROFILE_SHA: &str = "b5ebb652ad9b091e0e045e44d8adeb49fa7319c2f365c2ad150a3d567221e0cb"; diff --git a/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs b/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs index e254e7d6..c7c5c7ac 100644 --- a/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs +++ b/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{OriginalServeOptions, PrefixCacheOptions, PrefixTail, Tuning, describe}; fn base() -> (OriginalServeOptions, u32) { let options = OriginalServeOptions { diff --git a/crates/engine-qwen35-cuda/src/settings/capture_tests.rs b/crates/engine-qwen35-cuda/src/settings/capture_tests.rs index bee15337..9b9ea93b 100644 --- a/crates/engine-qwen35-cuda/src/settings/capture_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/capture_tests.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{EnvSource, MapEnv, ServeSettings, Settings}; #[test] fn only_the_operator_namespace_is_captured() { diff --git a/crates/engine-qwen35-cuda/src/settings/decode_tests.rs b/crates/engine-qwen35-cuda/src/settings/decode_tests.rs index 3619d1e7..2ecbcadb 100644 --- a/crates/engine-qwen35-cuda/src/settings/decode_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/decode_tests.rs @@ -1,5 +1,5 @@ //! Golden cases of the decode topic: each row is what the call site this field replaced returned for that value. -use super::*; +use super::{DecodeSettings, MapEnv, PleOnChain}; fn decode(pairs: &[(&str, &str)]) -> DecodeSettings { DecodeSettings::from_source(&MapEnv::of(pairs)) diff --git a/crates/engine-qwen35-cuda/src/settings/diagnostics_tests.rs b/crates/engine-qwen35-cuda/src/settings/diagnostics_tests.rs index 5a424651..b0dce80e 100644 --- a/crates/engine-qwen35-cuda/src/settings/diagnostics_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/diagnostics_tests.rs @@ -1,5 +1,5 @@ //! Golden cases of the diagnostics topic: each row is what the call site this field replaced returned for that value. -use super::*; +use super::{DiagnosticsSettings, MapEnv}; fn diag(pairs: &[(&str, &str)]) -> DiagnosticsSettings { DiagnosticsSettings::from_source(&MapEnv::of(pairs)) diff --git a/crates/engine-qwen35-cuda/src/settings/kv_tests.rs b/crates/engine-qwen35-cuda/src/settings/kv_tests.rs index 65eac585..0a619cba 100644 --- a/crates/engine-qwen35-cuda/src/settings/kv_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/kv_tests.rs @@ -1,5 +1,5 @@ //! Golden cases of the kv topic: each row is what the call site this field replaced returned for that value. -use super::*; +use super::{KvSettings, MapEnv}; fn kv(pairs: &[(&str, &str)]) -> KvSettings { KvSettings::from_source(&MapEnv::of(pairs)) diff --git a/crates/engine-qwen35-cuda/src/settings/memory_tests.rs b/crates/engine-qwen35-cuda/src/settings/memory_tests.rs index 4f00d787..90484943 100644 --- a/crates/engine-qwen35-cuda/src/settings/memory_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/memory_tests.rs @@ -1,5 +1,5 @@ //! Golden cases of the memory topic: each row is what the call site this field replaced returned for that value. -use super::*; +use super::{MapEnv, MemorySettings}; fn memory(pairs: &[(&str, &str)]) -> MemorySettings { MemorySettings::from_source(&MapEnv::of(pairs)) diff --git a/crates/engine-qwen35-cuda/src/settings/serve_tests.rs b/crates/engine-qwen35-cuda/src/settings/serve_tests.rs index 3abac8b2..1028654d 100644 --- a/crates/engine-qwen35-cuda/src/settings/serve_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/serve_tests.rs @@ -1,6 +1,6 @@ //! Golden cases of the serve topic: each row is what the call site this field replaced returned for that value. use super::parse::*; -use super::*; +use super::{MapEnv, ServeSettings}; fn serve(pairs: &[(&str, &str)]) -> ServeSettings { ServeSettings::from_source(&MapEnv::of(pairs)) From f2bc8884596ad759236f32e53e24ee16edd91499 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 20:57:34 +0100 Subject: [PATCH 3/7] engine-qwen35-cuda: no #[allow(unused_imports)] left (re-exports nobody used are gone, names only the test build needs are cfg(test), names only another platform needs sit under their cfg) Co-Authored-By: Claude Sonnet 5.5 --- .../combined_changed_boundary_proof.rs | 17 ++------ .../src/backend/native_down_candidate_only.rs | 20 +++------- .../adaptive_slots.rs | 22 +++-------- .../src/backend/native_down_public_pair.rs | 22 +++-------- .../src/backend/original_serve.rs | 7 ---- .../src/backend/original_serve/runner.rs | 16 -------- .../original_serve/runner/owner_run_steps.rs | 13 +++---- .../src/backend/original_serve_laptop.rs | 18 +-------- .../src/backend/original_serve_laptop/soak.rs | 19 +-------- .../backend/original_serve_memory_smoke.rs | 17 +------- .../original_serve_memory_smoke/inventory.rs | 20 +--------- .../backend/original_serve_prefix_smoke.rs | 17 +------- .../original_serve_prefix_smoke/workload.rs | 19 +-------- .../src/backend/original_serve_replay.rs | 19 +-------- .../src/backend/original_serve_replay/load.rs | 17 +------- .../src/backend/original_serve_replay/pass.rs | 19 +-------- .../original_serve_replay/required_path.rs | 19 +-------- .../src/backend/original_serve_replay/run.rs | 17 +------- .../src/backend/original_serve_smoke.rs | 17 +------- .../original_serve_smoke/smoke_main.rs | 18 +-------- .../src/backend/original_serve_ttft.rs | 18 +-------- .../src/conversation/memory.rs | 1 - .../src/conversation/mod.rs | 2 - .../src/memory_governor/page_cache.rs | 5 +-- .../src/model_binding/qwen4exp_input.rs | 6 --- .../qwen4exp_input/moe_expert.rs | 8 +--- .../src/model_binding/qwen4exp_input/mtp.rs | 34 +--------------- .../qwen4exp_input/mtp/backing.rs | 8 ++-- .../qwen4exp_input/mtp/mtp_weight_reads.rs | 7 ++-- .../qwen4exp_input/mtp/read_expert_rows.rs | 8 ++-- .../src/model_binding/qwen4exp_kar_ple.rs | 31 ++------------- .../qwen4exp_kar_ple/inherited_kar_archive.rs | 5 +-- .../qwen4exp_kar_ple/inherited_kar_tests.rs | 6 +-- .../load_pinned_inherited_archive.rs | 7 ++-- .../qwen4exp_kar_ple/pinned_profile.rs | 7 ++-- .../qwen4exp_kar_ple/pinned_profile_tests.rs | 5 +-- .../qwen4exp_kar_ple/private_copy.rs | 16 ++------ .../private_copy/checked_reader.rs | 7 ++-- .../qwen4exp_kar_ple/private_copy/inode.rs | 6 ++- .../src/qwen_forward/dense_weight_cache.rs | 2 - .../src/qwen_forward/executor.rs | 7 +--- .../qwen_forward/executor/original_prompt.rs | 5 --- .../qwen_forward/executor/prefill_chunk.rs | 17 +++----- .../executor/prefill_chunk/qwen_forward.rs | 14 +++---- .../prefill_chunk/qwen_forward/joint_chunk.rs | 1 + .../qwen_forward/prefill_chunk_planned.rs | 14 +++---- .../prefill_chunk_planned/window_ffn_flow.rs | 1 - .../executor/prefill_chunk/window_numeric.rs | 9 ++--- .../src/qwen_forward/gdn.rs | 36 +++-------------- .../src/qwen_forward/gdn/chain.rs | 3 +- .../src/qwen_forward/gdn/chunk_device.rs | 16 ++------ .../chunk_device/gdn_chunk_device_methods.rs | 15 ++----- .../gdn/chunk_device/numeric_gpu.rs | 24 ++---------- .../gdn/chunk_device/numeric_gpu/operands.rs | 13 ++----- .../src/qwen_forward/gdn/mirror.rs | 1 - .../src/qwen_forward/gdn/prefill_batch.rs | 8 +--- .../gdn/prefill_batch/gdn_stage.rs | 1 - .../src/qwen_forward/gdn/verification.rs | 1 - .../gdn/verification/compute_row.rs | 1 - .../engine-qwen35-cuda/src/qwen_forward/gr.rs | 20 +--------- .../src/qwen_forward/gr/batch_chunk.rs | 2 - .../qwen_forward/gr/batch_chunk/gr_stage.rs | 1 - .../batch_chunk/gr_stage_prepare_injection.rs | 1 - .../src/qwen_forward/gr/gr_stage.rs | 1 - .../qwen_forward/gr/output_workspace_gpu.rs | 15 ++----- .../gr/output_workspace_gpu/check_handoff.rs | 8 ---- .../gr/output_workspace_gpu/fresh_read.rs | 8 ---- .../src/qwen_forward/input.rs | 21 +--------- .../src/qwen_forward/input/ple_transport.rs | 6 --- .../ple_transport/ple_key_retained_gpu.rs | 12 +----- .../ple_key_retained_gpu/bf16.rs | 5 +-- .../src/qwen_forward/kar_ple_cache.rs | 6 --- .../src/qwen_forward/moe_expert.rs | 39 ++----------------- .../moe_expert/cached_expert_run.rs | 1 - .../src/qwen_forward/moe_expert/grouped.rs | 19 --------- .../moe_expert/grouped/adaptive_packets.rs | 2 - .../moe_expert/grouped/direct_gpu.rs | 35 ++--------------- .../packet_run_project_group_direct.rs | 1 - .../moe_expert/grouped/project_group.rs | 1 - .../grouped/resident/original_adaptive.rs | 2 +- .../moe_expert/moe_activation_reuse_gpu.rs | 13 ------- .../moe_expert/moe_down/moe_down_reuse_gpu.rs | 7 ---- .../down_reuse_refusal_rig.rs | 1 - .../src/qwen_forward/moe_prefill_batch.rs | 8 ---- .../src/qwen_forward/moe_route.rs | 16 +------- .../src/qwen_forward/moe_weight_cache.rs | 12 ++---- .../cache_ephemeral_routed.rs | 6 --- .../moe_weight_cache/cache_lru_index.rs | 1 - .../moe_weight_cache/cache_original_prompt.rs | 5 +-- .../moe_weights_original_prompt.rs | 1 - .../moe_weight_cache/cache_profile.rs | 2 - .../moe_weight_cache/cache_profile_fill.rs | 14 ++----- .../learned_main_lru_profile.rs | 1 - .../cache_profile_fill/moe_weight_cache.rs | 12 ++---- .../shared_quartet_preload.rs | 2 +- .../strata_adaptive_shared_pool.rs | 1 - .../moe_weight_cache/cache_strata_adaptive.rs | 4 -- .../moe_weight_cache/original_mtp_weights.rs | 4 +- .../moe_weight_cache/window_pins.rs | 10 +---- .../src/qwen_forward/mtp.rs | 16 -------- .../src/qwen_forward/mtp/state.rs | 2 - .../src/qwen_forward/mtp/state/chunk.rs | 4 +- .../src/qwen_forward/mtp_attention.rs | 22 ----------- .../mtp_attention/reuse_gpu_tests.rs | 6 +-- .../mtp_attention/reuse_gpu_tests/phases.rs | 6 --- .../src/qwen_forward/mtp_decode.rs | 6 --- .../src/qwen_forward/mtp_decode/batch_gpu.rs | 15 +------ .../mtp_decode/batch_gpu/check_loaded.rs | 18 ++------- .../mtp_decode/batch_gpu/check_loaded/flow.rs | 8 ---- .../flow_decode_edge_scenarios.rs | 8 ---- .../batch_gpu/check_loaded/position_at.rs | 8 ---- .../mtp_decode/batch_gpu/collection.rs | 8 ---- .../qwen_forward/mtp_decode/mtp_decoder.rs | 10 ++--- .../src/qwen_forward/mtp_experts.rs | 32 +-------------- .../mtp_experts/fixed_workspace.rs | 10 +---- .../fixed_workspace/fixed_workspace_gpu.rs | 5 +-- .../mtp_experts/mtp_expert_transport.rs | 11 +----- .../mtp_expert_transport_gpu.rs | 11 ------ .../src/qwen_forward/mtp_gr.rs | 15 ------- .../qwen_forward/original_mtp_full_owner.rs | 3 -- .../original_mtp_verified_adapter.rs | 1 - .../src/qwen_forward/original_serve_engine.rs | 3 -- .../original_serve_engine/round_tally.rs | 6 --- .../original_serve_engine/tests.rs | 8 ++-- .../tests/constructor_validates_dimensions.rs | 7 ---- .../tests/restore_attempts_do_not_depend.rs | 6 --- .../src/qwen_forward/original_serve_host.rs | 12 ++---- .../src/qwen_forward/original_serve_native.rs | 11 ------ .../src/qwen_forward/original_serve_pool.rs | 14 +------ .../qwen_forward/original_serve_request.rs | 5 ++- .../qwen_forward/original_serve_residency.rs | 27 ++----------- .../original_serve_residency/open_tier.rs | 11 +++--- .../src/qwen_forward/original_serve_stack.rs | 11 ------ .../original_serve_stack/lifecycle_fake.rs | 2 +- .../decode_phase_steps.rs | 2 - .../decode_steps.rs | 1 - .../original_serve_stack_open/assemble.rs | 1 - .../original_serve_stack/prefix.rs | 2 - .../original_serve_stack/prefix/tests.rs | 6 +-- .../prefix/tests/one_token_prompt_reads.rs | 7 ---- .../prefix/tests/second_session.rs | 6 --- .../qwen_forward/original_spec_controller.rs | 2 - .../original_spec_controller/tests.rs | 6 +-- .../adaptation_join_failure_is_reported.rs | 7 ---- .../tests/config_rejects_out_of_range.rs | 12 +----- .../tests/non_finite_window.rs | 7 ---- .../src/qwen_forward/original_spec_draft.rs | 2 +- .../src/qwen_forward/output.rs | 8 ---- .../src/qwen_forward/prompt_device_rows.rs | 5 --- .../prompt_device_rows/prompt_device_read.rs | 2 - .../src/qwen_forward/q6_attention_columns.rs | 6 --- .../src/qwen_forward/qsa_attention.rs | 12 ------ .../qsa_attention/attention_scratch/gpu.rs | 2 +- .../qsa_attention/retained_gpu_tests.rs | 6 +-- .../src/qwen_forward/qsa_index.rs | 37 +----------------- .../qwen_forward/qsa_index/index_resident.rs | 22 +++++------ .../qwen_forward/qsa_index/prompt_device.rs | 10 ++--- .../prompt_device/resident_device.rs | 17 +++----- .../resident_device/resident_qsa_completed.rs | 1 - .../resident_qsa_span_export_and_seal.rs | 1 - .../prompt_device/resident_device/scalar.rs | 16 -------- .../src/qwen_forward/qsa_prefill_batch.rs | 26 ------------- .../src/qwen_forward/router_scratch/gpu.rs | 22 +---------- .../qwen_forward/router_scratch/gpu/report.rs | 3 -- .../src/qwen_forward/session/chunk.rs | 12 ++---- .../session/chunk/qwen_chunk_txn.rs | 14 +++---- .../src/qwen_forward/session/chunk/verify.rs | 2 - .../qwen_forward/session/original_prompt.rs | 7 ++-- .../session/original_prompt/draft.rs | 2 - .../src/qwen_forward/session/tests.rs | 5 +-- .../tests/gdn_session_commit_advances_all.rs | 6 --- .../tests/retained_gr_handoff_identity.rs | 6 --- 172 files changed, 244 insertions(+), 1470 deletions(-) diff --git a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs index b51e95ba..b9ca28c8 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs @@ -1,21 +1,10 @@ //! Private sole new changed-path model gate; actual source identity/load preserved. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationExecution, - EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, - GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, - InputBindingError, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, - LoadedModel, MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, - OriginalServeMode, OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, - Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, - SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, close_context, load, thread, + Driver, EvaluationExecution, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, + Tokenizer, VerifiedGgufFile, }; #[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenForward, QwenSession}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners as LoadedTarget; use std::env; pub(super) mod rig; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs index cb8f8217..d9c3d79b 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only.rs @@ -1,20 +1,12 @@ //! Candidate-only PUBLIC quality proof against one retained actual Native arm. //! Historical wall time is never used as an A/B measurement. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, DenseWeightCache, Digest, Dimension, Driver, Duration, ErrorCode, - EvaluationExecution, EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FRAME_LIMIT, - FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, - GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, InputConstants, Instant, - KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, KarPleCache, - LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, ModelBinding, ModelDescriptor, MoeWeightCache, - MtpContinuation, MtpDecoder, MtpWindowError, MtpWindowSpec, Mutex, Ordering, OriginalServeChoice, - OriginalServeMode, OriginalServeOptions, OutputStage, PathBuf, Position, PrefixCacheOptions, PrefixTail, QUEUE, - Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, QwenForward, QwenSession, Rc, Receiver, RecentIds, - ResidentConversations, ResidentPolicy, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, SupportedModelTuple, - SyncSender, SystemClock, TargetStepProduct, TokenId, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, - combined_changed_boundary_proof, emit_terminal, error, generate, generate_mtp_resume, load, measurement, owner, - prepare_prompt, request, session, spawn, thread, + AtomicBool, CacheCounts, DenseWeightCache, Digest, Driver, Duration, EvaluationExecution, EvaluationMeasurement, + FRAME_LIMIT, FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, + GenerationStream, GenerationTerminal, InheritedKarArchive, Instant, KAR_MTP_PROFILE, KarPleCache, MODEL_DIGEST, + ModelBinding, MoeWeightCache, MtpContinuation, Mutex, Ordering, OutputStage, PathBuf, QUEUE, Qwen4ExpArtifact, + QwenForward, QwenSession, Rc, SHARD0, SHARD1, Sha256, Shared, SystemClock, Tokenizer, Usage, VerifiedGgufFile, + WindowWitness, emit_terminal, generate_mtp_resume, measurement, prepare_prompt, request, thread, }; use serde_json::{Value, json}; use std::{ diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs index 97fa3cfb..6adda8f2 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_candidate_only/adaptive_slots.rs @@ -2,25 +2,13 @@ //! No Native inference replay; original paired quality/timing remains separately required. use super::super::combined_changed_boundary_proof::rig::close_context_flags; use super::{ - Arc, AssertUnwindSafe, AtomicBool, AtomicU64, BACKEND_API_VERSION, BASELINE_SHA, Backend, BackendCapabilities, - BackendError, BackendIdentity, Baseline, CAP, CacheCounts, Clock, ContractError, DEVICE_BUDGET, DeferredTail, - Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, - FinishReason, GenerationEvent, GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, - InferenceMode, InheritedKarArchive, InputBindingError, Inputs, KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, - KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, - ModelBinding, ModelDescriptor, Mutex, OpenOptions, OpenOptionsExt, Ordering, OriginalServeChoice, - OriginalServeMode, OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Proof, Qwen4ExpArtifact, - Qwen35Cuda, Qwen35CudaStart, Rc, Read, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, - SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, Value, VerifiedGgufFile, WindowWitness, Write, - baseline, catch_unwind, env, error, fivecase_runtime, json, metadata, path, request, resume_unwind, save, sha, - thread, token_ids, + AssertUnwindSafe, AtomicBool, BASELINE_SHA, Baseline, CAP, DEVICE_BUDGET, Driver, InheritedKarArchive, Inputs, + KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, Mutex, OpenOptions, OpenOptionsExt, PathBuf, Qwen4ExpArtifact, Rc, + Read, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile, baseline, catch_unwind, env, fivecase_runtime, + json, metadata, path, request, resume_unwind, save, sha, token_ids, }; #[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{DenseWeightCache, Instant, KarPleCache, MoeWeightCache, OutputStage}; use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport}; use std::path::Path; diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs index 7bb955cc..94be2c58 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs @@ -1,23 +1,13 @@ //! One-load private PUBLIC generation pair; actual owner timings, never HTTP timings. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationExecution, - EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FRAME_LIMIT, FinishReason, Generation, - GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, - InferenceMode, InheritedKarArchive, InputBindingError, KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, - KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, - ModelBinding, ModelDescriptor, MtpContinuation, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, QUEUE, Qwen4ExpArtifact, Qwen35Cuda, - Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, SupportedModelTuple, - SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, emit_terminal, error, - generate_mtp_resume, load, measurement, owner, request, spawn, thread, + AtomicBool, CacheCounts, Digest, Driver, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, + FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, + GenerationTerminal, InheritedKarArchive, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, MtpContinuation, Mutex, + Ordering, PathBuf, QUEUE, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Sha256, Shared, SystemClock, Tokenizer, Usage, + VerifiedGgufFile, WindowWitness, emit_terminal, generate_mtp_resume, measurement, request, thread, }; #[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, session, -}; +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; #[cfg(test)] use super::prepare_prompt; use serde_json::{Value, json}; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve.rs b/crates/engine-qwen35-cuda/src/backend/original_serve.rs index 11748ae4..e3b2cd26 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve.rs @@ -134,17 +134,10 @@ pub(super) mod runner; mod tests; mod original_serve_mode; -#[allow(unused_imports)] pub(super) use original_serve_mode::choose; -#[allow(unused_imports)] pub(super) use original_serve_mode::context_fits; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] pub(super) use original_serve_mode::current_unsealed; #[cfg(not(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64")))] -#[allow(unused_imports)] pub(super) use original_serve_mode::current_unsealed; -#[allow(unused_imports)] -use original_serve_mode::ineligible; -#[allow(unused_imports)] pub(super) use original_serve_mode::published_prefix_summary; 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 5d67cd7c..0b4a6c61 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner.rs @@ -94,43 +94,27 @@ mod capture_tests { } mod stack_config_and_reports; -#[allow(unused_imports)] use stack_config_and_reports::CapturedIds; -#[allow(unused_imports)] use stack_config_and_reports::PhaseDurations; -#[allow(unused_imports)] use stack_config_and_reports::admission_error; -#[allow(unused_imports)] use stack_config_and_reports::capture_request; -#[allow(unused_imports)] use stack_config_and_reports::gpu_probe; -#[allow(unused_imports)] use stack_config_and_reports::log_request_end; -#[allow(unused_imports)] use stack_config_and_reports::meta_facts; -#[allow(unused_imports)] use stack_config_and_reports::open_error; -#[allow(unused_imports)] use stack_config_and_reports::publish_prefix_summary; -#[allow(unused_imports)] use stack_config_and_reports::stack_config; mod request_generation; -#[allow(unused_imports)] pub(in super::super) use request_generation::generate; -#[allow(unused_imports)] pub(in super::super) use request_generation::{ClientLink, RequestToServe, TokenVocabulary}; mod owner_run_steps; -#[allow(unused_imports)] use owner_run_steps::{ GenerateEnv, RecordedModel, abandon_stack, close_context, close_stack, open_run_stack, publish_open, serve_generate, sweep_idle, }; mod command_loop; -#[allow(unused_imports)] use command_loop::{LoopCtx, announce, answer_unload, command_loop}; mod reconfigure_command; -#[allow(unused_imports)] use reconfigure_command::{Live, ReopenEnv, reconfigure}; mod owner_run; -#[allow(unused_imports)] pub(in super::super) use owner_run::run; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs index 1bb36299..f740d369 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs @@ -2,14 +2,11 @@ //! sweep idle sessions and close everything; early exits stay in `run`. use super::{ - ActiveGuard, Admission, AtomicBool, BackendError, CapturedIds, ClientLink, Clock, Command, DeferredTail, Duration, - ErrorCode, FinishReason, ForwardError, GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationRequest, - GenerationSink, GenerationTerminal, IdleSweep, Live, LoadPhase, LoadedModel, LoopCtx, ModelBinding, Ordering, - OriginalServeOptions, OriginalServeStack, PREFIX_SUMMARY, PathBuf, PhaseDurations, PrefixTail, QUEUE, Rc, Receiver, - ReopenEnv, Reply, RequestToServe, ServeDevice, ServeError, ServeFailure, ServeRequest, ServeStop, Shared, - StackConfig, SystemClock, TokenVocabulary, Tokenizer, Usage, Utf8Pending, context_fits, emit_terminal, exhausted, - generate, invalid, load_failure, meta_facts, open_error, prepare_prompt, publish_prefix_summary, stack_config, - unavailable, + QUEUE, ActiveGuard, AtomicBool, BackendError, ClientLink, DeferredTail, ErrorCode, GenerationFailure, + GenerationRequest, GenerationSink, GenerationTerminal, IdleSweep, LoadedModel, LoadPhase, ModelBinding, Ordering, + OriginalServeOptions, OriginalServeStack, PathBuf, Rc, Reply, RequestToServe, Shared, SystemClock, Tokenizer, + TokenVocabulary, context_fits, emit_terminal, exhausted, generate, invalid, load_failure, meta_facts, open_error, + prepare_prompt, publish_prefix_summary, stack_config, unavailable, }; use leleka_backend_api::GenerationStream; use leleka_cuda_driver::Context; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs index 2fc42d56..3b521e32 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs @@ -27,23 +27,7 @@ //! //! Run: `cargo test -p leleka-engine-qwen35-cuda --features cuda-driver[,sm86] --release -- --ignored --nocapture //! original_serve_laptop_bench`. -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, - Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, - Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, load, request, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile}; use crate::qwen_forward::{ original_serve_engine::ServeOutcome, original_serve_request::{ServeError, ServeRequest}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_laptop/soak.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_laptop/soak.rs index 6fe1fdf3..50bf5b10 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_laptop/soak.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_laptop/soak.rs @@ -1,22 +1,5 @@ //! The serving passes of the laptop bench: the sequence, the soak limits and the per-request reports. -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PathBuf, Plan, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, - Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeOutcome, ServeRequest, - Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, - WindowWitness, elapsed, env, laptop_request, memory_line, request, soak, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{OriginalServeStack, Plan, ServeError, ServeOutcome, ServeRequest, env, laptop_request, memory_line}; /// The serving sequence and the soak limits. pub(super) struct Soak { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs index 6c37b5c1..e4077511 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke.rs @@ -24,21 +24,8 @@ //! Output lines: `MEM-REPORT ` (the governor's full report), `MEM-CENSUS `, `MEM-SOAK ...`, `MEM-SHED //! ...`, `MEM-RESULT`. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, - Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, - Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, probes, spawn, thread, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, session, + Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, + VerifiedGgufFile, }; use crate::qwen_forward::original_serve_stack::dbg_el; use crate::qwen_forward::{ diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/inventory.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/inventory.rs index ff162c1e..d6862d4e 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/inventory.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_memory_smoke/inventory.rs @@ -1,24 +1,6 @@ //! The inventory scenario: the allocation inventory and the load ledger at idle, after a long request and with the //! prefix cache full. -use super::{ - Admission, Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, - BackendIdentity, CacheCounts, Census, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, - EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, - GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, Governor, HostProc, InferenceMode, - InheritedKarArchive, InputBindingError, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, - LOAD_CONFIG_VERSION, Level, LoadedModel, MeasurementFailure, Mem, ModelBinding, ModelDescriptor, Mutex, Ordering, - OriginalServeChoice, OriginalServeMode, OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, - PrefixCacheOptions, PrefixConfig, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, - RecentIds, RequestShape, RuntimeConfig, ServeError, ServeRequest, Sha256, StackConfig, SupportedModelTuple, - SyncSender, SystemClock, Tokenizer, Tolerances, Usage, VerifiedGgufFile, WindowWitness, guard, inventory, list, - number, print_report, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{Mem, list, number, print_report}; /// The number after `key` in a prefix metrics line. fn metric(line: &str, key: &str) -> Option { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs index c706a7de..5203f790 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke.rs @@ -34,21 +34,8 @@ //! Run: `cargo test -p leleka-engine-qwen35-cuda -- --ignored --exact //! backend::original_serve_prefix_smoke::original_serve_prefix_cache_smoke`. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, - Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, - Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, probes, request, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, session, + Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, + VerifiedGgufFile, }; use crate::qwen_forward::original_serve_stack::dbg_el; use crate::qwen_forward::{ diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/workload.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/workload.rs index 52fc8ff5..37033324 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/workload.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_prefix_smoke/workload.rs @@ -1,22 +1,5 @@ //! The knobs and the scripted workload of the prefix-cache smoke (identical for every mode). -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail, - Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, Rng, RuntimeConfig, ServeError, - ServeRequest, Session, Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, - VerifiedGgufFile, WindowWitness, env, filler, number, text, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{Rng, Session, Tokenizer, env, filler, number, text}; /// What the operator asked for. pub(super) struct Plan { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs index d677b729..42ab06d4 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs @@ -30,23 +30,7 @@ //! //! Run (inside a holder job): ` --ignored --nocapture original_serve_replay_smoke`. use super::super::qwen_forward::original_serve_stack::dbg_el; -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, - Receiver, RecentIds, Reply, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, - Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, request, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile}; use crate::qwen_forward::{ original_serve_request::{ServeError, ServeRequest}, original_serve_stack::{OriginalServeStack, PrefixBudget, PrefixConfig, StackConfig}, @@ -65,5 +49,4 @@ fn original_serve_replay_smoke() { } mod required_path; -#[allow(unused_imports)] use required_path::required_path; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/load.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/load.rs index 7bb3f6a1..3a09f647 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/load.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/load.rs @@ -1,21 +1,6 @@ //! The captured requests and the pinned model of the replay. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail, - Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, ServeError, - ServeRequest, Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, - VerifiedGgufFile, WindowWitness, env, required_path, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, + InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, SHARD0, SHARD1, VerifiedGgufFile, env, required_path, }; pub(super) fn number(name: &str, default: usize) -> usize { diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/pass.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/pass.rs index a5cc8693..f18a2d10 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/pass.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/pass.rs @@ -1,24 +1,7 @@ //! One pass of an arm over the captured requests: every recorded prompt served greedily with the recorded output //! length as the budget, and what it printed. use super::load::number; -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail, - Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeRequest, - Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, - WindowWitness, env, load, pass, request, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{OriginalServeStack, PathBuf, ServeError, ServeRequest, env}; use crate::qwen_forward::original_serve_engine::ServeOutcome; use std::time::Duration; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs index cec55230..77c86354 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs @@ -1,24 +1,7 @@ //! Functions: `required_path`. //! Split out of `original_serve_replay` to keep its files under the line limit. -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail, - Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeRequest, - Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, - WindowWitness, env, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{PathBuf, env}; pub(super) fn required_path(name: &str) -> PathBuf { env::var_os(name).map(PathBuf::from).unwrap_or_else(|| panic!("missing operator-owned input {name}")) diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/run.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/run.rs index a5295269..a8fe7d78 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/run.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/run.rs @@ -3,22 +3,7 @@ use super::arm_flags::{self, ArmShape}; use super::load::{self, number}; use super::pass::Replay; use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PathBuf, PrefixBudget, PrefixCacheOptions, PrefixConfig, PrefixTail, - Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, Reply, RuntimeConfig, ServeError, - ServeRequest, Sha256, StackConfig, SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, - VerifiedGgufFile, WindowWitness, config, dbg_el, env, pass, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, + Driver, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget, PrefixConfig, Rc, StackConfig, dbg_el, env, }; use crate::qwen_forward::original_serve_stack::TailMode; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs index c46585b2..1db20934 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs @@ -26,24 +26,11 @@ //! with the first missing producer's name; that refusal is the expected result of this smoke until they land. use super::super::qwen_forward::original_serve_stack::dbg_el; use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, - Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, - Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, load, original_prompt, probes, + Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, + VerifiedGgufFile, }; #[cfg(all(test, target_arch = "x86_64"))] use super::original_serve_arms; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; use crate::qwen_forward::{ original_serve_request::{RequestSampling, ServeError, ServeRequest}, original_serve_stack::{OriginalServeStack, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs index 8c067990..017e513c 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs @@ -1,25 +1,11 @@ //! The main smoke: greedy twice across a reset, a sampled request, a cancellation, the optional parity corpus //! and a short prompt on the scalar draft-KV path. use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, OriginalServeStack, PROMPT, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, - Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeRequest, Sha256, StackConfig, - SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, agent_sampler, - collect, dbg_el, env, env_or, ids, open_pinned, open_stack, optin, report_timing, request, with_context, + OriginalServeStack, PROMPT, PathBuf, ServeError, ServeRequest, StackConfig, Tokenizer, agent_sampler, collect, + dbg_el, env, env_or, open_pinned, open_stack, optin, report_timing, request, with_context, }; #[cfg(all(test, target_arch = "x86_64"))] use super::original_serve_arms; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; mod corpus; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs index d901c80a..cd760f86 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs @@ -11,23 +11,7 @@ //! Inputs: those of the replay (`LELEKA_ORIGINAL_SERVE_REPLAY=yes`, model, expert tier, `LELEKA_REPLAY_CAPACITY`, //! `LELEKA_REPLAY_PREFIX_MIB`, `LELEKA_ORIGINAL_SERVE_RT_DIR`), `LELEKA_SWEEP_MAX_NEW` (4). use super::super::qwen_forward::original_serve_stack::dbg_el; -use super::{ - Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity, - CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, - EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest, - GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, - KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, - MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode, - OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc, - Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock, - Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, load, -}; -#[cfg(feature = "preview-path")] -use super::{ - DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError, - MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy, - TargetStepProduct, TokenId, -}; +use super::{Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile}; use crate::qwen_forward::{ original_serve_request::ServeRequest, original_serve_stack::{OriginalServeStack, PrefixBudget, PrefixConfig, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/conversation/memory.rs b/crates/engine-qwen35-cuda/src/conversation/memory.rs index cf3c5e0e..d56a4d7a 100644 --- a/crates/engine-qwen35-cuda/src/conversation/memory.rs +++ b/crates/engine-qwen35-cuda/src/conversation/memory.rs @@ -5,7 +5,6 @@ //! every ambiguity (malformed, duplicated, wrongly-united, I/O failure) //! reads as unknown so admission fails closed. -use std::io::BufRead; pub use leleka_engine_core::memory::{mem_available, memory_admit}; diff --git a/crates/engine-qwen35-cuda/src/conversation/mod.rs b/crates/engine-qwen35-cuda/src/conversation/mod.rs index d87df263..297daaaa 100644 --- a/crates/engine-qwen35-cuda/src/conversation/mod.rs +++ b/crates/engine-qwen35-cuda/src/conversation/mod.rs @@ -4,8 +4,6 @@ //! The pure policy modules live in `leleka-engine-core::conversation` and are re-exported here under their old paths; //! the CUDA-owner bindings live next to the session owners. -#[cfg(test)] -pub(crate) use leleka_engine_core::conversation::testing; pub use leleka_engine_core::conversation::{ binding, buffer, cache, checked, kv, manager, model, retention, snapshot, state, }; 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 bbe73443..02f599a6 100644 --- a/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs +++ b/crates/engine-qwen35-cuda/src/memory_governor/page_cache.rs @@ -1,9 +1,6 @@ //! Page-cache release after the load (`drop_file_cache`), moved out of `memory_governor` by STRA-338 (size). -use super::{ - BackendError, CacheWish, DeviceSample, Entry, EnvSource, FixedItem, Governor, GovernorConfig, HostFacts, HostProc, - KarForm, Mutex, OpenStage, PlanInput, SamplerGuard, Settings, Space, VramFacts, When, -}; +use super::{Governor, HostFacts, HostProc}; /// Give back the page cache the load created: the shards were read once to verify and to copy the resident bank, and /// nothing reads those pages again (the bank is a RAM copy). Left in place they are the cache pressure that pushed the diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs index 944971c6..ed680078 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs @@ -147,12 +147,6 @@ pub(crate) use native_output::NativeOutputRole; mod binding_identity_and_input_binding_error; mod model_binding; -#[allow(unused_imports)] -use model_binding::bind_expert_counts; mod validate_ple_descriptor; -#[allow(unused_imports)] -use validate_ple_descriptor::bind_layer; -#[allow(unused_imports)] use validate_ple_descriptor::bind_layers; -#[allow(unused_imports)] use validate_ple_descriptor::validate_ple_descriptor; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert.rs index 8850b1e8..a4896dcf 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert.rs @@ -150,22 +150,16 @@ pub(crate) struct MoeRoutedSourceScope<'source, 'group> { } mod moe_expert_weights; -#[allow(unused_imports)] use moe_expert_weights::descriptor; -#[allow(unused_imports)] use moe_expert_weights::index; -#[allow(unused_imports)] +#[cfg(test)] use moe_expert_weights::matrix_kind; -#[allow(unused_imports)] use moe_expert_weights::validate_range; -#[allow(unused_imports)] use moe_expert_weights::validate_selected; mod model_binding; mod routed_source_descriptor; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use routed_source_descriptor::routed_source_descriptor; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use routed_source_descriptor::routed_source_role; mod moe_routed_source_scope; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs index dfae1f25..70a0b676 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp.rs @@ -20,71 +20,41 @@ mod backing; mod tests; mod pack_identity; -#[allow(unused_imports)] use pack_identity::descriptor; -#[allow(unused_imports)] pub(super) use pack_identity::pack_identity; -#[allow(unused_imports)] pub(crate) use pack_identity::pinned_dense_bytes; -#[allow(unused_imports)] pub(crate) use pack_identity::rt_dense_name; -#[allow(unused_imports)] pub(crate) use pack_identity::rt_dense_roles; -#[allow(unused_imports)] pub(crate) use pack_identity::rt_dense_shape; mod mtp_weight_reads; -#[allow(unused_imports)] +#[cfg(test)] use mtp_weight_reads::validate_identity; mod read_expert_rows; -#[allow(unused_imports)] -use read_expert_rows::allocate; -#[allow(unused_imports)] +#[cfg(test)] use read_expert_rows::interleave_q2; -#[allow(unused_imports)] use read_expert_rows::read_exact_range; -#[allow(unused_imports)] use read_expert_rows::read_expert_rows; -#[allow(unused_imports)] use read_expert_rows::row_range; -#[allow(unused_imports)] use read_expert_rows::validate_numeric; mod mtp_kind_types; -#[allow(unused_imports)] use mtp_kind_types::Dense; -#[allow(unused_imports)] use mtp_kind_types::Descriptor; -#[allow(unused_imports)] pub(crate) use mtp_kind_types::MtpExpertMatrix; -#[allow(unused_imports)] pub(crate) use mtp_kind_types::MtpExpertRef; -#[allow(unused_imports)] pub(crate) use mtp_kind_types::MtpKind; -#[allow(unused_imports)] pub(crate) use mtp_kind_types::MtpRole; mod descriptors_types; -#[allow(unused_imports)] use descriptors_types::DESCRIPTORS; mod dense_bytes_types; -#[allow(unused_imports)] use dense_bytes_types::DENSE_BYTES; -#[allow(unused_imports)] use dense_bytes_types::EXPERT_BLOB; -#[allow(unused_imports)] use dense_bytes_types::EXPERT_BYTES; -#[allow(unused_imports)] use dense_bytes_types::FILE_PINS; -#[allow(unused_imports)] use dense_bytes_types::INDEX_BYTES; -#[allow(unused_imports)] use dense_bytes_types::INDEX_LIMIT; -#[allow(unused_imports)] use dense_bytes_types::MAX_READ; -#[allow(unused_imports)] use dense_bytes_types::MAX_ROWS; -#[allow(unused_imports)] use dense_bytes_types::MtpIndex; -#[allow(unused_imports)] pub(crate) use dense_bytes_types::MtpRows; -#[allow(unused_imports)] pub(crate) use dense_bytes_types::MtpWeights; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs index 628f694c..8708bb4b 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs @@ -1,11 +1,9 @@ //! 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. -use super::{ - BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File, - INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix, - MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, read_exact_range, read_expert_rows, -}; +use super::{File, InputBindingError, InputResult, Path}; +#[cfg(test)] +use super::{EXPERT_BLOB, MtpExpertMatrix, MtpKind, read_exact_range, read_expert_rows}; use sha2::{Digest, Sha256}; use std::io::Read; use std::os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt, PermissionsExt}; 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/qwen4exp_input/mtp/mtp_weight_reads.rs index fe25a4b9..e356776b 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs @@ -1,10 +1,9 @@ //! The reads of the MTP weights: dense rows, expert rows and the binding identity check. use super::{ - BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File, - INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix, - MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing, descriptor, read_exact_range, - read_expert_rows, row_range, validate_numeric, + DENSE_BYTES, DESCRIPTORS, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, INDEX_BYTES, MAX_ROWS, BindingIdentity, + InputBindingError, InputResult, ModelBinding, MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, + Path, backing, descriptor, read_exact_range, read_expert_rows, row_range, validate_numeric, }; impl MtpWeights { 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/qwen4exp_input/mtp/read_expert_rows.rs index 74665dbd..bc32d4a8 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs @@ -1,11 +1,9 @@ //! 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. -use super::{ - BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File, - INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix, - MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing, -}; +use super::{EXPERT_BLOB, MAX_READ, MAX_ROWS, File, InputBindingError, InputResult, MtpExpertMatrix, MtpKind, MtpRows}; +#[cfg(not(target_os = "linux"))] +use super::backing; pub(super) fn read_expert_rows( experts: &File, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs index 5d72a7a1..081eea89 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple.rs @@ -123,55 +123,30 @@ mod private_copy; mod inherited_kar_archive; #[cfg(target_os = "linux")] -#[allow(unused_imports)] -use inherited_kar_archive::check_read_only_archive; -#[cfg(target_os = "linux")] -#[allow(unused_imports)] -use inherited_kar_archive::open_read_only_archive; -#[cfg(target_os = "linux")] -#[allow(unused_imports)] use inherited_kar_archive::open_sealed_archive_fd; #[cfg(target_os = "linux")] -#[allow(unused_imports)] use inherited_kar_archive::reopen_read_only_archive; #[cfg(target_os = "linux")] -#[allow(unused_imports)] use inherited_kar_archive::verify_open_provenance; mod load_pinned_inherited_archive; -#[allow(unused_imports)] use load_pinned_inherited_archive::error; -#[allow(unused_imports)] +#[cfg(test)] use load_pinned_inherited_archive::input_diagnostic; -#[allow(unused_imports)] use load_pinned_inherited_archive::input_failure; -#[allow(unused_imports)] +#[cfg(test)] use load_pinned_inherited_archive::kar_diagnostic; -#[allow(unused_imports)] use load_pinned_inherited_archive::kar_failure; #[cfg(target_os = "linux")] -#[allow(unused_imports)] pub(crate) use load_pinned_inherited_archive::load_pinned_inherited_archive; #[cfg(target_os = "windows")] -#[allow(unused_imports)] pub(crate) use load_pinned_inherited_archive::load_pinned_inherited_archive; #[cfg(not(any(target_os = "linux", target_os = "windows")))] -#[allow(unused_imports)] pub(crate) use load_pinned_inherited_archive::load_pinned_inherited_archive; -#[allow(unused_imports)] -use load_pinned_inherited_archive::log_startup_read; mod pinned_profile; #[cfg(target_os = "linux")] -#[allow(unused_imports)] pub(crate) use pinned_profile::load_pinned_archive; #[cfg(not(target_os = "linux"))] -#[allow(unused_imports)] pub(crate) use pinned_profile::load_pinned_archive; -#[allow(unused_imports)] -use pinned_profile::pinned_parts; -#[allow(unused_imports)] pub(crate) use pinned_profile::pinned_profile; -#[allow(unused_imports)] +#[cfg(test)] use pinned_profile::pinned_profile_spec; -#[cfg(target_os = "linux")] -#[allow(unused_imports)] -use pinned_profile::verify_pinned_provenance; 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/qwen4exp_kar_ple/inherited_kar_archive.rs index 16ee32f6..a320d75d 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs @@ -2,9 +2,8 @@ //! Functions: `open_sealed_archive_fd`, `open_read_only_archive`, `check_read_only_archive`, `reopen_read_only_archi... use super::{ - ARCHIVE_DIGEST, BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, - KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, - PathBuf, RefCell, SparseArchive, VerifiedKarPleArtifact, private_copy, + ARCHIVE_DIGEST, PINNED_ARCHIVE_BYTES, PROVENANCE_DIGEST, File, InheritedKarArchive, InputBindingError, + InputResult, Path, PathBuf, SparseArchive, private_copy, }; use leleka_model_format::weight_source::{BackingKind, FileWeightSource, Verification, WeightIdentity}; 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/qwen4exp_kar_ple/inherited_kar_tests.rs index 64bd0485..36892039 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_tests.rs @@ -1,10 +1,6 @@ //! New real Linux seal/FD gate; tiny metadata fixture, no CUDA/model capability. #![cfg(target_os = "linux")] -use super::{ - BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPlePartProvenance, - KarPleProfile, KarPleProfileSpec, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, - VerifiedKarPleArtifact, -}; +use super::{File, InheritedKarArchive, InputBindingError, PINNED_ARCHIVE_BYTES, PROVENANCE_DIGEST, PathBuf}; #[cfg(target_os = "linux")] use super::{open_sealed_archive_fd, verify_open_provenance}; use rustix::fs::{MemfdFlags, SealFlags, fcntl_add_seals, fcntl_get_seals, memfd_create}; 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/qwen4exp_kar_ple/load_pinned_inherited_archive.rs index 5be59a2a..8f8bcde2 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/qwen4exp_kar_ple/load_pinned_inherited_archive.rs @@ -2,10 +2,9 @@ //! Functions: `open_archive_reader`, `load_pinned_inherited_archive`, `log_startup_read`, `load_pinned_inherited_arc... use super::{ - BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPleBinding, - KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, KarRowPacket, KarRowReader, LoadPhase, NATIVE_DIGESTS, - PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, VerifiedKarPleArtifact, - open_sealed_archive_fd, pinned_profile, reopen_read_only_archive, verify_open_provenance, + NATIVE_DIGESTS, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, BindingIdentity, File, InheritedKarArchive, + InputBindingError, InputResult, KarError, KarPleBinding, KarRowPacket, KarRowReader, LoadPhase, RefCell, + VerifiedKarPleArtifact, open_sealed_archive_fd, pinned_profile, reopen_read_only_archive, verify_open_provenance, }; /// The read handle of the inherited archive: a read-only reopen of the file, or the sealed memfd itself. diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs index eb2263ce..b3588b0d 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs @@ -2,10 +2,9 @@ //! Functions: `pinned_profile`, `pinned_parts`, `pinned_profile_spec`, `load_pinned_archive` and 3 more. use super::{ - ARCHIVE_DIGEST, BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, - KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PART0_F32_DIGEST, - PART1_F32_DIGEST, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, VIRTUAL_F32_DIGEST, VerifiedKarPleArtifact, - error, input_failure, kar_failure, private_copy, + ARCHIVE_DIGEST, NATIVE_DIGESTS, PART0_F32_DIGEST, PART1_F32_DIGEST, PROVENANCE_DIGEST, VIRTUAL_F32_DIGEST, File, + InheritedKarArchive, InputBindingError, InputResult, KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, + LoadPhase, Path, VerifiedKarPleArtifact, error, input_failure, kar_failure, private_copy, }; /// Candidate expectations from independently verified v4 conversion receipts 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/qwen4exp_kar_ple/pinned_profile_tests.rs index 765a889f..fb64dc2c 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs @@ -2,9 +2,8 @@ //! Functions: `diagnostic_cases`, `assert_kar_diagnostic_redacts`, `assert_input_diagnostic_survives_broken_sink`, `... use super::{ - BindingIdentity, File, InputBindingError, InputResult, KarError, KarPlePartProvenance, KarPleProfile, - KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PLE_ROWS, Path, PathBuf, RefCell, VerifiedKarPleArtifact, error, - input_diagnostic, kar_diagnostic, pinned_profile, pinned_profile_spec, + NATIVE_DIGESTS, PLE_ROWS, InputBindingError, KarError, LoadPhase, error, input_diagnostic, kar_diagnostic, + pinned_profile, pinned_profile_spec, }; #[cfg(not(target_os = "windows"))] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs index 192da567..0d39f35c 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs @@ -283,32 +283,24 @@ mod private_loader_tests { } mod inode; -#[allow(unused_imports)] +#[cfg(test)] use inode::diagnostic; #[cfg(target_os = "linux")] -#[allow(unused_imports)] pub(super) use inode::freeze; #[cfg(target_os = "macos")] -#[allow(unused_imports)] pub(super) use inode::freeze; -#[allow(unused_imports)] +#[cfg(target_os = "macos")] use inode::inode; -#[allow(unused_imports)] pub(super) use inode::open_regular; -#[allow(unused_imports)] +#[cfg(target_os = "macos")] use inode::phase_error; #[cfg(target_os = "macos")] -#[allow(unused_imports)] use inode::protected_root; -#[allow(unused_imports)] pub(super) use inode::provenance_error; -#[allow(unused_imports)] use inode::report_io; mod checked_reader; #[cfg(target_os = "macos")] -#[allow(unused_imports)] use checked_reader::checked_reader; -#[allow(unused_imports)] use checked_reader::copy_exact; -#[allow(unused_imports)] +#[cfg(test)] use checked_reader::copy_exact_reporting; 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/qwen4exp_kar_ple/private_copy/checked_reader.rs index c38b579c..f3886295 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/qwen4exp_kar_ple/private_copy/checked_reader.rs @@ -1,10 +1,9 @@ //! 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. -use super::{ - COPY_BUFFER, File, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions, - OpenOptionsExt, Path, Read, SOURCE_FLAGS, Seek, Write, inode, input_failure, phase_error, report_io, -}; +use super::{COPY_BUFFER, InputBindingError, InputResult, IoPhase, LoadPhase, Read, Write, input_failure, report_io}; +#[cfg(not(target_os = "linux"))] +use super::{SOURCE_FLAGS, File, Metadata, MetadataExt, OpenOptions, OpenOptionsExt, Seek, inode, phase_error}; #[cfg(target_os = "macos")] pub(super) fn checked_reader(own: &OwnedCopy, bytes: u64) -> InputResult { 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/qwen4exp_kar_ple/private_copy/inode.rs index 2a04e19b..b6afbfbe 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs @@ -2,9 +2,11 @@ //! Functions: `inode`, `diagnostic`, `report_io`, `phase_error` and 8 more. use super::{ - File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions, - OpenOptionsExt, Path, Read, SOURCE_FLAGS, Seek, Write, checked_reader, copy_exact, input_failure, + SOURCE_FLAGS, File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, + OpenOptions, OpenOptionsExt, Path, Seek, Write, copy_exact, input_failure, }; +#[cfg(not(target_os = "linux"))] +use super::{Read, checked_reader}; pub(super) fn inode(meta: &Metadata) -> Inode { (meta.dev(), meta.ino()) 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 efe08320..72ba859c 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 @@ -97,8 +97,6 @@ mod dense_slab_policy; mod workspaces; use workspaces::Workspaces; mod dense_weight_cache_methods; -#[allow(unused_imports)] use dense_slab_policy::dense_slab_policy; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use dense_slab_policy::startup_step; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs index dbe18fd8..54d43a73 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor.rs @@ -77,7 +77,6 @@ pub(crate) struct QwenForward; mod tests; mod prefill_step_product; -#[allow(unused_imports)] use prefill_step_product::diagnose; mod qwen_forward; mod read_layer_attention; @@ -85,15 +84,11 @@ mod step_layers; mod step_request; mod step_residual_capture; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use read_layer_attention::LayerEntry; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use read_layer_attention::prepare_layer_attention_micro; -#[allow(unused_imports)] use read_layer_attention::read_layer_attention; -#[allow(unused_imports)] +#[cfg(test)] use read_layer_attention::validate_descriptors; -#[allow(unused_imports)] use read_layer_attention::validate_layer_plan; pub(crate) use step_request::{StepCaches, StepPurpose, StepRequest}; 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 031f1752..7908febc 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 @@ -151,14 +151,9 @@ mod prompt_chunk_operands; pub(in crate::qwen_forward) use prompt_chunk_operands::{ ChunkCaches, ChunkDraft, PromptChunkSource, PromptChunkTarget, }; -#[allow(unused_imports)] use prompt_chunk_operands::{ChunkInFlight, ChunkRollback, ChunkWork, OpenChunk}; mod staged_input_enabled; -#[allow(unused_imports)] use staged_input_enabled::staged_input_enabled; mod original_prompt_executor; mod original_prompt_executor_drop; -#[allow(unused_imports)] use original_prompt_executor_drop::driver_error; -#[allow(unused_imports)] -pub(in crate::qwen_forward) use original_prompt_executor_drop::run_original_prompt; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs index 095553e6..c19701ab 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs @@ -4,13 +4,13 @@ #![allow(dead_code)] use super::super::session::chunk::QwenChunkTxn; use super::{ - BindingIdentity, BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage, - InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage, - MoeWeightCache, OutputStage, Position, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenForward, - QwenSession, QwenStepTxn, Result, Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, - TokenId, VerificationChunk, VerificationSource, WindowCaches, diagnose, prefill_chunk, - prepare_layer_attention_micro, read_layer_attention, validate_layer_plan, + BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrStage, InjectedResidual, InputStage, + KarPleCache, LayerEntry, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, + Position, QsaAttentionStage, QsaIndexStage, QwenForward, QwenSession, QwenStepTxn, Result, Stage, TargetStepProduct, + TokenId, diagnose, prepare_layer_attention_micro, read_layer_attention, validate_layer_plan, }; +#[cfg(test)] +use super::{StepCaches, StepRequest}; #[derive(Clone, Copy)] enum ChunkMoePolicy { Native, @@ -32,22 +32,17 @@ mod window_numeric; mod native_mmq_evaluation; mod target_step_product; -#[allow(unused_imports)] use target_step_product::chunk_diagnostic; mod qwen_forward; pub(crate) use qwen_forward::PrefillChunkInputs; use qwen_forward::PrefillChunkPlan; mod prepare_micro_ffn_rows; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use prepare_micro_ffn_rows::{MicroEnv, prepare_micro_ffn_rows}; mod prepare_q6_layer_columns; -#[allow(unused_imports)] use prepare_q6_layer_columns::prepare_q6_layer_columns; mod check_chunk_on_loaded; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] pub(in crate::qwen_forward) use check_chunk_on_loaded::check_chunk_on_loaded; mod read_chunk_attention_ffn; -#[allow(unused_imports)] use read_chunk_attention_ffn::{AttentionHandoff, read_chunk_attention_ffn}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs index be175d50..0642643c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs @@ -2,19 +2,17 @@ //! Split out of `prefill_chunk` to keep its files under the line limit. use super::{ - AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, - ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, - ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, QsaAttentionStage, - QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, Stage, StepCaches, - StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, TokenId, VerificationChunk, VerificationSource, - WindowCaches, chunk_diagnostic, diagnose, prefill_chunk, prepare_layer_attention_micro, prepare_micro_ffn_rows, - prepare_q6_layer_columns, qwen_forward, read_chunk_attention_ffn, read_layer_attention, validate_layer_plan, + AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, + GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, ModelBinding, MoeExpertStage, + MoeRouteStage, MoeWeightCache, OutputStage, Position, QsaAttentionStage, QsaIndexStage, QwenChunkTxn, QwenForward, + QwenSession, QwenStepTxn, Result, Stage, TargetStepProduct, TokenId, chunk_diagnostic, diagnose, + prepare_layer_attention_micro, prepare_micro_ffn_rows, prepare_q6_layer_columns, read_chunk_attention_ffn, + read_layer_attention, validate_layer_plan, }; #[cfg(all(test, target_arch = "x86_64"))] use super::{check_chunk_on_loaded, window_numeric}; mod joint_chunk; -#[allow(unused_imports)] use joint_chunk::AllocationTrace; pub(crate) use joint_chunk::PrefillChunkInputs; pub(super) use joint_chunk::PrefillChunkPlan; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs index 2c67420a..c431cae6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs @@ -7,6 +7,7 @@ use super::{ #[cfg(all(test, target_arch = "x86_64"))] use super::window_numeric; use crate::qwen_forward::mtp_decode::MtpDecoder; +#[cfg(test)] use leleka_cuda_driver::Context; /// The borrowed inputs of one prefill chunk (the session and the MoE cache travel beside them). diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs index 4db0ebcc..858c0c53 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs @@ -2,14 +2,12 @@ //! Defines `MicroBank`, `MicroBank`, `NativeMoe` and 6 more. use super::{ - AllocationTrace, AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, - Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, - MicroEnv, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, - PrefillChunkPlan, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, - QwenStepTxn, Result, Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TokenId, VerificationChunk, - VerificationSource, WindowCaches, chunk_diagnostic, diagnose, prepare_layer_attention_micro, - prepare_micro_ffn_rows, prepare_q6_layer_columns, qwen_forward, read_chunk_attention_ffn, read_layer_attention, - validate_layer_plan, + AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, + GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, ModelBinding, MoeExpertStage, + MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, PrefillChunkPlan, QsaAttentionStage, + QsaIndexStage, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, Stage, TokenId, chunk_diagnostic, + diagnose, prepare_layer_attention_micro, prepare_micro_ffn_rows, prepare_q6_layer_columns, read_chunk_attention_ffn, + read_layer_attention, validate_layer_plan, }; #[cfg(all(test, target_arch = "x86_64"))] use super::window_numeric; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs index ad336e50..e920ac5d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs @@ -9,7 +9,6 @@ use crate::qwen_forward::contract::TokenLayer; use crate::qwen_forward::gr::{DetachedGrRead, GrRead}; use crate::qwen_forward::moe_expert::PreparedMoeRow; use crate::qwen_forward::q6_attention_columns::ProjectionRow; -use crate::qwen_forward::qsa_attention::QsaReady; impl QwenForward { /// Attention, FFN read and routing of one row on the host stages; the policy selects the retained GR flow or the diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs index 6f76e6a6..7d7a2612 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric.rs @@ -2,12 +2,9 @@ //! The returned report owns only counts/booleans; its assertions belong AFTER //! the caller has closed all actual GPU owners and checked allocated_bytes=0. use super::{ - AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, GdnStage, - GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, ModelBinding, - MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, PrefillChunkPlan, - QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, - Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, TokenId, VerificationChunk, - VerificationSource, WindowCaches, qwen_forward, + ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, + Position, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, QwenSession, Result, Stage, StepCaches, + StepRequest, TargetStepProduct, TokenId, }; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; use crate::qwen_forward::mtp_decode::MtpDecoder; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs index 9e21b4fd..6783fc0e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs @@ -196,8 +196,6 @@ mod tests { } } -#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -pub(crate) use chunk_device::numeric_gpu::run_gdn_chunk_numeric; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod four_borrow_gpu; @@ -211,69 +209,45 @@ pub(in crate::qwen_forward) use prompt_device::{PromptLayer, PromptProgram, Prom mod cached_step; mod gdn_ready; mod stage_steps; -#[allow(unused_imports)] use cached_step::preflight_budget; -#[allow(unused_imports)] use cached_step::project_chain_input; -#[allow(unused_imports)] use cached_step::step_cached; mod projection; -#[allow(unused_imports)] use projection::convolve; -#[allow(unused_imports)] use projection::dispatch_projection; -#[allow(unused_imports)] use projection::normalize_qk; -#[allow(unused_imports)] +#[cfg(test)] use projection::project_retained; -#[allow(unused_imports)] use projection::{ProjectionOperands, project}; mod gates; -#[allow(unused_imports)] use gates::{GateHostOperands, OutNormScale}; mod step_operands; -#[allow(unused_imports)] +#[cfg(test)] use gates::all_finite; -#[allow(unused_imports)] use gates::allocate; -#[allow(unused_imports)] use gates::binding_error; -#[allow(unused_imports)] use gates::download; -#[allow(unused_imports)] use gates::download_unchecked; -#[allow(unused_imports)] use gates::gates; -#[allow(unused_imports)] use gates::out_norm; -#[allow(unused_imports)] pub(super) use gates::pool_enabled; -#[allow(unused_imports)] use gates::recur; -#[allow(unused_imports)] use gates::release; -#[allow(unused_imports)] +#[cfg(test)] pub(crate) use gates::set_pool_override; -#[allow(unused_imports)] use gates::upload; -#[allow(unused_imports)] use gates::validate_values; -#[allow(unused_imports)] use gates::zeros; -#[allow(unused_imports)] use step_operands::MirrorStep; -#[allow(unused_imports)] pub(in crate::qwen_forward) use step_operands::{ DeviceChunkRow, GdnLayerInput, GdnMatrixLayout, LeaseClaim, LeasedProjection, MirrorAuthority, ProjectedQkvSource, ReadoutClaim, RecurrenceOperands, }; mod driver_error; -#[allow(unused_imports)] pub(super) use driver_error::driver_error; -#[allow(unused_imports)] +#[cfg(test)] use driver_error::key_head; -#[allow(unused_imports)] +#[cfg(test)] use driver_error::state_index; #[cfg(test)] -#[allow(unused_imports)] use driver_error::validate_candidates; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain.rs index e2e53cdb..a7ddb479 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain.rs @@ -331,9 +331,8 @@ mod retained_qk_gpu { } mod allocate_qk_slot; -#[allow(unused_imports)] +#[cfg(test)] use allocate_qk_slot::allocate_qk_slot; -#[allow(unused_imports)] use allocate_qk_slot::normalize_retained_qk; mod chain; mod chain_drop; 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 757f9fa4..953c6c11 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 @@ -3,18 +3,10 @@ use super::super::session::chunk::GdnChunkMicro; use super::super::session::chunk::{GdnChunkRow, GdnChunkSeal, GdnChunkStart}; use super::{ - ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, Context, DenseFormat, DenseWeightCache, - DeviceBuffer, DeviceChunkRow, Dimension, DriverError, Error, GateHostOperands, GdnInputLease, GdnInputScratch, - GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, GdnStateKey, - GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, InputBindingError, LayerId, LeaseClaim, LeasedProjection, - MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, ProjectedQkvSource, ProjectionKind, ProjectionOperands, - ProjectionSpec, PromptLayer, PromptProgram, PromptSource, Q5KProjectionShape, Q6KProjectionShape, QkScratch, - QwenStepTxn, ReadoutClaim, RecurrenceOperands, ResidualReady, Result, STATE_ELEMENTS, Stage, TokenLayer, VALUES, - allocate, chain, download, download_unchecked, driver_error, pool_enabled, preflight_budget, release, state, - upload, validate_values, verification, + BindingIdentity, Context, DenseWeightCache, DeviceBuffer, Error, GdnPrior, HISTORY_ELEMENTS, ModelBinding, Result, + STATE_ELEMENTS, TokenLayer, VALUES, allocate, download, download_unchecked, driver_error, pool_enabled, + preflight_budget, upload, validate_values, }; -#[cfg(test)] -use super::CHANNELS; use leleka_cuda_driver::{GdnRowQueue, GdnStateFiniteGuard}; use std::{cell::Cell, rc::Rc}; pub(in crate::qwen_forward) const CHUNK_DEVICE_CHARGE: usize = 2 * STATE_ELEMENTS * 4 + 4; @@ -66,9 +58,7 @@ pub(in crate::qwen_forward) mod numeric_gpu; mod mirror_reuse_enabled; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use mirror_reuse_enabled::micro_rows; -#[allow(unused_imports)] use mirror_reuse_enabled::mirror_reuse_enabled; mod gdn_chunk_device_methods; 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/gdn_chunk_device_methods.rs index ebcd590f..abb0f45f 100644 --- 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/gdn_chunk_device_methods.rs @@ -2,17 +2,10 @@ //! Split out of `chunk_device` to keep its files under the line limit. use super::{ - ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, - ChunkReadout, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, Dimension, DriverError, Error, - GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease, - GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, - GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, - InputBindingError, LayerId, LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, - ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource, - Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, Rc, ReadoutClaim, ReadoutDownload, - RecurrenceOperands, ResidualReady, Result, STATE_ELEMENTS, Stage, TokenLayer, VALUES, allocate, chain, download, - download_unchecked, driver_error, micro_rows, mirror_reuse_enabled, pool_enabled, preflight_budget, release, state, - upload, validate_values, verification, + BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, ChunkReadout, Context, DenseWeightCache, DeviceBuffer, Error, + GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnPrior, GdnRowQueue, HISTORY_ELEMENTS, + ModelBinding, Rc, ReadoutDownload, Result, STATE_ELEMENTS, VALUES, allocate, download, download_unchecked, + driver_error, micro_rows, mirror_reuse_enabled, pool_enabled, preflight_budget, upload, validate_values, }; mod chunk_device_batch_compute; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs index 346878c5..0f8a3a3e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs @@ -4,16 +4,9 @@ use super::super::super::contract::{Dimension, LayerId}; use super::super::super::session::chunk::TestGdnComponentRows; use super::super::{RecurrenceOperands, convolve, recur}; use super::{ - ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHANNELS, CHUNK_DEVICE_CHARGE, Cell, - ChunkReadout, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, DriverError, Error, - GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease, - GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, - GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, - InputBindingError, LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, - ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource, - Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, Rc, ReadoutClaim, ResidualReady, Result, - STATE_ELEMENTS, Stage, TokenLayer, allocate, chain, download, driver_error, preflight_budget, release, state, - upload, validate_values, + BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkReadout, Context, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, + GdnChunkSeal, GdnChunkStart, GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, Rc, Result, STATE_ELEMENTS, allocate, + download, driver_error, preflight_budget, upload, validate_values, }; use leleka_cuda_driver::Driver; @@ -65,25 +58,14 @@ fn batch_adoption_is_consecutive_atomic_and_swaps_the_final_state_once() { } mod operands; -#[allow(unused_imports)] use operands::component_owner; -#[allow(unused_imports)] use operands::convolution_input; -#[allow(unused_imports)] use operands::convolution_weights; -#[allow(unused_imports)] use operands::difference; -#[allow(unused_imports)] use operands::operands; -#[allow(unused_imports)] use operands::reference; -#[allow(unused_imports)] use operands::require; mod exercise; -#[allow(unused_imports)] -use exercise::exercise; -#[allow(unused_imports)] pub(crate) use exercise::run_gdn_chunk_numeric; mod batch_adoption; -#[allow(unused_imports)] use batch_adoption::batch_adoption; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs index 63023748..e67ac3d2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs @@ -2,16 +2,9 @@ //! Functions: `operands`, `convolution_input`, `convolution_weights`, `difference` and 3 more. use super::{ - ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHANNELS, CHUNK_DEVICE_CHARGE, Cell, - Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, Dimension, Driver, DriverError, Error, - GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease, - GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, - GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, InputBindingError, LayerId, - LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, Operands, OutNormScale, - ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource, - Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, ROWS, Rc, ReadoutClaim, RecurrenceOperands, - Reference, ResidualReady, Result, STATE_ELEMENTS, Stage, TestGdnComponentRows, TokenLayer, allocate, chain, - convolve, driver_error, preflight_budget, recur, state, upload, validate_values, + CHUNK_DEVICE_CHARGE, Cell, Context, Error, GdnChunkDevice, GdnChunkStart, GdnPrior, Operands, ROWS, Rc, + RecurrenceOperands, Reference, Result, STATE_ELEMENTS, allocate, convolve, driver_error, preflight_budget, recur, + upload, validate_values, }; impl Operands { 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 4ad5b0d4..8f928b7d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror.rs @@ -74,5 +74,4 @@ mod gpu_tests; mod gdn_state_mirror_methods; mod mirror_readout; mod upload_checked; -#[allow(unused_imports)] use upload_checked::upload_checked; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs index a2bac559..0a986ef5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch.rs @@ -132,16 +132,10 @@ mod tests { mod gpu; mod gdn_batch_resources; -#[allow(unused_imports)] -use gdn_batch_resources::admit_batch_bytes; -#[allow(unused_imports)] +#[cfg(test)] pub(in crate::qwen_forward) use gdn_batch_resources::batch_device_bytes; -#[allow(unused_imports)] use gdn_batch_resources::f32_bytes; -#[allow(unused_imports)] use gdn_batch_resources::native_format; mod buffers; -#[allow(unused_imports)] -use buffers::release_pool; mod gdn_stage; mod step_batch; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs index ecd8e9e8..7b8ba09e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs @@ -1,7 +1,6 @@ //! Methods of `GdnStage`: `step_chunk_batch`. //! Split out of `prefill_batch` to keep its files under the line limit. -#[allow(unused_imports)] use super::step_batch::{ check_gdn_window, gather_gdn_rows, gdn_operands, latch_cuda_failure, prepare_or_refuse, run_gdn_program, settle_gdn, window_bytes, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs index 42607b35..5df07186 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification.rs @@ -79,6 +79,5 @@ pub(super) struct PoolRow<'ctx> { mod numeric_gpu; mod compute_row; -#[allow(unused_imports)] pub(super) use compute_row::compute_row; mod workspace; 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 ab502315..8e5c7a15 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 @@ -9,7 +9,6 @@ use super::{ }; mod verified_row_compute_and_lease; -#[allow(unused_imports)] pub(in super::super) use verified_row_compute_and_lease::compute_row; mod workspace; mod workspace_replay; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs index 2656cbc2..014e2fde 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr.rs @@ -93,9 +93,8 @@ mod gr_residual_reuse_gpu; mod batch_chunk; pub(in crate::qwen_forward) use batch_chunk::GrBatchRow; -pub(in crate::qwen_forward) use batch_chunk::GrMicroAttentionBlock as GrMicroBlock; pub(in crate::qwen_forward) use batch_chunk::{ - GrMicroAttention, GrMicroAttentionBank, GrMicroAttentionBlock, GrMicroInput, MicroBlockRequest, + GrMicroAttentionBank, GrMicroAttentionBlock, GrMicroInput, MicroBlockRequest, }; mod attention_chunk; @@ -108,42 +107,25 @@ pub(in crate::qwen_forward) use retained_handoff::AttentionBlockOutput; mod output_workspace_gpu; mod diagnose; -#[allow(unused_imports)] use diagnose::diagnose; -#[allow(unused_imports)] use diagnose::diagnose_extrema; mod gr_stage; mod read_cuda; mod residual_ready; -#[allow(unused_imports)] use read_cuda::read_cuda; mod read_cached_cuda; -#[allow(unused_imports)] use read_cached_cuda::admit_budget; -#[allow(unused_imports)] use read_cached_cuda::copy_cached_f32; -#[allow(unused_imports)] use read_cached_cuda::inject_cached_cuda; -#[allow(unused_imports)] use read_cached_cuda::read_cached_cuda; -#[allow(unused_imports)] use read_cached_cuda::release_all; -#[allow(unused_imports)] use read_cached_cuda::upload_bf16; -#[allow(unused_imports)] use read_cached_cuda::upload_cached_f32; -#[allow(unused_imports)] use read_cached_cuda::upload_f32; mod download_f32; -#[allow(unused_imports)] use download_f32::binding_error; -#[allow(unused_imports)] use download_f32::download_f32; -#[allow(unused_imports)] use download_f32::driver_error; -#[allow(unused_imports)] use download_f32::validate_layer; -#[allow(unused_imports)] use download_f32::validate_streams; -#[allow(unused_imports)] use download_f32::validate_values; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk.rs index ab536c17..888b0908 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk.rs @@ -52,9 +52,7 @@ pub(in crate::qwen_forward) struct GrBatchRow { } mod gr_micro_input; -#[allow(unused_imports)] pub(super) use gr_micro_input::micro_driver_error; -#[allow(unused_imports)] pub(super) use gr_micro_input::save_micro_values; mod batch_inject; mod gr_stage; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs index bcc85bf3..cf618a93 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs @@ -1,7 +1,6 @@ //! Methods of `GrStage`: `mint_micro_input`, `prepare_micro_initial`, `prepare_micro_after_ple`, `prepare_micro_afte... //! Methods of `GrBatchScope`: `detach_rows`, `refuse_device`, `seal`. -#[allow(unused_imports)] use super::super::super::dense_weight_cache::GrResident; use super::{ Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Dimension, Error, GrBatchScope, GrMicroAttention, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs index 55f4351c..5c7830db 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs @@ -1,7 +1,6 @@ //! Methods of `GrStage`: `prepare_detached_batch_injection`, `prepare_batch_injection`, `inject_batch`. //! Functions: `check_batch_read`. -#[allow(unused_imports)] use super::batch_inject::{device_inject, gather_batch}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::batch_inject::{finish_queued, queued_inject}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs index 3221a3c5..6675062c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs @@ -1,7 +1,6 @@ //! Methods of `GrStage`: `apply`, `read_ffn`, `read_attention`, `read_attention_after_ple` and 6 more. //! Functions: `copy_streams`, `resolve_gr_weights`, `read_candidate`, `check_injection_origin` and 2 more. -#[allow(unused_imports)] use super::super::dense_weight_cache::GrResident; use super::{ Context, DenseWeightCache, DeviceBuffer, Dimension, Error, GrPhase, GrRead, GrRole, GrScratch, GrStage, GrWeights, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs index 407ea719..5b327d43 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs @@ -2,11 +2,9 @@ //! Defines `Tally`. use super::{ - AttentionBlockOutput, BindingIdentity, Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Dimension, - DriverError, Error, GR_OUTPUT_BYTES, GR_OUTPUT_DEVICE_BYTES, GrBatchRow, GrMicroAttention, GrMicroAttentionBank, - GrMicroAttentionBlock, GrMicroBlock, GrMicroInput, GrRole, GrScratch, GrWeights, InputBindingError, LayerId, - MicroBlockRequest, ModelBinding, PleReady, QwenStepTxn, Rc, ReadCandidate, RefCell, RefMut, Result, TokenLayer, - download_f32, driver_error, inject_cached_cuda, read_cached_cuda, retained_handoff, upload_bf16, upload_f32, + BindingIdentity, Cell, Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GR_OUTPUT_DEVICE_BYTES, GrScratch, Rc, + ReadCandidate, RefCell, Result, download_f32, driver_error, inject_cached_cuda, read_cached_cuda, retained_handoff, + upload_bf16, upload_f32, }; use leleka_cuda_driver::Driver; @@ -99,18 +97,11 @@ fn original_first_fixed_outputs_repeat_overwrite_abort_and_cleanup() { } mod fresh_read; -#[allow(unused_imports)] use fresh_read::block; -#[allow(unused_imports)] use fresh_read::coefficients; -#[allow(unused_imports)] use fresh_read::fresh_inject; -#[allow(unused_imports)] use fresh_read::fresh_read; -#[allow(unused_imports)] use fresh_read::poison_all; -#[allow(unused_imports)] use fresh_read::streams; mod check_handoff; -#[allow(unused_imports)] use check_handoff::check_handoff; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs index 9b430423..f9a28ce3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs @@ -5,14 +5,6 @@ use super::{ BindingIdentity, Context, DeviceBuffer, Error, GR_OUTPUT_DEVICE_BYTES, GrScratch, ReadCandidate, Result, block, download_f32, driver_error, fresh_inject, fresh_read, poison_all, read_cached_cuda, retained_handoff, streams, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AttentionBlockOutput, Cell, DenseWeightCache, DetachedGrRead, Dimension, Driver, DriverError, GrBatchRow, - GrMicroAttention, GrMicroAttentionBank, GrMicroAttentionBlock, GrMicroBlock, GrMicroInput, GrRole, GrWeights, - InputBindingError, LayerId, MicroBlockRequest, ModelBinding, PleReady, QwenStepTxn, Rc, RefCell, RefMut, Stage, - TokenLayer, coefficients, -}; pub(super) fn check_handoff<'ctx>( scratch: &mut GrScratch<'ctx>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs index 769e3688..c4772494 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs @@ -2,14 +2,6 @@ //! Split out of `output_workspace_gpu` to keep its files under the line limit. use super::{Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GrScratch, Result, download_f32, driver_error, upload_f32}; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AttentionBlockOutput, BindingIdentity, Cell, DenseWeightCache, DetachedGrRead, Dimension, Driver, DriverError, - GrBatchRow, GrMicroAttention, GrMicroAttentionBank, GrMicroAttentionBlock, GrMicroBlock, GrMicroInput, GrRole, - GrWeights, InputBindingError, LayerId, MicroBlockRequest, ModelBinding, PleReady, QwenStepTxn, Rc, RefCell, RefMut, - Stage, TokenLayer, -}; pub(super) fn fresh_read( context: &Context<'_>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs index 047c6bfd..71314d89 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs @@ -220,39 +220,20 @@ mod ple_tests { mod input_stage; mod residual_streams; pub(super) use input_stage::PositionedToken; -#[allow(unused_imports)] -use input_stage::gather_ple; -#[allow(unused_imports)] -use input_stage::trace_ple; -#[allow(unused_imports)] +#[cfg(test)] use input_stage::validate_ids; mod gather_rows; -#[allow(unused_imports)] pub(super) use gather_rows::binding_error; -#[allow(unused_imports)] use gather_rows::gather_rows; mod input_stage_ple_micro; -#[allow(unused_imports)] -use input_stage_ple_micro::ple_cuda_cached; mod ple_cuda; -#[allow(unused_imports)] use ple_cuda::ple_budget; -#[allow(unused_imports)] use ple_cuda::ple_cuda; -#[allow(unused_imports)] -use ple_cuda::ple_project; -#[allow(unused_imports)] use ple_cuda::ple_upload; -#[allow(unused_imports)] use ple_cuda::ple_values; -#[allow(unused_imports)] use ple_cuda::ple_zeros; mod ple_upload_f32; -#[allow(unused_imports)] use ple_upload_f32::ple_download; -#[allow(unused_imports)] use ple_upload_f32::ple_driver_error; -#[allow(unused_imports)] use ple_upload_f32::ple_upload_f32; -#[allow(unused_imports)] use ple_upload_f32::ple_upload_u16; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport.rs index e21ae1da..82819a08 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport.rs @@ -50,17 +50,11 @@ struct Transport<'ctx> { mod ple_key_retained_gpu; mod role; -#[allow(unused_imports)] use role::admit; -#[allow(unused_imports)] use role::at; -#[allow(unused_imports)] pub(super) use role::compose; mod ple_inner_composition; -#[allow(unused_imports)] use ple_inner_composition::compose_inner; #[cfg(test)] -#[allow(unused_imports)] use ple_inner_composition::compose_observed; -#[allow(unused_imports)] pub(super) use ple_inner_composition::compose_queued; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs index 17ef3095..0abad6b0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs @@ -2,8 +2,8 @@ #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{ple_upload, ple_upload_f32}; use super::{ - Bf16ProjectionShape, Cell, Context, DeviceBuffer, Error, Finite, PLE_HC, PLE_HISTORY, PleCandidate, PleRows, Rc, - Result, Role, Transport, at, compose, ple_download, ple_driver_error, role, + Bf16ProjectionShape, Cell, Context, DeviceBuffer, Error, Finite, PleCandidate, PleRows, Rc, Result, Role, Transport, + at, compose, ple_download, ple_driver_error, }; #[cfg(test)] use super::{Observations, compose_observed}; @@ -216,17 +216,9 @@ fn prove_sticky_policy(ctx: &Context<'_>, device: &leleka_cuda_driver::Device<'_ } mod bf16; -#[allow(unused_imports)] use bf16::bf16; -#[allow(unused_imports)] use bf16::exact; -#[allow(unused_imports)] use bf16::original; -#[allow(unused_imports)] use bf16::owned_key; -#[allow(unused_imports)] -use bf16::run; -#[allow(unused_imports)] use bf16::source; -#[allow(unused_imports)] use bf16::value_bytes; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs index 6228f678..bc48ddeb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs @@ -2,9 +2,8 @@ //! Methods of `Chain`: `key_value`, `norms`, `gate`, `gated` and 2 more. use super::{ - Bf16ProjectionShape, Cell, Context, DeviceBuffer, Driver, Error, Finite, Matrices, PLE_HC, PLE_HISTORY, - PleCandidate, PleClosedWeights, Rc, Result, Role, Transport, at, ple_download, ple_driver_error, ple_upload, - ple_upload_f32, + Bf16ProjectionShape, Context, DeviceBuffer, Finite, Matrices, Role, Transport, at, ple_download, ple_driver_error, + ple_upload, ple_upload_f32, }; #[cfg(test)] use super::Observations; 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 85221281..85a14fca 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 @@ -134,18 +134,12 @@ mod slot_tests; mod lru_tests; mod scratch_bytes; -#[allow(unused_imports)] use scratch_bytes::assign_slots; -#[allow(unused_imports)] use scratch_bytes::lookup_rows; -#[allow(unused_imports)] use scratch_bytes::plan_gather; -#[allow(unused_imports)] use scratch_bytes::scratch_bytes; mod publish_gather; -#[allow(unused_imports)] use publish_gather::ahead_enabled; -#[allow(unused_imports)] use publish_gather::publish_gather; mod ahead_rows; mod kar_ple_cache_methods; 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 fe53fb98..45246230 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert.rs @@ -5,10 +5,8 @@ use super::contract::{Error, LayerId, Result, Stage, TokenLayer}; use super::gr::ResidualReady; use super::moe_route::RoutedExperts; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use super::moe_weight_cache::SourceMatrix; use super::moe_weight_cache::{CachedMoeMatrix, MoeWeightCache}; -#[allow(unused_imports)] use super::moe_weight_cache::{MmqChunkRequest, SharedTailRow}; use super::session::QwenStepTxn; use crate::model_binding::kar_expert_source::{KarExpertSource, KarSourceError}; @@ -70,65 +68,34 @@ mod tests; mod expert_step; pub(in crate::qwen_forward) use expert_step::ExpertRowRequest; -#[allow(unused_imports)] use expert_step::StepCuda; -#[allow(unused_imports)] -use expert_step::execute_cuda; -#[allow(unused_imports)] -use expert_step::execute_cuda_kar; -#[allow(unused_imports)] -use expert_step::kar_error; mod cached_expert_run; -#[allow(unused_imports)] use cached_expert_run::execute_cuda_cached; -#[allow(unused_imports)] use cached_expert_run::finish_with_parts; mod scoped_expert_mlp; -#[allow(unused_imports)] use scoped_expert_mlp::DownProvenance; -#[allow(unused_imports)] -use scoped_expert_mlp::cached_gate_up_scoped; -#[allow(unused_imports)] use scoped_expert_mlp::cached_mlp_down; mod expert_mlp_values; -#[allow(unused_imports)] use expert_mlp_values::expert_mlp; -#[allow(unused_imports)] +#[cfg(test)] use expert_mlp_values::finish_cached_mlp; -#[allow(unused_imports)] -use expert_mlp_values::project_cached_gate_up; -#[allow(unused_imports)] +#[cfg(test)] use expert_mlp_values::project_retained_gate_up; mod expert_matrix_projection; -#[allow(unused_imports)] use expert_matrix_projection::admit_budget; #[cfg(test)] -#[allow(unused_imports)] use expert_matrix_projection::collect_rows; -#[allow(unused_imports)] -use expert_matrix_projection::dual_format_kind; -#[allow(unused_imports)] use expert_matrix_projection::dual_routed_format; -#[allow(unused_imports)] use expert_matrix_projection::launch_cached_prepared; -#[allow(unused_imports)] use expert_matrix_projection::launch_cached_projection; -#[allow(unused_imports)] +#[cfg(test)] use expert_matrix_projection::launch_projection; -#[allow(unused_imports)] use expert_matrix_projection::project_matrix; -#[allow(unused_imports)] use expert_matrix_projection::{DeclaredMatrix, ExpertActivation, ExpertMatrix, MatrixDims}; mod validate_values; -#[allow(unused_imports)] use validate_values::binding_error; -#[allow(unused_imports)] use validate_values::download_f32; -#[allow(unused_imports)] use validate_values::driver_error; -#[allow(unused_imports)] use validate_values::upload_bytes; -#[allow(unused_imports)] use validate_values::upload_f32; -#[allow(unused_imports)] use validate_values::validate_values; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs index e6236395..575f6e91 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs @@ -1,7 +1,6 @@ //! Methods of `ActualSlotPacket`: `validate`. Methods of `ActualDown`: `take`. //! Functions: `shared_scalar_buffers`, `release_shared_inputs`, `scaled_shared`, `finish_with_parts` and 1 more. -#[allow(unused_imports)] use super::moe_down::{RetainedScalar, ScaledDown}; use super::{ ActualDown, ActualSlotPacket, BoundExpert, Cell, Context, DeviceBuffer, DownOrigin, DownProvenance, DownScope, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs index 02a2cccb..aac33f1b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped.rs @@ -11,11 +11,6 @@ use super::{ Stage, StepCuda, TokenLayer, TransportBuffer, admit_budget, binding_error, cached_mlp_down, download_f32, driver_error, dual_routed_format, execute_cuda_cached, launch_cached_projection, moe_down, validate_values, }; -#[cfg(test)] -use super::{ - DeclaredMatrix, DenseFormat, ExpertMatrix, ExpertRowRequest, InputBindingError, KarExpertSource, KarSourceError, - MoeExpertBlock, ProjectionKind, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, ResidualReady, -}; use leleka_cuda_driver::DownColumns; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod adaptive_packets; @@ -78,42 +73,28 @@ mod adaptive; mod prepared_moe_row; pub(in crate::qwen_forward) use prepared_moe_row::ChunkFfnLayer; -#[allow(unused_imports)] use prepared_moe_row::grouped_pairs; mod bound_rows; mod execute_bound; -#[allow(unused_imports)] use execute_bound::execute_bound; mod project_group; -#[allow(unused_imports)] use project_group::{ExpertGroup, project_group}; mod packet_run_project_group_direct; mod project_group_shared_fns; mod project_group_source_consumers; mod project_group_source_fenced; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] use project_group_source_consumers::project_group_source_consumers; mod direct_packets_fns; mod ordered_down_refusal; -#[allow(unused_imports)] use ordered_down_refusal::PacketGroupMembers; -#[allow(unused_imports)] use ordered_down_refusal::finish_shared; -#[allow(unused_imports)] use ordered_down_refusal::finish_shared_queued; -#[allow(unused_imports)] use ordered_down_refusal::ordered_down_refusal; -#[allow(unused_imports)] use ordered_down_refusal::use_direct_packets; -#[allow(unused_imports)] use ordered_down_refusal::use_shared_tail; -#[allow(unused_imports)] use ordered_down_refusal::validate_packet_pairs; mod finish_shared_with; -#[allow(unused_imports)] use finish_shared_with::RowTail; -#[allow(unused_imports)] use finish_shared_with::finish_shared_with; -#[allow(unused_imports)] use finish_shared_with::uses_adaptive; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets.rs index 0b0d40e6..a2c12a09 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets.rs @@ -8,12 +8,10 @@ use super::{ use crate::qwen_forward::cpu_expert_miss::runtime_error; mod adaptive_packet_projection; -#[allow(unused_imports)] pub(super) use adaptive_packet_projection::project_adaptive_packets; mod packet_plan; mod packet_wave; pub(super) use packet_wave::PacketWave; mod packet_wave_projection; -#[allow(unused_imports)] use packet_wave_projection::project_inner; mod gpu_wave_staging; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs index 7adfe339..082188af 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs @@ -1,15 +1,9 @@ //! ONE loaded actual-row transport proof. No source admission, ModelBinding, //! session advancement, standalone Load or full-model qualification is minted. use super::{ - BindingIdentity, BoundExpert, CachedMoeMatrix, ChunkFfnLayer, ChunkFfnRow, CompletedCpuRow, Context, DEVICE_PEAK, - DeclaredMatrix, DenseFormat, DeviceBuffer, DownColumns, DownProvenance, DownScope, DownSelection, DriverError, - Error, ExpertActivation, ExpertGroup, ExpertMatrix, ExpertReady, ExpertRowRequest, FF, GrRole, GrStage, - InputBindingError, K, KarExpertSource, KarSourceError, LayerId, MatrixDims, MmqChunkRequest, ModelBinding, - MoeExpertBlock, MoeExpertSelection, MoeExpertStage, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, - N, NativePromptFinish, PackedDown, PacketGroupMembers, PreparedMoeRow, ProjectionKind, ProjectionSpec, - Q5KProjectionShape, Q6KProjectionShape, QwenChunkTxn, Rc, ResidualReady, Result, RetainedDown, RoutedExperts, - RoutedFormat, RoutedGateUpQ8, RowTail, SharedTailRow, SourceMatrix, Stage, StepCuda, TokenLayer, TransportBuffer, - download_f32, driver_error, moe_down, validate_values, + ChunkFfnLayer, ChunkFfnRow, Context, DEVICE_PEAK, DeviceBuffer, DownScope, DownSelection, DriverError, Error, + ExpertReady, FF, GrStage, K, LayerId, ModelBinding, MoeExpertStage, MoeWeightCache, N, PreparedMoeRow, QwenChunkTxn, + Rc, Result, Stage, TransportBuffer, download_f32, driver_error, validate_values, }; use crate::qwen_forward::gr::DetachedGrRead; use crate::qwen_forward::session::{QwenStepTxn, ResetReplaySnapshot, chunk::ChunkAttentionRow}; @@ -70,44 +64,21 @@ pub(crate) struct LoadedArms<'a, 'k, 'ctx> { } mod policy; -#[allow(unused_imports)] -use policy::arm_attention_reads; -#[allow(unused_imports)] use policy::arm_chunk_rows; -#[allow(unused_imports)] -use policy::arm_consume_inputs; -#[allow(unused_imports)] -use policy::arm_ffn_rows; -#[allow(unused_imports)] -use policy::arm_prepare_row; -#[allow(unused_imports)] use policy::arm_tokens; -#[allow(unused_imports)] use policy::cancel_probe; -#[allow(unused_imports)] use policy::compare; -#[allow(unused_imports)] pub(super) use policy::copy_completed; -#[allow(unused_imports)] pub(super) use policy::observe_packet; -#[allow(unused_imports)] pub(super) use policy::policy; mod arm; -#[allow(unused_imports)] use arm::arm; -#[allow(unused_imports)] use arm::corrupted_bytes; -#[allow(unused_imports)] use arm::preflight_copy; -#[allow(unused_imports)] use arm::probe_payload; -#[allow(unused_imports)] use arm::refuse_alien_scope; mod probe; -#[allow(unused_imports)] use probe::output_differences; -#[allow(unused_imports)] use probe::same_outputs; -#[allow(unused_imports)] use probe::transport_probe; mod loaded_arms; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs index ba0e14ad..bf5454de 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs @@ -2,7 +2,6 @@ //! Methods of `DirectGroup`: `check_descriptors`, `run`, `project_gate_up`, `project_gate_up_role` and 6 more. use super::direct_packets_fns::PacketRun; -#[allow(unused_imports)] use super::project_group_shared_fns::*; use super::{ ActualSlotPacket, CachedMoeMatrix, ChunkFfnRow, Context, DeviceBuffer, DownColumns, DownOrigin, DownScope, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs index ec7e21fb..215642b1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs @@ -2,7 +2,6 @@ //! Methods of `DownArgs`: `refusal_values`. Functions: `project_group`. use super::packet_run_project_group_direct::{DownProjection, GroupBuffers, RefusalReplay}; -#[allow(unused_imports)] use super::project_group_shared_fns::{ GateUpColumns, check_group_descriptors, close_group_buffers, down_kind_format, down_outcome, gate_up_format, gate_up_plain, hidden_buffer, launch_down_in_workspace, launch_down_plain, prepared_refs, swiglu_into_hidden, 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 2ecbf600..9f4e03f6 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 @@ -11,7 +11,7 @@ use leleka_cuda_driver::{MmqWorkspace, OriginalMmqLayer}; mod expert_gather; mod layer_walk; use super::resident_layer::{LayerResources, Resident, RoutedGroups}; -use layer_walk::{SlotState, StagingPlan, Walk, WalkOwners}; +use layer_walk::{StagingPlan, Walk, WalkOwners}; pub(super) fn execute_adaptive_groups<'ctx>( resident: &Resident<'_, '_, 'ctx>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu.rs index 037141f6..a738d842 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu.rs @@ -62,24 +62,11 @@ fn small_context_refusals(device: &leleka_cuda_driver::Device<'_>) { } mod encoded; -#[allow(unused_imports)] -use encoded::bounded_gate_up; -#[allow(unused_imports)] use encoded::compare_mlp; -#[allow(unused_imports)] -use encoded::down; -#[allow(unused_imports)] use encoded::down_projection; -#[allow(unused_imports)] use encoded::encoded; -#[allow(unused_imports)] -use encoded::exact; -#[allow(unused_imports)] use encoded::format_case; -#[allow(unused_imports)] use encoded::raw; mod former_fixture_domain_refusal; -#[allow(unused_imports)] use former_fixture_domain_refusal::former_fixture_domain_refusal; -#[allow(unused_imports)] use former_fixture_domain_refusal::saturation_and_refusals; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu.rs index d6d9bb40..66773818 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu.rs @@ -44,17 +44,10 @@ mod pair; use down_reuse_refusal_rig::Rig; use pair::Env; mod exact; -#[allow(unused_imports)] use exact::down_weights; -#[allow(unused_imports)] use exact::exact; -#[allow(unused_imports)] use exact::original_down; -#[allow(unused_imports)] use exact::project; -#[allow(unused_imports)] use exact::refused; -#[allow(unused_imports)] use exact::retained; -#[allow(unused_imports)] use exact::scalar_weights; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/down_reuse_refusal_rig.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/down_reuse_refusal_rig.rs index e62afd84..a776f6e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/down_reuse_refusal_rig.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/down_reuse_refusal_rig.rs @@ -1,6 +1,5 @@ //! The refusal and abort phases of the retained Down proof (one body per phase, STRA-338). -#[allow(unused_imports)] use super::pair::{Env, le_bytes}; use super::{ Cell, Context, DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, RetainedScalar, ScaledDown, 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 f1626a3a..042fdf14 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 @@ -145,19 +145,11 @@ use route_micro::{ validate_micro, }; mod moe_prefill_resources; -#[allow(unused_imports)] use moe_prefill_resources::admit; -#[allow(unused_imports)] use moe_prefill_resources::down_format; -#[allow(unused_imports)] use moe_prefill_resources::f32_bytes; -#[allow(unused_imports)] use moe_prefill_resources::gate_up_format; -#[allow(unused_imports)] pub(in crate::qwen_forward) use moe_prefill_resources::validate_route_row; mod device_bytes; -#[allow(unused_imports)] use device_bytes::device_bytes; -#[allow(unused_imports)] -use device_bytes::release_pool; mod moe_prefill_stage; 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 627993b3..3a33ab2c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route.rs @@ -93,32 +93,20 @@ mod projection_tests { } mod router_logits; -#[allow(unused_imports)] +#[cfg(test)] use router_logits::admit_projection_budget; -#[allow(unused_imports)] pub(super) use router_logits::validate_activation; mod project_logits; -#[allow(unused_imports)] use project_logits::RouterInput; -#[allow(unused_imports)] use project_logits::binding_error; -#[allow(unused_imports)] +#[cfg(test)] use project_logits::collect_logits; -#[allow(unused_imports)] use project_logits::project_logits; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] pub(super) use project_logits::route_batch_row; -#[allow(unused_imports)] use project_logits::route_with; -#[allow(unused_imports)] -use project_logits::routed_from_raw; -#[allow(unused_imports)] pub(super) use project_logits::validate_logits; -#[allow(unused_imports)] use project_logits::validate_request; mod run_cuda; -#[allow(unused_imports)] pub(super) use run_cuda::map_driver_error; -#[allow(unused_imports)] use run_cuda::run_cuda; 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 935abee0..b01ff389 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 @@ -36,7 +36,10 @@ mod cache_strata_adaptive; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(in crate::qwen_forward) use cache_original_prompt::PromptWeightOwners; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -pub(crate) use cache_original_prompt::{PREFILL_STREAM_OVERRIDE, set_span_cache_override}; +#[cfg(test)] +pub(crate) use cache_original_prompt::PREFILL_STREAM_OVERRIDE; +#[cfg(test)] +pub(crate) use cache_original_prompt::set_span_cache_override; pub(crate) use cache_profile::{LearnedMainWitness, SharedPermanentWitness}; pub(crate) use cache_strata_adaptive::AdaptiveWitness; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] @@ -344,23 +347,16 @@ mod original_mtp_weights; pub(in crate::qwen_forward) use original_mtp_weights::{MtpHeadSources, RetainedOriginalMtpWeights}; mod validate_ranked_profile; -#[allow(unused_imports)] // pinning and the epoch are read by the decode graph reuse, which the stack does not wire yet #[allow(dead_code)] mod window_pins; use validate_ranked_profile::dual_layout; -#[allow(unused_imports)] use validate_ranked_profile::integer_iq3_triplet; -#[allow(unused_imports)] pub(super) use validate_ranked_profile::oldest_weight; -#[allow(unused_imports)] pub(in crate::qwen_forward) use validate_ranked_profile::original_dual_layout; -#[allow(unused_imports)] use validate_ranked_profile::original_mmq_triplet; -#[allow(unused_imports)] pub(super) use validate_ranked_profile::room_fits; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] pub(crate) use validate_ranked_profile::validate_ranked_profile; mod moe_cache_routed_owners; mod moe_weight_cache_methods; 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 320f3e75..7d388dda 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 @@ -116,17 +116,11 @@ struct MappedStage<'ctx> { } mod healthy_cancel; -#[allow(unused_imports)] use healthy_cancel::close_buffers; -#[allow(unused_imports)] use healthy_cancel::close_slot; -#[allow(unused_imports)] use healthy_cancel::combine; -#[allow(unused_imports)] use healthy_cancel::empty_slot; -#[allow(unused_imports)] use healthy_cancel::healthy_cancel; -#[allow(unused_imports)] pub(in crate::qwen_forward) use healthy_cancel::observe_cancel; mod ephemeral_mapped_stage; mod ephemeral_routed_owner; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index.rs index 9fbce35c..42cbba7b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index.rs @@ -33,7 +33,6 @@ pub(super) struct PreparedUpdates { mod tests; mod slot; -#[allow(unused_imports)] use slot::slot; mod lru_index; mod lru_index_seeding; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt.rs index 113f1bd9..3b405012 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt.rs @@ -16,13 +16,10 @@ pub static PREFILL_STREAM_OVERRIDE: std::sync::atomic::AtomicI8 = std::sync::ato static SPAN_CACHE_OVERRIDE: std::sync::atomic::AtomicI8 = std::sync::atomic::AtomicI8::new(-1); mod prompt_stream_settings; -#[allow(unused_imports)] use prompt_stream_settings::native_format; -#[allow(unused_imports)] use prompt_stream_settings::prompt_stream_settings; -#[allow(unused_imports)] +#[cfg(test)] pub(crate) use prompt_stream_settings::set_span_cache_override; -#[allow(unused_imports)] pub(crate) use prompt_stream_settings::span_cache_enabled; mod moe_weight_cache; mod moe_weights_original_prompt; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs index 5375eaef..2986fa32 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs @@ -1,7 +1,6 @@ //! Methods of `MoeWeightCache`: `original_prompt_moe`, `original_prompt_parts`, `original_prompt_precheck`. //! Functions: `raw_weight`, `shared_formats`, `shared_weights`. -#[allow(unused_imports)] use super::prompt_layer_fns::{PromptIo, PromptParts, PromptWeightOwners, SpanScan, run_prompt_layer}; use super::{ DenseWeightCache, DeviceBuffer, EncodedWeight, Entry, Error, GdnNativeFormat, HashMap, LayerId, ModelBinding, 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 8ba38ed7..fe770862 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 @@ -126,7 +126,5 @@ mod learned_main_sdet; mod ranked_profile; mod shared_permanent_pool; -#[allow(unused_imports)] pub(super) use shared_permanent_pool::learned_main_slot_bound; -#[allow(unused_imports)] pub(super) use shared_permanent_pool::remaining_shared_main; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs index 644c1ba9..dcf4b789 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs @@ -1,13 +1,8 @@ //! Binding-authenticated constructor; metadata alone cannot produce weights. use super::{ - AdaptiveWitness, BindingIdentity, BoundExpert, Cell, Context, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, - FixedMtpWeights, HashMap, LearnedMainWitness, LruIndex, MAIN_LIMIT, MmqChunkRequest, MmqFormat, MmqWeights, - MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, - MoeWeightDescriptor, MtpExpertPicks, MtpHeadSources, MtpInputWorkspace, MtpKind, MtpKvClaim, MtpKvResident, - MtpRole, MtpStepSite, PREFILL_STREAM_OVERRIDE, PendingMtpKv, PreparedUpdates, PromptWeightOwners, Rc, RefCell, - Result, RetainedOriginalMtpWeights, RoutedFiniteStage, RoutedGroupWorkspace, RoutedStageFiniteGuard, SharedKeys, - SharedPermanentWitness, SharedTailRow, SharedWeightsRequest, SourceMatrix, TripletLoanRequest, WORKING_RESERVE, - WeightCacheCounters, binding_error, cache_profile, cache_strata_adaptive, driver_error, + Context, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, + MoeWeightCache, MoeWeightDescriptor, Rc, RefCell, Result, WORKING_RESERVE, WeightCacheCounters, binding_error, + cache_profile, cache_strata_adaptive, driver_error, }; #[cfg(test)] use super::room_fits; @@ -181,9 +176,8 @@ mod reusable_spill_floor_planning { mod moe_weight_cache; mod profile_window_spill; -#[allow(unused_imports)] +#[cfg(test)] use profile_window_spill::profile_window_spill; -#[allow(unused_imports)] use profile_window_spill::profile_window_spill_with_floor; mod learned_main_lru_profile; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs index c290e0d0..8181c72a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs @@ -1,7 +1,6 @@ //! Methods of `MoeWeightCache`: `new_profile_shared_permanent_learned_main_lru`, `learned_main_totals`, `check_learn... //! Split out of `cache_profile_fill` to keep its files under the line limit. -#[allow(unused_imports)] #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::profile_build::{ProfileFile, ProfileKind, ProfileRequest}; use super::{ 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 7786e9cd..e6164ae8 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 @@ -2,15 +2,9 @@ //! Split out of `cache_profile_fill` to keep its files under the line limit. use super::{ - AdaptiveWitness, BindingIdentity, BoundExpert, Cell, Context, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, - FixedMtpWeights, HOST_CAP, HashMap, LearnedMainWitness, LruIndex, MAIN_LIMIT, MmqChunkRequest, MmqFormat, - MmqWeights, MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, - MoeWeightDescriptor, MtpExpertPicks, MtpHeadSources, MtpInputWorkspace, MtpKind, MtpKvClaim, MtpKvResident, - MtpRole, MtpStepSite, PREFILL_STREAM_OVERRIDE, PROFILE_SHA, PendingMtpKv, PinnedPool, PrefixPlan, PreparedUpdates, - ProfileLimits, PromptWeightOwners, RankedProfile, Rc, RefCell, Result, RetainedOriginalMtpWeights, - RoutedFiniteStage, RoutedGroupWorkspace, RoutedStageFiniteGuard, SharedKeys, SharedPermanentWitness, SharedTailRow, - SharedWeightsRequest, SourceMatrix, TripletLoanRequest, WORKING_RESERVE, binding_error, driver_error, - profile_window_spill_with_floor, + Context, DeviceRef, EncodedWeight, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, + MoeWeightCache, MoeWeightDescriptor, PROFILE_SHA, PinnedPool, PrefixPlan, ProfileLimits, RankedProfile, Result, + WORKING_RESERVE, binding_error, driver_error, profile_window_spill_with_floor, }; #[cfg(test)] use super::ProfileWitness; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs index 9120d462..ce98641a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs @@ -1,8 +1,8 @@ //! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile_mtp_input_spill_floo... //! Defines `QuartetRoom`. -#[allow(unused_imports)] #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] +#[cfg(test)] use super::profile_build::{ProfileFile, ProfileKind, ProfileRequest}; use super::{ DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs index ef7b0b56..0a850b46 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs @@ -1,7 +1,6 @@ //! Methods of `MoeWeightCache`: `new_native_strata_adaptive_shared_permanent`, `new_native_strata_adaptive_shared_pe... //! Functions: `adaptive_template`. Defines `AdaptivePlan`, `SharedKeys`. -#[allow(unused_imports)] use super::profile_build::ProfileFile; use super::{ Context, DeviceBuffer, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, 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 1dba08b1..fe0e91c5 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 @@ -94,13 +94,9 @@ pub(crate) struct AdaptiveWitness { } mod reserve; -#[allow(unused_imports)] use reserve::blob_bytes; -#[allow(unused_imports)] use reserve::cell; -#[allow(unused_imports)] use reserve::reserve; mod adaptive_cache; mod transfer_metadata_bound; -#[allow(unused_imports)] pub(super) use transfer_metadata_bound::transfer_metadata_bound; 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 ead074b1..e374c61c 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 @@ -161,8 +161,8 @@ mod share_tests { } mod dense_copies_equal; -#[allow(unused_imports)] +#[cfg(test)] use dense_copies_equal::dense_copies_equal; mod retained_original_mtp_weights; -#[allow(unused_imports)] +#[cfg(test)] use retained_original_mtp_weights::rt_kind; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs index 641d4d0b..0ed355a2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs @@ -7,15 +7,7 @@ //! `window_keys` remembers which entries a window reads; freeing one of them (only possible while unpinned) and //! releasing the pins both bump `weights_epoch`, which is part of the graph key, so a set recorded before is retired. //! Everything is `&self` (cells): the assembly holds the cache by shared reference while a request runs. -use super::{ - AdaptiveWitness, BindingIdentity, BoundExpert, Cell, Context, DeviceBuffer, DeviceRef, Error, FixedMtpWeights, - HashMap, LearnedMainWitness, LruIndex, MmqChunkRequest, MmqFormat, MmqWeights, MmqWorkspace, ModelBinding, - MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, MtpExpertPicks, - MtpHeadSources, MtpInputWorkspace, MtpKind, MtpKvClaim, MtpKvResident, MtpRole, MtpStepSite, - PREFILL_STREAM_OVERRIDE, PendingMtpKv, PreparedUpdates, PromptWeightOwners, Rc, RefCell, Result, - RetainedOriginalMtpWeights, RoutedFiniteStage, RoutedGroupWorkspace, RoutedStageFiniteGuard, SharedKeys, - SharedPermanentWitness, SharedTailRow, SharedWeightsRequest, SourceMatrix, TripletLoanRequest, window_pins, -}; +use super::{Error, MoeWeightCache, MoeWeightDescriptor, Result}; /// The entries a window reads, and whether the cache currently protects them. #[derive(Default)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs index 8c558b12..edc56c6f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp.rs @@ -61,31 +61,15 @@ pub(super) struct MtpFinalMixed { } mod mtp_frame; -#[allow(unused_imports)] -use mtp_frame::input_refusal; -#[allow(unused_imports)] -use mtp_frame::queued_fc_shape; mod step; -#[allow(unused_imports)] pub(super) use step::f32_weights; -#[allow(unused_imports)] use step::norm; -#[allow(unused_imports)] pub(super) use step::preflight; -#[allow(unused_imports)] pub(super) use step::project; -#[allow(unused_imports)] pub(super) use step::project_attention_output; -#[allow(unused_imports)] pub(super) use step::reserve; -#[allow(unused_imports)] pub(super) use step::step; -#[allow(unused_imports)] -use step::step_core; -#[allow(unused_imports)] pub(super) use step::warm_chunk_row; -#[allow(unused_imports)] pub(super) use step::warm_step; mod project_attention_out_numeric; -#[allow(unused_imports)] pub(super) use project_attention_out_numeric::project_attention_out_numeric; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state.rs index 4851c332..f93f0683 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state.rs @@ -72,9 +72,7 @@ pub(in crate::qwen_forward) struct RetainedFirstSeed { mod tests; mod dense_kv; -#[allow(unused_imports)] use dense_kv::validate_half; mod mtp_session; mod prefix_draft_snapshot; -#[allow(unused_imports)] use prefix_draft_snapshot::first_seed_retained_charge; 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 3d08bed3..f9eea1af 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 @@ -4,7 +4,7 @@ use super::{Error, MtpSession, Rc, Result, TargetStepOrigin}; use crate::model_binding::qwen4exp_input::ModelBinding; use crate::qwen_forward::{ - contract::{Dimension, Position}, + contract::Position, session::{QwenSession, chunk::QwenChunkTxn}, }; @@ -219,6 +219,6 @@ mod branch_refusal { } mod checked_chunk_end; -#[allow(unused_imports)] +#[cfg(test)] use checked_chunk_end::checked_chunk_end; mod mtp_session; 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 e1fcfec6..62e74d52 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention.rs @@ -90,39 +90,17 @@ mod reuse_gpu_tests; mod tests; mod attention_stage; -#[allow(unused_imports)] pub(super) use attention_stage::produce_kv_cell; mod attention_transport; -#[allow(unused_imports)] use attention_transport::attend_retained; -#[allow(unused_imports)] use attention_transport::attend_ring_retained; -#[allow(unused_imports)] use attention_transport::attention_driver_error; -#[allow(unused_imports)] use attention_transport::close_transport; -#[allow(unused_imports)] use attention_transport::gate_retained; -#[allow(unused_imports)] -use attention_transport::note_transport; -#[allow(unused_imports)] use attention_transport::release_transport; -#[allow(unused_imports)] -use attention_transport::upload_transport; -#[allow(unused_imports)] -use attention_transport::upload_transport_f32; mod dense_geometry; -#[allow(unused_imports)] -use dense_geometry::apply_gate; -#[allow(unused_imports)] -use dense_geometry::attend; -#[allow(unused_imports)] use dense_geometry::geometry; -#[allow(unused_imports)] use dense_geometry::norm_rope; -#[allow(unused_imports)] use dense_geometry::pack_kv; -#[allow(unused_imports)] use dense_geometry::split; -#[allow(unused_imports)] use dense_geometry::validate_window; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests.rs index 5aea608e..58a07d22 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests.rs @@ -1,10 +1,8 @@ //! New retained attention transport proof; no model/provider capability fixture. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ - Cell, Context, DenseGeometry, DenseKv, DeviceBuffer, Error, KvWindow, ModelBinding, MoeWeightCache, - MtpAttentionRead, MtpFrame, MtpKind, MtpRole, MtpSession, Q, QwenSession, Rc, Result, RetainedAttended, - RetainedGated, Stage, allocate, attend, attend_retained, download, gate_retained, geometry, release, upload, - upload_bytes, + Cell, Context, DenseGeometry, DeviceBuffer, Error, KvWindow, Q, Rc, RetainedAttended, RetainedGated, allocate, + attend_retained, download, gate_retained, geometry, release, upload, upload_bytes, }; use leleka_cuda_driver::{DenseFormat, Driver, ProjectionKind, ProjectionSpec}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests/phases.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests/phases.rs index ce1f9e04..4ba4a4d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests/phases.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/reuse_gpu_tests/phases.rs @@ -4,12 +4,6 @@ use super::{ AttendInput, Cell, Context, DenseGeometry, DeviceBuffer, Error, KvWindow, Q, Rc, RetainedAttended, RetainedGated, attend_retained, exact, gate_retained, geometry, half_kv, original_transfer_chain, out_weights, upload_bytes, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - DenseFormat, DenseKv, Driver, ModelBinding, MoeWeightCache, MtpAttentionRead, MtpFrame, MtpKind, MtpRole, - MtpSession, ProjectionKind, ProjectionSpec, QwenSession, Result, Stage, attend, release, -}; /// One context and the shared failure bit every phase works against. pub(super) struct Env<'c> { 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 563a790b..6ca94e7f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode.rs @@ -40,7 +40,6 @@ pub(crate) struct MtpDecoder { kv_prefill_host_charge: usize, } mod chunk; -pub(in crate::qwen_forward) use chunk::ReadyMtpChunk; #[cfg(test)] mod tests { @@ -179,17 +178,12 @@ mod batched_caller_tests { pub(in crate::qwen_forward) mod batch_gpu; mod mtp_window_spec; -#[allow(unused_imports)] use mtp_window_spec::kv_prefill_host_charge; mod first_seed_reuse_enabled; mod mtp_decoder; mod window_request; -#[allow(unused_imports)] use first_seed_reuse_enabled::first_seed_reuse_enabled; -#[allow(unused_imports)] use first_seed_reuse_enabled::needed_draft_predictions; -#[allow(unused_imports)] use first_seed_reuse_enabled::window_limit; -#[allow(unused_imports)] use first_seed_reuse_enabled::window_stage_error; pub(crate) use window_request::{DraftHeadOwners, MtpWindowRequest, WindowOwners}; 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 14c39eb8..6d4005a3 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 @@ -1,10 +1,8 @@ //! ONE authentic changed MTP boundary. Root schedules this ignored entry only. //! Full heads/state stay private; output contains counts and predicates only. use super::{ - DenseWeightCache, Dimension, DraftHeadOwners, Error, KarPleCache, KnownNext, ModelBinding, MoeWeightCache, - MtpDecoder, MtpInput, MtpSession, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, Position, - PrefillStepProduct, QwenForward, QwenSession, ReadyMtpChunk, Result, StepSessions, TargetStepProduct, TokenId, - VerificationChunk, VerificationSource, WindowCaches, WindowOwners, mtp, + 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::qwen_forward::contract::Stage; @@ -160,22 +158,13 @@ fn authentic_scalar_first_mtp_batch_prefix_rejection_cancel_and_cleanup() { print_report(&report); } mod collection; -#[allow(unused_imports)] pub(in crate::qwen_forward) use collection::after_joint_publish; -#[allow(unused_imports)] pub(in crate::qwen_forward) use collection::collect_head; -#[allow(unused_imports)] pub(in crate::qwen_forward) use collection::collect_row; -#[allow(unused_imports)] pub(in crate::qwen_forward) use collection::collecting; -#[allow(unused_imports)] use collection::different_token; -#[allow(unused_imports)] use collection::observe; -#[allow(unused_imports)] use collection::path; -#[allow(unused_imports)] use collection::row_matches; mod check_loaded; -#[allow(unused_imports)] use check_loaded::{Shared, check_loaded}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs index 166de95f..745ca460 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs @@ -2,17 +2,11 @@ //! Split out of `batch_gpu` to keep its files under the line limit. use super::{ - AssertUnwindSafe, Collection, DenseWeightCache, Dimension, DraftHeadOwners, Driver, Error, Expected, - InheritedKarArchive, KarPleCache, KnownNext, ModelBinding, MoeWeightCache, MtpDecoder, MtpInput, MtpSession, - MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, PathBuf, Position, PostcommitCancellation, - PrefillStepProduct, Qwen4ExpArtifact, QwenForward, QwenSession, ROW_CAP, Rc, ReadyMtpChunk, RefCell, Report, - ResetReplaySnapshot, Result, SNAPSHOT_CAP, Stage, StepSessions, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, - VerificationChunk, VerificationSource, VerifiedGgufFile, WindowCaches, WindowOwners, collection, different_token, - mtp, observe, row_matches, + Collection, DenseWeightCache, Dimension, Error, Expected, KarPleCache, ModelBinding, MoeWeightCache, MtpDecoder, + MtpWindowError, MtpWindowSpec, OutputStage, Position, PostcommitCancellation, QwenForward, QwenSession, ROW_CAP, Rc, + Report, ResetReplaySnapshot, Result, SNAPSHOT_CAP, Stage, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, + different_token, mtp, observe, row_matches, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::path; use crate::qwen_forward::mtp_decode::MtpVerifiedWindow; /// The window preparation of one flow against the candidate cache. The prepared window borrows the target session @@ -85,11 +79,7 @@ struct Flow<'a, 'ctx, 'o, 'p, 'k, 'd> { } mod position_at; -#[allow(unused_imports)] use position_at::admit_binding; -#[allow(unused_imports)] -use position_at::position_at; mod flow; mod flow_decode_edge_scenarios; -#[allow(unused_imports)] pub(super) use flow_decode_edge_scenarios::check_loaded; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs index 63835492..91589bdb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs @@ -6,14 +6,6 @@ use super::{ PostcommitCancellation, Prefix, QwenForward, Refs, ResetReplaySnapshot, Result, Stage, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, different_token, mtp, observe, row_matches, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AssertUnwindSafe, DenseWeightCache, Dimension, DraftHeadOwners, Driver, InheritedKarArchive, KarPleCache, - ModelBinding, MtpInput, MtpSession, MtpVerifiedWindow, MtpWindowRequest, OutputStage, PathBuf, Position, - PrefillStepProduct, Qwen4ExpArtifact, QwenSession, Rc, ReadyMtpChunk, RefCell, Shared, StepSessions, - VerificationChunk, VerificationSource, VerifiedGgufFile, WindowCaches, WindowOwners, collection, flow, -}; use crate::qwen_forward::mtp::KnownNext; /// What the cancelled T3 window is compared with: the reference tokens, the two accepted row expectations and the tail diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs index 1552af05..afa75bc8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs @@ -5,14 +5,6 @@ use super::{ Chain, Collection, Expected, Flow, MoeWeightCache, MtpDecoder, MtpWindowSpec, QwenForward, Rc, Refs, Report, ResetReplaySnapshot, Shared, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, admit_binding, mtp, row_matches, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AssertUnwindSafe, DenseWeightCache, Dimension, DraftHeadOwners, Driver, Error, InheritedKarArchive, KarPleCache, - KnownNext, ModelBinding, MtpInput, MtpSession, MtpVerifiedWindow, MtpWindowRequest, OutputStage, PathBuf, Position, - PrefillStepProduct, Qwen4ExpArtifact, QwenSession, ReadyMtpChunk, RefCell, Result, Stage, StepSessions, - VerificationChunk, VerificationSource, VerifiedGgufFile, WindowCaches, WindowOwners, collection, flow, -}; impl<'ctx> Flow<'_, 'ctx, '_, '_, '_, '_> { /// Automatic full restore invalidates the consumed source. Recover via 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 b8cc98e0..240090a4 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 @@ -6,14 +6,6 @@ use super::{ Position, QwenForward, QwenSession, ROW_CAP, Rc, Report, Result, SNAPSHOT_CAP, Shared, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AssertUnwindSafe, DenseWeightCache, DraftHeadOwners, Driver, Error, InheritedKarArchive, KarPleCache, KnownNext, - MtpInput, MtpSession, OutputStage, PathBuf, PrefillStepProduct, Qwen4ExpArtifact, ReadyMtpChunk, RefCell, - ResetReplaySnapshot, Stage, StepSessions, VerificationChunk, VerificationSource, VerifiedGgufFile, WindowCaches, - flow, -}; use crate::qwen_forward::executor::{StepCaches, StepRequest}; use crate::qwen_forward::mtp_decode::{MtpWindowRequest, WindowOwners}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs index c76cd619..a7e11f07 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs @@ -6,14 +6,6 @@ use super::{ PathBuf, Position, PostcommitCancellation, QwenSession, ROW_CAP, Rc, Report, ResetReplaySnapshot, Result, RowObservation, TargetStepProduct, TokenId, VOCAB, env, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AssertUnwindSafe, DenseWeightCache, DraftHeadOwners, Driver, InheritedKarArchive, KarPleCache, KnownNext, - MoeWeightCache, MtpInput, MtpSession, MtpWindowRequest, PrefillStepProduct, Qwen4ExpArtifact, QwenForward, - ReadyMtpChunk, RefCell, Shared, Stage, StepSessions, VerificationChunk, VerificationSource, VerifiedGgufFile, - WindowCaches, WindowOwners, -}; impl Collection { pub(super) fn begin(count: usize) -> Result { 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 26821682..e7f5b514 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 @@ -2,11 +2,11 @@ //! draft warm-up. Separate from `mtp_decode`, which holds the decoder itself. use super::{ - DenseWeightCache, Dimension, DraftHeadOwners, Error, KarPleCache, KnownNext, ModelBinding, MoeWeightCache, - MtpDecoder, MtpInput, MtpSession, MtpVerifiedWindow, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, - Position, PrefillStepProduct, QwenForward, QwenSession, ReadyMtpChunk, Result, StepSessions, TargetStepProduct, - TokenId, VerificationChunk, VerificationSource, WindowCaches, WindowOwners, first_seed_reuse_enabled, - kv_prefill_host_charge, mtp, needed_draft_predictions, reserve, window_limit, window_stage_error, + DenseWeightCache, Dimension, DraftHeadOwners, Error, KnownNext, ModelBinding, MoeWeightCache, MtpDecoder, MtpInput, + MtpSession, MtpVerifiedWindow, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, Position, + PrefillStepProduct, QwenForward, QwenSession, Result, StepSessions, TargetStepProduct, TokenId, VerificationChunk, + VerificationSource, WindowCaches, WindowOwners, first_seed_reuse_enabled, kv_prefill_host_charge, mtp, + needed_draft_predictions, reserve, window_limit, window_stage_error, }; #[cfg(all(test, target_arch = "x86_64"))] use super::batch_gpu; 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 f67cecca..30b7654c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts.rs @@ -42,41 +42,13 @@ struct S2Tile { mod tests; mod mtp_block; -#[allow(unused_imports)] -use mtp_block::admit_input; -#[allow(unused_imports)] -use mtp_block::compose_bound; -#[allow(unused_imports)] use mtp_block::moe_driver_error; -#[allow(unused_imports)] -use mtp_block::route_mixed; -#[allow(unused_imports)] use mtp_block::validate_route; mod routed_and_shared_experts; -#[allow(unused_imports)] -use routed_and_shared_experts::combine_uploaded; -#[allow(unused_imports)] -use routed_and_shared_experts::compose; -#[allow(unused_imports)] +#[cfg(test)] use routed_and_shared_experts::down_tile; -#[allow(unused_imports)] +#[cfg(test)] use routed_and_shared_experts::gate_up_tile; -#[allow(unused_imports)] use routed_and_shared_experts::route; -#[allow(unused_imports)] -use routed_and_shared_experts::routed; -#[allow(unused_imports)] -use routed_and_shared_experts::routed_down; -#[allow(unused_imports)] -use routed_and_shared_experts::routed_hidden; -#[allow(unused_imports)] -use routed_and_shared_experts::routed_parts; -#[allow(unused_imports)] -use routed_and_shared_experts::scale_shared; -#[allow(unused_imports)] -use routed_and_shared_experts::shared; -#[allow(unused_imports)] -use routed_and_shared_experts::shared_hidden; mod append_row; -#[allow(unused_imports)] use append_row::append_row; 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 ad77714f..0dcaef85 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 @@ -130,16 +130,8 @@ mod fixed_workspace_gpu; mod role; mod transport_drop; -#[allow(unused_imports)] use transport_drop::at; -#[allow(unused_imports)] use transport_drop::compose; -#[allow(unused_imports)] +#[cfg(test)] use transport_drop::compose_inner; -#[allow(unused_imports)] -use transport_drop::routed; -#[allow(unused_imports)] -use transport_drop::shared; -#[allow(unused_imports)] -use transport_drop::shared_project; mod fixed_buffers; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs index 1fcbda9f..08e23edf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs @@ -2,9 +2,8 @@ use super::super::mtp_expert_transport::{ExpertWeights, FixedReference, SelectedRoute, fixed_reference}; use super::{ - ALLOCATED_BYTES, BindingIdentity, CHARGES, Cell, Context, DEVICE_PEAK, DenseFormat, DeviceBuffer, Error, - ExpertInputs, FF, FixedBuffers, K, ModelBinding, MtpFrame, N, ProjectionKind, ProjectionSpec, QwenSession, Rc, - Result, Role, Slot, Transport, at, compose, compose_inner, download, moe_driver_error, role, shared, + ALLOCATED_BYTES, CHARGES, Cell, Context, DeviceBuffer, Error, ExpertInputs, FF, FixedBuffers, K, N, Rc, Result, + Role, Slot, Transport, at, compose, compose_inner, download, moe_driver_error, }; #[cfg(all(test, target_arch = "x86_64"))] use super::ObservedOutput; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport.rs index 609bc5a5..1bc66791 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport.rs @@ -55,22 +55,15 @@ mod mtp_expert_transport_gpu; pub(super) type FixedReference = (Box<[f32]>, Vec<(String, Box<[f32]>)>); mod role; -#[allow(unused_imports)] use role::at; -#[allow(unused_imports)] use role::{RoutedExpert, routed}; mod shared_project; -#[allow(unused_imports)] -use shared_project::compose_inner; #[cfg(test)] -#[allow(unused_imports)] use shared_project::compose_observed; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] pub(super) use shared_project::fixed_reference; -#[allow(unused_imports)] +#[cfg(test)] use shared_project::shared; -#[allow(unused_imports)] +#[cfg(test)] use shared_project::shared_project; -#[allow(unused_imports)] pub(super) use shared_project::{ExpertWeights, SelectedRoute, compose}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs index 6f6fd5d8..c02d7bfb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs @@ -80,22 +80,11 @@ impl<'c> Fixture<'c> { mod phases; use phases::Env; mod exact; -#[allow(unused_imports)] use exact::bank_fixture; -#[allow(unused_imports)] use exact::bytes; -#[allow(unused_imports)] -use exact::exact; -#[allow(unused_imports)] use exact::matrix; -#[allow(unused_imports)] use exact::original; -#[allow(unused_imports)] -use exact::original_project; -#[allow(unused_imports)] use exact::refusal; -#[allow(unused_imports)] use exact::scalar_matrix; -#[allow(unused_imports)] use exact::unchanged; mod owner_guards; 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 884ab4ce..d570d6cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr.rs @@ -58,24 +58,9 @@ struct Candidate { } mod driver_error; -#[allow(unused_imports)] use driver_error::admit_role; -#[allow(unused_imports)] pub(super) use driver_error::attention_read; -#[allow(unused_imports)] use driver_error::driver_error; -#[allow(unused_imports)] -use driver_error::fused; -#[allow(unused_imports)] pub(super) use driver_error::mlp_read; mod finalize; -#[allow(unused_imports)] -use finalize::down_silu; -#[allow(unused_imports)] -use finalize::final_gate; -#[allow(unused_imports)] pub(super) use finalize::finalize; -#[allow(unused_imports)] -use finalize::finalize_legacy; -#[allow(unused_imports)] -use finalize::inject_residual; 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 e22db6e9..a6da3fbe 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 @@ -126,11 +126,8 @@ mod tests { } mod original_mtp_request; -#[allow(unused_imports)] use original_mtp_request::capture_of; -#[allow(unused_imports)] use original_mtp_request::plan_error; mod mtp_full_owner_actor_close; mod original_mtp_full_owner_methods; -#[allow(unused_imports)] use mtp_full_owner_actor_close::driver_error; 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 9e1d3ea3..024f2d3d 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 @@ -90,5 +90,4 @@ pub(in crate::qwen_forward) struct DraftLaunch<'a, 'ctx> { mod driver_error; mod original_mtp_draft_receipt; mod original_prompt_executor; -#[allow(unused_imports)] use driver_error::driver_error; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine.rs index e94cad2b..77022ece 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine.rs @@ -199,7 +199,4 @@ mod tests; mod draft_completion; mod round_tally; -#[allow(unused_imports)] -use round_tally::tr_port; -#[allow(unused_imports)] pub(crate) use round_tally::{ServeCallbacks, SpeculativeRequest, serve_request}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs index 70e0382d..5e5b0d8a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs @@ -17,12 +17,6 @@ struct RoundTally { mod first_draft_engine_for_serve_engine; mod original_serve_settings; -#[allow(unused_imports)] pub(crate) use original_serve_settings::{ServeCallbacks, SpeculativeRequest, serve_request}; mod serve_rounds; -#[allow(unused_imports)] -use serve_rounds::serve_round; -#[allow(unused_imports)] use serve_rounds::serve_rounds; -#[allow(unused_imports)] -pub(super) use serve_rounds::tr_port; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs index 4763a638..6494bad2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs @@ -3,10 +3,10 @@ use super::super::original_spec_controller::{NanGuard, OriginalSpecController, SpecConfig, SpecError, SpecWindow}; use super::super::original_spec_draft::{DraftPreparation, DraftSampling, VerifiedWindow}; use super::{ - ADAPTIVE_DEFAULT, AdaptiveConfig, CommittedWindow, DraftCompletion, DraftLimits, DraftPick, EnvSource, Error, - FirstDraftSeed, MAX_T, OriginalDraftEngine, OriginalFirstDraftEngine, OriginalServeEngine, OriginalServePort, - OriginalServeSettings, OriginalSpecEngine, Rc, Result, ServeCallbacks, ServeOutcome, ServeStop, ServedWindow, - SpeculativeRequest, TargetSeedRow, serve_request, + ADAPTIVE_DEFAULT, AdaptiveConfig, CommittedWindow, DraftCompletion, DraftLimits, Error, FirstDraftSeed, + OriginalDraftEngine, OriginalFirstDraftEngine, OriginalServeEngine, OriginalServePort, OriginalServeSettings, + OriginalSpecEngine, Rc, Result, ServeCallbacks, ServeOutcome, ServeStop, ServedWindow, SpeculativeRequest, + TargetSeedRow, serve_request, }; use std::cell::RefCell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs index fa1fbea8..7db09501 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs @@ -6,13 +6,6 @@ use super::{ Error, Fake, OriginalDraftEngine, OriginalServeEngine, OriginalSpecEngine, VOCAB, engine, events, idx, model, prompt, seed_row, verify_commit, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AdaptiveConfig, DraftPick, DraftPreparation, DraftSampling, EnvSource, MAX_T, NanGuard, OriginalFirstDraftEngine, - OriginalServePort, OriginalSpecController, Rc, RefCell, Result, ServeCallbacks, SpecConfig, SpecError, SpecWindow, - SpeculativeRequest, TargetSeedRow, VerifiedWindow, -}; #[test] fn constructor_validates_dimensions() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs index 94500fb0..a2834156 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs @@ -9,12 +9,6 @@ use super::{ ServeStop, SpecConfig, SpecError, SpecWindow, SpeculativeRequest, VOCAB, VerifiedWindow, engine, events, idx, model, prompt, prompt_long, run_request, seed_row, serve, serve_in, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - DraftPick, EnvSource, MAX_T, NanGuard, OriginalServePort, Rc, RefCell, Result, ServeCallbacks, TargetSeedRow, - verify_commit, -}; #[test] fn restore_attempts_do_not_depend_on_engine_health_and_reset_draft_state() { 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 6b4f4948..56c0b7b7 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 @@ -39,9 +39,9 @@ use super::{ }; use crate::model_binding::qwen4exp_input::{BoundLayerKind, ModelBinding}; use leleka_cuda_driver::{ - AcceptedWindow, Context, DeviceBuffer, NativeHeadSelection, OriginalGpuEvent, OriginalMtpFullPolicy, - OriginalNativeHeadGraphResources, OriginalVerifier, OriginalVerifyGraphResources, OriginalVerifyQsaJournal, - OriginalVerifyWindow, OriginalVerifyWindowResult, SamplerParams, SamplerPath, + AcceptedWindow, Context, DeviceBuffer, OriginalGpuEvent, OriginalMtpFullPolicy, OriginalNativeHeadGraphResources, + OriginalVerifier, OriginalVerifyGraphResources, OriginalVerifyQsaJournal, OriginalVerifyWindowResult, SamplerParams, + SamplerPath, }; use std::rc::Rc; @@ -117,13 +117,9 @@ pub(in crate::qwen_forward) struct HostOwners<'a, 'ctx> { mod tests; mod request_sampling; -#[allow(unused_imports)] use request_sampling::adapt_defer; -#[allow(unused_imports)] use request_sampling::operator_line; -#[allow(unused_imports)] -use request_sampling::serial_publish; mod ple_on_chain; mod run_window_steps; -use run_window_steps::{report_window, run_pool_group}; +use run_window_steps::report_window; mod original_serve_host_native_serve_host; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native.rs index 112d032f..afd1396a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native.rs @@ -137,19 +137,8 @@ mod tests { } mod native_window; -#[allow(unused_imports)] -use native_window::draft_waits_for_commit; #[cfg(test)] -#[allow(unused_imports)] use native_window::draft_waits_for_commit_from; -#[allow(unused_imports)] use native_window::overlap; -#[allow(unused_imports)] -use native_window::trace_draft; -#[allow(unused_imports)] use native_window::trace_draft_line; -#[allow(unused_imports)] -use native_window::trace_logprobs; -#[allow(unused_imports)] -use native_window::trace_residual; mod native_serve_port_original_serve_port; 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 70bd383e..a408da2e 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 @@ -193,35 +193,23 @@ struct CrosscheckCounts { mod tests; mod prefetch_off_file_exists; -#[allow(unused_imports)] use prefetch_off_file_exists::admit_job; -#[allow(unused_imports)] use prefetch_off_file_exists::open_job; -#[allow(unused_imports)] pub(in crate::qwen_forward) use prefetch_off_file_exists::output_offset; #[cfg(test)] -#[allow(unused_imports)] pub(in crate::qwen_forward) use prefetch_off_file_exists::plan_experts; -#[allow(unused_imports)] pub(in crate::qwen_forward) use prefetch_off_file_exists::plan_experts_where; -#[allow(unused_imports)] use prefetch_off_file_exists::prefetch_off_file_exists; -#[allow(unused_imports)] use prefetch_off_file_exists::same_spans; -#[allow(unused_imports)] pub(in crate::qwen_forward) use prefetch_off_file_exists::scatter; mod direct_group_steps; -use direct_group_steps::{GroupWork, borrow_experts, compute_into_sink, group_formats, plan_expert_ids, prefetch_group}; +use direct_group_steps::{GroupWork, borrow_experts, compute_into_sink, group_formats}; mod cpu_expert_pool; mod pool_layer_trace; use pool_layer_trace::GroupTraceInfo; mod direct_tier; mod direct_tier_drop; -#[allow(unused_imports)] use direct_tier_drop::admit_eager; -#[allow(unused_imports)] use direct_tier_drop::native_cpu_error; -#[allow(unused_imports)] use direct_tier_drop::selection; -#[allow(unused_imports)] use direct_tier_drop::sink_result; 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 b04c13d7..48ec360a 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 @@ -10,8 +10,9 @@ use super::{contract::Error, original_serve_engine::ServeOutcome, original_spec_controller::SpecError}; use leleka_cuda_driver::{SamplerParams, SamplerPath}; -pub(in crate::qwen_forward) use leleka_engine_core::request::CONTEXT_SLACK; -pub(crate) use leleka_engine_core::request::{Admission, ENDOFTEXT_TOKEN, original_stop_tokens}; +pub(crate) use leleka_engine_core::request::{Admission, original_stop_tokens}; +#[cfg(test)] +pub(crate) use leleka_engine_core::request::ENDOFTEXT_TOKEN; /// How a request ended when it did not complete, over this stack's forward error. pub(crate) type ServeError = leleka_engine_core::request::ServeError; 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 b493031c..0f01bbbd 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 @@ -275,32 +275,22 @@ mod tests; mod tier_env_tests; mod tail_skip_rank; -#[allow(unused_imports)] pub(crate) use tail_skip_rank::effective_tail_rank; -#[allow(unused_imports)] +#[cfg(test)] pub(crate) use tail_skip_rank::set_tail_skip_arm; #[cfg(test)] -#[allow(unused_imports)] pub(in crate::qwen_forward) use tail_skip_rank::split_group; -#[allow(unused_imports)] +#[cfg(test)] pub(in crate::qwen_forward) use tail_skip_rank::split_group_tail; -#[allow(unused_imports)] -pub(crate) use tail_skip_rank::tail_skip_rank; mod split_group_pcie; -#[allow(unused_imports)] +#[cfg(test)] use split_group_pcie::adapt_decay; -#[allow(unused_imports)] use split_group_pcie::adapt_tuning; -#[allow(unused_imports)] pub(in crate::qwen_forward) use split_group_pcie::{choose_swaps, choose_swaps_by}; #[cfg(test)] -#[allow(unused_imports)] use split_group_pcie::choose_swaps_reference; -#[allow(unused_imports)] pub(in crate::qwen_forward) use split_group_pcie::pcie_locked_only; -#[allow(unused_imports)] pub(in crate::qwen_forward) use split_group_pcie::split_group_pcie; -#[allow(unused_imports)] pub(in crate::qwen_forward) use split_group_pcie::{PcieSplitPolicy, RoutedGroup}; mod cross_layer_potential; mod swap_tie_order; @@ -311,23 +301,12 @@ mod pcie_auto_on_window_pool; #[cfg(test)] mod strata_pcie_auto_tests; mod span_cache_and_pcie_lag; -#[allow(unused_imports)] use span_cache_and_pcie_lag::span_cache_enabled; mod source_spans; -#[allow(unused_imports)] pub(super) use source_spans::source_spans; -#[allow(unused_imports)] -use source_spans::swap_wait; mod open_tier; -#[allow(unused_imports)] pub(in crate::qwen_forward) use open_tier::loan_slots; -#[allow(unused_imports)] pub(in crate::qwen_forward) use open_tier::open_tier; -#[allow(unused_imports)] -use open_tier::pin_resident_complement; -#[allow(unused_imports)] pub(in crate::qwen_forward) use open_tier::refill_defer_enabled; -#[allow(unused_imports)] pub(in crate::qwen_forward) use open_tier::refill_lent; -#[allow(unused_imports)] pub(in crate::qwen_forward) use open_tier::settle_refill; 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 04c4d0bf..4c659764 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 @@ -2,13 +2,12 @@ //! Split out of `original_serve_residency` to keep its files under the line limit. use super::{ - AtomicU32, Context, CpuExpertPool, EnvSource, Error, ExpertTierConfig, LOAN_FLOOR, MappedExpertBank, ModelBinding, - MoeWeightCache, ORIGINAL_VERIFY_MAX_PCIE_FETCHES, Ordering, OriginalCacheOptions, OriginalExpertCache, - OriginalGpuStream, OriginalRankedExperts, OriginalServePool, OriginalVerifyCpuRows, OriginalVerifyCpuSink, - OriginalVerifyGpuPlan, OriginalVerifyPcieSource, PathBuf, PcieSplitPolicy, Rc, ResidentExpertBankSpan, Result, - RoutedGroup, SpanCache, StrataPcieAuto, SwapSources, TieOrder, VANILLA_FREE_FLOOR_MIB, VERIFIER_ASSEMBLY_MIB, - driver_error, original_cache_startup, span_cache_enabled, + LOAN_FLOOR, VANILLA_FREE_FLOOR_MIB, VERIFIER_ASSEMBLY_MIB, Context, Error, ExpertTierConfig, ModelBinding, + MoeWeightCache, OriginalCacheOptions, OriginalExpertCache, OriginalRankedExperts, Rc, ResidentExpertBankSpan, + Result, SpanCache, driver_error, original_cache_startup, span_cache_enabled, }; +#[cfg(not(target_os = "linux"))] +use super::MappedExpertBank; use leleka_cuda_driver::RefillBatchOptions; /// generate.cpp startup of the tier for the serve stack: size and open the cache after every other owner, 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 4dcf5d8a..13d245e7 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 @@ -242,28 +242,17 @@ use decode_graph_reuse::{Began, DecodeGraphKey, Ended, GraphReuse, Why}; mod stack_groups; use stack_groups::{RequestState, ServePolicy, TierState}; mod stack_config_and_ttft_marks; -#[allow(unused_imports)] use stack_config_and_ttft_marks::at; -#[allow(unused_imports)] use stack_config_and_ttft_marks::failure; -#[allow(unused_imports)] use stack_config_and_ttft_marks::plan_error; -#[allow(unused_imports)] use stack_config_and_ttft_marks::prefill_bytes; -#[allow(unused_imports)] use stack_config_and_ttft_marks::tier_for; mod original_serve_stack_methods; mod prompt_chunk; -#[allow(unused_imports)] pub(crate) use prompt_chunk::dbg_el; -#[allow(unused_imports)] use prompt_chunk::operator_line; -#[allow(unused_imports)] use prompt_chunk::operator_note; -#[allow(unused_imports)] use prompt_chunk::operator_text; -#[allow(unused_imports)] use prompt_chunk::report_kernel_selection; -#[allow(unused_imports)] use prompt_chunk::vram_note; mod original_serve_stack_device_ports; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs index 1db86781..eb7d1a11 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/lifecycle_fake.rs @@ -26,7 +26,7 @@ mod port; mod prefix; mod stack; -pub(crate) use graphs::{Bank, GraphBook, Refusals}; +pub(crate) use graphs::GraphBook; pub(crate) use prefix::{FakeBlock, FakeState}; pub(crate) use stack::FakeStack; 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/original_serve_stack_methods/decode_phase_steps.rs index 538565b0..5f733c27 100644 --- 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/original_serve_stack_methods/decode_phase_steps.rs @@ -8,8 +8,6 @@ use super::{ StackConfig, assemble_with_window_fallback, disassemble, failure, operator_line, operator_text, original_serve_residency, profile, }; -use crate::qwen_forward::moe_weight_cache::SharedKeys; -use crate::qwen_forward::original_serve_host::HostOutcome; use leleka_cuda_driver::{OriginalQsaMappedJournal, OriginalQsaResidentIndex}; pub(super) type QsaOwners<'ctx> = [Option<(OriginalQsaResidentIndex<'ctx>, OriginalQsaMappedJournal<'ctx>)>; 48]; 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/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs index bfc31855..e31a0eb7 100644 --- 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/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs @@ -2,7 +2,6 @@ //! window, the settlement of its outcome and the serve step. The order of the operations, the error paths and the //! log lines are those of the single function they were taken from. -#[allow(unused_imports)] use super::decode_view::{Book, DecodeView, Extra, Ids, Owners, Policy, Reads, Refill, Tier}; use super::{ AssembleFailure, AssembleInputs, Began, DecodeGraphKey, DecodeResources, DeviceBuffer, Ending, Error, 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/original_serve_stack_methods/original_serve_stack_open/assemble.rs index 69a49aa6..5804f06a 100644 --- 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/original_serve_stack_methods/original_serve_stack_open/assemble.rs @@ -1,7 +1,6 @@ //! The start and the end of `OriginalServeStack::open`, moved out of it by STRA-338 (size): the config-derived values //! computed before any allocation and the final assembly of the stack from the opened parts. -#[allow(unused_imports)] use super::open_phases::{Buffers, Core, TierParts}; use super::{ Context, Error, ExpertBlobSizes, GraphReuse, ModelBinding, OriginalServeStack, OriginalVerifyExpertFormats, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix.rs index 01dc9ece..64674f5e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix.rs @@ -189,8 +189,6 @@ mod tests; mod clock_tests; mod prefix_config; -#[allow(unused_imports)] use prefix_config::admission_reading; -#[allow(unused_imports)] use prefix_config::lcp; mod prefix_serve; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs index e0fd1b35..bc5792ca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs @@ -1,10 +1,6 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). -use super::{ - AnyClock, ByteSize, ChunkOutcome, Clock, Consider, Error, PolicyParams, PrefixBudget, PrefixConfig, PrefixDevice, - PrefixMatch, PrefixServe, PrefixStore, PrefixSummary, Reject, Start, Stats, Stopwatch, StoreConfig, TailMode, - budget, -}; +use super::{ByteSize, ChunkOutcome, Error, PrefixBudget, PrefixConfig, PrefixDevice, PrefixServe, Start, TailMode}; use crate::backend::original_prompt::{PlanLimits, PromptOptions, PromptPath, PromptPlan, ResumePoint}; pub(super) const G: usize = 256; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs index aac693e0..d3a8198e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs @@ -8,13 +8,6 @@ use super::{ Block, ChunkOutcome, Fake, G, PrefixBudget, PrefixConfig, PrefixServe, State, cfg, doc, full_digest, governor, request, serve, session, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AnyClock, ByteSize, Bytes, Clock, Consider, Error, PlanLimits, PolicyParams, PrefixDevice, PrefixMatch, - PrefixStore, PrefixSummary, PromptOptions, PromptPath, PromptPlan, Reject, ResumePoint, Stats, Stopwatch, - StoreConfig, budget, turn, -}; /// Upstream 41cf05a0 `aece46db` (a 1-token prompt with `--spec`): the prompt has no token to read (the single token is /// the first diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs index df0c7671..c1c82681 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs @@ -7,12 +7,6 @@ use super::{ Block, Fake, G, PrefixServe, State, TailMode, cfg, doc, full_digest, request, serve, session, tail_serve, turn, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AnyClock, ByteSize, Clock, Consider, Error, PlanLimits, PolicyParams, PrefixDevice, PrefixMatch, PrefixStore, - PrefixSummary, PromptOptions, PromptPath, PromptPlan, Reject, ResumePoint, Stats, Stopwatch, StoreConfig, -}; #[test] fn a_second_session_with_the_same_system_prompt_resumes_from_the_shared_blocks_and_ends_in_the_full_reads_state() { 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 47e20a9b..086cd7cb 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 @@ -152,9 +152,7 @@ mod tests; mod finish_round_steps; use finish_round_steps::{RoundFacts, combine_round}; mod trace_enabled; -#[allow(unused_imports)] pub(crate) use trace_enabled::stats_enabled; -#[allow(unused_imports)] pub(crate) use trace_enabled::trace_enabled; mod original_spec_controller_finish; mod original_spec_controller_methods; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs index 354051af..d1b8c306 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs @@ -2,9 +2,8 @@ use super::super::original_spec_draft::{DraftPick, FirstSeedPoint, OriginalFirstDraftEngine, TargetSeedRow}; use super::{ - AdaptiveConfig, AdaptivePolicy, Choice, DraftBatch, DraftPlan, DraftPolicy, DraftPreparation, DraftSampling, Error, - MAX_T, NanGuard, Offer, Origin, OriginalDraftEngine, OriginalSpecController, OriginalSpecEngine, PrefixMemo, Rc, - Result, RoundFacts, SpecConfig, SpecError, SpecStats, SpecWindow, SuffixDrafter, VerifiedWindow, + AdaptiveConfig, DraftPreparation, DraftSampling, Error, NanGuard, OriginalDraftEngine, OriginalSpecController, OriginalSpecEngine, + Result, SpecConfig, SpecError, SpecWindow, }; mod golden; @@ -244,7 +243,6 @@ fn run_to_the_end( setup: EndRunSetup, min_p: f32, ) -> (Fake, Vec, OriginalSpecController) { - use super::super::original_spec_adaptive::AdaptiveConfig; let EndRunSetup { max_t, mtp, suffix, adaptive } = setup; let p = prompt(prompt_len); let mut e = Fake::new(&p[..prompt_len - 1]); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs index 09855f9d..85ce291a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs @@ -8,13 +8,6 @@ use super::{ OriginalSpecController, Result, SpecConfig, SpecError, SpecWindow, VOCAB, begin, config, drive, expected, next, prompt, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AdaptiveConfig, AdaptivePolicy, Choice, DraftBatch, DraftPlan, DraftPolicy, MAX_T, Offer, Origin, - OriginalDraftEngine, OriginalSpecEngine, PrefixMemo, Rc, RoundFacts, SpecStats, SuffixDrafter, TargetSeedRow, - VerifiedWindow, -}; #[test] fn adaptation_join_failure_is_reported_even_after_a_good_draft() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs index 2354ef51..59862f8f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs @@ -4,16 +4,9 @@ //! the_adaptive_window_emits_the_same_text_as_a_fixed_one_under_any_drafter .... use super::{ - EndRunSetup, Error, Fake, NanGuard, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, begin, config, drive, + AdaptiveConfig, EndRunSetup, Error, Fake, NanGuard, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, begin, config, drive, expected, prompt, run_to_the_end, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AdaptiveConfig, AdaptivePolicy, Choice, DraftBatch, DraftPick, DraftPlan, DraftPolicy, DraftPreparation, - DraftSampling, FirstSeedPoint, MAX_T, Offer, Origin, OriginalDraftEngine, OriginalFirstDraftEngine, - OriginalSpecEngine, PrefixMemo, Rc, Result, RoundFacts, SpecStats, SuffixDrafter, TargetSeedRow, VerifiedWindow, -}; #[test] fn config_rejects_out_of_range_and_mtp_zero_means_max_t() { @@ -53,7 +46,6 @@ fn begin_request_validates_tokens_and_rejects_a_live_request() { #[test] fn the_adaptive_window_emits_the_same_text_as_a_fixed_one_under_any_drafter() { - use super::super::super::original_spec_adaptive::AdaptiveConfig; for bad in [None, Some(0), Some(1), Some(3)] { for probs in [vec![0.95; 8], vec![0.3; 8], vec![0.9, 0.8, 0.6, 0.5, 0.4, 0.9, 0.9, 0.9]] { for suffix in [0usize, 3] { @@ -78,7 +70,6 @@ fn the_adaptive_window_emits_the_same_text_as_a_fixed_one_under_any_drafter() { #[test] fn the_adaptive_window_learns_to_verify_wide_when_the_drafter_is_perfect() { - use super::super::super::original_spec_adaptive::AdaptiveConfig; let p = prompt(6); let mut e = Fake::new(&p[..5]); let mut c = OriginalSpecController::new(config(6, 6, 0).with_adaptive(Some(AdaptiveConfig::new(6, 5)))).unwrap(); @@ -277,7 +268,6 @@ fn a_one_token_prompt_speculates_from_position_zero() { } fn assert_one_token_prompt_speculates(suffix: usize, adaptive: bool) { - use super::super::super::original_spec_adaptive::AdaptiveConfig; let p = prompt(1); let mut e = Fake::new(&[]); let mut cfg = config(4, 4, suffix); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs index 7f81e87c..39e23214 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs @@ -7,13 +7,6 @@ use super::{ Error, Fake, NanGuard, OriginalSpecController, OriginalSpecEngine, SpecError, VOCAB, begin, config, drive, expected, guarded, prompt, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - AdaptiveConfig, AdaptivePolicy, Choice, DraftBatch, DraftPick, DraftPlan, DraftPolicy, DraftPreparation, - DraftSampling, FirstSeedPoint, MAX_T, Offer, Origin, OriginalDraftEngine, OriginalFirstDraftEngine, PrefixMemo, Rc, - Result, RoundFacts, SpecStats, SuffixDrafter, TargetSeedRow, VerifiedWindow, -}; #[test] fn a_non_finite_window_is_run_again_from_its_checkpoint_and_the_request_completes() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_draft.rs index 302a3453..ac65cb46 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_draft.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_draft.rs @@ -216,7 +216,7 @@ fn drain_after(result: Result, drain: Result<()>) -> Result { } mod projection_row; -#[allow(unused_imports)] pub(super) use projection_row::project; -#[allow(unused_imports)] pub(super) use projection_row::project_retained; mod column_projection; -#[allow(unused_imports)] use column_projection::project_impl; mod q6_numeric; -#[allow(unused_imports)] use q6_numeric::Q6Job; -#[allow(unused_imports)] use q6_numeric::numeric; -#[allow(unused_imports)] use q6_numeric::numeric_retained; 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 f6b7ece8..90e5ec92 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs @@ -101,25 +101,13 @@ pub(super) struct NativePromptAttentionBatch<'source, 'lease, 'ctx> { } mod qsa_ready; -#[allow(unused_imports)] -use qsa_ready::decode_cached; mod decode_selected_cached; -#[allow(unused_imports)] use decode_selected_cached::SelectedKvBytes; -#[allow(unused_imports)] use decode_selected_cached::attend_retained; -#[allow(unused_imports)] use decode_selected_cached::attention_driver_error; -#[allow(unused_imports)] use decode_selected_cached::decode_selected_cached; -#[allow(unused_imports)] use decode_selected_cached::gate_retained; -#[allow(unused_imports)] use decode_selected_cached::release_retained; -#[allow(unused_imports)] -use decode_selected_cached::upload_retained_bytes; -#[allow(unused_imports)] -use decode_selected_cached::upload_retained_f32; mod native_attended; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(super) use native_attended::PromptDevices; 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 c8354765..bfef4f74 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 @@ -4,7 +4,7 @@ use super::{ attend_retained, attention_driver_error, gate_retained, release, upload_bytes, validate_values, }; use crate::model_binding::qwen4exp_input::QsaMatrixKind; -use leleka_cuda_driver::{Bf16ProjectionShape, Driver}; +use leleka_cuda_driver::Driver; use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind}; fn bits(a: &[f32], b: &[f32]) { 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 5545ae82..39812674 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 @@ -1,10 +1,8 @@ //! New retained attention transport proof; no model/provider capability fixture. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ - BindingIdentity, Cell, ChunkLayer, Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, - PromptDevices, ProvenRow, Q, QsaAttendBuffers, QsaAttended, QsaGated, QsaMatrixRole, QsaPrepared, QsaSelectedCache, - QwenStepTxn, Rc, Result, SelectedKvBytes, Stage, TokenLayer, allocate, attend_retained, download, gate_retained, - release, upload, upload_bytes, + 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 leleka_cuda_driver::{Bf16ProjectionShape, Driver}; 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 ede545c1..7860c6b6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index.rs @@ -248,76 +248,43 @@ mod native_state; pub(in crate::qwen_forward) mod prompt_device; mod context; -#[allow(unused_imports)] use context::context; -#[allow(unused_imports)] use context::device_peak; mod index_kernels; mod qsa_index_stage; mod qsa_pending; -#[allow(unused_imports)] use index_kernels::BlockQuery; -#[allow(unused_imports)] use index_kernels::append; -#[allow(unused_imports)] use index_kernels::norm; -#[allow(unused_imports)] use index_kernels::pack; -#[allow(unused_imports)] pub(super) use index_kernels::project; -#[allow(unused_imports)] use index_kernels::rope; -#[allow(unused_imports)] use index_kernels::select; -#[allow(unused_imports)] use index_kernels::select_with_keys; -#[allow(unused_imports)] use index_kernels::split; mod qsa_projection; -#[allow(unused_imports)] pub(super) use qsa_projection::QsaLayerProjection; -#[allow(unused_imports)] pub(super) use qsa_projection::admit_budget; -#[allow(unused_imports)] use qsa_projection::dispatch_projection; -#[allow(unused_imports)] pub(super) use qsa_projection::project_cached_out; -#[allow(unused_imports)] -use qsa_projection::project_device; -#[allow(unused_imports)] use qsa_projection::project_input; -#[allow(unused_imports)] +#[cfg(test)] use qsa_projection::project_input_numeric; -#[allow(unused_imports)] +#[cfg(test)] pub(super) use qsa_projection::project_out_numeric; -#[allow(unused_imports)] use qsa_projection::{ProjectionSources, QsaMatrixLayout}; mod validate_ids; -#[allow(unused_imports)] pub(super) use validate_ids::allocate; -#[allow(unused_imports)] pub(super) use validate_ids::binding_error; -#[allow(unused_imports)] pub(super) use validate_ids::download; -#[allow(unused_imports)] pub(super) use validate_ids::download_bytes; -#[allow(unused_imports)] pub(super) use validate_ids::driver_error; -#[allow(unused_imports)] pub(in crate::qwen_forward) use validate_ids::project_cached_out_scratch; -#[allow(unused_imports)] pub(super) use validate_ids::project_scratch_out_numeric; -#[allow(unused_imports)] pub(super) use validate_ids::release; -#[allow(unused_imports)] use validate_ids::reserve; -#[allow(unused_imports)] pub(super) use validate_ids::upload; -#[allow(unused_imports)] pub(super) use validate_ids::upload_bytes; -#[allow(unused_imports)] use validate_ids::validate_half; -#[allow(unused_imports)] pub(super) use validate_ids::validate_ids; -#[allow(unused_imports)] pub(super) use validate_ids::validate_values; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs index f0a66c49..e49029f6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs @@ -1,13 +1,11 @@ //! Actor-owned bounded index-key mirror; host QsaPrior remains canonical. //! Only exact immutable parent identity permits incremental device publication. use super::{ - Bf16ProjectionShape, BindingIdentity, BlockQuery, Context, DenseFormat, DenseWeightCache, DeviceBuffer, Directory, - DriverError, Error, GrRole, InputBindingError, KvPage, LayerId, ModelBinding, PAGE, Position, ProjectionKind, - ProjectionSources, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, QsaAttendBuffers, QsaGated, - QsaInputLease, QsaInputScratch, QsaLayerProjection, QsaMatrixKind, QsaMatrixLayout, QsaMatrixRole, QsaOwner, - QsaPrior, QsaSelectedCache, QsaSelectionRequest, QsaWeights, QwenStepTxn, Rc, ResidualReady, Result, Stage, State, - TokenLayer, admit_budget, context, device_peak, driver_error, reserve, select_with_keys, validate_values, + BindingIdentity, BlockQuery, Context, DeviceBuffer, Error, QsaPrior, QsaSelectionRequest, Rc, Result, admit_budget, + context, device_peak, driver_error, reserve, select_with_keys, validate_values, }; +#[cfg(test)] +use super::{Directory, KvPage, LayerId, PAGE, Position, QsaOwner, State, TokenLayer}; #[cfg(all(test, target_arch = "x86_64"))] use super::combined_qsa_observer; #[cfg(test)] @@ -247,20 +245,18 @@ mod gpu { } mod max_rows; -#[allow(unused_imports)] +#[cfg(test)] use max_rows::capacity; -#[allow(unused_imports)] +#[cfg(test)] use max_rows::delta; -#[allow(unused_imports)] +#[cfg(test)] use max_rows::max_rows; -#[allow(unused_imports)] +#[cfg(test)] use max_rows::update; -#[allow(unused_imports)] +#[cfg(test)] use max_rows::upload_words; mod synthetic_late_prior; #[cfg(test)] -#[allow(unused_imports)] use synthetic_late_prior::synthetic_late_prior; #[cfg(test)] -#[allow(unused_imports)] use synthetic_late_prior::synthetic_late_prior_for; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs index 1ba96826..19438c9e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device.rs @@ -6,13 +6,9 @@ use super::super::qsa_attention::PromptDevices; use super::super::qsa_prompt_index::PromptChunkOwners; use super::super::session::{TargetStepOrigin, chunk::QwenChunkTxn}; use super::{ - Bf16ProjectionShape, BindingIdentity, BlockQuery, Cell, Context, DenseFormat, DenseWeightCache, DeviceBuffer, - Directory, DriverError, Error, GrRole, InputBindingError, LayerId, ModelBinding, Position, ProjectionKind, - ProjectionSources, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, QsaAttendBuffers, QsaGated, - QsaIndexKeyCache, QsaInputLease, QsaInputScratch, QsaLayerProjection, QsaMatrixKind, QsaMatrixLayout, - QsaMatrixRole, QsaOwner, QsaPending, QsaPrior, QsaSelectedCache, QsaSelectionRequest, QsaWeights, QwenStepTxn, Rc, - ResidualReady, Result, Stage, TokenLayer, allocate, context, download, driver_error, project, - project_scratch_out_numeric, upload, validate_values, + BindingIdentity, Context, DenseWeightCache, DeviceBuffer, DriverError, Error, GrRole, LayerId, ModelBinding, + QsaMatrixKind, QsaMatrixRole, QsaOwner, QsaPending, QsaPrior, QsaWeights, QwenStepTxn, Rc, ResidualReady, Result, + Stage, TokenLayer, allocate, download, driver_error, project, project_scratch_out_numeric, upload, validate_values, }; use crate::qwen_forward::prompt_device_rows::PromptWeights; use leleka_cuda_driver::{ 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 61b07083..f5788a65 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 @@ -4,17 +4,11 @@ //! stores all twelve actual seals before joint target/draft publication. use super::super::super::{input::InputReady, session::QwenSession}; use super::{ - Bf16ProjectionShape, BindingIdentity, BlockQuery, CompletedQsaKvAppend, Context, DenseFormat, DenseWeightCache, - DeviceBuffer, Directory, DriverError, Error, GrRole, InputBindingError, LayerId, ModelBinding, - NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalQsaDeviceSelection, - OriginalQsaPromptDevice, OriginalQsaPromptWeights, Position, ProjectionKind, ProjectionSources, ProjectionSpec, - PromptChunkOwners, PromptDevices, PromptWeights, Q5KProjectionShape, Q6KProjectionShape, QsaAttendBuffers, - QsaChunkPrior, QsaGated, QsaIndexKeyCache, QsaIndexPrior, QsaInputLease, QsaInputScratch, QsaKvAppendTarget, - QsaLayerProjection, QsaMatrixKind, QsaMatrixLayout, QsaMatrixRole, QsaNativeKind, QsaOwner, QsaPrior, - QsaPromptIndexState, QsaPromptKv, QsaResident, QsaSelectedCache, QsaSelectionRequest, QsaWeights, QwenChunkTxn, - QwenStepTxn, Rc, ResidualReady, Result, Stage, TargetStepOrigin, TokenLayer, allocate, check_prompt_shapes, - context, device_error, download, native, project, project_scratch_out_numeric, prompt_projections, upload, - validate_values, + BindingIdentity, Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, + NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalQsaPromptWeights, QsaMatrixKind, + QsaMatrixRole, QsaNativeKind, QsaOwner, QsaPrior, QsaResident, QsaWeights, QwenStepTxn, Rc, ResidualReady, Result, + Stage, TargetStepOrigin, TokenLayer, allocate, check_prompt_shapes, device_error, download, native, project, + project_scratch_out_numeric, prompt_projections, upload, validate_values, }; use leleka_cuda_driver::{ OriginalQsaIndexBatch, OriginalQsaIndexCheckpoint, OriginalQsaResidentAppendTarget, OriginalQsaResidentIndex, @@ -132,7 +126,6 @@ pub(in crate::qwen_forward) struct ResidentQsaRow<'row, 'ctx> { } mod scalar; -pub(in crate::qwen_forward) use scalar::{ResidentQsaScalar, ResidentQsaScalarReady}; mod resident_qsa_completed; pub(in crate::qwen_forward) use resident_qsa_completed::ResidentSealOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs index 4c61cc80..38fbfce0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs @@ -1,7 +1,6 @@ //! Methods of `ResidentQsaCompleted`: `first`, `rows`, `layer`, `validate_rows` and 7 more. //! Defines `ResidentSealOwners`. -#[allow(unused_imports)] use super::resident_qsa_layer::mint; use super::{ Context, DenseWeightCache, Error, InputReady, LayerId, ModelBinding, NativeBatchWorkspace, 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/resident_qsa_span_export_and_seal.rs index 21cb35c3..7147ada6 100644 --- 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/resident_qsa_span_export_and_seal.rs @@ -1,7 +1,6 @@ //! Methods of `ResidentQsaLayer`: `export_span`, `export_kv`, `export_index`, `export_tail` and 5 more. //! Methods of `ResidentQsaPublication`: `publish_validated`. Functions: `span_views`. Defines `SpanViews`. -#[allow(unused_imports)] use super::resident_qsa_layer::rehome; use super::{ Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, NativeBatchWorkspace, OriginalDeviceBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs index c179be2c..b157eadd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar.rs @@ -87,25 +87,9 @@ struct ScalarHost { type GateBuffers<'ctx> = [Option>; 4]; mod scalar_row_admission; -#[allow(unused_imports)] -use scalar_row_admission::check_scalar_shapes; -#[allow(unused_imports)] -use scalar_row_admission::check_scalar_txn; -#[allow(unused_imports)] -use scalar_row_admission::check_txn_input; -#[allow(unused_imports)] use scalar_row_admission::driver; -#[allow(unused_imports)] -use scalar_row_admission::scalar_gate; mod scalar_row_run; -#[allow(unused_imports)] use scalar_row_run::apply_gate; -#[allow(unused_imports)] use scalar_row_run::upload_gate_inputs; mod gated_out_projection; -#[allow(unused_imports)] use gated_out_projection::gate_and_out; -#[allow(unused_imports)] -use gated_out_projection::project_gated_out; -#[allow(unused_imports)] -use gated_out_projection::release_gate_buffers; 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 7ba734de..2b21587f 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 @@ -39,40 +39,14 @@ pub(super) struct NativeOutRow<'ctx> { mod projection_operands; pub(super) use projection_operands::{AttendedRows, AttentionRow, ChunkAttentionSlot, NativeQsaDevices}; mod native_projection_row; -#[allow(unused_imports)] use native_projection_row::check_batch; -#[allow(unused_imports)] -use native_projection_row::check_input; -#[allow(unused_imports)] -use native_projection_row::check_inputs; -#[allow(unused_imports)] -use native_projection_row::chunk_owners; -#[allow(unused_imports)] use native_projection_row::native; -#[allow(unused_imports)] use native_projection_row::native_error; -#[allow(unused_imports)] pub(super) use native_projection_row::project; -#[allow(unused_imports)] -use native_projection_row::project_batches; mod projection_rows; -#[allow(unused_imports)] use projection_rows::check_batches; -#[allow(unused_imports)] use projection_rows::check_shapes; -#[allow(unused_imports)] use projection_rows::concat_mixed; -#[allow(unused_imports)] -use projection_rows::gather_rows; -#[allow(unused_imports)] pub(super) use projection_rows::project_out; -#[allow(unused_imports)] -use projection_rows::project_rows; -#[allow(unused_imports)] -use projection_rows::ready_rows; -#[allow(unused_imports)] use projection_rows::retained_matrices; -#[allow(unused_imports)] -use projection_rows::row_values; -#[allow(unused_imports)] use projection_rows::split_rows; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu.rs index c8a54803..fb8df9ba 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu.rs @@ -1,9 +1,8 @@ //! Synthetic numerical storage proof only; no model binding or source product is fabricated. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ - Bf16ProjectionShape, BindingIdentity, Cell, Context, DeviceBuffer, EXTENTS, Error, GrRole, MATRIX_BYTES, RESERVE, - ROUTER_BYTES, Rc, RefMut, ResidualReady, Result, RouterBuffers, TokenLayer, map_driver_error, validate_activation, - validate_logits, + Bf16ProjectionShape, Cell, Context, DeviceBuffer, EXTENTS, Error, MATRIX_BYTES, RESERVE, ROUTER_BYTES, Rc, Result, + RouterBuffers, map_driver_error, validate_activation, validate_logits, }; use leleka_cuda_driver::Driver; use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind}; @@ -101,32 +100,15 @@ fn original_first_fixed_router_all_logits_routes_repeat_reset_and_cleanup() { } mod report; -#[allow(unused_imports)] use report::activation; -#[allow(unused_imports)] use report::candidate; -#[allow(unused_imports)] use report::close_all; -#[allow(unused_imports)] use report::finish; -#[allow(unused_imports)] -use report::float_bytes; -#[allow(unused_imports)] use report::healthy; -#[allow(unused_imports)] use report::matrix_bytes; -#[allow(unused_imports)] use report::original; -#[allow(unused_imports)] use report::original_project; -#[allow(unused_imports)] use report::original_route; -#[allow(unused_imports)] use report::snapshot; -#[allow(unused_imports)] -use report::valid_product; mod valid_reset; -#[allow(unused_imports)] use valid_reset::numeric; -#[allow(unused_imports)] -use valid_reset::valid_reset; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs index 3275ad14..d1a886c0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs @@ -5,9 +5,6 @@ use super::{ Bf16ProjectionShape, Context, DeviceBuffer, Error, MATRIX_BYTES, Report, Result, RouterBuffers, map_driver_error, validate_activation, validate_logits, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{AssertUnwindSafe, BindingIdentity, Cell, Driver, GrRole, Rc, RefMut, ResidualReady, TokenLayer, report}; impl Report { pub(super) fn guard(&mut self, passed: bool) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs index 29121f58..461e4fd9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk.rs @@ -1,10 +1,9 @@ //! Private layer-major staging. Original committed owner never advances here. #![allow(dead_code)] use super::{ - BindingIdentity, BoundLayerKind, Context, Dimension, Error, FiniteLogits, GdnOwner, GdnPending, GdnPrior, GrRole, - InjectedResidual, InputReady, LayerId, ModelBinding, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, - QsaOwner, QsaPending, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, ThreadId, - TokenId, TokenLayer, chunk, + BindingIdentity, Context, Dimension, Error, GdnPrior, GrRole, InjectedResidual, InputReady, LayerId, ModelBinding, + PlePrior, Position, QsaIndexPrior, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, + TokenId, TokenLayer, }; mod txn_groups; @@ -308,13 +307,8 @@ pub(in crate::qwen_forward) struct TestGdnComponentRows { } mod gdn_chunk_start; -#[allow(unused_imports)] use gdn_chunk_start::host_charge; -#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] -use gdn_chunk_start::same_window_proof; mod host_charge_bounded; -#[allow(unused_imports)] use host_charge_bounded::host_charge_bounded; mod qwen_chunk_txn; mod test_gdn_component_rows; 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 9ccf55b9..4a368b2b 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 @@ -2,14 +2,12 @@ //! Split out of `chunk` to keep its files under the line limit. use super::{ - ActiveMicroWindow, AttentionProgress, AttentionSource, BatchProgress, BindingIdentity, BoundLayerKind, - ChunkAttentionRow, ChunkCommit, ChunkDraftPublication, ChunkFfnRow, ChunkMicroWindow, ChunkRowResidual, Context, - Dimension, Error, FfnInjectionRow, FiniteLogits, GdnChunkAnchor, GdnChunkJournal, GdnChunkMicro, GdnChunkRow, - GdnChunkSeal, GdnChunkStart, GdnOwner, GdnPending, GdnPrior, GrRole, InjectedResidual, InputReady, LayerId, - MicroProgress, ModelBinding, PleOwner, PlePending, PlePrior, Position, PreparedLayerRow, PromptInit, QsaIndexPrior, - QsaOwner, QsaPending, QwenChunkTxn, QwenSession, QwenStepTxn, Rc, Result, Row, STATE_CAPACITY, Stage, - TargetStepOrigin, ThreadId, TokenId, TokenLayer, VerifiedDraftPublication, VerifiedTargetPrefix, chunk, - host_charge, host_charge_bounded, + ActiveMicroWindow, AttentionProgress, AttentionSource, BatchProgress, ChunkAttentionRow, ChunkCommit, + ChunkDraftPublication, ChunkFfnRow, ChunkMicroWindow, ChunkRowResidual, Context, Dimension, Error, FfnInjectionRow, + GdnChunkAnchor, GdnChunkJournal, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnPrior, GrRole, + InjectedResidual, InputReady, LayerId, MicroProgress, ModelBinding, PlePrior, Position, PreparedLayerRow, + PromptInit, QsaIndexPrior, QwenChunkTxn, QwenSession, QwenStepTxn, Rc, Result, Row, STATE_CAPACITY, Stage, + TargetStepOrigin, TokenId, TokenLayer, host_charge, host_charge_bounded, }; mod qwen_chunk_txn_attention_sources; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs index ed07c9db..fb63e905 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify.rs @@ -40,8 +40,6 @@ pub(in crate::qwen_forward) trait VerifiedDraftPublication { mod tests; mod verified_target_prefix; -#[allow(unused_imports)] use verified_target_prefix::greedy_prefix; -#[allow(unused_imports)] use verified_target_prefix::verification_extra_charge; mod qwen_chunk_txn; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs index 222fe1a9..2718068b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs @@ -7,10 +7,9 @@ use super::super::qsa_index::prompt_device::resident_device::{ ParkedLayerSpan, ParkedPrefix, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, ResidentQsaSeal, SpanExport, }; use super::{ - BindingIdentity, BoundLayerKind, Context, Dimension, Error, FiniteLogits, GdnOwner, GdnPending, GdnPrior, GrRole, - InjectedResidual, InputReady, LayerId, ModelBinding, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, - QsaOwner, QsaPending, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, ThreadId, - TokenId, TokenLayer, chunk, + BindingIdentity, Context, Dimension, Error, GdnPrior, GrRole, InputReady, LayerId, ModelBinding, PlePrior, Position, + QsaIndexPrior, QsaOwner, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, TokenId, + TokenLayer, }; use std::cell::{Cell, RefCell}; pub(in crate::qwen_forward) mod draft; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs index f02c4e78..bc99f804 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft.rs @@ -81,7 +81,5 @@ pub(in crate::qwen_forward) use window_origins::WindowOrigins; mod original_draft_checkpoint; mod original_draft_session_ring_restore; mod published_first_materialized; -#[allow(unused_imports)] use published_first_materialized::draft_driver_error; -#[allow(unused_imports)] use published_first_materialized::published_first_materialized; 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 000eec53..bcd7ac97 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs @@ -1,9 +1,8 @@ //! Unit tests of this module (split out of its file; the test ids are unchanged). use super::{ - BoundLayerKind, Context, Error, FiniteLogits, GdnOwner, GdnPending, GdnPrior, GrRole, InjectedResidual, InputReady, - LayerId, ModelBinding, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, QsaOwner, QsaPending, QwenSession, - Rc, Result, Stage, TargetStepOrigin, ThreadId, TokenId, TokenLayer, + 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::qwen_forward::contract::Dimension; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs index 135b8a9f..4a8ea199 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs @@ -8,12 +8,6 @@ use super::{ BindingIdentity, Dimension, Error, GdnPending, InputReady, LayerId, QwenSession, Rc, Stage, TokenId, TokenLayer, position, token, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - BoundLayerKind, Context, FiniteLogits, GdnOwner, GdnPrior, GrRole, InjectedResidual, ModelBinding, PleOwner, - PlePending, PlePrior, Position, QsaIndexPrior, QsaOwner, QsaPending, Result, TargetStepOrigin, ThreadId, -}; #[test] fn gdn_session_commit_advances_all_state_once_and_failed_reset_preserves_owner() { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs index 2a813873..f35ba114 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs @@ -8,12 +8,6 @@ use super::{ BindingIdentity, Dimension, Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, PlePrior, QsaIndexPrior, QsaOwner, QwenSession, Rc, Stage, TokenLayer, position, token, }; -// used only with some cargo features of this crate -#[allow(unused_imports)] -use super::{ - BoundLayerKind, Context, FiniteLogits, GrRole, InjectedResidual, ModelBinding, Position, QsaPending, Result, - TargetStepOrigin, ThreadId, TokenId, -}; #[test] fn retained_gr_handoff_identity_is_lazy_and_refuses_same_position_rebegin() { From 8b5e94fce9c273ed0545787ebe2c931ccd97313e Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 20:59:50 +0100 Subject: [PATCH 4/7] engine-qwen35-cuda: no #[allow(unused_imports)] left (re-exports nobody used are gone, names only the test build needs are cfg(test), names only another platform needs sit under their cfg) Co-Authored-By: Claude Sonnet 5.5 --- .../src/model_binding/qwen4exp_kar_ple/private_copy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs index 0d39f35c..0b4b73ee 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy.rs @@ -289,7 +289,7 @@ use inode::diagnostic; pub(super) use inode::freeze; #[cfg(target_os = "macos")] pub(super) use inode::freeze; -#[cfg(target_os = "macos")] +#[cfg(any(test, target_os = "macos"))] use inode::inode; pub(super) use inode::open_regular; #[cfg(target_os = "macos")] From e45e4d7aa08652ee24932cb17717419e1aa23ce6 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 21:04:47 +0100 Subject: [PATCH 5/7] engine crates: the generated doc headers (Methods of ..., Functions: ..., Split out of ...) are real descriptions of what the file is and why it is a file of its own (438 files, comment lines only) Co-Authored-By: Claude Sonnet 5.5 --- .../src/conversation/cache/conversation_cache.rs | 5 +++-- .../src/conversation/cache/conversation_checkpoint.rs | 4 ++-- .../cache/tests/retained_buffers_count_against_bytes.rs | 6 +++--- .../conversation/cache/tests/what_is_not_superseded.rs | 5 ++--- .../engine-core/src/conversation/kv/kv_image_readback.rs | 4 ++-- .../src/conversation/kv/kv_image_save_restore.rs | 5 +++-- crates/engine-core/src/conversation/kv/layout.rs | 4 ++-- .../src/conversation/manager/conversation_manager.rs | 4 ++-- .../conversation_resume_checkpoints.rs | 5 +++-- .../conversation_manager/conversation_state_events.rs | 4 ++-- .../conversation/manager/conversation_options_default.rs | 4 ++-- .../conversation/manager_tests/byte_budget_and_slot.rs | 9 ++++----- .../conversation/manager_tests/continuing_chat_reuses.rs | 7 +++---- .../engine-core/src/conversation/manager_tests/hash.rs | 4 ++-- .../manager_tests/sim_device_session_device.rs | 4 ++-- .../src/conversation/snapshot_tests/fixture.rs | 4 ++-- .../src/conversation/snapshot_tests/full_session.rs | 4 ++-- .../src/conversation/snapshot_tests/golden_state.rs | 4 ++-- .../src/conversation/snapshot_tests/kv_level.rs | 4 ++-- .../src/conversation/snapshot_tests/kv_region.rs | 4 ++-- .../snapshot_tests/layer_snapshots_are_byte_exact.rs | 7 +++---- .../engine-core/src/conversation/snapshot_tests/pools.rs | 4 ++-- crates/engine-core/src/prefix_cache/store/decayed.rs | 3 +-- .../src/prefix_cache/store/policy_params_default.rs | 3 +-- .../engine-core/src/prefix_cache/store/prefix_store.rs | 4 ++-- .../store/prefix_store/prefix_store_consider_commit.rs | 4 ++-- .../store/prefix_store/prefix_store_evict_and_budget.rs | 4 ++-- .../store/prefix_store/prefix_store_stats_and_clock.rs | 4 ++-- .../prefix_cache/store/tests/hit_by_another_session.rs | 8 +++----- .../src/prefix_cache/store/tests/request_resumes_from.rs | 7 +++---- crates/engine-core/src/prompt/prompt_options.rs | 4 ++-- crates/engine-core/src/spec/adaptive/adaptive_config.rs | 4 ++-- crates/engine-core/src/spec/adaptive/adaptive_policy.rs | 4 ++-- crates/engine-core/src/spec/adaptive/spec_stats.rs | 4 ++-- .../src/spec/adaptive/tests/default_ceiling.rs | 5 ++--- .../adaptive/tests/stationary_regimes_reach_the_best.rs | 6 +++--- .../src/backend/original_serve/original_serve_mode.rs | 4 ++-- .../src/backend/original_serve/runner/command_loop.rs | 4 ++-- .../src/backend/original_serve/tests.rs | 4 +++- .../src/backend/original_serve_replay/required_path.rs | 4 ++-- crates/engine-qwen35-cuda/src/backend/tests.rs | 4 ++++ .../src/conversation/resident/tests.rs | 4 +++- crates/engine-qwen35-cuda/src/experimental/tests.rs | 4 +++- crates/engine-qwen35-cuda/src/model_binding/mod.rs | 3 +++ .../binding_identity_and_input_binding_error.rs | 5 +++-- .../src/model_binding/qwen4exp_input/gdn/tests.rs | 3 ++- .../src/model_binding/qwen4exp_input/gr/tests.rs | 3 ++- .../src/model_binding/qwen4exp_input/model_binding.rs | 4 ++-- .../qwen4exp_input/moe_expert/model_binding.rs | 4 ++-- .../model_binding/model_binding_moe_descriptors.rs | 4 ++-- .../qwen4exp_input/moe_expert/moe_expert_weights.rs | 4 ++-- .../qwen4exp_input/moe_expert/moe_routed_source_scope.rs | 4 ++-- .../moe_expert/routed_source_descriptor.rs | 4 ++-- .../qwen4exp_input/mtp/dense_bytes_types.rs | 4 ++-- .../qwen4exp_input/mtp/descriptors_types.rs | 4 ++-- .../model_binding/qwen4exp_input/mtp/mtp_kind_types.rs | 4 ++-- .../model_binding/qwen4exp_input/mtp/pack_identity.rs | 4 ++-- .../src/model_binding/qwen4exp_input/mtp/tests.rs | 4 +++- .../qwen4exp_input/validate_ple_descriptor.rs | 4 ++-- .../qwen_forward/dense_weight_cache/dense_slab_policy.rs | 4 ++-- .../dense_weight_cache/dense_weight_cache_methods.rs | 4 ++-- .../dense_cache_buffers_and_close.rs | 4 ++-- .../dense_cache_eager_layer_load.rs | 4 ++-- .../dense_cache_gdn_qsa_workspaces.rs | 5 +++-- .../dense_cache_matrix_registration.rs | 4 ++-- .../dense_cache_ple_and_verify_weights.rs | 5 +++-- .../dense_cache_prompt_and_gdn_scratch.rs | 5 +++-- .../dense_weight_cache_constructors.rs | 4 ++-- .../src/qwen_forward/dense_weight_cache/workspaces.rs | 5 +++-- .../executor/original_prompt/original_prompt_executor.rs | 5 +++-- .../original_prompt_executor/construction_and_parking.rs | 4 ++-- .../construction_and_parking/executor_construction.rs | 5 +++-- .../session_park_and_qsa_owners.rs | 4 ++-- .../prompt_executor_forward_and_close.rs | 3 +-- .../prompt_chunk_forward.rs | 5 +++-- .../prompt_chunk_forward/forward_draft.rs | 2 +- .../prompt_chunk_forward/forward_final.rs | 2 +- .../prompt_chunk_forward/forward_input.rs | 2 +- .../prompt_chunk_forward/forward_layers.rs | 2 +- .../prompt_executor_close.rs | 3 +-- .../prompt_executor_retire_owners.rs | 4 ++-- .../original_prompt/original_prompt_executor_drop.rs | 5 +++-- .../executor/original_prompt/staged_input_enabled.rs | 3 +-- .../executor/prefill_chunk/check_chunk_on_loaded.rs | 5 +++-- .../executor/prefill_chunk/prepare_micro_ffn_rows.rs | 4 ++-- .../prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs | 2 +- .../prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs | 2 +- .../prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs | 2 +- .../prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs | 2 +- .../executor/prefill_chunk/prepare_q6_layer_columns.rs | 4 ++-- .../qwen_forward/executor/prefill_chunk/qwen_forward.rs | 4 ++-- .../executor/prefill_chunk/qwen_forward/joint_chunk.rs | 2 +- .../qwen_forward/prefill_chunk_cached_windowed.rs | 4 ++-- .../qwen_forward/prefill_chunk_native_windowed.rs | 5 +++-- .../prefill_chunk/qwen_forward/prefill_chunk_planned.rs | 5 +++-- .../qwen_forward/prefill_chunk_planned/chunk_layer.rs | 2 +- .../qwen_forward/prefill_chunk_planned/chunk_setup.rs | 2 +- .../qwen_forward/prefill_chunk_planned/host_attention.rs | 2 +- .../prefill_chunk_planned/window_attention.rs | 2 +- .../qwen_forward/prefill_chunk_planned/window_experts.rs | 2 +- .../qwen_forward/prefill_chunk_planned/window_ffn.rs | 2 +- .../prefill_chunk_planned/window_ffn_flow.rs | 2 +- .../executor/prefill_chunk/read_chunk_attention_ffn.rs | 5 +++-- .../executor/prefill_chunk/target_step_product.rs | 4 ++-- .../executor/prefill_chunk/window_numeric/proof.rs | 3 ++- .../src/qwen_forward/executor/prefill_step_product.rs | 5 +++-- .../executor/qwen_forward/qwen_forward_reset.rs | 3 +-- .../src/qwen_forward/executor/read_layer_attention.rs | 5 +++-- .../src/qwen_forward/executor/reset_replay_sdet.rs | 4 +++- .../src/qwen_forward/executor/step_layers.rs | 3 ++- .../src/qwen_forward/executor/tests.rs | 3 ++- .../src/qwen_forward/gdn/cached_step.rs | 5 +++-- .../src/qwen_forward/gdn/chain/allocate_qk_slot.rs | 5 +++-- .../src/qwen_forward/gdn/chain/chain.rs | 4 ++-- .../gdn/chain/chain/chain_construction_and_buffers.rs | 4 ++-- .../gdn/chain/chain/chain_projection_convolution.rs | 4 ++-- .../gdn/chain/chain/chain_readout_and_finish.rs | 4 ++-- .../src/qwen_forward/gdn/chain/chain/chain_row_queue.rs | 5 +++-- .../src/qwen_forward/gdn/chain/chain_drop.rs | 3 +-- .../gdn/chunk_device/gdn_chunk_device_methods.rs | 3 +-- .../chunk_device_batch_compute.rs | 5 +++-- .../chunk_device_construction.rs | 5 +++-- .../chunk_device_finish_cleanup.rs | 4 ++-- .../gdn/chunk_device/mirror_reuse_enabled.rs | 4 ++-- .../qwen_forward/gdn/chunk_device/native_fused_step.rs | 4 ++-- .../gdn/chunk_device/numeric_gpu/batch_adoption.rs | 5 +++-- .../gdn/chunk_device/numeric_gpu/exercise.rs | 5 +++-- .../gdn/chunk_device/numeric_gpu/operands.rs | 4 ++-- .../src/qwen_forward/gdn/driver_error.rs | 4 ++-- crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs | 5 +++-- .../engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs | 4 ++-- .../qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs | 3 +-- .../state_mirror_compute_and_admit.rs | 5 +++-- .../state_mirror_publish_and_close.rs | 4 ++-- .../src/qwen_forward/gdn/mirror/mirror_readout.rs | 4 ++-- .../src/qwen_forward/gdn/mirror/upload_checked.rs | 3 +-- .../src/qwen_forward/gdn/prefill_batch/buffers.rs | 5 +++-- .../gdn/prefill_batch/gdn_batch_resources.rs | 5 +++-- .../src/qwen_forward/gdn/prefill_batch/gdn_stage.rs | 4 ++-- .../src/qwen_forward/gdn/prefill_batch/step_batch.rs | 5 ++++- .../src/qwen_forward/gdn/projection.rs | 5 +++-- .../src/qwen_forward/gdn/stage_steps.rs | 4 ++-- .../src/qwen_forward/gdn/verification/compute_row.rs | 4 ++-- .../compute_row/verified_row_compute_and_lease.rs | 4 ++-- .../gdn/verification/compute_row/workspace.rs | 4 ++-- .../gdn/verification/compute_row/workspace_replay.rs | 5 +++-- .../src/qwen_forward/gdn/verification/workspace.rs | 3 +-- .../src/qwen_forward/gr/batch_chunk/batch_inject.rs | 4 +++- .../src/qwen_forward/gr/batch_chunk/gr_micro_input.rs | 4 ++-- .../src/qwen_forward/gr/batch_chunk/gr_stage.rs | 5 +++-- .../gr/batch_chunk/gr_stage_prepare_injection.rs | 4 ++-- .../engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs | 4 ++-- .../src/qwen_forward/gr/download_f32.rs | 4 ++-- .../engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs | 5 +++-- .../src/qwen_forward/gr/output_workspace_gpu.rs | 3 +-- .../gr/output_workspace_gpu/check_handoff.rs | 4 ++-- .../qwen_forward/gr/output_workspace_gpu/fresh_read.rs | 4 ++-- .../src/qwen_forward/gr/read_cached_cuda.rs | 4 ++-- .../engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs | 4 ++-- .../src/qwen_forward/gr/residual_ready.rs | 4 ++-- crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs | 3 ++- crates/engine-qwen35-cuda/src/qwen_forward/input.rs | 4 ++++ .../src/qwen_forward/input/gather_rows.rs | 5 +++-- crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs | 3 +++ .../src/qwen_forward/input/input_stage.rs | 5 +++-- .../src/qwen_forward/input/input_stage_ple_micro.rs | 5 +++-- .../src/qwen_forward/input/ple_cuda.rs | 5 +++-- .../input/ple_transport/ple_key_retained_gpu/bf16.rs | 4 ++-- .../src/qwen_forward/input/ple_transport/role.rs | 5 +++-- .../src/qwen_forward/input/ple_upload_f32.rs | 4 ++-- .../src/qwen_forward/input/residual_streams.rs | 4 ++-- .../qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs | 5 +++-- .../src/qwen_forward/kar_ple_cache/lru_tests.rs | 5 +++-- .../src/qwen_forward/kar_ple_cache/publish_gather.rs | 4 ++-- .../src/qwen_forward/kar_ple_cache/row_parity_probe.rs | 5 +++-- .../src/qwen_forward/kar_ple_cache/scratch_bytes.rs | 5 +++-- .../src/qwen_forward/kar_ple_cache/slot_tests.rs | 5 +++-- .../src/qwen_forward/moe_expert/cached_expert_run.rs | 5 +++-- .../qwen_forward/moe_expert/expert_matrix_projection.rs | 6 ++++-- .../src/qwen_forward/moe_expert/expert_mlp_values.rs | 6 ++++-- .../src/qwen_forward/moe_expert/expert_step.rs | 6 ++++-- .../adaptive_packets/adaptive_packet_projection.rs | 5 +++-- .../grouped/adaptive_packets/packet_wave_projection.rs | 5 +++-- .../qwen_forward/moe_expert/grouped/direct_gpu/arm.rs | 5 +++-- .../moe_expert/grouped/direct_gpu/loaded_arms.rs | 5 +++-- .../qwen_forward/moe_expert/grouped/direct_gpu/policy.rs | 6 ++++-- .../qwen_forward/moe_expert/grouped/direct_gpu/probe.rs | 5 +++-- .../src/qwen_forward/moe_expert/grouped/execute_bound.rs | 6 ++++-- .../moe_expert/grouped/finish_shared_with.rs | 5 +++-- .../moe_expert/grouped/ordered_down_refusal.rs | 6 ++++-- .../grouped/packet_run_project_group_direct.rs | 6 ++++-- .../qwen_forward/moe_expert/grouped/prepared_moe_row.rs | 6 ++++-- .../src/qwen_forward/moe_expert/grouped/project_group.rs | 6 ++++-- .../moe_expert/grouped/project_group_source_consumers.rs | 5 +++-- .../moe_expert/grouped/project_group_source_fenced.rs | 5 +++-- .../moe_expert/moe_activation_reuse_gpu/encoded.rs | 5 +++-- .../former_fixture_domain_refusal.rs | 5 +++-- .../src/qwen_forward/moe_expert/moe_down/down_scope.rs | 5 +++-- .../moe_expert/moe_down/moe_down_reuse_gpu/exact.rs | 4 ++-- .../moe_expert/moe_down/resident_packed_down.rs | 5 +++-- .../qwen_forward/moe_expert/moe_down/retained_scalar.rs | 5 +++-- .../src/qwen_forward/moe_expert/scoped_expert_mlp.rs | 5 +++-- .../src/qwen_forward/moe_expert/tests.rs | 3 ++- .../src/qwen_forward/moe_expert/validate_values.rs | 4 ++-- .../src/qwen_forward/moe_prefill_batch/device_bytes.rs | 5 +++-- .../moe_prefill_batch/moe_prefill_resources.rs | 5 +++-- .../qwen_forward/moe_prefill_batch/moe_prefill_stage.rs | 5 +++-- .../src/qwen_forward/moe_prefill_batch/tests.rs | 4 +++- .../src/qwen_forward/moe_route/project_logits.rs | 6 ++++-- .../src/qwen_forward/moe_route/router_logits.rs | 5 +++-- .../src/qwen_forward/moe_route/run_cuda.rs | 5 +++-- .../src/qwen_forward/moe_route/tests.rs | 4 ++++ .../cache_ephemeral_routed/ephemeral_mapped_stage.rs | 5 +++-- .../cache_ephemeral_routed/ephemeral_routed_owner.rs | 4 ++-- .../ephemeral_routed_owner/ephemeral_owner_allocation.rs | 5 +++-- .../ephemeral_owner_loans_and_drain.rs | 5 +++-- .../ephemeral_owner_stage_transfer.rs | 5 +++-- .../cache_ephemeral_routed/healthy_cancel.rs | 5 +++-- .../moe_weight_cache/cache_lru_index/lru_index.rs | 5 +++-- .../cache_lru_index/lru_index_seeding.rs | 5 +++-- .../moe_weight_cache/cache_lru_index/slot.rs | 4 ++-- .../moe_weight_cache/cache_lru_index/tests.rs | 4 +++- .../cache_original_prompt/moe_weight_cache.rs | 5 +++-- .../cache_original_prompt/moe_weights_original_prompt.rs | 5 +++-- .../cache_original_prompt/prompt_stream_settings.rs | 5 +++-- .../moe_weight_cache/cache_profile/learned_main_sdet.rs | 3 ++- .../moe_weight_cache/cache_profile/ranked_profile.rs | 5 +++-- .../cache_profile/shared_permanent_pool.rs | 5 +++-- .../cache_profile_fill/learned_main_lru_profile.rs | 5 +++-- .../cache_profile_fill/moe_weight_cache.rs | 4 ++-- .../moe_weight_cache/pinned_triplet_preload.rs | 5 +++-- .../moe_weight_cache/profile_ranked_fill_and_pool.rs | 5 +++-- .../cache_profile_fill/profile_window_spill.rs | 5 +++-- .../cache_profile_fill/shared_quartet_preload.rs | 5 +++-- .../cache_profile_fill/strata_adaptive_shared_pool.rs | 5 +++-- .../cache_strata_adaptive/adaptive_cache.rs | 5 +++-- .../moe_weight_cache/cache_strata_adaptive/reserve.rs | 5 +++-- .../moe_weight_cache/cache_strata_adaptive/tests.rs | 4 ++-- .../cache_strata_adaptive/transfer_metadata_bound.rs | 3 +-- .../moe_weight_cache/moe_cache_routed_owners.rs | 5 +++-- .../moe_weight_cache/moe_weight_cache_methods.rs | 4 ++-- .../moe_weight_cache_methods/moe_cache_close_owners.rs | 4 ++-- .../moe_cache_compose_shared_and_mtp.rs | 5 +++-- .../moe_weight_cache_methods/moe_cache_lru_updates.rs | 5 +++-- .../moe_cache_lru_updates/shared_keys.rs | 4 ++-- .../moe_cache_main_entry_routed_source.rs | 4 ++-- .../moe_cache_matrix_and_mtp_lookup.rs | 4 ++-- .../moe_cache_mmq_chunk_admission.rs | 5 +++-- .../moe_cache_mmq_constructors.rs | 4 ++-- .../moe_cache_shared_tail_constructors.rs | 4 ++-- .../moe_cache_triplet_plan_upload.rs | 5 +++-- .../moe_cache_validate_prepare_step.rs | 4 ++-- .../original_mtp_weights/dense_copies_equal.rs | 5 +++-- .../retained_original_mtp_weights.rs | 5 +++-- .../moe_weight_cache/routed_source_health.rs | 4 ++-- .../moe_weight_cache/routed_workspace_owner.rs | 5 +++-- .../moe_weight_cache/validate_ranked_profile.rs | 5 +++-- .../engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs | 6 ++++-- .../qwen_forward/mtp/project_attention_out_numeric.rs | 5 +++-- .../qwen_forward/mtp/state/chunk/checked_chunk_end.rs | 6 ++++-- .../src/qwen_forward/mtp/state/chunk/mtp_session.rs | 4 ++-- .../src/qwen_forward/mtp/state/dense_kv.rs | 5 +++-- .../src/qwen_forward/mtp/state/mtp_session.rs | 5 +++-- .../src/qwen_forward/mtp/state/prefix_draft_snapshot.rs | 5 +++-- .../src/qwen_forward/mtp/state/tests.rs | 4 +++- crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs | 6 ++++-- .../src/qwen_forward/mtp_attention/attention_stage.rs | 6 ++++-- .../qwen_forward/mtp_attention/attention_transport.rs | 5 +++-- .../src/qwen_forward/mtp_attention/dense_geometry.rs | 5 +++-- .../src/qwen_forward/mtp_attention/tests.rs | 3 ++- .../qwen_forward/mtp_decode/batch_gpu/check_loaded.rs | 4 ++-- .../mtp_decode/batch_gpu/check_loaded/flow.rs | 5 +++-- .../batch_gpu/check_loaded/flow_decode_edge_scenarios.rs | 5 +++-- .../mtp_decode/batch_gpu/check_loaded/position_at.rs | 4 ++-- .../src/qwen_forward/mtp_decode/batch_gpu/collection.rs | 5 +++-- .../qwen_forward/mtp_decode/first_seed_reuse_enabled.rs | 6 ++++-- .../src/qwen_forward/mtp_decode/mtp_window_spec.rs | 5 +++-- .../src/qwen_forward/mtp_experts/append_row.rs | 4 ++-- .../mtp_experts/fixed_workspace/fixed_buffers.rs | 5 +++-- .../mtp_experts/fixed_workspace/fixed_workspace_gpu.rs | 4 +++- .../src/qwen_forward/mtp_experts/fixed_workspace/role.rs | 6 ++++-- .../mtp_experts/fixed_workspace/transport_drop.rs | 5 +++-- .../src/qwen_forward/mtp_experts/mtp_block.rs | 6 ++++-- .../mtp_expert_transport_gpu/exact.rs | 5 +++-- .../mtp_expert_transport_gpu/owner_guards.rs | 5 +++-- .../mtp_experts/mtp_expert_transport/role.rs | 6 ++++-- .../mtp_experts/mtp_expert_transport/shared_project.rs | 5 +++-- .../mtp_experts/routed_and_shared_experts.rs | 5 +++-- .../src/qwen_forward/mtp_experts/tests.rs | 4 +++- .../src/qwen_forward/mtp_gr/driver_error.rs | 6 ++++-- .../src/qwen_forward/mtp_gr/finalize.rs | 6 ++++-- .../mtp_full_owner_actor_close.rs | 5 +++-- .../original_mtp_full_owner_methods.rs | 6 ++++-- .../original_mtp_full_owner/original_mtp_request.rs | 5 +++-- .../original_mtp_verified_adapter/driver_error.rs | 5 +++-- .../original_mtp_draft_receipt.rs | 6 ++++-- .../original_prompt_executor.rs | 6 ++++-- .../src/qwen_forward/original_serve_config/tests.rs | 3 ++- .../original_serve_engine/draft_completion.rs | 4 ++-- .../draft_completion/serve_engine_draft_commit.rs | 5 +++-- .../qwen_forward/original_serve_engine/round_tally.rs | 4 ++-- .../round_tally/original_serve_settings.rs | 5 +++-- .../original_serve_engine/round_tally/serve_rounds.rs | 5 +++-- .../src/qwen_forward/original_serve_engine/tests.rs | 3 ++- .../tests/constructor_validates_dimensions.rs | 5 ++--- .../tests/restore_attempts_do_not_depend.rs | 6 ++---- .../original_serve_host_native_serve_host.rs | 4 ++-- .../qwen_forward/original_serve_host/request_sampling.rs | 5 +++-- .../src/qwen_forward/original_serve_host/tests.rs | 3 ++- .../native_serve_port_original_serve_port.rs | 4 ++-- .../qwen_forward/original_serve_native/native_window.rs | 5 +++-- .../qwen_forward/original_serve_pool/cpu_expert_pool.rs | 5 +++-- .../src/qwen_forward/original_serve_pool/direct_tier.rs | 5 +++-- .../qwen_forward/original_serve_pool/direct_tier_drop.rs | 4 ++-- .../original_serve_pool/prefetch_off_file_exists.rs | 5 +++-- .../src/qwen_forward/original_serve_pool/tests.rs | 3 ++- .../src/qwen_forward/original_serve_request/tests.rs | 3 ++- .../original_serve_residency/source_spans.rs | 4 ++-- .../original_serve_residency/span_cache_and_pcie_lag.rs | 4 ++-- .../original_serve_residency/split_group_pcie.rs | 5 +++-- .../original_serve_residency/tail_skip_rank.rs | 4 ++-- .../src/qwen_forward/original_serve_residency/tests.rs | 3 ++- .../original_serve_stack/conversation/tests.rs | 3 ++- .../original_serve_stack_device_ports.rs | 4 ++-- .../original_serve_stack_decode_phase.rs | 4 ++-- .../original_serve_stack_decode_phase/decode_steps.rs | 5 ++--- .../original_serve_stack_decode_phase/decode_view.rs | 2 +- .../original_serve_stack_memory_classes.rs | 4 ++-- .../original_serve_stack_metrics_close.rs | 4 ++-- .../original_serve_stack_open.rs | 4 ++-- .../original_serve_stack_open/assemble.rs | 4 ++-- .../original_serve_stack_open/open_phases.rs | 4 ++-- .../original_serve_stack_prefill_chunk.rs | 4 ++-- .../original_serve_stack_prefill_phase.rs | 4 ++-- .../original_serve_stack/prefix/prefix_config.rs | 4 ++-- .../original_serve_stack/prefix/prefix_serve.rs | 4 ++-- .../prefix_serve/prefix_serve_after_phase_parking.rs | 4 ++-- .../prefix_serve/prefix_serve_store_and_shedding.rs | 4 ++-- .../qwen_forward/original_serve_stack/prefix/tests.rs | 3 ++- .../prefix/tests/one_token_prompt_reads.rs | 7 ++----- .../original_serve_stack/prefix/tests/second_session.rs | 7 ++----- .../qwen_forward/original_serve_stack/prompt_chunk.rs | 4 ++-- .../original_serve_stack/stack_config_and_ttft_marks.rs | 4 ++-- .../qwen_forward/original_serve_stack/stack_groups.rs | 4 ++-- .../src/qwen_forward/original_serve_stack/tests.rs | 3 ++- .../src/qwen_forward/original_serve_verifier/tests.rs | 3 ++- .../original_spec_controller_finish.rs | 5 +++-- .../original_spec_controller_start_request.rs | 5 +++-- .../original_spec_controller_verify_commit.rs | 4 ++-- .../src/qwen_forward/original_spec_controller/tests.rs | 3 ++- .../tests/adaptation_join_failure_is_reported.rs | 6 ++---- .../tests/config_rejects_out_of_range.rs | 7 +++---- .../original_spec_controller/tests/non_finite_window.rs | 7 +++---- .../original_spec_controller/trace_enabled.rs | 4 ++-- .../src/qwen_forward/output/original_prompt_sample.rs | 5 +++-- .../src/qwen_forward/output/output_stage.rs | 4 ++-- .../output/output_stage/output_stage_load_and_logits.rs | 4 ++-- .../output_stage/output_stage_sampling_projection.rs | 5 +++-- .../src/qwen_forward/output/output_stage_test_replay.rs | 4 ++-- .../engine-qwen35-cuda/src/qwen_forward/output/tests.rs | 3 ++- .../prompt_device_rows/prompt_device_read.rs | 4 ++-- .../prompt_device_read/produce_original_gdn.rs | 5 +++-- .../prompt_device_read/read_completion.rs | 4 ++-- .../prompt_device_rows/prompt_ple_history.rs | 4 ++-- .../src/qwen_forward/prompt_device_rows/std_ops_deref.rs | 4 ++-- .../std_ops_deref/prompt_device_rows.rs | 5 +++-- .../std_ops_deref/prompt_device_rows_ple_read.rs | 4 ++-- .../std_ops_deref/source_input_deref.rs | 4 ++-- .../q6_attention_columns/column_projection.rs | 5 +++-- .../qwen_forward/q6_attention_columns/projection_row.rs | 5 +++-- .../src/qwen_forward/q6_attention_columns/q6_numeric.rs | 5 +++-- .../qwen_forward/qsa_attention/decode_selected_cached.rs | 5 +++-- .../src/qwen_forward/qsa_attention/native_attended.rs | 5 +++-- .../src/qwen_forward/qsa_attention/qsa_ready.rs | 5 +++-- .../src/qwen_forward/qsa_index/context.rs | 5 +++-- .../qsa_index/directory/qsa_directory_sdet.rs | 3 +++ .../src/qwen_forward/qsa_index/index_kernels.rs | 4 ++-- .../qwen_forward/qsa_index/index_resident/max_rows.rs | 5 +++-- .../qsa_index/index_resident/synthetic_late_prior.rs | 3 +-- .../resident_device/resident_qsa_completed.rs | 5 +++-- .../prompt_device/resident_device/resident_qsa_layer.rs | 5 +++-- .../prompt_device/resident_device/resident_qsa_prior.rs | 5 +++-- .../resident_device/resident_qsa_span_export_and_seal.rs | 5 +++-- .../resident_device/scalar/gated_out_projection.rs | 4 ++-- .../resident_device/scalar/scalar_row_admission.rs | 4 ++-- .../resident_device/scalar/scalar_row_run.rs | 4 ++-- .../src/qwen_forward/qsa_index/qsa_index_stage.rs | 5 +++-- .../src/qwen_forward/qsa_index/qsa_pending.rs | 4 ++-- .../src/qwen_forward/qsa_index/qsa_projection.rs | 4 ++-- .../src/qwen_forward/qsa_index/selected_cache/tests.rs | 3 ++- .../src/qwen_forward/qsa_index/validate_ids.rs | 4 ++-- .../qsa_prefill_batch/native_projection_row.rs | 5 +++-- .../qwen_forward/qsa_prefill_batch/projection_rows.rs | 4 ++-- .../src/qwen_forward/router_scratch/gpu/report.rs | 5 +++-- .../src/qwen_forward/router_scratch/gpu/valid_reset.rs | 5 +++-- .../src/qwen_forward/session/chunk/gdn_chunk_start.rs | 5 +++-- .../qwen_forward/session/chunk/host_charge_bounded.rs | 5 +++-- .../src/qwen_forward/session/chunk/qwen_chunk_txn.rs | 5 +++-- .../qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs | 4 ++-- .../session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs | 5 +++-- .../qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs | 4 ++-- .../qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs | 5 +++-- .../chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs | 5 +++-- .../chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs | 4 ++-- .../chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs | 5 +++-- .../chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs | 4 ++-- .../qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs | 4 ++-- .../session/chunk/test_gdn_component_rows.rs | 4 ++-- .../src/qwen_forward/session/chunk/txn_groups.rs | 4 ++-- .../qwen_forward/session/chunk/verify/qwen_chunk_txn.rs | 4 ++-- .../qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs | 5 +++-- .../qwen_chunk_txn/qwen_chunk_txn_verification_state.rs | 4 ++-- .../qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs | 5 +++-- .../src/qwen_forward/session/chunk/verify/tests.rs | 3 ++- .../session/chunk/verify/verified_target_prefix.rs | 4 ++-- .../original_prompt/draft/original_draft_checkpoint.rs | 5 +++-- .../draft/original_draft_session_ring_restore.rs | 5 +++-- .../draft/published_first_materialized.rs | 4 ++-- .../session/original_prompt/original_prompt_input.rs | 4 ++-- .../original_prompt_input_qsa_seed.rs | 4 ++-- .../original_prompt_input/qwen_session.rs | 5 +++-- .../session/original_prompt/original_prompt_phase.rs | 4 ++-- .../session/original_prompt/original_prompt_txn.rs | 3 +-- .../original_prompt_txn/original_prompt_txn_begin.rs | 4 ++-- .../original_prompt_txn_prior_and_abort.rs | 4 ++-- .../original_prompt_txn/original_prompt_txn_publish.rs | 4 ++-- .../src/qwen_forward/session/original_verified/tests.rs | 4 +++- .../src/qwen_forward/session/qwen_session.rs | 4 ++-- .../src/qwen_forward/session/qwen_step_txn.rs | 3 +-- .../session/qwen_step_txn/qwen_step_txn_inputs.rs | 4 ++-- .../session/qwen_step_txn/qwen_step_txn_prior_finish.rs | 4 ++-- .../src/qwen_forward/session/reset_replay_snapshot.rs | 5 +++-- .../engine-qwen35-cuda/src/qwen_forward/session/tests.rs | 3 ++- .../session/tests/gdn_session_commit_advances_all.rs | 8 +++----- .../session/tests/retained_gr_handoff_identity.rs | 8 +++----- crates/engine-qwen35-cuda/src/serve_meta/tests.rs | 4 +++- crates/engine-qwen35-cuda/src/serve_tuning/tests.rs | 4 ++++ crates/engine-qwen35-cuda/src/settings/capture_tests.rs | 4 ++++ 438 files changed, 1084 insertions(+), 843 deletions(-) diff --git a/crates/engine-core/src/conversation/cache/conversation_cache.rs b/crates/engine-core/src/conversation/cache/conversation_cache.rs index a5374a9d..6f47f887 100644 --- a/crates/engine-core/src/conversation/cache/conversation_cache.rs +++ b/crates/engine-core/src/conversation/cache/conversation_cache.rs @@ -1,5 +1,6 @@ -//! Methods of `ConversationCache`: `new`, `enabled`, `budget`, `slots` and 15 more. Functions: `deepest_key`. -//! Split out of `cache` to keep its files under the line limit. +//! Behaviour of the parked-conversation cache: byte and slot accounting, the retained K/V reuse buffers, best-prefix +//! lookup, making room by eviction, removal of superseded copies and `put`. +//! Pure CPU policy; the types and the `ParkedConversation` trait it works on are in the parent `cache` module. use super::{ CheckpointKey, ConversationCache, ConversationImageKey, ConversationKv, ConversationKvReuse, Match, diff --git a/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs b/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs index a3491442..9d82b16c 100644 --- a/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs +++ b/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs @@ -1,5 +1,5 @@ -//! Methods of `ConversationCheckpoint`: `bytes`. Methods of `ConversationKv`: `bytes`, `buffers`, `buffers_mut`. -//! Implements `Default for SavedConversation`, `ParkedConversation for SavedConversation`. +//! Byte accounting of a saved checkpoint and of a layer's K/V buffers, the reuse bookkeeping for retained K/V, and +//! the `ParkedConversation` view of a host-memory `SavedConversation` (live and checkpoint keys, steering, size). use super::{ CheckpointKey, ConversationBuffer, ConversationCheckpoint, ConversationImageKey, ConversationKv, diff --git a/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs b/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs index 3971be70..010a0a59 100644 --- a/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs +++ b/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs @@ -1,6 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! retained_buffers_count_against_bytes_but_not_slots, a_b_a_recovery_and_slot_eviction, -//! checkpoints_steering_and_boundary_rules, image_identity_is_part_of_the_prefix .... +//! Pins the cache accounting and eviction rules: retained K/V buffers cost bytes but no slot, A-B-A recovery, slot +//! and byte eviction oldest first, checkpoint, steering and boundary matching, image identity as part of the prefix, +//! and superseded copies of one conversation never pushing another out. use super::{A, B, ConversationCache, ConversationImageKey, ConversationKv, cp, exact_kv_layers, image, size_of, with}; diff --git a/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs b/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs index 6c62309e..a9cf235a 100644 --- a/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs +++ b/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs @@ -1,6 +1,5 @@ -//! Tests of `tests` by topic: what_is_not_superseded, -//! disabled_caches_store_nothing, take_out_of_range_is_none_and_prefix_len_is_generic_over_token_types, -//! struct_sizes_match_the_64_bit_original_layout. +//! Pins what the cache must NOT treat as superseded (other conversations sharing only a root, a different steering +//! mode, entries without checkpoints), plus the disabled-cache, out-of-range `take` and struct-layout edge cases. use super::{ A, B, ConversationCache, ConversationCheckpoint, ConversationImageKey, ConversationKv, SavedConversation, cp, 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 9706651b..4f8886c9 100644 --- a/crates/engine-core/src/conversation/kv/kv_image_readback.rs +++ b/crates/engine-core/src/conversation/kv/kv_image_readback.rs @@ -1,5 +1,5 @@ -//! Functions: `verify_ring`, `kv_verify`. -//! Split out of `kv` to keep its files under the line limit. +//! Read-back check of a restored K/V layer: the saved bytes and the drafter ring's resident pages are compared with +//! the device and the authoritative payload is fingerprinted. Diagnostic only; it never changes model state. use super::{ ConvResult, ConversationKv, KvLayer, KvPool, KvTarget, QsaDesc, StateMemory, Verifier, kv_validate, region, 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 95d15b35..bfb979f5 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 @@ -1,5 +1,6 @@ -//! Methods of `Verifier`: `compare`, `failure`. -//! Functions: `set_geometry`, `reusable_prefix`, `capture_buffer`, `capture_layer` and 5 more. +//! Capture, validation and restore of one layer's K/V image against device memory. Capture keeps the unchanged prefix +//! of buffers retained from an earlier restore and copies only the rest; restore refills streamed residency. +//! Also the `Verifier` that compares device bytes with the image for the read-back check. use super::{ ConvError, ConvResult, ConversationKv, IDX_BLOCK, KvLayer, KvPool, KvTarget, Layout, ModelGeometry, PAGE_SIZE, diff --git a/crates/engine-core/src/conversation/kv/layout.rs b/crates/engine-core/src/conversation/kv/layout.rs index 0bd3a91a..8b55d9df 100644 --- a/crates/engine-core/src/conversation/kv/layout.rs +++ b/crates/engine-core/src/conversation/kv/layout.rs @@ -1,5 +1,5 @@ -//! Methods of `Layout`: `sizes`. -//! Functions: `kv_q4_bytes_per_head`, `valid_extent`, `geometry_ok`, `check_layout_inputs` and 12 more. +//! Byte layout of one layer's K/V image: the snapshot format code, the extent and geometry checks, and the sizes of +//! keys, values, scales and pooled indexer rows. `kv_bytes` and `kv_capture_bytes` give the sizes a capture needs. use super::{ ConvError, ConvResult, ConversationKv, IDX_BLOCK, KV_HYBRID, KV_ROTATED, KvLayer, KvPool, Layout, ModelGeometry, diff --git a/crates/engine-core/src/conversation/manager/conversation_manager.rs b/crates/engine-core/src/conversation/manager/conversation_manager.rs index e97714f5..49224e07 100644 --- a/crates/engine-core/src/conversation/manager/conversation_manager.rs +++ b/crates/engine-core/src/conversation/manager/conversation_manager.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `conversation_resume_checkpoints`, `conversation_state_events`. -//! Split out of `manager` to keep its files under the line limit. +//! Hub of the `ConversationManager` implementation: the resume and checkpoint half and the state and parking half +//! live in the two child modules and share the imports declared here. use super::{ CheckpointKey, ConvError, ConvResult, ConversationCache, ConversationCheckpoint, ConversationImageKey, 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 8735e1d3..c579b7ac 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 @@ -1,5 +1,6 @@ -//! Methods of `ConversationManager`: `pick_resume`, `take_incoming`, `restore_parked`, `align_to_request` and 10 more. -//! Split out of `conversation_manager` to keep its files under the line limit. +//! The request path of `ConversationManager`: choose what a request resumes from (live session, checkpoint or parked +//! conversation), restore and position the device, then keep the checkpoint chain through the prompt and at the end. +//! Mirrors the resume choice and `checkpoint_at` of the Original's `generate.cpp`. use super::{ ConvError, ConvResult, ConversationCheckpoint, ConversationImageKey, ConversationManager, PromptAction, PromptPath, 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 1bfd0e3d..0814efe3 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 @@ -1,5 +1,5 @@ -//! Methods of `ConversationManager`: `new`, `options`, `live`, `live_ok` and 13 more. -//! Split out of `conversation_manager` to keep its files under the line limit. +//! The state half of `ConversationManager`: construction, read-only views of the live tokens, checkpoints and cache, +//! the event log, invalidation, and the parking of the current session (size estimate, making room, capture, store). use super::{ CheckpointKey, ConvResult, ConversationCache, ConversationCheckpoint, ConversationKvReuse, ConversationManager, diff --git a/crates/engine-core/src/conversation/manager/conversation_options_default.rs b/crates/engine-core/src/conversation/manager/conversation_options_default.rs index af5aceb8..3b648d38 100644 --- a/crates/engine-core/src/conversation/manager/conversation_options_default.rs +++ b/crates/engine-core/src/conversation/manager/conversation_options_default.rs @@ -1,5 +1,5 @@ -//! Implements `Default for ConversationOptions`. Functions: `images_below`, `starts_with`, `is_allocation`. -//! Split out of `manager` to keep its files under the line limit. +//! Default `ConversationOptions` and the prompt-prefix helpers the manager uses: picture positions below a limit, +//! the "saved point is a prefix of the request" test, and the classification of allocation failures. use super::{ConvError, ConversationImageKey, ConversationOptions}; diff --git a/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs b/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs index 7f4f3014..61f47879 100644 --- a/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs +++ b/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs @@ -1,8 +1,7 @@ -//! Tests of manager_tests by topic (moved out of the test file by STRA-338): -//! the_byte_budget_and_slot_limit_evict_oldest_first, -//! an_incompatible_parked_image_is_discarded_and_the_request_falls_back, -//! a_failed_restore_transfer_is_fatal_to_the_request, -//! switching_steering_invalidates_checkpoints_and_isolates_parked_images .... +//! Pins the manager's budget and failure rules: the byte budget and slot limit evict oldest first, an incompatible +//! parked image is discarded, a failed restore transfer is fatal, steering switches isolate parked images, a +//! cancelled prompt keeps its checkpoints, periodic checkpoints follow the chunk stride, and pictures and the PLE +//! history window are part of the resume identity. use super::{ConversationImageKey, DeviceEngine, ReplayedRequest, TURN, chat, gen_tokens, options, world}; diff --git a/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs b/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs index 75d1bd2b..1460bbfa 100644 --- a/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs +++ b/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs @@ -1,7 +1,6 @@ -//! Tests of manager_tests by topic (moved out of the test file by STRA-338): -//! a_continuing_chat_reuses_the_live_session_without_a_copy, an_identical_prompt_still_reads_its_last_token, -//! a_rewritten_tail_resumes_from_the_turn_boundary_checkpoint, the_shared_root_is_pinned_while_other_checkpoints_rotate -//! .... +//! Pins which source a request resumes from: a continuing chat reuses the live session without a copy, a rewritten +//! tail resumes from the turn-boundary checkpoint, the shared root stays pinned while other checkpoints rotate, +//! switching conversations parks and restores exactly, and physical-memory admission gates parking. use super::{GIB, ReplayedRequest, Run, TURN, World, chat, gen_tokens, options, world}; diff --git a/crates/engine-core/src/conversation/manager_tests/hash.rs b/crates/engine-core/src/conversation/manager_tests/hash.rs index e2f310ff..96261fce 100644 --- a/crates/engine-core/src/conversation/manager_tests/hash.rs +++ b/crates/engine-core/src/conversation/manager_tests/hash.rs @@ -1,5 +1,5 @@ -//! Methods of `SimDevice`: `per`, `row_bytes`, `write_cell`, `mirror_ring` and 7 more. -//! Implements `StateMemory for SimDevice`. Functions: `hash`, `pat`, `pattern`, `idx`. +//! The simulated device memory of the manager tests: token-prefix hashing and patterns, the `SimDevice` byte regions +//! (running state, K/V pools, indexer rows, drafter ring) and its `StateMemory` implementation. use super::{ IdxKind, KvLayer, KvPool, PAGE, RingBlocks, SLOTS, SimDevice, StateMemory, StateRegion, kv_region, state_sizes, diff --git a/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs b/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs index c9b9902f..257b4a67 100644 --- a/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs +++ b/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs @@ -1,5 +1,5 @@ -//! Methods of `ReplayedRequest`: `new`. Methods of `World`: `read_plan`, `request`. -//! Implements `SessionDevice for SimDevice`. +//! The simulated world of the manager tests: `SimDevice` as a `SessionDevice`, the small model geometry, the +//! `World` that replays requests (reading a prompt plan into device state) and the chat and token generators. use super::{ ConversationImageKey, ConversationManager, ConversationOptions, DeviceEngine, Fixture, FixtureGeometry, GIB, diff --git a/crates/engine-core/src/conversation/snapshot_tests/fixture.rs b/crates/engine-core/src/conversation/snapshot_tests/fixture.rs index e7f93bd4..1c6f0bb8 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/fixture.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/fixture.rs @@ -1,5 +1,5 @@ -//! Methods of `Fx`: `new`, `unchanged`, `restore`, `reject` and 13 more. -//! Functions: `fixture_geometry`, `fixture_session`, `fixture_checkpoint`, `fixture_image` and 3 more. +//! The fixture of the snapshot tests: a small model with a first, a last and a drafter layer registered in host +//! memory, a complete saved image, and the checks `Fx` runs on it (sizes, save, restore, rejection before any write). use super::{ ConversationCheckpoint, ConversationImageKey, ConversationKvReuse, ConversationView, HostMemory, IDX_BLOCK, diff --git a/crates/engine-core/src/conversation/snapshot_tests/full_session.rs b/crates/engine-core/src/conversation/snapshot_tests/full_session.rs index 504ec73d..ce4a69ae 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/full_session.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/full_session.rs @@ -1,5 +1,5 @@ -//! Methods of `Session`: `new`, `spare`, `fill`, `save_checkpoint` and 9 more. -//! Functions: `session_geometry`, `put_session_regions`, `session_spec`, `full_session`. Defines `Session`. +//! The whole-session scenario of the snapshot tests: a main and a draft layer with running state and checkpoints in +//! one host memory, saved and restored, with the observations compared against the golden values. use super::{ ConversationCheckpoint, ConversationImageKey, ConversationKv, ConversationKvReuse, Fixture, HYBRID, HostMemory, diff --git a/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs b/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs index fe714149..b412eb3a 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs @@ -1,5 +1,5 @@ -//! Functions: `golden_state`, `fnv`, `fnv_buf`, `assert_kv` and 2 more. -//! Split out of `snapshot_tests` to keep its files under the line limit. +//! Helpers that compare saved images, K/V layers and checkpoints with the golden JSON the Original's C++ produced: +//! FNV fingerprints of the buffers and the field-by-field assertions. use super::{ConversationCheckpoint, ConversationKv, SavedConversation}; diff --git a/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs b/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs index f7d9e702..3cd00fd8 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs @@ -1,5 +1,5 @@ -//! Methods of `Level`: `save`, `restore`, `reject_hybrid_streaming`, `reject_bad_extents` and 5 more. -//! Functions: `kv_level`. Defines `Level`. +//! The per-layer K/V scenario of the snapshot tests: for one format and residency mode, save, restore, verify, and +//! reject hybrid-streaming and bad extents, over one fixture layer in host memory. use super::{ ConversationKv, Fixture, HYBRID, HostMemory, KV_INT8, KV_Q4, KV_VALUE_INT8, KvLayer, KvPool, KvTarget, equal, diff --git a/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs b/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs index 15244030..9bbb63c0 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs @@ -1,5 +1,5 @@ -//! Methods of `Alloc`: `put`. Methods of `Fixture`: `new`, `with_geometry`, `source`, `fill` and 1 more. -//! Functions: `kv_region`, `mk_view`, `equal`, `q4_per_head` and 8 more. Defines `Alloc`, `Dims`. +//! Allocation of the K/V pools of a snapshot-test layer (fp16, INT8, Q4_0 and hybrid formats, device slots and host +//! pools) in host memory, and the region and view helpers the other snapshot tests share. use super::{ ConversationCheckpoint, ConversationImageKey, ConversationKv, ConversationView, Fixture, FixtureGeometry, HYBRID, diff --git a/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs b/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs index 61f985bc..7caef515 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs @@ -1,7 +1,6 @@ -//! Tests of snapshot_tests by topic (moved out of the test file by STRA-338): -//! layer_snapshots_are_byte_exact_across_formats_and_residency_modes, whole_session_snapshots_round_trip_exactly, -//! validation_rejects_before_any_device_write_and_faults_are_fatal, -//! checkpoint_save_restore_round_trips_through_host_memory .... +//! Pins the snapshot contracts: layer and whole-session images are byte exact across formats and residency modes, +//! validation rejects before any device write, checkpoints round-trip through host memory, and geometry, carve sizes, +//! layouts and payload hashes match the Original's golden values. use super::{ ConversationCheckpoint, ConversationKv, Fixture, HYBRID, HostMemory, IDX_BLOCK, IdxKind, KV_F16, KV_INT8, KV_Q4, diff --git a/crates/engine-core/src/conversation/snapshot_tests/pools.rs b/crates/engine-core/src/conversation/snapshot_tests/pools.rs index a1dfcfd3..49f02dc9 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/pools.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/pools.rs @@ -1,5 +1,5 @@ -//! Methods of `Pools`: `new`, `register`, `image`. Functions: `mark_present`. -//! Split out of `snapshot_tests` to keep its files under the line limit. +//! The K/V pool set of a snapshot-test layer: which buffers a format has (fp16, INT8, Q4_0), registering them in host +//! memory and building the matching image. use super::{ ConversationKv, HostMemory, IdxKind, KvLayer, KvPool, ModelGeometry, Pools, QsaDesc, StateRegion, kv_region, diff --git a/crates/engine-core/src/prefix_cache/store/decayed.rs b/crates/engine-core/src/prefix_cache/store/decayed.rs index 3162928a..ac306720 100644 --- a/crates/engine-core/src/prefix_cache/store/decayed.rs +++ b/crates/engine-core/src/prefix_cache/store/decayed.rs @@ -1,5 +1,4 @@ -//! Functions: `decayed`. -//! Split out of `store` to keep its files under the line limit. +//! Half-life decay of a hit mass or prior with age, shared by the store's value estimate. pub(super) fn decayed(value: f64, age: u64, half_life: f64) -> f64 { diff --git a/crates/engine-core/src/prefix_cache/store/policy_params_default.rs b/crates/engine-core/src/prefix_cache/store/policy_params_default.rs index 889d82da..730c7369 100644 --- a/crates/engine-core/src/prefix_cache/store/policy_params_default.rs +++ b/crates/engine-core/src/prefix_cache/store/policy_params_default.rs @@ -1,5 +1,4 @@ -//! Methods of `Candidate`: `key`, `blocks`. Implements `Default for PolicyParams`. -//! Split out of `store` to keep its files under the line limit. +//! The operator-facing default values of `PolicyParams`, and the accessors of an admission `Candidate`. use super::{Candidate, PolicyParams}; 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 e904a804..f36680bf 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `admit`, `prefix_store_consider_commit`, `prefix_store_evict_and_budget` and 2 more. -//! Split out of `store` to keep its files under the line limit. +//! Hub of the `PrefixStore` implementation: admission, the consider and commit path, eviction and budget, the +//! statistics and clock, and node scoring each live in a child module over the shared store types. use super::{ Block, ByteSize, CHAIN_SEED, Candidate, Consider, HashMap, HashSet, KeptTail, Match, Node, NodePayload, diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs index 887dc6e1..7d240b09 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixStore`: `consider`, `consider_tail`, `candidate_value`, `commit` and 3 more. -//! Split out of `prefix_store` to keep its files under the line limit. +//! Admission decision and commit of prefix-store nodes: `consider` (is a node worth its bytes), the request-end tail +//! variants, the value estimate of a candidate, and `commit` once the caller has built the payloads. use super::{ByteSize, Candidate, Consider, HashSet, KeptTail, NodePayload, PrefixStore, Reject}; 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/prefix_store_evict_and_budget.rs index 7f8a74c0..8cd67ed9 100644 --- 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/prefix_store_evict_and_budget.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixStore`: `enforce_budget`, `abort`, `release_orphans`, `evict` and 6 more. -//! Split out of `prefix_store` to keep its files under the line limit. +//! Removal from the prefix store: enforcing the byte budget, aborting a candidate, evicting a node together with the +//! blocks only it covered, orphan release, clearing, and the invariant check. use super::{ByteSize, Candidate, HashSet, Node, PrefixStore}; #[cfg(any(test, feature = "testing"))] 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/prefix_store_stats_and_clock.rs index aad9e3b4..3e1c4add 100644 --- 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/prefix_store_stats_and_clock.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixStore`: `new`, `config`, `stats`, `bytes` and 26 more. -//! Split out of `prefix_store` to keep its files under the line limit. +//! Construction, statistics, request clock and expiry of the prefix store, and its lookups: the longest token-exact +//! match, the hash-only prefix match a router uses, the node heads, and the hit and miss records that feed admission. use super::{ ByteSize, CHAIN_SEED, HashMap, HashSet, Match, Node, PrefixStore, Stats, StoreConfig, chain_step, decayed, diff --git a/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs b/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs index 393b5b6f..55aae5b2 100644 --- a/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs +++ b/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs @@ -1,8 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_hit_by_another_session_makes_a_shared_root_outlive_private_leaves, -//! thinning_a_chain_keeps_the_deepest_node_and_the_blocks_it_needs, -//! the_budget_is_enforced_again_when_the_real_payload_is_bigger_than_the_estimate, -//! commit_refuses_blocks_that_are_not_the_candidates .... +//! Pins the store's sharing and budget behaviour: a hit by another session keeps a shared root alive, chains are +//! thinned, the budget is enforced again when a payload exceeds its estimate, collisions are never matched, the node +//! cap evicts by value, and long agent sessions stay inside the budget with a fast lookup. use super::{ BLOCK, Consider, G, Payload, PolicyParams, PrefixStore, Reject, STATE, StoreConfig, chain, put, store, tokens, diff --git a/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs b/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs index 465352f4..7691e4f5 100644 --- a/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs +++ b/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs @@ -1,7 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_request_resumes_from_the_deepest_node_of_any_session, common_prefixes_are_stored_once, -//! a_node_with_descendants_is_a_branch_point_and_a_frontier_is_not, -//! the_prompt_end_checkpoint_survives_the_decode_end_checkpoint_of_its_request .... +//! Pins resume and eviction semantics of the store: resume from the deepest node of any session, shared prefixes +//! stored once, branch points versus frontiers, request-end tail nodes and their supersession, retention and expiry, +//! and value-ordered eviction under a full budget. use super::{ BLOCK, Consider, G, MINUTE, Payload, PolicyParams, PrefixStore, Reject, STATE, StoreConfig, put, put_tail, diff --git a/crates/engine-core/src/prompt/prompt_options.rs b/crates/engine-core/src/prompt/prompt_options.rs index 1e2351fb..355920cb 100644 --- a/crates/engine-core/src/prompt/prompt_options.rs +++ b/crates/engine-core/src/prompt/prompt_options.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptOptions`: `original_mode17`. -//! Methods of `PromptPlan`: `new_in_context`, `new`, `prompt`, `next_segment` and 1 more. +//! Prompt planning of the Original serve path: the options and capacity choice (auto ladder, cache-slot loan), the +//! validity checks, the `PromptPlan` iterator that cuts a prompt into segments, and `drive`, which runs a plan. use super::{ DriveError, DriveSummary, PlanError, PlanLimits, PromptAction, PromptOptions, PromptPath, PromptPlan, PromptRunner, diff --git a/crates/engine-core/src/spec/adaptive/adaptive_config.rs b/crates/engine-core/src/spec/adaptive/adaptive_config.rs index f1bff54e..56dd11f3 100644 --- a/crates/engine-core/src/spec/adaptive/adaptive_config.rs +++ b/crates/engine-core/src/spec/adaptive/adaptive_config.rs @@ -1,5 +1,5 @@ -//! Methods of `AdaptiveConfig`: `new`, `with_policy`, `set_option`, `set_tuning` and 1 more. -//! Methods of `Cell`: `rate`, `add`. Functions: `p_bucket`, `m_bucket`, `logit`, `sigmoid`. +//! Constants of the adaptive window policy: construction, the `LELEKA_SPEC_POLICY` presets, named options for replay +//! arms, the acceptance `Cell` statistics, and the probability bucketing and logit helpers. use super::{AdaptiveConfig, Cell, FLOOR_CEILING, FLOOR_CEILING_LEGACY, MAX_T, P_BUCKETS, P_EDGES}; diff --git a/crates/engine-core/src/spec/adaptive/adaptive_policy.rs b/crates/engine-core/src/spec/adaptive/adaptive_policy.rs index fc06c6dc..02994f8f 100644 --- a/crates/engine-core/src/spec/adaptive/adaptive_policy.rs +++ b/crates/engine-core/src/spec/adaptive/adaptive_policy.rs @@ -1,5 +1,5 @@ -//! Methods of `AdaptivePolicy`: `new`, `config`, `rounds`, `begin_request` and 7 more. -//! Split out of `adaptive` to keep its files under the line limit. +//! State and calibration of the adaptive window policy: per-request reset, the acceptance rate of an MTP draft or a +//! suffix row, the per-width cost mean and its fit, and the candidate widths offered to the decision. use super::{ AdaptiveConfig, AdaptivePolicy, Cand, Cell, M_BUCKETS, MAX_T, N0_BUCKET, N0_DEPTH, N0_SUFFIX, Offer, Origin, diff --git a/crates/engine-core/src/spec/adaptive/spec_stats.rs b/crates/engine-core/src/spec/adaptive/spec_stats.rs index 61504a89..31c2a8cd 100644 --- a/crates/engine-core/src/spec/adaptive/spec_stats.rs +++ b/crates/engine-core/src/spec/adaptive/spec_stats.rs @@ -1,5 +1,5 @@ -//! Methods of `SpecStats`: `record`, `line`. -//! Split out of `adaptive` to keep its files under the line limit. +//! Per-round statistics of the adaptive policy (width, accepted rows, flags, milliseconds) and the one-line report +//! printed from them. use super::{MAX_T, RoundFlags, SpecStats}; diff --git a/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs b/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs index 29d6cb9e..2bb08d08 100644 --- a/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs +++ b/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs @@ -1,6 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! the_default_ceiling_is_the_new_one_and_the_legacy_switch_restores_the_old_policy_exactly, -//! the_smooth_floor_moves_continuously_with_the_bar, a_trace_is_reproducible, stats_line_reports_the_histograms. +//! Pins the policy constants: the default draft-floor ceiling is the new one, the legacy switch restores the earlier +//! policy exactly, the smooth floor moves continuously with the bar, traces are reproducible, and the stats line. use super::{ AdaptiveConfig, AdaptivePolicy, CODE_COSTLY, FLOOR_CEILING, P_BUCKETS, P_EDGES, PROSE_CHEAP, Rng, RoundFlags, diff --git a/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs b/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs index 5bce6e24..0307a1c5 100644 --- a/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs +++ b/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs @@ -1,6 +1,6 @@ -//! Tests of `tests` by topic: stationary_regimes_reach_the_best_fixed_width, -//! it_widens_when_rows_are_cheap_and_narrows_when_they_are_not, it_follows_a_change_of_content_and_of_cost, -//! reaction_to_a_switch_takes_tens_of_rounds_not_hundreds .... +//! Pins the adaptive window's learning: stationary regimes reach the best fixed width, it widens when rows are cheap +//! and narrows when not, follows a change of content or cost, explores cheaply, interpolates unmeasured widths, and +//! keeps the draft plan inside its bounds. use super::{ AdaptivePolicy, CODE_CHEAP, CODE_COSTLY, Choice, MAX_T, Offer, Origin, PROSE_CHEAP, PROSE_COSTLY, REPEAT, Rng, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs index 3933e54a..cbf970e6 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeMode`: `parse`, `as_str`. Methods of `ExpertSource`: `parse`, `as_str`. -//! Implements `Default for OriginalServeOptions`. +//! Parsing and printing of the Original-path choices (`OriginalServeMode`, `ExpertSource`, `PrefixTail`), the +//! published prefix-cache pool summary, and the default and run-time validation of `OriginalServeOptions`. use super::{ BackendError, ConfigFacts, ExpertSource, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs index ae4676f5..6c62bc7e 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs @@ -1,5 +1,5 @@ -//! The command loop of the Original owner, moved out of `run` by STRA-338 (size): receive, sweep the idle sessions, -//! and answer each command in the order `run` did. +//! The command loop of the Original owner: publish readiness, then receive commands, sweep idle sessions while none +//! arrives, and answer Load (refused), Reconfigure, Unload and Generate until unload or shutdown. use super::{ BackendError, Command, Duration, GenerateEnv, IdleSweep, Live, LoadPhase, LoadedModel, Ordering, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs index 7fa58caa..b03cc57b 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of `original_serve`. +//! Pins the Original-path selection and options: modes parse and print symmetrically, `Auto` takes the Original path +//! only when everything is sealed and fed, explicit `Original` never falls back and names what is missing, `Preview` +//! is never overridden, option bounds, the conversation-cache defaults, and the eight-cell slack of the fit test. use super::{ConfigFacts, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, PathBuf, choose, context_fits}; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs index 77c86354..d2aa3bb5 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs @@ -1,5 +1,5 @@ -//! Functions: `required_path`. -//! Split out of `original_serve_replay` to keep its files under the line limit. +//! Reads an operator-owned input path from an environment variable for the replay and the GPU proofs; a missing +//! variable panics with its name, so a proof never runs against a guessed file. use super::{PathBuf, env}; diff --git a/crates/engine-qwen35-cuda/src/backend/tests.rs b/crates/engine-qwen35-cuda/src/backend/tests.rs index 1477b82b..05cf4462 100644 --- a/crates/engine-qwen35-cuda/src/backend/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/tests.rs @@ -1,3 +1,7 @@ +//! Backend-level tests of the Native path: the queued-owner identity digest, explicit KAR selection and context +//! admission, request caps and sampling plans, incremental UTF-8 publication, cancel with a full control queue, +//! control-token encoding, and a request arriving during the deferred tail. + use super::{ Active, ActiveGuard, Arc, AtomicBool, Backend, BackendError, Command, DeferredTail, Digest, ErrorCode, EvaluationExecution, FRAME_LIMIT, GenerationRequest, InferenceMode, KAR_LOAD_REPLY_TIMEOUT, KAR_PROFILE, diff --git a/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs b/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs index 7bf82d4c..dde09a75 100644 --- a/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs +++ b/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the resident-conversation store: a disabled policy keeps the single continuation, an identical prompt may +//! reuse the live session but not a parked one, A-B-A swaps pick the longest prefix (ties to the newest), slots and +//! bytes bound the parked set oldest first, unusable candidates are dropped, and operator settings parse strictly. use super::{ResidentConversations, ResidentPolicy, ResumeSource}; diff --git a/crates/engine-qwen35-cuda/src/experimental/tests.rs b/crates/engine-qwen35-cuda/src/experimental/tests.rs index 0cfc2d99..eb9c96c2 100644 --- a/crates/engine-qwen35-cuda/src/experimental/tests.rs +++ b/crates/engine-qwen35-cuda/src/experimental/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the experimental-mode admission: the default is off and changes nothing, each mode selects the Original's +//! format and programs, exclusions follow its rules, pool sizes match, the digest binds modes, values and files, +//! an enabled mode is refused until the forward pass consumes it, and control-vector files are validated at load. use super::{ ExperimentalConfig, ExperimentalError, KvFormat, Mode, OptIn, PathBuf, Program, ensure_consumed, diff --git a/crates/engine-qwen35-cuda/src/model_binding/mod.rs b/crates/engine-qwen35-cuda/src/model_binding/mod.rs index c70d0831..896574b4 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/mod.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/mod.rs @@ -1,3 +1,6 @@ +//! Binding of the pinned model files to the engine: the KAR expert source and its levels, the Qwen4Exp input +//! binding (weights read from the verified artifact) and the KAR PLE source. + pub(crate) mod kar_expert_source; pub(crate) mod kar_levels; pub(crate) mod qwen4exp_input; 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/qwen4exp_input/binding_identity_and_input_binding_error.rs index f204b1dd..7e64b905 100644 --- 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/qwen4exp_input/binding_identity_and_input_binding_error.rs @@ -1,5 +1,6 @@ -//! Methods of `BindingIdentity` and `BoundLayer`, and the `Display` and `Error` impls of `InputBindingError`: what a -//! binding says about itself and how its failures read. +//! The small identity and constants types of the input binding: `Display` text of `InputBindingError`, the identity +//! that ties a weights handle to its binding, the index and kind of a bound layer, and the `InputConstants` read from +//! the artifact (PLE head offsets and vocabularies, EOS, context length) with their validation. use super::{ BindingIdentity, BoundLayer, BoundLayerKind, InputBindingError, InputConstants, InputResult, PLE_ROWS, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs index 152e1f18..5588f4c6 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the GDN weight binding: the epsilon is the Original's exact layer operand, the projection kinds and +//! containers are the closed set, and shapes and row bounds are checked before any read. use super::{E, NATIVE_EPSILON, TensorSignature, block_range, descriptor, exact_bf16, kind}; #[test] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs index 7b1c8b58..c19514cf 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the GR weight binding: only exact finite BF16 containers are accepted, role shapes are frozen, and the final +//! layer has no injection. use super::{GrRole, InputBindingError, TensorSignature, exact_bf16, role_set, validate_descriptor}; #[test] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs index 01bcc7d2..08b6a223 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs @@ -1,5 +1,5 @@ -//! Methods of `ModelBinding`: `bind`, `from_artifact`, `from_artifact_with_kar_ple`, `with_kar_expert_source` and 22... -//! Functions: `bind_expert_counts`. +//! The `ModelBinding` over a verified Qwen4Exp artifact: its constructors (plain, with KAR PLE, KAR expert source or +//! MTP pack), layer and expert counts, the embedding and PLE row reads, and expert-count validation. use super::{ BindingError, BindingIdentity, BoundLayer, EMBEDDING_VALUES, GlobalRole, InputBindingError, InputConstants, 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/qwen4exp_input/moe_expert/model_binding.rs index 5c7492c0..cc206e1d 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `model_binding_moe_descriptors`, `moe_expert_block_reads`. -//! Split out of `moe_expert` to keep its files under the line limit. +//! Hub of the `ModelBinding` MoE accessors: expert matrix admission and preload descriptors (one child) and the +//! block reads of selected expert rows from the artifact (the other). use super::{ E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, 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/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs index 6a2bfac8..3df9d6cc 100644 --- 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/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs @@ -1,5 +1,5 @@ -//! Methods of `ModelBinding`: `moe_expert_weights`, `moe_preload_descriptor`, `check_preload_key`, `moe_preload_bloc... -//! Functions: `moe_matrix`, `check_gate_scalar`, `preload_key`, `preload_matrix_role` and 1 more. +//! Admission of one layer's routed and shared MoE matrices against the expected kind, shape and extent, and the +//! preload descriptors and blocks of routed experts that the MoE weight cache reads to preload pinned experts. use super::super::routed_source_descriptor::validate_rows_finite; use super::super::routed_source_descriptor::{check_matrix_tensor, check_moe_metadata, selected_expert}; 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/qwen4exp_input/moe_expert/moe_expert_weights.rs index d6b5e839..536c5ddc 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeExpertWeights`: `matches`, `matrix`, `shape`, `kind`. -//! Methods of `MoeExpertBlock`: `kind`, `columns`, `rows`, `bytes` and 1 more. +//! Accessors of the admitted `MoeExpertWeights` and `MoeExpertBlock`, and the decoding of raw tensor kinds into +//! `MoeMatrixKind` for routed and shared matrices, with the selection and row-range checks. use super::{ BindingIdentity, E, EXPERTS, FF, InputResult, Matrix, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, 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/qwen4exp_input/moe_expert/moe_routed_source_scope.rs index 9f6078db..0ac270dd 100644 --- 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/qwen4exp_input/moe_expert/moe_routed_source_scope.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeRoutedSourceScope`: `retarget`, `check_first_member`, `check_members`. -//! Methods of `ModelBinding`: `with_moe_routed_group_source`, `moe_shared_preload_descriptors`, `moe_shared_preload_... +//! The routed-source group scope (`MoeRoutedSourceScope`): retargeting it to a new set of experts with member checks, +//! and the shared-expert preload descriptors and blocks streamed from the artifact. use super::routed_source_descriptor::check_moe_metadata; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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/qwen4exp_input/moe_expert/routed_source_descriptor.rs index 0465a865..1175c012 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeRoutedSourceScope`: `validate_binding`, `descriptor`, `block`, `bank_span` and 2 more. -//! Methods of `ModelBinding`: `with_moe_routed_source`, `check_members_select`, `open_routed_source`. +//! Source descriptors and reads of routed experts: model-metadata and finite-weight admission, and the scope's +//! descriptor, block, bank-span and mapped-span reads over the retained artifact owners. use super::{ BindingIdentity, E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, 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/qwen4exp_input/mtp/dense_bytes_types.rs index 7111885e..eaadea4a 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs @@ -1,5 +1,5 @@ -//! Defines `MtpIndex`, `MtpRows`, `MtpWeights`. -//! DENSE_BYTES, EXPERT_BYTES, EXPERT_BLOB, INDEX_BYTES, MAX_ROWS, MAX_READ .... +//! The pinned MTP pack: byte sizes, read limits and file digests of `dense.txt`, `dense.bin` and `experts.bin`, and +//! the `MtpWeights`, `MtpRows` and `MtpIndex` owners that hold its files and rows. use super::{BindingIdentity, File, MtpKind}; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs index 1e6b5260..3debfba7 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs @@ -1,5 +1,5 @@ -//! Items of the parent module. -//! Split out of `mtp` to keep its files under the line limit. +//! The table of the 31 MTP tensors: for each role its name, source file, shape, source SHA-256 and, where it is +//! packed into `dense.bin`, the kind and byte placement. use super::{Dense, Descriptor, MtpKind, MtpRole}; 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/qwen4exp_input/mtp/mtp_kind_types.rs index 1271f2e4..66e8346e 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs @@ -1,5 +1,5 @@ -//! Defines `MtpKind`, `MtpExpertMatrix`, `MtpExpertRef` and 3 more. -//! MtpKind, MtpExpertMatrix, MtpRole, Descriptor, Dense. +//! The vocabulary of the MTP pack: storage kinds, expert matrices, the roles of its tensors, and the `Descriptor` +//! and `Dense` records that describe one tensor. #[derive(Clone, Copy, Debug, Eq, PartialEq)] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs index 45917a99..718a3883 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs @@ -1,5 +1,5 @@ -//! Methods of `IndexScan`: `accept`, `fits`, `complete`. Methods of `MtpIndex`: `inspect`. -//! Functions: `pack_identity`, `descriptor`, `pinned_dense_bytes`, `rt_dense_roles` and 6 more. +//! Identity and index of the MTP pack: the digests that name it, the descriptor lookup, the RT-directory contract +//! (consumed roles, names, kinds, shapes) and the strict parser that turns `dense.txt` into a validated `MtpIndex`. use super::{ DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, FILE_PINS, INDEX_LIMIT, InputBindingError, InputResult, MtpIndex, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs index 0eecf459..0dffcfcd 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the MTP pack binding: exact receipts and runtime index, the RT contract's roles and shapes, malformed +//! descriptors never becoming an index, bounded rows and lossless Q2 planes keeping signed zeros, non-finite weights +//! refused, and an identity that cannot be recreated from metadata. use super::{ BindingIdentity, DESCRIPTORS, INDEX_LIMIT, InputBindingError, MtpIndex, MtpKind, MtpRole, interleave_q2, row_range, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs index fde7c92c..63e755c1 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs @@ -1,5 +1,5 @@ -//! Methods of `InputConstants`: `test_fixture`. Methods of `BindingIdentity`: `test_identity`. -//! Functions: `validate_ple_descriptor`, `bind_layers`, `bind_layer`. +//! Bind-time admission of a Qwen4Exp artifact: the per-layer token-embedding (PLE) descriptor and the ordered list of +//! bound layers with their kinds. Also the test fixtures for `InputConstants` and `BindingIdentity`. use super::{ BoundLayer, BoundLayerKind, GlobalRole, InputBindingError, InputResult, LayerRole, PLE_ROWS, Qwen4ExpArtifact, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs index a43267db..59a8c5fc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs @@ -1,5 +1,5 @@ -//! Functions: `dense_slab_policy`, `startup_step`. -//! Split out of `dense_weight_cache` to keep its files under the line limit. +//! Startup policy of the dense weight cache: whether dense weights are packed into 64 MiB slabs or get one allocation +//! each, and the step-named refusal message of the prompt-capacity startup. Both layouts place the same bytes. use super::SlabPolicy; 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_weight_cache_methods.rs index cd4089b4..32e39404 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_weight_cache_methods.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `dense_cache_buffers_and_close`, `dense_cache_eager_layer_load`, `dense_cache_gdn_qsa_works... -//! Split out of `dense_weight_cache` to keep its files under the line limit. +//! The `impl DenseWeightCache` blocks by responsibility: constructors, eager layer load, matrix registration, PLE and +//! verifier weight views, prompt and GDN scratch, GDN/QSA workspaces, buffers and close. Shared imports live here. use super::{ ALL_MIRROR_BYTES, BoundLayerKind, Cell, Context, DenseCacheCounters, DenseWeightCache, DeviceBuffer, DeviceRef, 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_weight_cache_methods/dense_cache_buffers_and_close.rs index 0c319e4e..15a08ad4 100644 --- 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_weight_cache_methods/dense_cache_buffers_and_close.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `gr_buffers`, `counters`, `chunk_modules`, `close` and 4 more. -//! Functions: `close_into`. +//! Buffer access and teardown of the dense weight cache: GR buffers, counters, chunk modules and the consuming close, +//! which releases scratch, modules, batch workspaces, buffers and slabs and keeps the first error. use super::{ Context, DenseCacheCounters, DenseWeightCache, DeviceBuffer, Error, GrResident, ModelBinding, QkScratch, Rc, 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_weight_cache_methods/dense_cache_eager_layer_load.rs index 0e608622..66d39b1c 100644 --- 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_weight_cache_methods/dense_cache_eager_layer_load.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `new_with_selected`, `unloaded`, `load_eager`, `reserve_layer_tables` and 6 more. -//! Functions: `reserve_table`. +//! Eager load of the dense weights at construction: reserves the layer tables, loads the router, GDN and QSA layers +//! of a binding into the slab allocator and adds the scratch owners. use super::{ ALL_MIRROR_BYTES, BoundLayerKind, Cell, Context, DenseCacheCounters, DenseWeightCache, Error, GdnInputScratch, 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_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs index 2b451667..76f5fbbe 100644 --- 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_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseWeightCache`: `gdn_batch_resources`, `qsa_native_workspace`, `test_record_gr_batch_completed`, `... -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! Lookups of the dense cache that the decode and prompt paths borrow from: GDN batch resources, QSA workspace, +//! GDN and QSA scratch loans, and the per-layer GDN, QSA, GR and router entries with buffer handles for a held +//! verify assembly. use super::{ Cell, Context, DenseWeightCache, DeviceBuffer, DeviceRef, Error, GdnInputLease, GdnInputScratch, GdnResident, 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_weight_cache_methods/dense_cache_matrix_registration.rs index 2a0233d9..1ef9605a 100644 --- 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_weight_cache_methods/dense_cache_matrix_registration.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `add`, `add_f32`, `add_bf16`, `add_gr` and 13 more. Defines `ExpectedPleMatrix`. -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! Registration of dense matrices (raw, F32, BF16, GR roles, the retained PLE matrices) into the cache with byte and +//! finite checks, plus binding validation and the router, GR, PLE and native batch scratch loans. use super::{ Context, DenseWeightCache, DeviceRef, Error, GrBatchInjectWorkspace, GrResident, GrRole, GrScratch, ModelBinding, 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_weight_cache_methods/dense_cache_ple_and_verify_weights.rs index 3085ba48..809b4d4a 100644 --- 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_weight_cache_methods/dense_cache_ple_and_verify_weights.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseWeightCache`: `ple`, `ple_key`, `ple_value`, `ple_value_tile` and 16 more. -//! Functions: `gdn_native_type`, `qsa_native_type`. +//! Read-only views of the loaded dense weights: PLE key, value and norm slots, GDN and QSA matrix and norm slots, and +//! the ordered operands of the Original verifier window (GDN weights, QSA gammas, native MMVQ projections). They are +//! the cache's own allocations, so no host conversion happens at this boundary. use super::{ BoundLayerKind, Context, DenseWeightCache, DeviceBuffer, DeviceRef, Error, GdnMatrixKind, GdnMatrixRole, 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_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs index cfe3279e..ab31a03d 100644 --- 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_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseWeightCache`: `new_original_prompt_capacity`, `load_prompt_owners`, `load_prompt_workspaces`, `l... -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! The prompt-capacity constructor of the dense weight cache (prompt owners, workspaces and scratch sized for the +//! chunk capacity) and the pools that serve it: idle GDN finite guards, pooled GDN state buffers and the GDN +//! verification workspace. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GdnVerificationWorkspace, ModelBinding, QkScratch, Rc, RefCell, 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_weight_cache_methods/dense_weight_cache_constructors.rs index 222b2aa4..1c3900dc 100644 --- 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_weight_cache_methods/dense_weight_cache_constructors.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `new`, `new_qsa_selected`, `new_qsa_selected_router`, `new_qsa_selected_router_gr_... -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! The named constructors of the dense weight cache, from the plain cache up to the selected router, GR batch, QK, +//! attention and MTP journal variants, and the attachment of the prompt owners, queues and native QSA resources. use super::{ Context, DenseWeightCache, Error, ModelBinding, QkScratch, QsaAttentionScratch, Rc, RefCell, Result, RouterScratch, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs index e6ac1bf0..4fe9d212 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs @@ -1,5 +1,6 @@ -//! The lazily created workspaces of the dense weight cache, moved out of it by STRA-338 (size): consecutive owners, -//! declared in the order the cache dropped them, so the drop order is unchanged. +//! The lazily created workspaces of the dense weight cache (GDN, QSA, GR and router scratch, idle guards and pooled +//! GDN state buffers), all empty at construction and filled on first use. The fields are declared in the order the +//! cache drops them, so the drop order is unchanged. use super::{ DeviceBuffer, GdnInputScratch, GrBatchInjectWorkspace, GrScratch, QkScratch, QsaAttentionScratch, QsaIndexKeyCache, 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 e4965950..bef1d479 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 @@ -1,5 +1,6 @@ -//! Groups the submodules `construction_and_parking`, `prompt_executor_forward_and_close`, `prompt_executor_retire_ow... -//! Split out of `original_prompt` to keep its files under the line limit. +//! Impl family of `OriginalPromptExecutor`, the owner of every device resource of the layer-major Original prefill +//! (prompt rows, GDN, QSA, MTP). The children share this import list: construction and parking, chunk forward, +//! retirement. use super::{ BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, 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/construction_and_parking.rs index d1693815..29946253 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/construction_and_parking.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `executor_construction`, `session_park_and_qsa_owners`. -//! Split out of `original_prompt_executor` to keep its files under the line limit. +//! Construction of an `OriginalPromptExecutor` and the parking of its session state. Builds the device owners and the +//! twelve resident QSA layers; parks, imports and restores the session for the prefix cache. use super::{ BoundLayerKind, Context, DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, 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/construction_and_parking/executor_construction.rs index 98757cbf..35ec4a20 100644 --- 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/construction_and_parking/executor_construction.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptExecutor`: `new`, `new_with_mtp_weights`, `check_construction`, `empty` and 17 more. -//! Split out of `construction_and_parking` to keep its files under the line limit. +//! Builds an `OriginalPromptExecutor`: the prompt, GDN, QSA and MTP device owners and the twelve resident QSA layers. +//! Also the drafter hooks the serve host calls on it (RT bank selection, prompt length, draft limit, idle, KV +//! restore). use super::{ BoundLayerKind, Context, DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, 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/construction_and_parking/session_park_and_qsa_owners.rs index ce25343b..f386fa5f 100644 --- 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/construction_and_parking/session_park_and_qsa_owners.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptExecutor`: `take_qsa_owners`, `adopt_qsa_owners`, `rebuild_qsa_layers`, `checkpoint_ses... -//! Defines `QsaOwners`. +//! Session handoff of the executor: the resident QSA owners lent to the native verifier for a decode phase and taken +//! back, and the checkpoint, park, import and restore of the session point (prefix cache, request reset). use super::{ DenseWeightCache, Error, ModelBinding, OriginalPromptExecutor, OriginalSessionCheckpoint, ParkedBlock, 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/prompt_executor_forward_and_close.rs index 82e5aa82..533cdaf0 100644 --- 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/prompt_executor_forward_and_close.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `prompt_chunk_forward`, `prompt_executor_close`. -//! Split out of `original_prompt_executor` to keep its files under the line limit. +//! Running and closing a prompt chunk on the executor: the forward pass over the arena and the consuming `close`. use super::{ BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, 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/prompt_executor_forward_and_close/prompt_chunk_forward.rs index 9fcf0cff..5065a867 100644 --- 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/prompt_executor_forward_and_close/prompt_chunk_forward.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptExecutor`: `forward`, `arena_holds_window`, `admit_window`, `finish_forward` and 4 more. -//! Functions: `trace_step`, `arena_serves_chunk`, `trace_error`. Defines `ForwardDone`, `StagedRows`. +//! `OriginalPromptExecutor::forward`: one batched prompt chunk, from input staging through every layer to the final +//! row, its sample and the draft KV. An error rolls the transaction and the draft back; success leaves a pending +//! target to publish. use super::{ BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs index 689dc743..8f588029 100644 --- 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the draft-KV phase of `OriginalPromptExecutor::forward`. +//! The draft-KV phase of `OriginalPromptExecutor::forward`. use super::{ ChunkDraft, Context, Error, MoeWeightCache, OriginalDraftKvPending, OriginalMtpPrefill, 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs index ec4f8bc2..4e5a75af 100644 --- 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the final row of `OriginalPromptExecutor::forward` (conditioning preview, sample, R trace). +//! The final row of `OriginalPromptExecutor::forward` (conditioning preview, sample, R trace). use super::{ Carrier, ChunkWork, DenseWeightCache, Error, ModelBinding, OriginalPromptExecutor, OriginalPromptSample, 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs index 52f68fb7..d1dfe7d2 100644 --- 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the input phase of `OriginalPromptExecutor::forward` (staging, row upload, PLE read-ahead). +//! The input phase of `OriginalPromptExecutor::forward` (staging, row upload, PLE read-ahead). use super::{ ChunkInFlight, Context, DenseWeightCache, Error, InputStage, KarPleCache, ModelBinding, OriginalPrefillArena, 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs index a3040fb8..7558d188 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/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the layer loop of `OriginalPromptExecutor::forward`, one helper per phase of a layer. +//! The layer loop of `OriginalPromptExecutor::forward`, one helper per phase of a layer. use super::{ BoundLayerKind, Carrier, ChunkWork, DenseWeightCache, Error, InputStage, ModelBinding, MoeWeightCache, 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/prompt_executor_forward_and_close/prompt_executor_close.rs index 07311086..7cc06990 100644 --- 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/prompt_executor_forward_and_close/prompt_executor_close.rs @@ -1,5 +1,4 @@ -//! Methods of `OriginalPromptExecutor`: `close`. -//! Split out of `prompt_executor_forward_and_close` to keep its files under the line limit. +//! Consuming `close` of the executor; the retirement of the owners itself is `close_inner`. use super::{OriginalPromptExecutor, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs index 8e36bcd0..9a7e17bd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptExecutor`: `close_inner`, `retire_device_owners`, `retire_mtp_and_layers`. -//! Split out of `original_prompt_executor` to keep its files under the line limit. +//! Retirement of the executor's device owners: prompt, GDN, QSA, transport, attention, MTP and the resident layers. +//! Every owner is closed even after a failure; the first error is kept and the executor is marked failed. use super::{Error, OriginalPromptExecutor, Result, driver_error}; 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 c7e1af8b..5397dbbd 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 @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptPending`: `publish`. -//! Implements `Drop for OriginalPromptExecutor`, `Drop for OriginalPromptPending` and 2 more. +//! Publication and rollback of a prompt chunk: `OriginalPromptPending::publish`, and the drops that close the +//! executor or abort an unpublished transaction. Also the `PromptRunner` that drives the chunks of a prompt plan, and +//! `driver_error`. use super::{ ChunkCaches, ChunkDraft, Error, NoPromptHooks, OriginalPromptComposer, OriginalPromptExecutor, OriginalPromptHooks, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs index 159ecd34..172eb120 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs @@ -1,5 +1,4 @@ -//! Functions: `staged_input_enabled`. -//! Split out of `original_prompt` to keep its files under the line limit. +//! The `prefill_staged_input` switch: staged chunk input, or the per-token host path of the KAR inputs (the A/B arm). /// `LELEKA_PREFILL_STAGED_INPUT=0` keeps the per-token host path of the KAR inputs (the A/B arm). diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs index cc2806e2..be5921b4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs @@ -1,5 +1,6 @@ -//! Methods of `Ids`: `new`, `position`. -//! Methods of `Rig`: `snapshot`, `prefill`, `step_final`, `prefill_chunk` and 7 more. +//! GPU test phase on the loaded target: a genuine four-row prefill chunk must reproduce the scalar known-next path +//! exactly (logits, greedy token, residual, state, draft), and a cancelled chunk must leave the committed target and +//! draft untouched. #![cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs index ee6dceaf..3c357e07 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs @@ -1,5 +1,5 @@ -//! Methods of `MicroRows`: `reserve`, `push`, `collect`, `inject`. Functions: `prepare_micro_ffn_rows`. -//! Defines `MicroEnv`, `MicroSources`, `MicroBlockSources` and 2 more. +//! FFN preparation of a micro window of a prefill layer: the attention blocks of the window, one whole retained-GR +//! FFN read over them, then the per-row proofs. The block kinds and the FFN routing are the child modules. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs index 4a3c5283..3a26d009 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the routing of the FFN reads of a micro window. +//! The routing of the FFN reads of a micro window. use super::{ ChunkFfnRow, Context, DetachedGrRead, Error, ForwardPhase, GrStage, MicroEnv, MoeExpertStage, MoeMicroProducts, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs index c9af8168..b2d405a1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the native prompt GDN attention blocks of a micro window. +//! The native prompt GDN attention blocks of a micro window. use super::{ ChunkAttentionRow, Context, DetachedGrRead, Error, GdnChunkDevice, GdnStage, GrMicroAttentionBank, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs index e32da09c..302994ae 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the row-by-row attention blocks of a micro window (device GDN owner or host stages). +//! The row-by-row attention blocks of a micro window (device GDN owner or host stages). use super::{ BoundLayerKind, ChunkAttentionRow, DetachedGrRead, Error, ForwardPhase, GdnChunkDevice, GdnStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs index d043ec7e..20f61a2f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the native prompt QSA attention blocks of a micro window. +//! The native prompt QSA attention blocks of a micro window. use super::{ ChunkAttentionRow, Context, Error, GrMicroAttentionBank, GrStage, MicroBlockRequest, MicroEnv, MicroRows, 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 911129b7..32fcda05 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 @@ -1,5 +1,5 @@ -//! Functions: `prepare_q6_layer_columns`, `q6_inputs`, `q6_roles`, `q6_project` and 1 more. -//! Split out of `prefill_chunk` to keep its files under the line limit. +//! Q6K projection of the attention rows of a layer: the validated residual input of each row goes through the layer's +//! 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}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs index 0642643c..f251b02e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `joint_chunk`, `prefill_chunk_cached_windowed`, `prefill_chunk_native_windowed` and 1 more. -//! Split out of `prefill_chunk` to keep its files under the line limit. +//! Chunk entry points of `QwenForward`: the joint target+draft prefill chunk in its cached, MMQ and native windowed +//! forms, and the planned layer loop they share. use super::{ AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs index c431cae6..501f8aff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the inputs and the joint target+draft publication shared by the prefill chunk entry points. +//! The inputs and the joint target+draft publication shared by the prefill chunk entry points. use super::{ ChunkMoePolicy, DenseWeightCache, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, QwenForward, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs index 80b6caba..090a2c7a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenForward`: `test_chunk_on_loaded`, `prefill_chunk_mmq_joint`, `prefill_chunk_cached_joint`, `prepa... -//! Split out of `qwen_forward` to keep its files under the line limit. +//! Entry points of `QwenForward` for the cached prefill chunk: MMQ joint, cached joint and the private outer256 +//! windowed experiments (plain and retained-GR transport). Normal serving stays on outer64 with the host transport. use super::{ ChunkMoePolicy, MoeWeightCache, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, QwenSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs index cb788161..ced380a7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenForward`: `prefill_chunk_native_integer_iq3_windowed256_retained_gr_joint`, `prepare_prefill_chun... -//! Split out of `qwen_forward` to keep its files under the line limit. +//! Entry point of `QwenForward` for the native IntegerIQ3 prefill chunk: outer256 layers run in windows of at most 64 +//! rows over the retained-GR transport; the draft is warmed and published with the target only after all 48 layers +//! completed. use super::{ AllocationTrace, ChunkMoePolicy, Error, MoeWeightCache, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs index 858c0c53..474fa71a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs @@ -1,5 +1,6 @@ -//! Methods of `ChunkEnv`: `new`, `with_boundary`, `native_prompt`. Methods of `ChunkRun`: `window`. -//! Defines `MicroBank`, `MicroBank`, `NativeMoe` and 6 more. +//! The planned prefill chunk: admission, the `ChunkEnv` every phase reads, the `ChunkRun` of the rows a run covers +//! and the layer loop that ends in the output head. The phases are the child modules (setup, layer, window attention, +//! FFN, experts). use super::{ AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs index ce89ceca..fef33659 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: one layer of the prefill chunk, its GDN device owner and its windows. +//! One layer of the prefill chunk, its GDN device owner and its windows. use super::window_experts::ExpertRun; use super::window_ffn::WindowOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs index 496b946d..0d720bb1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: admission, transaction begin, input rows and output head of one prefill chunk. +//! Admission, transaction begin, input rows and output head of one prefill chunk. use super::{ ChunkEnv, ChunkMoePolicy, ChunkOpening, Context, DenseWeightCache, Error, InjectedResidual, InputStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs index b9490f66..5215db16 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the host GDN and QSA attention stages of one prefill row, shared by the FFN-row and micro-FFN paths. +//! The host GDN and QSA attention stages of one prefill row, shared by the FFN-row and micro-FFN paths. use super::{ DenseWeightCache, ForwardPhase, GdnStage, LayerId, ModelBinding, Position, QsaAttentionStage, QsaIndexStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs index 65062021..2fb5da02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the attention reads of one window of a prefill layer. +//! The attention reads of one window of a prefill layer. use super::{ ChunkEnv, ChunkRun, Error, GrStage, InjectedResidual, InputStage, LayerEntry, LayerId, MicroBank, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs index 82248e3f..5709e1e9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the expert execution and the batched FFN injection of one window of a prefill layer. +//! The expert execution and the batched FFN injection of one window of a prefill layer. use super::{ ChunkEnv, ChunkMoePolicy, ChunkRun, Error, GrStage, InjectedResidual, LayerId, MoeExpertStage, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs index 7606f215..0d9ef893 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the projected columns and the prepared FFN rows of one window of a prefill layer. +//! The projected columns and the prepared FFN rows of one window of a prefill layer. use super::{ AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkRun, Error, ForwardPhase, GdnStage, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs index e920ac5d..d08b94b2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the host stages of one prefill row (GDN or QSA attention, GR injection, FFN read, routing). +//! The host stages of one prefill row (GDN or QSA attention, GR injection, FFN read, routing). use super::{ AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkMoePolicy, ForwardPhase, GrStage, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs index ea40d3bf..006ebbdb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs @@ -1,5 +1,6 @@ -//! Methods of `AttentionHandoff`: `new`. -//! Methods of `QwenForward`: `test_layer0_pair_on_loaded`, `run_layer0_diagnostic`. +//! The FFN read of a chunk attention row: the detached attention residual and the block output (`AttentionHandoff`) +//! go to the retained GR bank. Also the layer-0 pair diagnostic, whose four-row chunk must refuse with the executor +//! error. use super::{DenseWeightCache, ForwardPhase, GrStage, ModelBinding, Result, diagnose}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs index 996646a8..9698f1db 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs @@ -1,5 +1,5 @@ -//! Methods of `TargetStepProduct`: `from_chunk_commit`. Functions: `chunk_diagnostic`. -//! Split out of `prefill_chunk` to keep its files under the line limit. +//! `TargetStepProduct` of a committed prefill chunk (only the checked joint publisher supplies its final source) and +//! the `chunk_diagnostic` tracer, which prints the stage, layer and rows of a failure in test builds only. use super::{Result, TargetStepProduct}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs index dc9ae9c8..7ac9ec4c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs @@ -1,4 +1,5 @@ -//! The proof phases of the window boundary observer (STRA-338 size: extract-method only). +//! The phases of the window boundary observer: the unchanged Native4 baseline measured first, the windowed candidate +//! under the retained-GR policy compared with it, and the cancellation phase. use super::{ BoundaryPlan, Cell, ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs index 2b65df2f..9448b57c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs @@ -1,5 +1,6 @@ -//! Methods of `PrefillStepProduct`: `mtp_source`. -//! Methods of `TargetStepProduct`: `test_prefix_residual`, `mtp_source`, `predicted`, `position` and 1 more. +//! `mtp_source` of a finished step: the validated product (token, position, ten residual streams, origin) an MTP +//! draft starts from, for a known-next prefill step and for a full target step. A stale origin or a non-finite stream +//! is refused. use super::{ Error, ForwardPhase, ModelBinding, Position, PrefillStepProduct, QwenSession, Result, TargetStepOrigin, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs index e293b4b5..a5548050 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs @@ -1,5 +1,4 @@ -//! Methods of `QwenForward`: `reset`. -//! Split out of `qwen_forward` to keep its files under the line limit. +//! `QwenForward::reset`: returns the session to the empty prompt. use super::{QwenForward, QwenSession, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs index 09a1be14..1be83f22 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs @@ -1,5 +1,6 @@ -//! Functions: `read_layer_attention`, `read_layer_one`, `prepare_layer_attention_micro`, `prepare_layer_one_micro` a... -//! Defines `LayerEntry`. +//! The GR attention read of one layer of a step: layer 0 applies, layer 1 consumes the PLE producer first, later +//! layers read from the previous residual. Also the micro-window variants and the layer-plan and descriptor +//! validation. use super::{ BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GrRead, GrStage, InjectedResidual, InputStage, 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_sdet.rs index f5111017..f3bc82c3 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_sdet.rs @@ -1,4 +1,6 @@ -//! Cache-reset-replay numerical proof, moved out of `executor.rs` by STRA-338 (size); same module path as before. +//! GPU test: cached forward and legacy replay agree numerically across an actual reset of the same session (not two +//! fresh requests), with the cache counters unchanged and only equality and bounded counts reported, never tensor +//! words. use super::{ BoundLayerKind, DenseWeightCache, Dimension, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs index 7a5576a4..8947e066 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs @@ -1,4 +1,5 @@ -//! Phases of `QwenForward::step_core` (STRA-338 size: extract-method only, same order of operations). +//! The layer phases of `QwenForward::step_core`: cache preparation, the input row, the layer loop (attention half +//! with GDN or QSA, FFN half with routing and experts) and the step finish. The order of the stages is the contract. use super::{ BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, 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 33c2ff59..04ea33bd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the layer-plan topology check (the exact contiguous closed sequence) and, on a GPU, that a missing output +//! refuses before the layers without committing state and that two tokens finish all layers and commit. use super::{ BoundLayerKind, Dimension, Error, LayerId, OutputStage, Position, QwenForward, QwenSession, QwenStepTxn, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs index f31ac909..a0548099 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs @@ -1,5 +1,6 @@ -//! Methods of `CachedGdn`: `project`, `run`, `leading_products`, `recurrence` and 3 more. -//! Functions: `step_cached`, `open_chain`, `settle_cached`, `chain_output_role` and 3 more. +//! One native GDN token step with the dense-weight cache: projections, convolution, q/k norm, gates, recurrence. +//! Runs on a step-local `Chain`, then publishes the next recurrent state through the mirror only if the whole step +//! succeeded; on failure the computed candidate is discarded and the chain is cleaned up. use super::{ CandidatePair, Context, DEVICE_PEAK, DenseWeightCache, DeviceBuffer, Error, GdnInputLease, GdnLayerInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs index 9d675158..008bb41f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs @@ -1,5 +1,6 @@ -//! Methods of `QkScratch`: `test_slot_bytes`, `new`, `validate`, `take` and 2 more. Methods of `Role`: `count`. -//! Functions: `allocate_qk_slot`, `normalize_retained_qk`. +//! The retained whole-QK scratch slot of the GDN chain and the q/k normalisation that writes into it. +//! One slot is lent to a chain at a time and must come back as the same allocation; a failed return forbids every +//! later take. Also gives each chain `Role` its element count and the products and borrows their accessors. use super::{ BindingIdentity, CHANNELS, Cell, Context, DeviceBuffer, Error, HISTORY_ELEMENTS, MirrorAuthority, Product, 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 d7f84f03..3b13793e 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `chain_construction_and_buffers`, `chain_projection_convolution`, `chain_readout_and_finish... -//! Split out of `chain` to keep its files under the line limit. +//! The step-local `Chain` of GDN stage products, split by phase: construction and buffers, scalar projection and +//! convolution stages, readout and finish, and the one-drain row queue. All phases share the chain's private slots. use super::{ BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, DeviceOperand, DeviceProduct, Error, GdnLayerInput, 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_construction_and_buffers.rs index c745c2dc..7bc99b28 100644 --- 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_construction_and_buffers.rs @@ -1,5 +1,5 @@ -//! Methods of `Chain`: `new`, `validate`, `set_verification_pool`, `return_fixed` and 15 more. -//! Split out of `chain` to keep its files under the line limit. +//! Construction of a step-local `Chain` and its slot bookkeeping: pending operands, products, buffer lookup. +//! Every lookup refuses a stale epoch, a wrong role or a foreign chain, so a capability cannot outlive its drain. use super::{ BindingIdentity, Cell, Chain, Context, DeviceBuffer, DeviceOperand, DeviceProduct, Error, GdnMatrixKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs index 315b56b0..f313d5bc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs @@ -1,5 +1,5 @@ -//! Methods of `Chain`: `upload_values`, `note`, `note_err`, `free` and 10 more. -//! Split out of `chain` to keep its files under the line limit. +//! The scalar (host-readback) stages of the GDN chain: upload, projection, convolution, q/k normalisation, gates. +//! Each producer runs its own kernel and its own finite readback; callers never hand in a separate numeric proof. use super::{ CHANNELS, Chain, DeviceBuffer, Error, GdnMatrixKind, GdnMatrixLayout, HISTORY_ELEMENTS, Product, QkReturn, 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/chain_readout_and_finish.rs index b728b448..b7ffaa02 100644 --- 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/chain_readout_and_finish.rs @@ -1,5 +1,5 @@ -//! Methods of `Chain`: `import_chunk_readout`, `out_norm`, `drain`, `finish`. -//! Split out of `chain` to keep its files under the line limit. +//! The tail of the GDN chain: import of a chunk readout, the output norm, and the drain that ends the chain. +//! `drain` bumps the epoch (invalidating every product), returns pooled slots and frees the rest. use super::{Chain, DeviceBuffer, Error, Product, Rc, Result, Role, VALUES, download, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs index f769eedc..52d07aa7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs @@ -1,5 +1,6 @@ -//! Methods of `Chain`: `run_row_queue`, `reserve_row_slots`, `drain_row_queue`, `row_input_buffers` and 12 more. -//! Functions: `check_distinct_slots`. Defines `RowSlots`, `RowInputBuffers`, `RowOutputBuffers`. +//! The queued row of the GDN chain: conv, q/k norm, beta sigmoid, gates, recurrence and out-norm in ONE driver drain. +//! The scalar chain's intermediate host readbacks and fences are gone; every stage output is still scanned for finite +//! values and nothing is published unless the whole drain was clean. Also lends recurrence inputs to the caller. use super::{ Chain, DeviceBuffer, DeviceOperand, Error, GdnLayerInput, GdnRowQueue, Product, QkvInput, QueueInputs, QueuedRow, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs index 4f0b8715..ae72fb6e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs @@ -1,5 +1,4 @@ -//! Implements `Drop for Chain`. -//! Split out of `chain` to keep its files under the line limit. +//! Drop of a `Chain`: drains it, so slots go back to their pools or are freed even when a step bails out early. use super::Chain; 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/gdn_chunk_device_methods.rs index abb0f45f..6ad48c03 100644 --- 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/gdn_chunk_device_methods.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `chunk_device_batch_compute`, `chunk_device_construction`, `chunk_device_finish_cleanup`. -//! Split out of `chunk_device` to keep its files under the line limit. +//! The `GdnChunkDevice` methods by phase: construction and admission, per-row and batch compute, finish and cleanup. use super::{ BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, ChunkReadout, Context, DenseWeightCache, DeviceBuffer, Error, 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/gdn_chunk_device_methods/chunk_device_batch_compute.rs index 460d22fb..5eca8118 100644 --- 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/gdn_chunk_device_methods/chunk_device_batch_compute.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnChunkDevice`: `finish_batch`, `history`, `step_source`, `read_checked` and 13 more. -//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. +//! Per-row and per-batch recurrence compute of a `GdnChunkDevice`: upload or borrow the inputs, run the step, +//! read the readout back and mint the row edges. The earliest full-state refusal precedes the readout and any user. +//! Also adopts the final state of a batch that drained clean. use super::{ ChunkEdge, ChunkReadout, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, HISTORY_ELEMENTS, Rc, ReadoutDownload, 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/gdn_chunk_device_methods/chunk_device_construction.rs index 6b0e3d57..04241e1e 100644 --- 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/gdn_chunk_device_methods/chunk_device_construction.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnChunkDevice`: `new`, `empty`, `copy_history`, `take_prior_owners` and 16 more. -//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. +//! Construction and admission of a `GdnChunkDevice`: prior-state upload, verification pool, optional row queue. +//! Validates that rows, batches and micro-windows are exactly the next rows of the chunk from the cursor. +//! Nothing is mutated until a clean drain completes the step. use super::{ BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, Context, DenseWeightCache, DeviceBuffer, Error, 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/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs index c5299ddb..3c2efd22 100644 --- 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/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnChunkDevice`: `finish`, `sealed_prior`, `return_scratch_and_guard`, `adopt_final_state` and 5 more. -//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. +//! End of life of a `GdnChunkDevice`: seal the chunk, return scratch and guards, adopt the final state, clean up. +//! Covers the ordinary chunk and the MTP verification variant. Cleanup keeps the first failure, frees the rest. use super::{ DenseWeightCache, Error, GdnChunkDevice, GdnChunkSeal, GdnPrior, ModelBinding, Result, STATE_ELEMENTS, download, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs index 8fe6391c..f820325e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs @@ -1,5 +1,5 @@ -//! Methods of `ChunkEdge`: `into_parts`, `into_row`. Methods of `ChunkReadout`: `into_parts`, `same_owner`. -//! Implements `Drop for ChunkReadout`. Functions: `mirror_reuse_enabled`, `micro_rows`. +//! Edge and readout handles of a GDN chunk row, and the `prefill_gdn_mirror` switch for reusing the resident mirror. +//! A `ChunkReadout` frees its device buffer on drop; it can be consumed only by the chain that owns its scope. use super::{ Cell, ChunkEdge, ChunkReadout, Context, DeviceBuffer, Error, GdnChunkMicro, GdnChunkRow, Rc, Result, VALUES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs index ff2ccf6b..da0a7e89 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnChunkDevice`: `bind_native_fused`, `native_fused_operands`, `complete_native_fused_step`. -//! Implements `Drop for GdnChunkDevice`. +//! The in-place fused T1 recurrence of a verification `GdnChunkDevice`: bind the closed fused program to its +//! workspace, hand out the step operands, complete the step. Also the Drop that cleans up the chunk's device owners. use super::{DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, Rc, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs index 87950278..7d727ccb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs @@ -1,5 +1,6 @@ -//! Functions: `batch_adoption`, `adoption_rows`, `adoption_phase`, `batch_operand_guards` and 6 more. -//! Split out of `numeric_gpu` to keep its files under the line limit. +//! GPU-test proof of batch adoption on a `GdnChunkDevice`: only the next consecutive rows form a batch, a refused +//! batch mutates nothing, an accepted one advances the cursor and swaps the final state into place once. +//! Pure ownership and identity: no kernel runs, the final state is a recognisable pattern. use super::{ BindingIdentity, Context, Dimension, Error, GdnChunkDevice, GdnChunkRow, GdnPrior, HISTORY_ELEMENTS, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs index 81e5f18f..36f1d02d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs @@ -1,5 +1,6 @@ -//! Methods of `Fixture`: `new`, `row_guards`, `run_rows`, `compute_row` and 12 more. -//! Functions: `require_rejected_clean`, `exercise`, `run_gdn_chunk_numeric`. Defines `Fixture`, `ComputedRow`. +//! GPU-test driver of the chunk-device recurrence proof: 65 rows, the seal, finite guards and abort/replay. +//! Compares every readout and interior state against a same-PTX reference and checks that wrong rows, rival seals and +//! non-finite sources are refused without moving the owner. use super::{ BUDGET, BindingIdentity, CHUNK_DEVICE_CHARGE, ChunkReadout, Context, Counts, DeviceBuffer, Dimension, Driver, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs index e67ac3d2..65f4b9a9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs @@ -1,5 +1,5 @@ -//! Methods of `Operands`: `recurrence`. -//! Functions: `operands`, `convolution_input`, `convolution_weights`, `difference` and 3 more. +//! Deterministic row inputs, convolution data and the reference recurrence of the chunk-device GPU proof, plus the +//! component owner that holds real buffers without a model binding. use super::{ CHUNK_DEVICE_CHARGE, Cell, Context, Error, GdnChunkDevice, GdnChunkStart, GdnPrior, Operands, ROWS, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs index aa103a5f..c0082b22 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs @@ -1,5 +1,5 @@ -//! Functions: `driver_error`, `validate_candidates`, `state_index`, `key_head`. -//! Split out of `gdn` to keep its files under the line limit. +//! Maps CUDA driver errors to the GDN `Error` and holds the GDN state addressing checks (`state_index`, `key_head`). +//! The state address is the exact native layout, never a head-major reinterpretation. use super::{DriverError, Error, KEY_HEADS, Result, Stage, VALUE_HEADS, WIDTH}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs index 7a215694..e9cb7f87 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs @@ -1,5 +1,6 @@ -//! Methods of `RecurHost`: `validate`, `upload_all`. -//! Functions: `gates`, `upload_gate_inputs`, `run_gate_kernels`, `release_owned` and 16 more. +//! Kernel runners of the scalar GDN stages: gates, the recurrence step and the output norm, with their device +//! upload, download and release helpers. Every output is read back and checked finite before use. +//! Also the `prefill_gdn_pool` switch that pools the 3.1 MB state buffers across layers and chunks. use super::{ CandidatePair, Context, DeviceBuffer, Error, InputBindingError, POOL_OVERRIDE, RecurrenceOperands, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs index 1d760b45..9d05ad2e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnReady`: `identity`, `output`, `validate_origin`, `take_pending`. -//! Split out of `gdn` to keep its files under the line limit. +//! Accessors of `GdnReady`, the finished output of one GDN layer step: its identity, origin check and the pending +//! recurrent candidate, which can be taken once (the session is the only publisher). use super::{BindingIdentity, Error, GdnPending, GdnReady, Result, TokenLayer}; 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/gdn_state_mirror_methods.rs index cda577a1..1dbca0e2 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/gdn_state_mirror_methods.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `state_mirror_compute_and_admit`, `state_mirror_publish_and_close`. -//! Split out of `mirror` to keep its files under the line limit. +//! The `GdnStateMirror` methods by phase: construction, admission and compute, then publish, adopt and close. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GdnPending, GdnPrior, GdnStateKey, GdnStateMirror, 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/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs index 9af89767..8184ad6a 100644 --- 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/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnStateMirror`: `new`, `allocate_mirror`, `compute`, `compute_retained` and 13 more. -//! Split out of `gdn_state_mirror_methods` to keep its files under the line limit. +//! Admission and compute half of `GdnStateMirror`: allocate the resident state buffer at load, check that a prior is +//! exactly the state the mirror holds, upload it on a miss, run the step and mint the candidate. +//! Nothing here changes the mirror's identity; only `publish` does. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GdnPrior, GdnStateMirror, MIRROR_BYTES, MirrorNext, 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/gdn_state_mirror_methods/state_mirror_publish_and_close.rs index afc3ac2a..76d06f34 100644 --- 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/gdn_state_mirror_methods/state_mirror_publish_and_close.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnStateMirror`: `compute_borrowed`, `step_products`, `publish`, `admit_publish` and 5 more. -//! Split out of `gdn_state_mirror_methods` to keep its files under the line limit. +//! Publish half of `GdnStateMirror`: replace the resident buffer by an admitted candidate, hand the resident image to +//! a chunk, adopt a sealed chunk's state, and close. A hit key is never published before replacement cleanup is done. use super::{ Context, DeviceBuffer, Error, GdnPending, GdnPrior, GdnStateKey, GdnStateMirror, MIRROR_BYTES, MirrorAuthority, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs index dee8dede..e5a9f756 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs @@ -1,5 +1,5 @@ -//! Methods of `MirrorReadout`: `test_values`, `into_parts`, `same_owner`, `into_host`. -//! Implements `Drop for MirrorReadout`. +//! The readout of one mirror step: the device buffer and the finite host values read back from it. +//! Only the recurrence producer can pair the buffer with its readback; dropping it frees the device buffer. use super::{DeviceBuffer, Error, MirrorReadout, Rc, ReadoutClaim, Result, VALUES, driver_error, validate_values}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs index fd54ab2f..d7725965 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs @@ -1,5 +1,4 @@ -//! Functions: `upload_checked`. -//! Split out of `mirror` to keep its files under the line limit. +//! Uploads host f32 values into a fresh device buffer, freeing it and latching the failed flag if the copy fails. use super::{Cell, Context, DeviceBuffer, Error, Result, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs index c6a999bf..e3c88b02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs @@ -1,5 +1,6 @@ -//! Methods of `Buffers`: `allocated_bytes`, `new`, `pool_sizes`, `from_pool` and 1 more. Methods of `Images`: `take`. -//! Functions: `next_buffer`, `release_pool`. Defines `PoolIter`, `Images`, `Projections` and 1 more. +//! The per-call device buffers of one batched GDN prefill step: BF16/FP16 activation images, projection outputs and +//! rolling histories, sized for `tokens` rows. Allocated as one pool and released together, so a failed allocation +//! leaves nothing behind. use super::{ ALPHA_BETA, Bf16Profile, Buffers, CHANNELS, Context, DeviceBuffer, Error, HISTORY_ELEMENTS, MIXED, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs index 321b6ac5..39abc3f5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnBatchResources`: `new`, `new_for_prompt`, `new_capacity`, `admit_capacity` and 8 more. -//! Implements `Drop for GdnBatchResources`. +//! The persistent owner of the batched GDN prefill program: closed driver program, dequantization scratch and the +//! per-call buffers, charged once per context before the routed prefix plan is admitted. +//! Buffers grow to a prompt's token count; closing releases scratch, program and buffers (also on Drop). use super::{ ALPHA_BETA, BATCH_RESERVE, BATCH_SCRATCH_BYTES, Bf16Profile, Buffers, CHANNELS, Context, DeviceBuffer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs index 7b8ba09e..18c0c3cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnStage`: `step_chunk_batch`. -//! Split out of `prefill_batch` to keep its files under the line limit. +//! Entry point `GdnStage::step_chunk_batch`: the batched Strata-prefill GDN step over one causal micro-window. +//! Rows and cursor come only from the validated micro; every row edge is minted after the whole batch drained finite. use super::step_batch::{ check_gdn_window, gather_gdn_rows, gdn_operands, latch_cuda_failure, prepare_or_refuse, run_gdn_program, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs index 44b04be4..ca08d80e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs @@ -1,4 +1,7 @@ -//! Phases of `GdnStage::step_chunk_batch` (STRA-338 size: extract-method only). +//! The phases of `GdnStage::step_chunk_batch`: check the window, gather its genuine rows, resolve the layer's +//! resident matrices, run the closed batch program and settle. Edges are minted only after the whole batch drained +//! finite and the chunk device adopted the final state; a refusal marks the chunk device and, on CUDA failure, the +//! transport. use super::{ BoundLayerKind, Buffers, CHANNELS, ChunkReady, Context, DenseWeightCache, DeviceBuffer, Dimension, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs index 15a9b678..353a7fdb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs @@ -1,5 +1,6 @@ -//! Methods of `ProjectionOperands`: `without_cache`. -//! Functions: `project`, `project_leased`, `project_uploaded`, `upload_matrix_block` and 10 more. +//! Scalar projection stages of the GDN layer: QKV, alpha, beta, Z and Out matrix products, the convolution and the +//! q/k normalisation, each with a host readback checked finite. Uses the resident dense-weight cache and the input +//! lease when present, otherwise uploads the matrix block for this call only. use super::gates::{release_with_owned, upload_unless_resident}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs index 5232ac92..b65e495a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnStage`: `step_chunk_selected`, `step`, `step_projected`, `step_impl` and 4 more. -//! Split out of `gdn` to keep its files under the line limit. +//! The `GdnStage` step entry points of one token: pick the fused native owner, the cached chain or the uncached path. +//! Validates binding, layer, input origin and prior before any device work, then returns a `GdnReady` candidate. use super::{ BoundLayerKind, CandidatePair, Context, DenseWeightCache, DeviceChunkRow, Dimension, Error, GateHostOperands, 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 8e5c7a15..42d9a2e4 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `verified_row_compute_and_lease`, `workspace`, `workspace_replay`. -//! Split out of `verification` to keep its files under the line limit. +//! Row compute of MTP verification, split by owner: the verified row, the `Workspace` it runs in, and accepted-prefix +//! replay on that workspace. use super::{ ActiveLease, BindingIdentity, COUNTS, Cell, Context, DEVICE_BYTES, DeviceBuffer, Error, GdnChunkRow, GdnChunkStart, 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_compute_and_lease.rs index 11aafebf..e3c0f751 100644 --- 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_compute_and_lease.rs @@ -1,5 +1,5 @@ -//! Methods of `ActiveLease`: `validate`, `refuse`. Methods of `VerifiedRow`: `history`, `validate`. -//! Functions: `compute_row`. +//! One verified GDN row of MTP verification: the recurrence compute over the workspace buffers, plus the checks +//! of the active lease and of a saved `VerifiedRow`. A refused lease invalidates every row minted under it. use super::{ ActiveLease, BindingIdentity, Context, Error, GdnStateFiniteGuard, HISTORY_ELEMENTS, LayerId, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs index d682c95d..08b66fd4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs @@ -1,5 +1,5 @@ -//! Methods of `Workspace`: `new`, `empty`, `reserve_slot_tables`, `allocate_owners` and 15 more. -//! Split out of `compute_row` to keep its files under the line limit. +//! The verification `Workspace`: fixed device owners (three state buffers, readout, finite guard, per-row operands) +//! for one verify round. Admits a lease, lends layers and rows out, takes them back and records verified rows. use super::{ ActiveLease, BindingIdentity, COUNTS, Cell, Context, DEVICE_BYTES, DeviceBuffer, Error, GdnChunkRow, GdnChunkStart, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs index ec6c2233..1b221d19 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs @@ -1,5 +1,6 @@ -//! Methods of `Workspace`: `replay`, `replayed_prior`, `replay_row`, `settle_replay` and 9 more. -//! Methods of `ReplaySeal`: `validate_prior`. Implements `Drop for Workspace`, `Drop for PoolRow`. +//! Replay of the accepted prefix on the verification workspace: after a verify round, re-run only the accepted rows +//! from the untouched device prior and return the resulting `GdnPrior`. Checks cancellation between rows. +//! Also cleanup and Drop of the workspace and of pooled rows. use super::{ ActiveLease, COUNTS, DeviceBuffer, Error, GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, PoolRow, Rc, ReplaySeal, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs index 069d4962..7319fc3d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs @@ -1,5 +1,4 @@ -//! Methods of `Workspace`: `bind_native_fused`. -//! Split out of `verification` to keep its files under the line limit. +//! Binds the closed fused T1 program to the verification `Workspace`, so fused rows reuse its owners and lease. use super::{ActiveLease, Error, Rc, RefCell, Result, Workspace, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs index 1c872fae..7111bb61 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs @@ -1,4 +1,6 @@ -//! Phases of `GrStage::inject_batch` (STRA-338 size: extract-method only). +//! The phases of `GrStage::inject_batch`: gather the consecutive rows, run the queued T1/T2/T3 workspace path or the +//! generic device path, and publish one `InjectedResidual` per row. The exclusive scratch lease ends before any host +//! finite validation or publication of a row capability. use super::{ Cell, Context, DenseWeightCache, DeviceBuffer, Error, GrBatchRow, GrBatchScope, GrRole, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs index 7f0837fc..1f51bc17 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs @@ -1,5 +1,5 @@ -//! Methods of `GrMicroInput`: `validate_origin`, `identity`. Methods of `GrMicroAttention`: `into_parts`. -//! Implements `Drop for GrMicroAttentionBank`. Functions: `save_micro_values`, `micro_driver_error`. +//! Micro-window side of GR: accessors of the immutable current-row input, the attention bank that owns the micro +//! device (legacy or native), and its close/Drop. Maps driver errors for the micro path and saves finite row values. use super::{ BindingIdentity, DetachedGrRead, DeviceBuffer, DriverError, Error, GrBatchScope, GrMicroAttention, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs index cf618a93..fffc2e0c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `GrStage`: `mint_micro_input`, `prepare_micro_initial`, `prepare_micro_after_ple`, `prepare_micro_afte... -//! Methods of `GrBatchScope`: `detach_rows`, `refuse_device`, `seal`. +//! GR over one micro-window of rows: mint micro inputs (initial, after PLE, after FFN) and read the attention blocks +//! of every row in one device call. Checks that all rows are the next positions of one layer and that the bank, +//! binding and transaction agree; refusal closes the micro device. use super::super::super::dense_weight_cache::GrResident; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs index 5c7830db..652a910b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs @@ -1,5 +1,5 @@ -//! Methods of `GrStage`: `prepare_detached_batch_injection`, `prepare_batch_injection`, `inject_batch`. -//! Functions: `check_batch_read`. +//! Batch injection of GR: prepare the FFN-side detached reads of a chunk and inject each block output back into its +//! residual streams. Every read is checked against the transaction (binding, origin, position, finite witnesses). use super::batch_inject::{device_inject, gather_batch}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs index 50c757a2..ccaf73df 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs @@ -1,5 +1,5 @@ -//! Methods of `GrScratch`: `new`, `new_identity`, `allocate_owned`, `buffer` and 5 more. -//! Methods of `GrRead`: `ready`, `finish`. Implements `Drop for GrScratch`. +//! GR scratch and failure diagnostics: the eagerly charged actor-owned scratch slot (11 device owners) that every GR +//! read overwrites, its lease/finish, and the labelled aggregate diagnostics that reveal no tensor data. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GR_INJECT_BYTES, GR_OUTPUT_BYTES, GR_OWNED_DEVICE_BYTES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs index 6996c3e0..ed066814 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs @@ -1,5 +1,5 @@ -//! Methods of `GrStage`: `validate_detached_ffn`, `validate_ffn_ready`. -//! Functions: `download_f32`, `driver_error`, `binding_error`, `validate_values` and 2 more. +//! Host-side helpers shared by the GR stages: finite device readback, driver and binding error mapping, and the +//! shape checks of values, layers and streams. Also validates a detached FFN read against the current transaction. use super::{ DetachedGrRead, DeviceBuffer, Dimension, DriverError, Error, GrRole, GrStage, InputBindingError, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs index 6675062c..dbd0ec3b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `GrStage`: `apply`, `read_ffn`, `read_attention`, `read_attention_after_ple` and 6 more. -//! Functions: `copy_streams`, `resolve_gr_weights`, `read_candidate`, `check_injection_origin` and 2 more. +//! Single-row entry points of the GR stage: `apply` for layer 0, the attention and FFN reads, the final mix and the +//! injection of a block output into the residual streams. Each entry validates origin, layer and transaction before +//! touching the device; the result is a read capability or an `InjectedResidual`. use super::super::dense_weight_cache::GrResident; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs index 5b327d43..9ef07ee5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs @@ -1,5 +1,4 @@ -//! Functions: `run_proof`, `compare_outputs`, `release_owners`, `original_first_fixed_outputs_repeat_overwrite_abort... -//! Defines `Tally`. +//! GPU test that the fixed GR output workspace is overwritten on every repeat read, survives an abort and is cleaned. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GR_OUTPUT_DEVICE_BYTES, GrScratch, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs index f9a28ce3..3e02ac1a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs @@ -1,5 +1,5 @@ -//! Functions: `check_handoff`, `handoff_reference`, `residual_differences`, `ffn_differences`. -//! Split out of `output_workspace_gpu` to keep its files under the line limit. +//! GPU-test check of the attention to FFN handoff: the swapped producer feeds the FFN read without a host residual +//! upload, and residual and FFN outputs are compared against fresh-allocation references. use super::{ BindingIdentity, Context, DeviceBuffer, Error, GR_OUTPUT_DEVICE_BYTES, GrScratch, ReadCandidate, Result, block, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs index c4772494..58ef0927 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs @@ -1,5 +1,5 @@ -//! Functions: `fresh_read`, `release_reverse`, `fresh_read_launch`, `queue_fresh_read` and 5 more. -//! Split out of `output_workspace_gpu` to keep its files under the line limit. +//! GPU-test reference of the output workspace proof: fresh-allocation GR read and inject with the original +//! allocation boundary, plus the pattern inputs and the NaN poison that proves every retained byte is overwritten. use super::{Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GrScratch, Result, download_f32, driver_error, upload_f32}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs index 4a3a8c63..a8916ba0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs @@ -1,5 +1,5 @@ -//! Functions: `read_cached_cuda`, `borrow_read_outputs`, `borrow_read_inject`, `cached_read_body` and 12 more. -//! Split out of `gr` to keep its files under the line limit. +//! The cached GR read and inject on the actor-owned scratch: queued read kernels, the finite mask naming the first +//! failing stage, and the upload/copy/budget helpers. No result is cached: every active byte is rewritten per call. use super::{ Cell, Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GrPhase, GrScratch, ReadCandidate, RefCell, Result, diagnose, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs index ef86c7e1..8720b631 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs @@ -1,5 +1,5 @@ -//! Methods of `OwnedReadWeights`: `upload`, `select`, `release`. -//! Methods of `ReadWork`: `allocate`, `norm_down_silu`, `up_gates`, `release`. +//! The uncached GR read: upload the weights (unless resident), run norm, down projection, SiLU, up gates and the +//! inject coefficients on a fresh workspace, read them back and release everything before publishing. use super::{ Context, DeviceBuffer, Error, GrPhase, GrWeights, ReadCandidate, Result, diagnose, diagnose_extrema, download_f32, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs index f19790c5..e1c01364 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs @@ -1,5 +1,5 @@ -//! Methods of `ResidualReady`: `oracle_inject`, `validate_origin`, `identity`, `streams` and 1 more. -//! Methods of `InjectedResidual`: `from_candidates`, `validate_origin`, `identity`, `streams`. +//! Accessors of the GR capabilities: `ResidualReady` (a read result with mixed values and streams) and +//! `InjectedResidual` (streams after injection). Each can be checked for binding and role origin. use super::{BindingIdentity, Error, GrRole, InjectedResidual, ResidualReady, Result, TokenLayer, validate_streams}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs index 6375eba7..bdbed92a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of `gr`. +//! Pins GR refusals: shape and numeric failures leave inputs unchanged, a late NaN publishes no streams, norm and +//! post-op overflow are detected, not masked, and an injected capability from another model or stage is refused. use super::{ BindingIdentity, Dimension, Error, GrRole, InjectedResidual, LayerId, TokenLayer, validate_layer, validate_streams, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs index 71314d89..f69e9d6f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs @@ -1,3 +1,7 @@ +//! The input stage of a model step: the types of what a token step consumes (InputReady with its residual streams and +//! PLE rows, the chunk-wide StagedInput) and of the PLE history it advances (owner, prior, pending, ready). +//! The behaviour lives in the submodules; this file holds the data and the constants of the PLE layout. + #![allow(dead_code)] use super::contract::{Dimension, Error, Position, Result, Stage, TokenId}; 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 53c5d647..7fae45e2 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 @@ -1,5 +1,6 @@ -//! Methods of `InputReady`: `test_fixture`. Methods of `PleOwner`: `new`, `matches`. -//! Functions: `gather_rows`, `binding_error`. +//! The PLE history state of a session: PlePrior (the nine-slot history before a step), PlePending and PleReady (a +//! step in flight), plus the head-major gather of the sixteen PLE rows of one token. +//! Kept apart from input_stage so the history types can be checked and advanced without the input stage's callers. use super::{ BindingIdentity, Dimension, EMBEDDING_VALUES, Error, GrRole, InjectedResidual, InputBindingError, InputError, 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 cfe43abb..1eb2ece0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs @@ -1,3 +1,6 @@ +//! The sixteen PLE row indices of a token: a wrapping multiplicative hash of the token and its two predecessors +//! (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}; 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 6949a8df..ed3d11f1 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 @@ -1,5 +1,6 @@ -//! Methods of `InputStage`: `consume`, `consume_kar`, `consume_kar_deferred`, `ple_rows_ahead` and 3 more. -//! Functions: `admit_kar_input`, `stage_new_embedding`, `window_ple_row`, `gather_window_rows` and 3 more. +//! InputStage: turns a token and position into the step's input, its embedding broadcast to the four residual streams +//! and its sixteen PLE rows, for decode (`consume`) and for KAR-backed prefill (`consume_kar`, `..._deferred`). +//! The deferred form only records rows for the chunk-wide device gather; it never materialises per-row host values. use super::{ Context, Dimension, EMBEDDING_VALUES, Error, InputBindingError, InputError, InputReady, InputStage, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs index 399c35f7..0211fed1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs @@ -1,5 +1,6 @@ -//! Methods of `InputStage`: `prepare_ple_micro_input`, `apply_ple_micro_cached`, `apply_ple`, `apply_ple_cached`. -//! Functions: `check_micro_origin`, `check_micro_source`, `copy_ple_values`, `check_micro_admission` and 12 more. +//! The PLE step of InputStage: validates the genuine layer-one residual and the PLE prior, composes the key, value, +//! gate and history update on the device, and returns the new streams and history as one candidate or none. +//! No session history escapes on a numerical or transport refusal; the micro-window form covers a whole window. use super::{ Context, DenseWeightCache, Dimension, Error, GrRole, InjectedResidual, InputReady, InputStage, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs index da7d7a26..34b1a794 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs @@ -1,5 +1,6 @@ -//! Methods of `PleUploads`: `upload`. Methods of `OwnedPleAux`: `upload`, `select`, `release`. -//! Functions: `ple_cuda`, `project_key_value`, `ple_project`, `project_resident_key` and 6 more. +//! The CUDA composition of one PLE row from separate uploads: key and value projection of the embedding, then gate, +//! norms and convolution over the residual streams and the nine-slot history, with resident or uploaded weights. +//! Owns every device buffer of the step and releases them before a candidate can leave. use super::{ Bf16ProjectionShape, Context, DenseWeightCache, DeviceBuffer, Error, ModelBinding, PLE_DEVICE_PEAK, PLE_HC, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs index bc48ddeb..57ab95cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs @@ -1,5 +1,5 @@ -//! Methods of `Matrices`: `new`, `aux`, `unchanged`, `close`. -//! Methods of `Chain`: `key_value`, `norms`, `gate`, `gated` and 2 more. +//! Test support for the retained-PLE proof: synthetic BF16 PLE matrices and the legacy chain (one key projection and +//! forty ephemeral value tiles) that the whole-matrix retained path must reproduce bit for bit. use super::{ Bf16ProjectionShape, Context, DeviceBuffer, Finite, Matrices, Role, Transport, at, ple_download, ple_driver_error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs index 0d49a691..034f8eb2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs @@ -1,5 +1,6 @@ -//! Methods of `Role`: `count`. Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 8 more. -//! Implements `Drop for Transport`. Functions: `at`, `compose`, `admit`. +//! Impls of the PLE transport: the device buffers of one invocation, the certificates (`Finite`) a full readback +//! mints for each role (key, value, norms, gate, conv, history, streams), and the entry points `compose` and `admit`. +//! Any CUDA failure latches the invocation as failed, so nothing it produced can be published. use super::{ Cell, Context, DeviceBuffer, Error, Finite, PLE_HC, PLE_HISTORY, PleCandidate, PleRows, Rc, Result, Role, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs index 7febeb4f..3546598c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs @@ -1,5 +1,5 @@ -//! Methods of `InputStage`: `prepare_original_prompt_history`, `finish_original_prompt_history`, `prepare_prompt_dev... -//! Functions: `ple_upload_f32`, `ple_upload_u16`, `ple_download`, `ple_driver_error`. +//! Host-device transfer helpers of the PLE path (f32 and u16 uploads, readback, driver error mapping) and the +//! preparation of the prompt PLE history on the device: seeding it from the prior, closing it after a prefill chunk. use super::{ Context, DenseWeightCache, DeviceBuffer, DriverError, Error, GrRole, InputReady, InputStage, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs index 664e8e89..b42eca24 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs @@ -1,5 +1,5 @@ -//! Methods of `ResidualStreams`: `broadcast`, `values`. -//! Methods of `InputReady`: `binding_identity`, `token`, `position`, `streams` and 3 more. Implements `From for Error`. +//! Accessors of the input step: `ResidualStreams` (one embedding broadcast to the four residual streams, checked for +//! shape and finiteness) and the read-only view of `InputReady` (binding, token, position, streams, PLE rows). use super::{ BindingIdentity, EMBEDDING_VALUES, Error, InputError, InputReady, Position, ResidualStreams, Result, StagedInput, 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_methods.rs index 1fa25287..322a8841 100644 --- 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_methods.rs @@ -1,5 +1,6 @@ -//! Methods of `KarPleCache`: `new`, `admit_budget`, `allocate_scratch`, `admit_binding` and 15 more. -//! Functions: `check_stage_rows`, `encode_staged`, `verify_ahead_packets`, `serialize_books` and 4 more. +//! The lifecycle of `KarPleCache`: admission of the budget and binding, the staging scratch, staging a chunk of PLE +//! rows (hits, misses, packets from the read-ahead or the archive), commit after the device accepted the scatter, +//! and the direct 16-row gather with scatter, decode and finite readback. The cache map changes only in `commit`. use super::{ AHEAD_KEEP, AHEAD_THREADS, Ahead, Arc, CACHE_BYTES, Context, DeviceBuffer, Error, GatherPlan, KarPleBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs index 8fad61f9..df0bc762 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs @@ -1,5 +1,6 @@ -//! Methods of `Rng`: `next`, `row`. Methods of `Scan`: `new`, `victim`, `plan`, `gather`. -//! Functions: `token`, `gather_equals_the_full_scan_on_random_sequences`, `chunks_and_gathers_interleaved_keep_every... +//! Pins the resident-row LRU of the KAR PLE cache: gather planning equals a full-scan reference on random +//! sequences, chunks and gathers interleaved keep every row in its own slot, and eviction examines a handful of +//! queue items, not the whole cache. use super::{Lookup, Residents, SLOTS, assign_slots, lookup_rows, plan_gather, publish_gather}; use std::collections::HashMap; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs index 7dc91ff8..b8df218f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs @@ -1,5 +1,5 @@ -//! Methods of `Ahead`: `collect`. Functions: `publish_gather`, `ahead_enabled`. -//! Split out of `kar_ple_cache` to keep its files under the line limit. +//! Publication of a gather the device accepted (evict victims, map new rows, age the sixteen rows in order), the +//! `LELEKA_PLE_AHEAD` switch for read-ahead of the next chunk's packets, and collection of a finished read-ahead. use super::{Ahead, PlannedMiss, Residents}; 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 9b8ab142..ff609710 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 @@ -1,5 +1,6 @@ -//! Functions: `fnv`, `probe_binding`, `probe_rows`, `dump_decoded_rows_for_original_comparison` and 2 more. -//! Split out of `kar_ple_cache` to keep its files under the line limit. +//! Ignored probes against the real KAR archive and a GPU: dump the decoded PLE rows as FNV hashes for comparison +//! with the Original, and check that the batch read equals the sixteen-row reads. They admit a plain file path +//! through the same verification as production. use super::{BindingIdentity, KarPleBinding, KarPleCache, PLE_ROWS}; use crate::model_binding::qwen4exp_kar_ple::pinned_profile; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs index 94838bc2..5344a1ca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs @@ -1,5 +1,6 @@ -//! Methods of `Residents`: `len`, `get`, `contains_key`, `try_reserve` and 7 more. -//! Methods of `KarPleStaged`: `updates`, `slots`. Implements `Hasher for RowHasher`. +//! The row bookkeeping of the KAR PLE cache: `Residents`, the map of cached rows with a recency queue that finds +//! the oldest rows without scanning, the hasher for dense row numbers, and the pure slot planning for a chunk +//! (`lookup_rows`, `assign_slots`) and a gather (`plan_gather`). Nothing here touches the device. use super::{ Entry, Error, GatherPlan, Hasher, KarPleStaged, Lookup, MAX_MISSES, PlannedMiss, Residents, Result, RowHasher, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs index 3d6dca7d..6dd06703 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs @@ -1,5 +1,6 @@ -//! Functions: `apply`, `the_scatter_staging_buffers_match_the_update_records`, `chunk`, `consistent` and 9 more. -//! Defines `Given`. +//! Pins the slot assignment of the KAR PLE cache: fresh rows get distinct free slots, hits keep their slots and +//! refresh age, a full cache evicts the oldest untouched rows, rows match by id not position, and a chunk that needs +//! more slots than the untouched rows hold is refused. Also the scatter staging sizes. use super::{Error, Lookup, MAX_MISSES, Residents, UPDATE_RECORD_BYTES, assign_slots, lookup_rows, scratch_bytes}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs index 575f6e91..51f578a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs @@ -1,5 +1,6 @@ -//! Methods of `ActualSlotPacket`: `validate`. Methods of `ActualDown`: `take`. -//! Functions: `shared_scalar_buffers`, `release_shared_inputs`, `scaled_shared`, `finish_with_parts` and 1 more. +//! Cached-weights execution of one expert row: routed Down packets, the scalar-gated shared expert and the combine. +//! Owns the partial buffers of a run and closes every one of them whatever failed, so a failure never leaks device +//! memory. Also holds the origin checks that tie a Down packet to the binding and layer that minted it. use super::moe_down::{RetainedScalar, ScaledDown}; use super::{ 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 4e89fa25..86e3e2a4 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 @@ -1,5 +1,7 @@ -//! Functions: `matrix_dims`, `gate_up_dims`, `prepared_routed_format`, `gate_up_prepared_format` and 15 more. -//! Defines `MatrixDims`, `ExpertMatrix`, `ExpertActivation` and 2 more. +//! Projection of one expert matrix (Gate, Up or Down): shape and format admission, launch plan per matrix kind, +//! readback. The declared dimensions come from the binding; each matrix kind maps to exactly one launch (dense, +//! routed prepared Q8 or cached MMQ), and a kind without a plan is refused. The uncached diagnostic path uploads the +//! raw matrix here. use super::{ BoundExpert, CachedMoeMatrix, Context, DEVICE_PEAK, DenseFormat, DeviceBuffer, Error, FF, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs index 3a2962a0..c3ed9aaa 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs @@ -1,5 +1,7 @@ -//! Functions: `expert_mlp`, `cached_expert_mlp`, `uncached_hidden`, `project_cached_gate_up` and 3 more. -//! Split out of `moe_expert` to keep its files under the line limit. +//! One expert MLP (Gate and Up, SwiGLU, Down) returning host values, on the uncached diagnostic path or on cached +//! weights. The uncached path keeps its original download and re-upload chain; the cached path keeps Gate/Up on the +//! device. Release of every owned buffer is attempted after the last use and a cleanup failure withholds a finished +//! candidate. use super::expert_matrix_projection::{gate_up_dims, gate_up_prepared_format}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs index 8fd3e1c9..96ed8a92 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs @@ -1,5 +1,7 @@ -//! Methods of `ExpertReady`: `identity`, `output`, `validate_origin`, `from_completed`. -//! Methods of `StepCuda`: `dispatch`, `dispatch_prepared`. +//! Entry of one MoE expert step: validates the FFN row, uploads the activation and dispatches the routed experts and +//! the shared expert (weight cache, KAR archive or uncached diagnostic) into an `ExpertReady` row. All descriptors +//! and expert ids are admitted before any CUDA work; the activation and the prepared owner are released whatever the +//! dispatch result, and the dispatch error wins over cleanup errors. use super::{ BindingIdentity, BoundExpert, Context, DeviceBuffer, Error, ExpertActivation, ExpertReady, GrRole, K, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs index f91c557d..8da4a37c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs @@ -1,5 +1,6 @@ -//! Functions: `project_adaptive_packets`. -//! Split out of `adaptive_packets` to keep its files under the line limit. +//! Entry that projects every expert group of one chunk batch into its slot packets on the adaptive path. +//! It owns the ephemeral routed owner for the call and drains it whatever the outcome, so no pending expert transfer +//! outlives the batch, including after a prepare, copy or cancel error. use super::super::direct_packets_fns::PacketRun; use super::super::packet_run_project_group_direct::DirectRun; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs index f51e597e..af8a880e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs @@ -1,5 +1,6 @@ -//! Functions: `project_inner`, `observe_adaptive`, `ephemeral_slot_count`. -//! Split out of `adaptive_packets` to keep its files under the line limit. +//! Driver of one adaptive packet wave: observe the rows for the adaptive policy, classify the expert groups, stage +//! the GPU misses, run the CPU miss batches, then finish the GPU queue. Also checks that the ephemeral routed owner +//! has a supported slot count (legacy 2, or mapped 8 or 16). use super::super::direct_packets_fns::PacketRun; use super::super::packet_run_project_group_direct::DirectRun; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs index bf231305..107d86f7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs @@ -1,5 +1,6 @@ -//! Functions: `arm`, `probe_payload`, `preflight_copy`, `corrupted_bytes` and 1 more. -//! Split out of `direct_gpu` to keep its files under the line limit. +//! Setup of one proof arm of the direct-Down transport probe: real layer-0 chunk rows, the probe payload and the +//! corrupted-byte and refused-scope cases the all-copy preflight uses. Completed layer-0 FFN products stay private; +//! no injection, head or target publication is made, and a cancelled chunk is dropped, not repaired. use super::{ Cell, ChunkFfnLayer, DEVICE_PEAK, DownScope, Error, FF, K, LoadedArms, MoeExpertStage, N, Observation, ObservedArm, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs index 8d458a04..f006eead 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs @@ -1,5 +1,6 @@ -//! Methods of `LoadedArms`: `arm`, `matches_snapshot`, `precheck`, `reference_and_candidate` and 2 more. -//! Methods of `QwenForward`: `test_direct_down_on_loaded`. +//! The arms of the loaded direct-Down proof on a real binding and session: reference, candidate, cancelled and +//! recovery runs of the same three-row chunk. Pins that a cancelled arm is refused after the copy and leaves the +//! session snapshot untouched, and that the recovery arm after a reset reproduces the reference outputs. use super::{ CANCELLED_ON_COPY, DirectDownReport, DirectRun, Error, K, LoadedArms, N, ObservedArm, QwenForward, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs index 3d9b7147..5a98259d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs @@ -1,5 +1,7 @@ -//! Methods of `Observation`: `begin`, `take`. Methods of `DirectDownReport`: `assert_after_teardown`. -//! Implements `Drop for Observation`. Functions: `policy`, `copy_completed`, `observe_packet`, `compare` and 7 more. +//! Observation hooks and the report of the direct-Down proof: whether an arm uses the old split-and-pack or the +//! direct copy, recording of the copied packets, and their comparison. Also builds the chunk inputs of an arm. The +//! report is asserted only after the caller closed every cache, session and Context; it is not a full-target commit +//! proof. use super::{ CANCELLED_ON_COPY, COPIED, ChunkAttentionRow, ChunkFfnRow, DenseWeightCache, DetachedGrRead, DeviceBuffer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs index 1c468146..70070e82 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs @@ -1,5 +1,6 @@ -//! Methods of `Probe`: `run`, `fill_sentinels`, `split_and_pack_old`, `copy_direct` and 7 more. -//! Functions: `transport_probe`, `output_differences`, `same_outputs`. +//! Byte-level transport probe: the old split-and-pack of a grouped Down result against the direct whole-group copy. +//! Both packets start from sentinels so untouched slots are compared too. Also pins the refusals: an invalid slot or +//! column in the all-copy preflight mutates nothing, an alien scope is refused, and a non-finite source is refused. use super::{ Cell, Context, DownScope, DownSelection, DriverError, Error, ExpertReady, K, N, Probe, Rc, Result, SLOTS, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs index 698fb918..048f1718 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs @@ -1,5 +1,7 @@ -//! Functions: `execute_bound`, `open_bound`, `finish_bound`, `is_extended_group` and 8 more. -//! Split out of `grouped` to keep its files under the line limit. +//! Entry of one chunk layer on the bound (cached-weight) path: admit and reserve device room, upload the row +//! activations, prepare their Q8 owners, run the rows, then close every owner. Decides whether the rows run as sorted +//! expert groups and opens the step-local Down scope; any failure marks the transport failed and the primary error +//! wins over cleanup errors. use super::bound_rows::{BoundRows, DirectPacketInputs}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs index d1e0bb83..07936fb1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs @@ -1,5 +1,6 @@ -//! Methods of `SharedOwners`: `scale_shared`, `combine_with`, `close_all`. -//! Functions: `finish_shared_with`, `uses_adaptive`. Defines `RowTail`, `SharedOwners`. +//! Shared-expert tail of one chunk row: scalar-gate scaling of the shared expert and the weighted combine with the +//! routed Down packet, finished by a caller-supplied combine. Holds the partial owners of the row and closes every +//! one in a fixed order whatever failed; also tells whether the adaptive path serves the row. use super::{ BoundExpert, Context, DeviceBuffer, DownOrigin, DownProvenance, DownScope, Error, ExpertActivation, K, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs index b4fe4bbc..7550d988 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs @@ -1,5 +1,7 @@ -//! Functions: `ordered_down_refusal`, `replay_selection`, `use_direct_packets`, `validate_packet_pairs` and 5 more. -//! Defines `PacketGroupMembers`. +//! Refusal and finish rules shared by the direct packet groups: replay of a numerical Q8 refusal in original row +//! order, packet and pair validation against the row origins, and the shared-expert finish. A later column's +//! quantizer refusal must not overtake an earlier column's Down NonFinite, so the refusal is replayed ascending; +//! every packet is closed whatever the first failure was. use super::finish_shared_with::RowTail; use super::packet_run_project_group_direct::{DownProjection, RefusalReplay}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs index bf5454de..d23a38fb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs @@ -1,5 +1,7 @@ -//! Methods of `PacketRun`: `project_group_direct`. -//! Methods of `DirectGroup`: `check_descriptors`, `run`, `project_gate_up`, `project_gate_up_role` and 6 more. +//! Plain device path (no source fence) that projects one expert group into its row slot packets: Gate and Up, SwiGLU, +//! grouped Down, then copy of the Down columns into each row's packet. Defines the group and run descriptors the +//! direct and source paths share. Origins of all rows are validated before any packet is mutably loaned, and every +//! group buffer is closed whatever the outcome. use super::direct_packets_fns::PacketRun; use super::project_group_shared_fns::*; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs index 448ef6b3..60dd5406 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs @@ -1,5 +1,7 @@ -//! Methods of `PreparedMoeRow`: `validate`, `into_read`. -//! Methods of `MoeExpertStage`: `prepare_chunk_row`, `prepare_chunk_row_detached`, `execute_chunk`, `execute_chunk_n... +//! Per-row entry of the chunk MoE stage: prepares a row from its detached GR read and route, and executes the rows of +//! a chunk layer on the ordinary or the native-prompt path. The chunk transaction validates each row and its micro- +//! batch size (1 to 64 rows) before experts run; the direct packet path is used when the cache allows it. Also holds +//! the row-to-expert inverse grouping. use super::bound_rows::DirectPacketInputs; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs index 215642b1..dc1f54ed 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs @@ -1,5 +1,7 @@ -//! Methods of `ResidentGroup`: `run`, `project_gate_up`, `project_gate_up_role`, `finish_gate_up` and 7 more. -//! Methods of `DownArgs`: `refusal_values`. Functions: `project_group`. +//! Resident (or adaptive workspace) path that projects one expert group: Gate and Up, SwiGLU, then grouped Down +//! stored into the Down cells of the group's rows. Each Gate/Up role keeps the original finite stage boundary; a +//! numerical refusal of a later column is replayed in row order so it cannot overtake an earlier column's NonFinite. +//! Destination cells must still be empty. use super::packet_run_project_group_direct::{DownProjection, GroupBuffers, RefusalReplay}; use super::project_group_shared_fns::{ 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 c201cdc5..d9a78724 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 @@ -1,5 +1,6 @@ -//! Methods of `DirectGroup`: `run_source`, `source_gate_up`, `source_up`, `source_gate_up_role` and 5 more. -//! Functions: `project_group_source_consumers`, `check_source_members`. +//! Source-backed direct group: Gate, Up, SwiGLU and Down of one expert read through the opened routed source scope. +//! The scope ends after the last private consumer and before any packet coverage or group acceptance; a failure +//! discards every copied private packet. Also checks that the source members match the group descriptors. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::packet_run_project_group_direct::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs index 04722779..c824cfa1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs @@ -1,5 +1,6 @@ -//! Methods of `PacketRun`: `direct_group`, `project_group_fenced`. Functions: `source_members`. -//! Split out of `grouped` to keep its files under the line limit. +//! Fenced entry of the source-backed direct group: opens the source scope around the consumers of one expert group. +//! The mandatory source finish is attempted even after a failure and runtime primary errors are preserved; the cache +//! is rechecked after the matrix and source loans ended. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::direct_packets_fns::PacketRun; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs index 2177729d..6772340d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs @@ -1,5 +1,6 @@ -//! Functions: `block_geometry`, `fill_block`, `encoded`, `exact` and 9 more. -//! Split out of `moe_activation_reuse_gpu` to keep its files under the line limit. +//! Deterministic encoded expert-matrix fixtures and the reference MLP of the retained Gate/Up proof (GPU tests only). +//! Builds quantized blocks for each matrix kind with bounded values, runs the same Down kernel and a download and re- +//! upload reference chain, and checks the outputs are bit-exact and the uploaded matrices unchanged. use super::{ Cell, Context, DenseFormat, DeviceBuffer, DriverError, FF, MatrixDims, MoeMatrixKind, N, ProjectionKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs index 82e41d0d..0580e4cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs @@ -1,5 +1,6 @@ -//! Methods of `DomainFixture`: `build`, `release`. -//! Functions: `hidden_extrema`, `former_fixture_domain_refusal`, `nonfinite_hidden_refused`, `late_nan_projection_re... +//! Refusal cases of the retained Gate/Up proof: the fixture of a former domain failure, non-finite hidden values, a +//! late NaN written by a real projection, a Down shape mismatch, and saturation. Each case must be refused by genuine +//! native admission before the retained projection owner is published. use super::{ Cell, Context, DeviceBuffer, DriverError, Error, FF, MatrixDims, MoeMatrixKind, N, compare_mlp, down_projection, 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 706731a6..99d20c2a 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 @@ -1,5 +1,6 @@ -//! Methods of `DownScope`: `new`, `with_routed_finite`, `with_routed_workspace`, `with_workspace` and 15 more. -//! Functions: `check_grouped_selections`, `completed_row_source`. Defines `GroupedColumn`, `GroupedHandoff`. +//! The step-local scope every Down output of one expert step is minted under: its epoch, failure flag and workspaces. +//! A CUDA failure recorded in the scope poisons it, so no later consumer can use a Down output of a failed step. Also +//! splits a grouped Down allocation into per-slot Down owners once its producer readback is finite. use super::{ Cell, CompletedCpuRow, Context, DeviceBuffer, DownScope, DownSelection, Error, K, N, Rc, Result, RetainedDown, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs index 4477606e..c7155b96 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs @@ -1,5 +1,5 @@ -//! Functions: `exact`, `down_weights`, `scalar_weights`, `project` and 3 more. -//! Split out of `moe_down_reuse_gpu` to keep its files under the line limit. +//! Fixtures and exact-comparison helpers of the retained Down proof: seeded Down and scalar weight bytes, the +//! original Down projection, retained Down outputs, and a check that an expected refusal is counted. use super::{ Cell, Context, DenseFormat, DeviceBuffer, DownScope, DownSelection, Error, N, ProjectionKind, ProjectionSpec, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs index 1eed90dc..f1d194c3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentPackedDown`: `new`, `validate`, `complete`, `with_completed` and 7 more. -//! Split out of `moe_down` to keep its files under the line limit. +//! Destination of the K routed Down outputs of one resident chunk row, filled by one closed producer copy. +//! Coverage is published only after the copy and the origin and cancellation postchecks succeeded; partial coverage +//! is never visible, and the window can be lent out only once every slot is covered. use super::{DeviceBuffer, DownScope, Error, K, N, Rc, ResidentPackedDown, Result, ScaledDown}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs index 8d62a8f5..24f49ab6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs @@ -1,5 +1,6 @@ -//! Methods of `RetainedScalar`: `close`. Methods of `TransportBuffer`: `buffer`, `buffer_mut`, `close`, `release`. -//! Implements `Drop for TransportBuffer`. +//! Ownership and lifetime of the retained Down device buffers: scalar, scaled shared and the packed routed Down. +//! `TransportBuffer` fails closed (a failed scope refuses every access) and releases its device memory on drop; the +//! packed owner fills K slots in order and lends only a complete, in-scope packet to the combine. use super::{ DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, Result, RetainedDown, RetainedScalar, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs index f2ffd2ae..f49b9fc8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs @@ -1,5 +1,6 @@ -//! Functions: `check_origin`, `swiglu_hidden`, `project_down`, `close_down_parts` and 4 more. Defines `DownProvenance`. -//! Split out of `moe_expert` to keep its files under the line limit. +//! Expert MLP on cached weights whose Down output is minted inside a step-local `DownScope` (Gate, Up, SwiGLU, Down). +//! Gate, Up and hidden stay on the device as scope-owned buffers; the Down result is recorded under the scope's +//! origin and every owner is closed after use, the primary failure winning over cleanup failures. use super::expert_matrix_projection::{MatrixDims, gate_up_dims, gate_up_prepared_format}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs index dfb7a46c..7ccaf69b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the expert-row collection and finite checks: completed tiles keep all rows, a late failure withholds the +//! candidate, and a non-finite last expert output is refused while a signed zero is retained. use super::{DEVICE_PEAK, Error, FF, N, admit_budget}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs index 06f1e390..87826447 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs @@ -1,5 +1,5 @@ -//! Functions: `validate_values`, `upload_bytes`, `upload_f32`, `download_f32` and 2 more. -//! Split out of `moe_expert` to keep its files under the line limit. +//! Shared helpers of the expert stage: finite and length checks of host values, f32 upload and download of device +//! buffers, and the mapping of binding and driver errors onto the stage error. use super::{Context, DeviceBuffer, DriverError, Error, InputBindingError, Result, Stage}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs index 95a83f12..a6cde714 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs @@ -1,5 +1,6 @@ -//! Methods of `Buffers`: `new`, `from_pool`, `into_outputs`, `release`. -//! Functions: `device_bytes`, `release_pool`, `buffer_sizes`, `allocate_pool` and 4 more. +//! Device buffers of one batched prefill MoE step: the per-call sizes in allocation order and the `Buffers` that +//! own them. Sizes depend on the window row count, the router profile and whether the combine runs. The pool is +//! released as a whole, and outputs are handed out only after the internal owners are released. use super::{ Buffers, Context, DeviceBuffer, EXPERTS, Error, FF, MIXED, MoeBf16Profile, Result, SELECTED, driver_error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs index ddcc799c..dc266b01 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs @@ -1,5 +1,6 @@ -//! Methods of `MoePrefillResources`: `new`, `validate_context`, `allocated_bytes`, `close` and 1 more. -//! Methods of `RouteRow`: `validate_origin`. Implements `Drop for MoePrefillResources`, `Drop for MoeMicroProducts`. +//! Persistent resources of the batched prefill MoE router and shared expert, and the products it hands to the caller. +//! Owns the allocation charge, context check and close of both; validates that every route row and window come from +//! the genuine FFN reads of the layer under the same binding, and that route ids and weights are valid. use super::{ BindingIdentity, Context, DeviceBuffer, EXPERTS, Error, GdnNativeFormat, GrRole, LayerId, MOE_BATCH_SCRATCH_BYTES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs index c8048bcc..be8d3520 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `MoePrefillStage`: `transient_bytes`, `route_shared_micro`, `combine_micro`. -//! Split out of `moe_prefill_batch` to keep its files under the line limit. +//! Entry points of the batched prefill MoE stage over one micro-window: the router and shared expert, and the later +//! separate combine. The combine consumes only the products' own device outputs, so it re-routes nothing and +//! recomputes no shared expert; it is single-use per window and fenced against the actual chunk rows and binding. use super::{ Buffers, CombineInput, CombineOperands, CombineWindow, Error, MIXED, MicroInputs, MoeBf16Profile, MoeMicroProducts, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs index c042c301..93d935c9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the prefill MoE contract: a route row needs distinct in-range ids and finite, ordered unit weights, the +//! shared formats are the six native kinds, device byte counts follow the prompt-path buffer set, and f32 staging is +//! little-endian. use super::{ EXPERTS, Error, FF, GdnNativeFormat, MIXED, MoeBf16Profile, MoeWeightDescriptor, SELECTED, device_bytes, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs index 07e81d07..e93d098d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs @@ -1,5 +1,7 @@ -//! Functions: `activation_bytes`, `upload_router_matrix`, `finish_logits`, `project_logits` and 9 more. -//! Defines `RouterInput`. +//! Router projection and route validation: the 512 router logits of one mixed residual, then the raw top-10 turned +//! into `RoutedExperts` only through the same checks, for a per-row and for a batch route. Validates request shape, +//! binding and finite logits; the router matrix is uploaded here only on the uncached diagnostic path, and every +//! owner is released explicitly. use super::{ Bf16ProjectionShape, BindingIdentity, COLUMNS, Context, DenseWeightCache, Dimension, EXPERTS, Error, ExpertId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs index 3d1b0543..da22f8de 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs @@ -1,5 +1,6 @@ -//! Methods of `RouterLogits`: `from_preceding`, `fixture`. -//! Methods of `RoutedExperts`: `new`, `identity`, `experts`, `weights` and 2 more. +//! Producer-owned router products and the route entry points of `MoeRouteStage`. +//! `RouterLogits` and `RoutedExperts` can be made only by the router producer for one token, layer and binding; the +//! stage routes from the typed FFN read, through the retained router scratch or the closed CUDA operation. use super::{ BindingIdentity, COLUMNS, Context, DenseWeightCache, EXPERTS, Error, ExpertId, FiniteF32, GrRole, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs index 15b5376d..58efaaf4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs @@ -1,5 +1,6 @@ -//! Functions: `logits_to_bytes`, `decode_route`, `release_route_buffers`, `run_cuda` and 1 more. -//! Split out of `moe_route` to keep its files under the line limit. +//! The fixed CUDA route operation: the 512 logits go to the device and the top-10 expert ids and weights come back. +//! Explicit releases are part of success: a cleanup failure withholds the host result. Also maps driver errors to the +//! closed runtime error categories. use super::{Context, DriverError, EXPERTS, Error, IDS_BYTES, LOGITS_BYTES, Result, SELECTED, Stage, WEIGHTS_BYTES}; use leleka_cuda_driver::DeviceBuffer; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs index a6ecbfca..efc2f346 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs @@ -1,3 +1,7 @@ +//! Pins the router contract against an independent reference: typed results keep tie order and weights, wrong +//! binding, token or layer identity and bad topology or logits are refused before dispatch, malformed or non-finite +//! routes are never published, driver failures return no partial route, and rank weights never grow. + use super::{ BindingIdentity, DriverError, EXPERTS, Error, ExpertId, LOGITS_BYTES, LayerId, Result, RoutedExperts, RouterLogits, SELECTED, Stage, TokenId, TokenLayer, map_driver_error, route_with, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs index 04563ab5..df50fec3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `MappedStageShape`: `slots`. -//! Methods of `EphemeralRoutedOwner`: `new_mapped`, `slot_count`, `uses_mapped`, `mapped_eligible`. +//! The mapped variant of the ephemeral routed owner: 8 or 16 whole-triplet slots filled by a device copy straight +//! from the retained expert bank pages, with no host payload read. Owns the slot state machine (idle, pending, +//! completed, in use), its byte accounting and drain/release. The owner delegates here whenever `mapped` is set. use super::{ Buffers, Context, DeviceBuffer, EphemeralRoutedOwner, Error, HOST_LIMIT, MappedExpertCopyScratch, MappedSlot, 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 867b84b8..a0fb07d2 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `ephemeral_owner_allocation`, `ephemeral_owner_loans_and_drain`, `ephemeral_owner_stage_tra... -//! Split out of `cache_ephemeral_routed` to keep its files under the line limit. +//! The non-mapped half of `EphemeralRoutedOwner`, split by phase: allocation and key checks, staging and transfer, +//! loans and drain. Each phase file is an `impl` block of the one owner; the slot state machine stays in the parent. use super::{ Buffers, CLOSED_MAXIMUM, Cell, Context, DeviceBuffer, EphemeralRoutedOwner, Error, HOST_LIMIT, MappedStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs index 2956ac23..7780ae2f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs @@ -1,5 +1,6 @@ -//! Methods of `EphemeralRoutedOwner`: `new`, `validate_maximum`, `allocate_idle`, `room` and 9 more. -//! Functions: `key_identity_ok`, `key_shape_ok`. +//! Construction and admission of the ephemeral routed owner: the two idle whole-triplet slots, the room check against +//! the context budget and free device memory, and the key checks that tie a staged triplet to its binding and layer. +//! Every allocation is made up front so a later stage can never fail on device memory. use super::{ CLOSED_MAXIMUM, Context, DeviceBuffer, EphemeralRoutedOwner, Error, MappedStage, ModelBinding, 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_loans_and_drain.rs index 2a1aa7f6..433addf0 100644 --- 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_loans_and_drain.rs @@ -1,5 +1,6 @@ -//! Methods of `EphemeralRoutedOwner`: `loan_completed`, `borrow_triplet`, `with_triplet_inner`, `settle_inner_loan` ... -//! Split out of `ephemeral_routed_owner` to keep its files under the line limit. +//! Loan, drain and release of the ephemeral routed owner: a completed triplet is lent once to a synchronous callback +//! and returns to idle. Drain waits for every pending copy and keeps the buffers; release closes everything and +//! poisons the owner on any failure so a half-released slot is never reused. use super::{ Buffers, DeviceBuffer, EphemeralRoutedOwner, Error, MappedStage, MoeRoutedSourceScope, MoeWeightDescriptor, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs index 1f4e1d17..d6ef3ad2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs @@ -1,5 +1,6 @@ -//! Methods of `EphemeralRoutedOwner`: `stage_inner`, `fixed_preparation`, `admit_stage`, `install_idle_buffers` and ... -//! Functions: `check_block_matches`. Defines `DetachedPayloads`. +//! Staging side of the ephemeral routed owner: admit a triplet against the host and device limits, read its three +//! blocks from the routed source, detach the host payloads and enqueue one owned copy into an idle slot. Also polls +//! and waits for that copy and installs the finished buffers, so a slot is Completed only once all roles landed. use super::{ Buffers, Cell, DeviceBuffer, EphemeralRoutedOwner, Error, HOST_LIMIT, ModelBinding, MoeExpertBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs index df7531ee..f1f95c1d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs @@ -1,5 +1,6 @@ -//! Functions: `healthy_cancel`, `observe_cancel`, `combine`, `close_buffers` and 2 more. -//! Split out of `cache_ephemeral_routed` to keep its files under the line limit. +//! Cancellation and cleanup helpers shared by the ephemeral routed owner and its mapped stage: the rule that only an +//! observed executor cancel on a healthy owner keeps the owner alive, and the buffer and slot release functions that +//! keep the first error while still closing every buffer. use super::{Buffers, Cell, Error, Result, Slot, Stage, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs index 864d8cd7..7e4f92f3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs @@ -1,5 +1,6 @@ -//! Methods of `LruIndex`: `new`, `with_capacity`, `metadata_bytes`, `len` and 15 more. -//! Split out of `cache_lru_index` to keep its files under the line limit. +//! The bounded min-heap behind the per-matrix expert LRU: ages by descriptor slot, atomic batch update (prepare then +//! commit), removal, and the oldest-key search that skips the protected keys of the current round. It is the only +//! eviction order of the MoE cache, so the slot count and the heap/position coherence are checked here. use super::{ ABSENT, Error, HOST_LIMIT, LruIndex, MAX_KEYS, MAX_PROTECTED, MoeWeightDescriptor, Node, PER_LAYER, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs index b5df35b6..ef9d74d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs @@ -1,5 +1,6 @@ -//! Methods of `LruIndex`: `seed_existing`, `is_pristine`, `load_seed`, `seed_insert` and 5 more. -//! Split out of `cache_lru_index` to keep its files under the line limit. +//! Seeding of an empty `LruIndex` from entries that already exist on the device: used by constructors that fill the +//! cache before it is published. A refused seed restores the empty state, and `matches_existing` lets a test prove +//! the index equals the actual owners. use super::{ABSENT, Error, LruIndex, MAX_KEYS, MoeWeightDescriptor, Node, Result, slot}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs index 1aeb438a..28d35f04 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs @@ -1,5 +1,5 @@ -//! Functions: `slot`. -//! Split out of `cache_lru_index` to keep its files under the line limit. +//! Maps an expert or shared-weight descriptor (layer, expert, role) to its fixed slot in the LRU position table, +//! and refuses any coordinate outside the 48-layer, 512-expert domain. use super::{Error, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs index 790c7145..b6a82219 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs @@ -1,4 +1,6 @@ -//! Pure metadata proof. Literal descriptors convey no model, weight or device authority. +//! Pins the bounded LRU index against a scan oracle: oldest-first order with protected keys, atomic batch refusals, +//! descriptor collisions, a full index and long deterministic churn. Literal descriptors carry no model or device +//! authority, so these tests run without a GPU. use super::{LruIndex, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, slot}; #[cfg(any(test))] use super::HOST_LIMIT; 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 66646e50..29bfd194 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 @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_original_prompt_arena`, `retained_bank_mapping`, `arena_workspace`, `attach_are... -//! Functions: `arena_driver_error`, `shared_descriptors`, `shared_bytes`. Defines `ArenaPlan`, `ExpertBankMapping`. +//! Bring-up of the original prefill arena on `MoeWeightCache`: carves the arena from the prefill options, maps the +//! retained expert bank, builds the MMQ workspace with its expert group arena, and attaches the copy schedule and +//! prompt device. Also the prompt-routing capture, the end of a prompt expert stream and the per-expert span lookups. use super::{ Context, Error, LayerId, MmqRoutingPolicy, MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs index 2986fa32..b3538863 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `original_prompt_moe`, `original_prompt_parts`, `original_prompt_precheck`. -//! Functions: `raw_weight`, `shared_formats`, `shared_weights`. +//! Entry point of one original-prompt MoE layer on the cache: borrows the disjoint owners the layer drives (shared +//! weights, copy ring, span state), prechecks binding and dense cache, and loads the router and shared weights raw. +//! The layer body itself is in `prompt_layer_fns`. use super::prompt_layer_fns::{PromptIo, PromptParts, PromptWeightOwners, SpanScan, run_prompt_layer}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs index 5fab9bc9..3499405a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs @@ -1,5 +1,6 @@ -//! Functions: `prompt_stream_settings`, `native_format`, `span_cache_enabled`, `set_span_cache_override`. -//! Split out of `cache_original_prompt` to keep its files under the line limit. +//! Settings of the prompt expert stream and span cache: whether a prefill chunk copies every expert of every layer +//! through an issuer thread or uses the per-layer copy ring, and the per-arm overrides the replay harness sets. +//! Also maps a descriptor's raw kind to its native format. use super::{Error, GdnNativeFormat, MoeWeightDescriptor, PREFILL_STREAM_OVERRIDE, Result, SPAN_CACHE_OVERRIDE}; 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_sdet.rs index 7c9752e1..686e5d21 100644 --- 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_sdet.rs @@ -1,4 +1,5 @@ -//! Pure current-age bootstrap policy proof; no binding/device/weight certificate. +//! Pins the learned-main bootstrap: a seeded LRU index equals the scan over the actual ages, refused seeds restore +//! the empty owner, and `learned_main_slot_bound` equals the expanded multiset count. Pure policy, no device. use super::super::cache_lru_index::LruIndex; use super::{MoeWeightDescriptor, learned_main_slot_bound}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs index 54861722..8ed42848 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs @@ -1,5 +1,6 @@ -//! Methods of `RankedProfile`: `parse`, `check_header`, `parse_pair`, `ordered_pairs` and 1 more. -//! Methods of `PlanBudget`: `capacity`, `new`. Defines `PlanBudget`. +//! Parser of the ranked expert profile (the `STRP` file: header, SHA check, ordered layer/expert pairs and the +//! optional rank table) and the prefix planner: `PlanBudget` turns the device limits into the largest whole-triplet +//! prefix of the ranking that can stay pinned. Pure metadata; it reads no weights and touches no device. use super::{ Digest, EXPERTS, Error, HOST_CAP, LAYERS, PAIRS, PrefixPlan, ProfileLimits, RankedProfile, Result, Sha256, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs index 37bd6688..c7567864 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `SharedPermanentPool`: `new`, `contains`, `quartet`, `descriptor_count` and 7 more. -//! Functions: `remaining_shared_main`, `learned_main_slot_bound`. +//! The permanent pool of shared-expert quartets (gate, up, down, scalar) of all 48 layers, pinned for the model +//! lifetime, with per-role hit, fill and eviction counters. Also the two sizing rules that leave the rest of the main +//! tier to the learned LRU: what remains after the shared bytes and the upper bound of routed slots. No device state. use super::{Error, LAYERS, MoeWeightDescriptor, Result, RoleTraffic, SHARED_MAX_BYTES, SharedPermanentPool}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs index 8181c72a..e93190f0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_profile_shared_permanent_learned_main_lru`, `learned_main_totals`, `check_learn... -//! Split out of `cache_profile_fill` to keep its files under the line limit. +//! Constructor of the MoE cache whose routed main tier is a learned LRU over the shared permanent pool: the preload +//! bytes are kept, routed residency is then learned from traffic. Also the witness and totals that check the actual +//! main entries against the byte limit and the slot bound. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::profile_build::{ProfileFile, ProfileKind, ProfileRequest}; 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 e6164ae8..cf672050 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `pinned_triplet_preload`, `profile_ranked_fill_and_pool`. -//! Split out of `cache_profile_fill` to keep its files under the line limit. +//! The `MoeWeightCache` constructors of the profile fill: the ranked fill with its pinned pool and the pinned triplet +//! preload. use super::{ Context, DeviceRef, EncodedWeight, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs index 76872ac1..46ddd439 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `preload_pinned_triplet`, `admit_pinned_triplet`, `pinned_layouts`, `check_pinned_ro... -//! Defines `PinnedLayouts`, `PinnedSource`, `PinnedAdmission`. +//! Preload of one pinned routed expert triplet of the ranked profile: admit it against room and spill reserve, read +//! its three raw blocks from the binding, upload them (dual or mixed layout) and commit them as pinned main entries +//! with the traffic counters. Also the profile witness that reads those counters back for tests. use super::{ DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, 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/profile_ranked_fill_and_pool.rs index 026acb27..ddcfac42 100644 --- 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/profile_ranked_fill_and_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile`, `new_native_intege... -//! Functions: `ranked_keys`. Defines `MapReservation`, `ProfileFill`. +//! Constructors of the MoE cache for the ranked profile with the retained MTP KV and shared tail: derive the prefix +//! plan from the first-expert descriptors of every layer, reserve the one weight map under the metadata ceiling, +//! install the pinned pool and preload the ranked prefix. An MTP input or spill floor widens the window reserve. use super::{ Context, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs index d93b6f83..eec7ee48 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs @@ -1,5 +1,6 @@ -//! Functions: `profile_window_spill`, `profile_window_spill_with_floor`. -//! Split out of `cache_profile_fill` to keep its files under the line limit. +//! The device bytes the prefill MoE micro-window keeps live next to the pinned pool (the live prefill owners and the +//! GDN chunk charge), optionally raised by a reusable spill floor. The profile planners reserve this much beyond the +//! pinned prefix. use super::{Error, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs index ce98641a..627bff67 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile_mtp_input_spill_floo... -//! Defines `QuartetRoom`. +//! Preload of the shared-expert quartets (gate, up, down, scalar) into the main tier of a profile with a shared +//! permanent pool: admission against room and spill, upload, then publication with no fallible step after the first +//! insert. Also the shared-pool witness that reconciles the traffic counters with actual residency. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs index 0a850b46..15a6d3b3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_native_strata_adaptive_shared_permanent`, `new_native_strata_adaptive_shared_pe... -//! Functions: `adaptive_template`. Defines `AdaptivePlan`, `SharedKeys`. +//! Constructors of the MoE cache for the Strata adaptive policy (copy transport or mapped transport): size the shared +//! permanent pool and the adaptive plan from the descriptor template, admit the whole allocation bound before the +//! first shared upload, then adopt the adaptive owner. A failed build closes the cache. use super::profile_build::ProfileFile; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs index e1b01cd6..338e706a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs @@ -1,5 +1,6 @@ -//! Methods of `AdaptiveCache`: `preload`, `unpublished`, `validate`, `revalidate_keys` and 19 more. -//! Defines `StagedPairs`, `Staged`, `UploadReserve` and 1 more. +//! The adaptive expert cache of the Strata policy: the device slots that hold whole expert triplets and the transfer +//! queue of the current round. It observes every routed row, serves hits, stages the due swaps after each verified +//! window, polls the copies and publishes a swap only after its transfer completed. use super::{ ADAPT_EVERY, ADAPT_SWAPS, AdaptiveCache, AdaptivePolicy, AdaptiveSizing, AdaptiveWitness, CachedMoeMatrix, Context, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs index 30892856..c4b37459 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs @@ -1,5 +1,6 @@ -//! Methods of `AdaptivePolicy`: `new`, `template_charges`, `initial_slots_for`, `measure_metadata` and 13 more. -//! Functions: `reserve`, `cell`, `blob_key_identity_ok`, `blob_key_shape_ok` and 2 more. Defines `InitialSlots`. +//! `AdaptivePolicy`, the pure frequency policy of the Strata adaptive cache: usage counters, the resident map and the +//! initial slots of the ranked prefix, then swap selection per verified window (candidates used twice or more +//! against the coldest residents). Holds metadata only; the adapter owns the buffers and confirms every transfer. use super::{ ADAPT_EVERY, ADAPT_SWAPS, AdaptivePolicy, CELLS, EXPERTS, Error, HOST_CAP, LAYERS, MoeWeightDescriptor, PrefixPlan, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs index d16d0a25..3719e80e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs @@ -1,5 +1,5 @@ -//! Pure source-policy oracle only. No fabricated BindingIdentity, device slot, -//! event completion, CPU expert output, or model acceptance certificate. +//! Pins the adaptive policy to its Strata original: frequency threshold, same-layer slots, pending transition, +//! decay and refusals of bad observations. A pure oracle; no binding identity, device slot or completion is faked. use super::{AdaptivePolicy, EXPERTS, Error, LAYERS, MoeWeightDescriptor, ProfileLimits, RankedProfile, Swap}; use sha2::{Digest, Sha256}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs index bcbb6a6a..0c647e11 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs @@ -1,5 +1,4 @@ -//! Functions: `transfer_metadata_bound`. -//! Split out of `cache_strata_adaptive` to keep its files under the line limit. +//! The host metadata bound of one adaptive round: the swap count times the size of a transfer record. use super::{ADAPT_SWAPS, Transfer}; 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 275f36da..95b7d66c 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 @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `routed_output_owner`, `uses_mapped_expert_source`, `ephemeral_routed_owner`, `route... -//! Functions: `triplet_keys`, `adaptive_raw_triplet`. +//! The routed-expert owners of the MoE cache and the loans through them: output owner, ephemeral owner, resident +//! queue, CPU miss owner, and the Strata adaptive row observation, window completion and polling. The callbacks lend +//! whole triplet buffers read-only; no fill, poll or mutable cache access happens while a loan is held. use super::{ CachedMoeMatrix, Context, DeviceBuffer, Error, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, 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_weight_cache_methods.rs index 85532e76..d9364c9a 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_weight_cache_methods.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `moe_cache_close_owners`, `moe_cache_compose_shared_and_mtp`, `moe_cache_lru_updates` and 7... -//! Split out of `moe_weight_cache` to keep its files under the line limit. +//! The `impl MoeWeightCache` blocks by responsibility: constructors, lookup, triplet and chunk admission, LRU +//! updates, shared and MTP composition, routed source fills, validation and teardown. Shared imports live here. use super::{ BoundExpert, CachedMoeMatrix, Cell, Context, Dense, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, 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_weight_cache_methods/moe_cache_close_owners.rs index 2dafb974..29ab6b1b 100644 --- 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_weight_cache_methods/moe_cache_close_owners.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `close_original_owners`, `close_original_owners`, `close_shared_owners`, `close_work... -//! Functions: `close_shared`. +//! Consuming teardown of the MoE cache: closes the Original owners, shared owners, workspaces and every encoded +//! weight in a fixed order, keeps the first error and counts an owner still held elsewhere as a failed close. use super::{Error, MoeWeightCache, Rc, 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_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs index e2733f83..0a7d53cd 100644 --- 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_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `compose_target_shared_tail`, `compose_shared`, `compose_fixed_mtp_experts`, `admit_... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Composition of the closed device producers over cache-owned weights: target shared tail, the fixed MTP experts, +//! the MTP KV ring (prepare and attend) and MMQ assembly. Descriptors are admitted before any fill and every weight +//! stays borrowed until the producer's completion readback has consumed the result. use super::super::super::shared_expert_workspace::{SharedTailInputs, SharedTailKeys, WorkspaceOwner}; use super::moe_cache_lru_updates::shared_keys::{raw_shared_buffers, shared_descriptors}; 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_weight_cache_methods/moe_cache_lru_updates.rs index 2115c4ce..a0995b38 100644 --- 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_weight_cache_methods/moe_cache_lru_updates.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `prepare_lru_updates`, `spill_updates`, `pinned_updates_allowed`, `commit_lru_update... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! LRU bookkeeping of the main tier (prepare, commit, eviction key, removal) and the lending of whole shared weights: +//! the native prefill resources and `with_native_shared_weights`. Shared weights are filled without evicting one +//! another and stay protected while lent. use super::{ Context, DeviceBuffer, EncodedWeight, Entry, Error, HashMap, LruIndex, ModelBinding, MoeExpertSelection, 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_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs index 4fc406e1..452f782d 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_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs @@ -1,5 +1,5 @@ -//! The four shared-expert descriptors, their fill and their raw buffers: common to the native shared-weights loan and -//! the target shared tail. +//! The four shared-expert descriptors of a layer, their fill and their raw buffers: common to the native +//! shared-weights loan and the target shared tail. use super::{ DeviceBuffer, EncodedWeight, Entry, Error, HashMap, ModelBinding, MoeExpertSelection, MoeExpertWeights, 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_weight_cache_methods/moe_cache_main_entry_routed_source.rs index 2e5dcda7..22bfbc74 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_weight_cache_methods/moe_cache_main_entry_routed_source.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `main_entry`, `main_entry_owned_gate_up`, `with_matrix_routed_source`, `source_healt... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Main-tier lookup and fill for routed expert matrices: the entries that hit or fill the cache, the loan of a cache +//! matrix to a closed routed-source consumer, and the adaptive slot matrix, which can never fill or evict. use super::{ CachedMoeMatrix, DeviceRef, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, ModelBinding, MoeMatrixRole, 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_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs index 3db41975..e1beb533 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_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `matrix`, `shared_scalar`, `admit_mtp_input_workspace`, `mtp_input_workspace_support... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Read-side lookups of the MoE cache: a routed or shared matrix, the shared scalar, the MTP bank, matrix and F32 +//! rows, and the MTP input workspace admission and completion count. Lookups never fill or evict. use super::{ CachedMoeMatrix, Context, DeviceBuffer, Error, MTP_INPUT_WORKSPACE_BYTES, ModelBinding, MoeExpertSelection, 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_weight_cache_methods/moe_cache_mmq_chunk_admission.rs index ec011233..22bd5258 100644 --- 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_weight_cache_methods/moe_cache_mmq_chunk_admission.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `note_test_mmq_dispatch`, `mmq_context`, `weight_layout`, `has_original_prompt_mmq` ... -//! Functions: `admit_triplets`. +//! MMQ chunk admission and workspace access of the MoE cache: checks every triplet of a chunk against the kind +//! admission policy before quantization, cache fill or a gate/up kernel runs, and lends the MMQ workspace and the +//! three whole weights of a triplet. A refused triplet declines the whole chunk. use super::{ BoundExpert, Context, Error, MmqChunkAdmission, MmqChunkRequest, MmqFormat, MmqRoutingPolicy, MmqWeights, 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_weight_cache_methods/moe_cache_mmq_constructors.rs index de242680..038742ff 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_weight_cache_methods/moe_cache_mmq_constructors.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile_mtp_input_spill_floo... -//! Functions: `dense_f32_words`. +//! The base constructors of the MoE cache: the empty cache of one binding and context, the pinned MTP pack upload +//! (with or without its expert bank), and the MMQ, native MMQ and integer IQ3 variants with the retained MTP KV. use super::{ Cell, Context, Dense, Error, HashMap, MTP_DENSE_LIMIT, MTP_PACK_EXPERT_BANK_BYTES, MmqRoutingPolicy, ModelBinding, 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_weight_cache_methods/moe_cache_shared_tail_constructors.rs index a9898858..32081b79 100644 --- 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_weight_cache_methods/moe_cache_shared_tail_constructors.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail`, `new_native_integer_iq3_mm... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Constructors that add the target shared tail and the bounded LRU index to the MoE cache, plus the small +//! accessors the profile and adaptive builders use (pinned test, spill length, main reservation, request note). use super::{ Context, Error, LruIndex, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Rc, RefCell, Result, 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_weight_cache_methods/moe_cache_triplet_plan_upload.rs index ca172969..7aaaadea 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_weight_cache_methods/moe_cache_triplet_plan_upload.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `with_integer_mmq_triplet`, `triplet_fill`, `triplet_owners`, `triplet_admit` and 16... -//! Functions: `read_triplet`. Defines `TripletAccounting`, `TripletPlan`. +//! Triplet access to the MMQ weights: plans a gate/up/down request, fills only what is missing under room and slot +//! admission, uploads whole triplets and publishes them after driver completion with no fallible step after the +//! first insert. A full hit allocates and uploads nothing. use super::{ BoundExpert, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, ModelBinding, MoeExpertSelection, 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_weight_cache_methods/moe_cache_validate_prepare_step.rs index 2518e367..71d4f5dd 100644 --- 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_weight_cache_methods/moe_cache_validate_prepare_step.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `owners_failed`, `validate_original_owners`, `validate_original_owners`, `validate` ... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Validation and per-step preparation of the MoE cache: binding, context and owner health checks, the transient MMQ +//! reserve, the room routine that evicts for a request while protecting lent entries, and plain device upload. use super::moe_cache_main_entry_routed_source::fill_fns::Room; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs index 761418b1..d795fedb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `share_rt_mtp_dense`, `share_entry`, `device_copies_equal`, `adopt_rt_buffer` and 2 ... -//! Functions: `dense_copies_equal`. +//! Merges the two device copies of the MTP dense roles on the RT-directory path: when both are read back and prove +//! byte-equal, the cache adopts the RT bank allocation and frees its own, so the model holds one copy. Also builds +//! the retained original MTP weights from the cache. use super::{ Cell, Context, Dense, Error, ModelBinding, MoeWeightCache, MtpDenseShare, MtpKind, MtpRole, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs index 60b5893e..15cd8597 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs @@ -1,5 +1,6 @@ -//! Methods of `RetainedOriginalMtpWeights`: `from_rt_bank`, `rt_dense`, `rt_extras`, `dense_file_bytes` and 11 more. -//! Functions: `rt_kind`. Defines `HeadBinding`. +//! The model-lifetime MTP weights taken from the loaded RT bank: dense roles, extras and the expert bank, shared +//! by reference and checked against the role contract. Serves the scalar prefill graph weights and the full MTP +//! forward role order, choosing between the native head and the gathered draft-vocabulary head. use super::{ Context, DeviceBuffer, Error, FULL_FORWARD_ROLES, ModelBinding, MtpHeadSources, MtpKind, MtpRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs index 80a421cf..5b60dbfa 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs @@ -1,5 +1,5 @@ -//! Methods of `RoutedSourceHealth`: `validate`. -//! Methods of `MoeWeightCache`: `note_permanent_lookup`, `note_permanent_hit`, `note_permanent_fill`, `note_permanen... +//! Health check of the routed source (failed flag, poisoned context, binding identity) and the cache hooks that count +//! lookups, hits, fills and evictions of permanent-pool entries in the active pool (pinned or adaptive shared). use super::{Context, Error, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, RoutedSourceHealth}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs index ff50ccfb..3d476cd2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs @@ -1,5 +1,6 @@ -//! Methods of `RoutedWorkspaceOwner`: `new`, `matches_context`, `is_failed`, `with_workspace` and 1 more. -//! Methods of `RoutedResidentOwner`: `new`, `matches_context`, `is_failed`, `with_queue` and 1 more. +//! The small device owners the routed expert path leases from the MoE cache: the routed group workspace, the resident +//! queue and the MTP input workspace. Each is created once per context, lent to one synchronous callback at a time, +//! marked failed on any execution error and released on close or drop. use super::{ BindingIdentity, Cell, Context, Error, MTP_INPUT_WORKSPACE_BYTES, MtpInputWorkspace, MtpInputWorkspaceOwner, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs index 0b123d07..3609cb77 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs @@ -1,5 +1,6 @@ -//! Methods of `EncodedWeight`: `close`. -//! Methods of `RoutedFiniteOwner`: `new`, `matches_context`, `is_failed`, `check_stage` and 1 more. +//! Admission rules of the MoE cache: bounded validation of a ranked profile before the driver loads, the room +//! predicate, which descriptors get the padded dual MMQ layout (and the Original prompt formats), triplet shape +//! checks, and `RoutedFiniteOwner`, the guard that proves a routed stage output is finite. use super::{ Cell, Context, DeviceBuffer, EncodedWeight, Error, MAIN_LIMIT, MmqFormat, MoeWeightDescriptor, RefCell, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs index 2e987f06..82321638 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpFrame`: `within_bounds`, `validate`, `token`, `position` and 1 more. -//! Methods of `MtpInput`: `from_previous`, `frame`, `streams`, `from_target` and 5 more. +//! The frame of one draft token and the input of a draft step: `MtpFrame` (which target position, token and depth a +//! draft branch stands on) and `MtpInput`, the pre-FC norms and the two Q8_0 matrices that turn the source residual +//! and the next-token embedding into the draft step input. Frames are valid only for the current target session and +//! epoch, so a reset or rewind invalidates every older one. No CPU forward arithmetic happens here. use super::{ Context, DeviceBuffer, Dimension, Error, KnownNext, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, MtpKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs index 6c915119..53e5b7c6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs @@ -1,5 +1,6 @@ -//! Functions: `project_gated`, `project_attention_out_numeric`. -//! Split out of `mtp` to keep its files under the line limit. +//! Output projection of the draft attention: the 6144 gated attention values to 2560 through the Q8_0 matrix. +//! It reads the retained gated device buffer directly, reserving the same output and quantizer room as the original +//! upload-based path. use super::{ Context, DenseFormat, DeviceBuffer, Error, ProjectionKind, ProjectionSpec, Result, allocate, download, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs index 6358a365..5c5a9210 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs @@ -1,5 +1,7 @@ -//! Methods of `ValidatedWarmEnd`: `from_txn`. -//! Methods of `MtpSession`: `stage_chunk`, `stage_chunk_bound`, `stage_chunk_with_end`, `admit_chunk_start` and 2 more. +//! Staging of a draft chunk branch over an actual bounded target chunk: `MtpSession::stage_chunk` forks a private +//! candidate, and `MtpChunkStage` validates its anchor and lineage and publishes it once. The live draft stays +//! borrowed until the joint target and draft publication, so a failed chunk leaves it unchanged; also checks the +//! chunk end position against its limit. use super::{ Error, ModelBinding, MtpChunkStage, MtpSession, Position, QwenChunkTxn, QwenSession, Rc, Result, TargetStepOrigin, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs index 238c23cf..09ccd802 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs @@ -1,5 +1,5 @@ -//! Methods of `MtpSession`: `test_chunk_snapshot`, `test_chunk_eq`. -//! Split out of `chunk` to keep its files under the line limit. +//! Test-only numeric snapshot of a chunk-candidate draft session and its comparison, used to prove that a refused or +//! cancelled chunk left the draft bit-identical. #[cfg(all(test, target_arch = "x86_64"))] use super::MtpChunkNumericSnapshot; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs index cb8ca8f2..d00ef22e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseKv`: `empty`, `append`, `ring_validate`, `ring_same` and 6 more. Functions: `validate_half`. -//! Split out of `state` to keep its files under the line limit. +//! Immutable dense draft K/V (`DenseKv`): append one cell for a frame, validate and compare the ring mirror, and read +//! the half-precision window of a frame. Cells are shared and never mutated; an append returns a new value, and every +//! cell is checked finite before it is admitted. use super::{ BindingIdentity, Cell, CellPair, DenseKv, Error, HALF_ROW, HalfWindow, MtpFrame, Rc, Result, WINDOW, Weak, reserve, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs index 7a891d2f..e7590f70 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs @@ -1,5 +1,6 @@ -//! Methods of `MtpSession`: `new`, `frame`, `prior`, `validate_frame` and 17 more. Functions: `seed_frame_foreign`. -//! Split out of `state` to keep its files under the line limit. +//! The draft session `MtpSession`: committed draft K/V, residual and position, and the frames and checkpoints derived +//! from them. Commit publishes only a fully produced pending K/V and residual; restore accepts only checkpoints of +//! this live lineage, including the closed first-seed restore that replaces a repeated warm. use super::{ Cell, DenseKv, Dimension, Error, ModelBinding, MtpCheckpoint, MtpFrame, MtpSession, Position, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs index 2ebf9e07..74f6aae7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs @@ -1,5 +1,6 @@ -//! Methods of `PrefixDraftSnapshot`: `has_prefix`, `numeric_eq`, `retained_bytes`. -//! Methods of `MtpSession`: `test_prefix_snapshot`, `admit_snapshot_owner`, `admit_snapshot_frame`. +//! Test-only snapshot of the draft state after a target prefix, with its numeric comparison and retained size, and +//! the admission checks of its owner and frame. Also keeps the live-checkpoint count honest: dropping an +//! `MtpCheckpoint` releases its slot against the cap. use super::{CellPair, Error, HALF_ROW, MtpCheckpoint, MtpFrame, Rc, Result}; #[cfg(all(test, target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs index 510c1d5e..a8ad2fe1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the draft state rules: first-seed restore keeps the real snapshot and rolls back to the original, a coupled +//! refusal never re-mints or mutates, ring operations need the exact parent epoch and branch, and a new pending +//! token, epoch or residual is refused atomically. Metadata and lineage only, not a CUDA or numerical proof. use super::{ BindingIdentity, Cell, CellPair, DenseKv, Dimension, Error, HALF_ROW, MtpCheckpoint, MtpFrame, MtpSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs index e71200c7..bfa66aa2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpFinalMixed`: `from_native_mixer`, `frame`, `values`. -//! Functions: `step`, `warm_step`, `warm_chunk_row`, `run_blocks` and 12 more. Defines `MtpBlocks`. +//! One MTP draft step: attention read, draft attention, MLP read, experts, final mix, optional greedy head, then +//! commit of the draft state; also the norm and projection helpers the draft stages share. The known-next warm path +//! and the chunk-row path run it without a head; a chunk row commits only a private draft. Block products live until +//! the step is committed and synchronized; a teardown ambiguity stays sticky. use super::{ Bf16ProjectionShape, Cell, Context, DenseFormat, DeviceBuffer, Error, ModelBinding, MoeWeightCache, MtpChunkStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs index 8e7ede5c..7312adca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpAttentionReady`: `frame`, `output`, `streams`, `inject` and 2 more. -//! Methods of `MtpAttentionStage`: `run`. Implements `Drop for RetainedAttended`, `Drop for RetainedGated`. +//! The MTP draft attention stage: runs one dense draft attention row over the read of the source row and returns +//! `MtpAttentionReady`, which carries a pending K/V cell and never commits a draft position. Admits every pinned +//! descriptor before CUDA work, produces the K/V cell and Q and gate of the row, and owns the retained attended and +//! gated buffers until they are closed. use super::{ Cell, Context, DenseGeometry, DenseKv, DeviceBuffer, Error, KV, KvWindow, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs index f062d5d3..ff0c392f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs @@ -1,5 +1,6 @@ -//! Methods of `AttendBuffers`: `upload_window`, `attend`, `attend_ring`. Methods of `GateBuffers`: `apply`. -//! Functions: `release_transport`, `close_transport`, `note_transport`, `upload_transport` and 7 more. +//! Device transport of the draft attention: window upload, attend (with or without the actor's K/V ring), gate and +//! the release of every step-local buffer. Each buffer is released explicitly whatever failed; a failed launch or +//! release withholds the readback and flags the step transport as failed. use super::{ Cell, Context, DenseGeometry, DeviceBuffer, Error, KvWindow, Q, Rc, Result, RetainedAttended, RetainedGated, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs index 1923060f..09552f82 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs @@ -1,5 +1,6 @@ -//! Functions: `geometry`, `validate_window`, `norm_rope_launch`, `norm_rope` and 6 more. -//! Split out of `mtp_attention` to keep its files under the line limit. +//! Geometry and launches of the dense draft attention: causal window shape for a position, the budget of its scratch, +//! norm and rope, K/V packing, query and gate split, the attend launch and the gate application. Windows are half- +//! precision cells checked against the geometry before any launch. use super::{ Context, DenseGeometry, DeviceBuffer, Error, HALF_CELL, KV, NormGamma, PackedKv, Q, QGate, Result, WINDOW, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs index 282b5669..8e0eb2e1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the draft attention shape rules: the causal geometry and its budget boundaries, and the window shape, half +//! domains and preservation of caller buffers. use super::{Error, geometry, validate_window}; #[test] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs index 745ca460..ea9edd93 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs @@ -1,5 +1,5 @@ -//! Defines `Shared`, `Refs`, `Chain` and 2 more. -//! Split out of `batch_gpu` to keep its files under the line limit. +//! State types of the loaded batched-MTP proof: the loan of the loaded stages, the reference tokens and snapshots, +//! the scalar chain and prefix, and the flow every phase runs on (GPU tests only). use super::{ Collection, DenseWeightCache, Dimension, Error, Expected, KarPleCache, ModelBinding, MoeWeightCache, MtpDecoder, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs index 91589bdb..7c605da8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs @@ -1,5 +1,6 @@ -//! Methods of `Flow`: `step`, `warm`, `observe`, `matches_state` and 8 more. Defines `CancelledWindow`. -//! Split out of `check_loaded` to keep its files under the line limit. +//! Phases of the loaded batched-MTP proof: the scalar references, the candidate seed, refused windows and the +//! cancelled T3 publication. Each phase compares the batched window with the scalar reference on the same loaded +//! model and requires a cancelled window to leave the session state unchanged (GPU tests only). use super::{ Chain, Collection, Error, Expected, Flow, MoeWeightCache, MtpDecoder, MtpWindowError, MtpWindowSpec, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs index afa75bc8..375c452b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs @@ -1,5 +1,6 @@ -//! Methods of `Flow`: `eos_prefix`, `max_one`, `idle_window`, `no_advance`. Functions: `check_loaded`. -//! Split out of `check_loaded` to keep its files under the line limit. +//! Edge scenarios of the loaded batched-MTP proof and its entry point: an accepted prefix ending in EOS, a window +//! limited to one token (which exercises rewind and head-free catch-up), and windows with nothing to advance. A +//! window with zero remaining or an authoritative EOS must do no draft work and publish nothing (GPU tests only). use super::{ Chain, Collection, Expected, Flow, MoeWeightCache, MtpDecoder, MtpWindowSpec, QwenForward, Rc, Refs, Report, 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 240090a4..199031fd 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 @@ -1,5 +1,5 @@ -//! Methods of `Shared`: `step`, `window`. Methods of `Flow`: `open`. Functions: `position_at`, `admit_binding`. -//! Split out of `check_loaded` to keep its files under the line limit. +//! Shared loan of the loaded stages for the batched-MTP proof: scalar steps, window preparation and opening a flow. +//! Also the position helper and the host cap check for the snapshots and draft copies (GPU tests only). use super::{ Dimension, Flow, ModelBinding, MoeWeightCache, MtpDecoder, MtpVerifiedWindow, MtpWindowError, MtpWindowSpec, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs index a7e11f07..fee32aa3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs @@ -1,5 +1,6 @@ -//! Methods of `Collection`: `begin`, `finish`. Methods of `PostcommitCancellation`: `arm`, `cancelled`. -//! Implements `Drop for Collection`, `Drop for PostcommitCancellation`. +//! Row observation of the batched-MTP proof: a collector that records the head words, residual and state of up to +//! three rows while a window runs, and a post-commit cancellation trigger. Both are armed for one scope and cleared +//! on drop. Heads and state stay private; the report holds counts and predicates only (GPU tests only). use super::{ COLLECTOR, Collection, Collector, Dimension, Error, Expected, ModelBinding, OutputStage, POSTCOMMIT_CANCEL, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs index 723120dc..16afe095 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs @@ -1,5 +1,7 @@ -//! Functions: `first_seed_reuse_enabled`, `needed_draft_predictions`, `window_limit`, `window_stage_error`. -//! Split out of `mtp_decode` to keep its files under the line limit. +//! Policy and bounds of an MTP decoder window: whether the first draft seed may be reused, how many draft predictions +//! a window needs, its position limit, and how a cancelled stage maps to a window error. Reuse is on only with the +//! adaptive expert policy and no numerical observer active. The seed already fills slot zero, so the bounds change +//! speculative work only; verification and accepted-prefix limits are unchanged. use super::{Error, MoeWeightCache, MtpWindowError, Result}; #[cfg(all(test, target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs index 678df959..5a7aa4a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs @@ -1,5 +1,6 @@ -//! Methods of `MtpWindowSpec`: `new`. Methods of `MtpVerifiedWindow`: `tokens`, `draft_steps`, `into_parts`. -//! Implements `From for MtpWindowError`. Functions: `kv_prefill_host_charge`. +//! Request and result types of one verified MTP window: depth, remaining tokens and EOS of the spec, the window +//! error, and the verified tokens with the draft step count. Also holds the conservative host charge of the draft K/V +//! prefill of a prompt. use super::{Dimension, Error, MtpVerifiedWindow, MtpWindowError, MtpWindowSpec, Result, TargetStepProduct, TokenId}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs index 147bdac3..212fbe33 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs @@ -1,5 +1,5 @@ -//! Functions: `append_row`. -//! Split out of `mtp_experts` to keep its files under the line limit. +//! Splits one Q2_0 expert row into the separate scale and code planes of an `S2Tile`, byte for byte. +//! Each 18-byte block is a half-precision scale plus 16 code bytes; a non-finite scale is refused. use super::{Error, Result, S2Tile}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs index 6d833944..8fdecc7c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs @@ -1,5 +1,6 @@ -//! Methods of `FixedBuffers`: `new`, `check`, `take`, `put` and 1 more. -//! Methods of `MtpExpertWorkspace`: `new`, `compose`, `close`. Implements `Drop for FixedBuffers`. +//! Pre-allocated device buffers of the fixed-ABI draft MoE workspace (`FixedBuffers`) and its public owner +//! `MtpExpertWorkspace`. Buffers are taken for an invocation and put back after it; a failed context or a missing +//! buffer is refused, and every buffer is released on close or drop. use super::{ ALLOCATED_BYTES, BindingIdentity, CHARGES, Cell, Context, DEVICE_PEAK, DeviceBuffer, Error, ExpertInputs, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs index 08e23edf..378fdfa5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs @@ -1,4 +1,6 @@ -//! GPU proof of the fixed-ABI draft MoE workspace (moved out of mtp_expert_workspace.rs; test builds only). +//! GPU proof of the fixed-ABI draft MoE workspace (test builds only): repeated invocations over the leased buffers +//! match the reference bit for bit, and an abort, a late non-finite value, bad input or a failed flag is refused +//! cleanly. use super::super::mtp_expert_transport::{ExpertWeights, FixedReference, SelectedRoute, fixed_reference}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs index d2b727b2..44c02fc0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs @@ -1,5 +1,7 @@ -//! Methods of `Role`: `slot`, `output_slot`, `count`. -//! Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 11 more. +//! The roles of the fixed draft MoE workspace (which routed or shared stage a buffer serves, its slot and element +//! count) and the per-invocation `Transport` that leases buffers from it: upload, produce, finite readback, release. +//! Also runs the original FP32-scale quantizers, whose completed scales are inspected before any grouped dot uses +//! them. use super::{ Cell, DEVICE_PEAK, DeviceBuffer, Error, FF, Finite, FixedBuffers, N, Rc, Result, Role, Slot, Transport, at, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs index aca3f382..2c100937 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs @@ -1,5 +1,6 @@ -//! Methods of `Packed`: `new`, `pack`, `observe_packed`, `combine`. Methods of `Slot`: `bytes`. -//! Implements `Drop for Transport`. Functions: `at`, `routed_hidden`, `routed_down`, `routed` and 8 more. +//! Expert math of the fixed workspace transport: routed hidden and Down per expert, the shared expert (gate, up, +//! scaled by its scalar), the packed routed Downs and the final combine in router slot order. Also releases every +//! leased buffer when a transport drops; the first failure stops before any later expert runs. use super::{ CHARGES, Cell, DenseFormat, DeviceBuffer, Error, ExpertInputs, FF, Finite, FixedBuffers, K, N, Packed, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs index ed66185b..84481737 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpBlock`: `frame`, `output`. Methods of `MtpExpertStage`: `run`, `run_checked`. -//! Functions: `admit_input`, `route_mixed`, `compose_bound`, `moe_driver_error` and 1 more. +//! Entry of the draft MoE block: `MtpExpertStage::run` routes the mixed row and composes the routed and shared +//! experts into a pending `MtpBlock`. All fixed dense roles are admitted before the first model row or CUDA call. The +//! composed device products live only in the current frame-bound invocation, so none escapes to a later draft +//! position or rollback epoch. use super::mtp_expert_transport::SelectedRoute; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs index 020194da..e08d9cd4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs @@ -1,5 +1,6 @@ -//! Methods of `Env`: `compare_observed`. Functions: `exact`, `bytes`, `fill_blob_part`, `bank_fixture` and 12 more. -//! Defines `SharedStage`. +//! Original reference chain and fixtures of the MTP expert transport proof (GPU tests only). +//! Builds a synthetic expert bank, runs each routed expert and the shared expert through the original stages with +//! every stage read back, and checks the retained transport matches that baseline bit for bit. use super::{ BANK_BYTES, BLOB_BYTES, Cell, Context, DenseFormat, DeviceBuffer, Env, Error, ExpertWeights, FF, IDS, N, Original, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs index 781050cf..7e3c7800 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs @@ -1,5 +1,6 @@ -//! Methods of `Env`: `private_owner_guards`. Functions: `gate_guards`, `slot_guards`. Defines `Count`. -//! Split out of `mtp_expert_transport_gpu` to keep its files under the line limit. +//! Owner guards of the MTP expert transport proof (GPU tests only): a released or foreign-invocation product is never +//! accepted by another transport, a Down of the wrong slot cannot be packed, and the packed destination cannot +//! combine early. use super::{ Cell, Context, DeviceBuffer, Env, Error, IDS, Packed, ROUTE, Role, RoutedExpert, Transport, refusal, routed, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs index 34d3c647..a9049856 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs @@ -1,5 +1,7 @@ -//! Methods of `Role`: `count`. Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 9 more. -//! Implements `Drop for Transport`. +//! The per-invocation `Transport` of the MTP expert stage: allocates, uploads, produces and reads back device buffers +//! for one invocation, plus the routed expert Down and hidden steps. A product is accepted only with its exact role +//! and current invocation owner; every buffer is released on close or drop, and the original quantizers run with +//! their scales inspected before any dot. use super::{ Cell, Context, DEVICE_PEAK, DeviceBuffer, Error, FF, Finite, K, N, Rc, Result, Role, Transport, download, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs index fe6cff1e..b6041e1a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs @@ -1,5 +1,6 @@ -//! Methods of `Packed`: `new`, `pack`, `observe_packed`, `combine`. -//! Functions: `shared_project`, `shared_hidden`, `shared_down`, `shared_scaled` and 6 more. +//! Shared expert, packing and combine of the MTP expert transport: shared gate, up, hidden, down and scalar scaling, +//! the routed Downs packed in slot order, and the weighted combine. Entry points `compose` and `compose_observed` run +//! a whole block; the first failure stops before any later expert runs. use super::{ Cell, Context, DenseFormat, DeviceBuffer, Error, FF, Finite, K, N, Packed, ProjectionKind, ProjectionSpec, Rc, 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/routed_and_shared_experts.rs index f74804f5..24705c45 100644 --- 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/routed_and_shared_experts.rs @@ -1,5 +1,6 @@ -//! Functions: `route`, `route_on_device`, `compose`, `routed_parts` and 9 more. Defines `MtpRoutingScope`. -//! Split out of `mtp_experts` to keep its files under the line limit. +//! Expert math of the MTP block on uploaded activations: route on the device, routed Gate/Up/hidden/Down parts, +//! shared expert, and the original ordered combine in router slot order. Also repacks Q2_0 expert rows into the +//! separate scale and code planes of `S2Tile`. use super::{ Context, DeviceBuffer, Error, FF, K, ModelBinding, MoeWeightCache, MtpRole, N, Result, S2Tile, allocate, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs index efae8aa1..7936f0e5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the MTP expert adapter: gate/up and down tiles keep every byte label (signed-zero and subnormal scales +//! included), a bad shape or non-finite scale is refused, and a route with duplicate, out-of-range or bad weights is +//! refused. use super::{Error, K, down_tile, gate_up_tile, validate_route}; fn fixture(rows: usize, blocks: usize, salt: u8) -> Vec { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs index fa00280e..4d16cc36 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpAttentionRead`: `frame`, `streams`, `mixed`, `inject`. -//! Methods of `MtpMlpReady`: `frame`, `streams`, `mixed`, `inject`. +//! The fused GR reads of the MTP draft step: `MtpAttentionRead` and `MtpMlpReady` (residual streams, mixed row and +//! injection) and the fused launches that produce them. Products are bound to their draft frame and never commit +//! target or draft state; the four dense matrices are admitted before the launch, and each completed component is +//! validated before the next entry consumes it. use super::{ Candidate, Context, Error, FUSED_PEAK, H, ModelBinding, MoeWeightCache, MtpAttentionRead, MtpAttentionReady, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs index cc458628..006fe3d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs @@ -1,5 +1,7 @@ -//! Functions: `admit_final_inputs`, `finalize`, `finalize_checked`, `final_matrix` and 7 more. -//! Defines `FinalStageInputs`. +//! Final chain of the MTP draft step: the MTP block output and MLP streams are normalized, gated and injected into +//! the draft's final mixed row (`MtpDraftFinal`). Frame, finiteness and dense-shape admission precede any launch. The +//! legacy host-transfer chain stays as the numerical baseline that the retained chain is proved against, never as a +//! fallback. use super::{ Cell, Context, Error, FINAL_PEAK, H, ModelBinding, MoeWeightCache, MtpBlock, MtpDraftFinal, MtpFinalMixed, MtpKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs index 0532d79a..a166474c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalMtpFullOwner`: `validate`, `actor_mut`, `actor`, `close` and 1 more. -//! Implements `Drop for OriginalMtpFullOwner`. Functions: `driver_error`. +//! Access and teardown of `OriginalMtpFullOwner`: the validated, exclusive loan of its MTP actor, a read-only actor +//! view, and close. The actor drains its stream and closes the drafter before the retained weights it holds are +//! released, in the source order. No mutable ring reference escapes the owner, and drop closes best-effort. use super::{Context, Error, ModelBinding, OriginalMtpActor, OriginalMtpFullOwner, Result, Stage}; 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/original_mtp_full_owner_methods.rs index 9d85da25..245a2544 100644 --- 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/original_mtp_full_owner_methods.rs @@ -1,5 +1,7 @@ -//! Methods of `OriginalMtpFullOwner`: `bind_reserve`, `assemble_rt`, `assemble`, `assemble_core` and 5 more. -//! Split out of `original_mtp_full_owner` to keep its files under the line limit. +//! Assembly of the full MTP draft owner: the startup byte reserve, and the load from an RT directory or from the +//! pinned pack held by the MoE cache. Follows the source order: load meter and native head, checked plan, optional +//! draft head, shared drafter, then the actor that adopts drafter, ring and weights; a failed step closes everything +//! built so far. use super::{ AdoptParts, Context, DraftAttachmentTables, DraftAttachmentTarget, Error, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs index 98a2a695..c0dce4cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalMtpRequest`: `ring_int8`. -//! Implements `From for OriginalMtpLoadError`, `From for OriginalMtpLoadError`. Functions: `plan_error`, `capture_of`. +//! The load request of the Original MTP drafter (`OriginalMtpRequest`, with the Original defaults of window 32768 and +//! the INT8 window-ring draft state) and the mapping of plan, driver and engine failures onto `OriginalMtpLoadError`. +//! Also builds the load capture (device, expert count, cells of the primary QSA state) the plan is checked against. use super::{ Context, Error, ModelBinding, OriginalMtpCapture, OriginalMtpKvStartup, OriginalMtpLoadError, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs index df7e03da..2c9fafe8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs @@ -1,5 +1,6 @@ -//! Functions: `driver_error`. -//! Split out of `original_mtp_verified_adapter` to keep its files under the line limit. +//! Maps a CUDA driver error onto the engine error of the verified MTP adapter: a context mismatch is an identity +//! mismatch, size and shape errors are dimension errors, budget errors are allocation errors, anything else is a CUDA +//! execution failure. use super::Error; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs index f4ab3d3c..5c64e9a6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs @@ -1,5 +1,7 @@ -//! Methods of `OriginalMtpDraftReceipt`: `ids`, `probabilities`, `count`, `first_position` and 2 more. -//! Methods of `OriginalVerifiedMtpReceipt`: `new`, `commit_origin_foreign`, `after_target_commit`. +//! Receipts that carry a verifier window into an MTP draft: the draft receipt (ids, probabilities, first position and +//! accepted row), the verified-window receipt before the target commit, and the published-window variant. A draft is +//! valid only while the real target prefix still equals the commit that produced it; skipped, extra or cross-branch +//! publication is refused before MTP capture. use super::{ Context, Error, ModelBinding, NativeHeadSelection, OriginalCommittedMtpReceipt, OriginalDraftSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs index 0d766959..b13408e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs @@ -1,5 +1,7 @@ -//! Methods of `OriginalPromptExecutor`: `launch_committing_mtp`, `admit_launch`, `launch_origin`, `finish_committing... -//! Split out of `original_mtp_verified_adapter` to keep its files under the line limit. +//! The MTP drafting calls of `OriginalPromptExecutor` on a committed verifier window: launch the draft behind the +//! commit and finish it after the commit is published, the full draft, the first draft after the prompt, and the +//! draft sampling and history setters. Follows the source order verifier completion, target commit, draft; this +//! neither commits target state nor accepts tokens, and a draft is sealed into the receipt of the committed origin. use super::{ AcceptedWindow, CompletedOriginalMtpDraft, DraftLaunch, DraftTarget, Error, ModelBinding, MtpDraftOwners, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs index e2ecd974..e5a50f94 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the Mode17 values derived for the Original serve path: pack expert bank and footprint switches, blob sizes, +//! rope theta scale, MTP policies, sampler path flags, request parameter mapping and the geometry and prefill carve. use super::{ Error, ExpertBlobSizes, OriginalMtpGrVariant, RopeConstants, SamplerPath, driver_sampler_params, greedy_params, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs index e4d1fb4b..dece4ef9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `original_serve_engine_original_spec_engine`, `serve_engine_draft_commit`. -//! Split out of `original_serve_engine` to keep its files under the line limit. +//! The draft half of OriginalServeEngine: the commit-before-draft protocol (`serve_engine_draft_commit`) and the +//! OriginalSpecEngine face the speculative controller drives (`spec_engine_for_serve_engine`). use super::{ CommittedWindow, DraftCompletion, DraftLimits, DraftPick, DraftStage, Error, FirstStage, MAX_T, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs index 3889d20e..5f2ca3ee 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs @@ -1,5 +1,6 @@ -//! Methods of `DraftCompletion`: `validate`. Methods of `ServedWindow`: `rows`, `committed_rows`. -//! Implements `OriginalDraftEngine for OriginalServeEngine`. +//! OriginalServeEngine: constructor, window admission and checks, and the one-shot MTP draft (replay, seed, chain) +//! cached for the controller's callbacks, with commit enqueued before any draft reads the branch. +//! The engine only keeps the protocol discipline; every number comes from the `OriginalServePort` owners behind it. use super::{ CommittedWindow, DraftCompletion, DraftLimits, DraftPick, DraftStage, Error, FirstStage, MAX_T, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs index 5e5b0d8a..2e576a2b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs @@ -1,5 +1,5 @@ -//! Defines `RoundTally`. -//! Split out of `original_serve_engine` to keep its files under the line limit. +//! RoundTally, the produced-token and round counters of one served request and why it stopped, with the submodules +//! that run the request: settings, the round loop and the first-draft stage. use super::{ ADAPTIVE_DEFAULT, AdaptiveConfig, CommittedWindow, DraftCompletion, DraftLimits, DraftPick, DraftStage, EnvSource, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs index 3750c636..a9325d3c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalServeSettings`: `mode17`, `from_environment`, `adaptive_wanted`, `arms_from_environment` and ... -//! Methods of `SpeculativeRequest`: `from_request`. Functions: `serve_request`. +//! OriginalServeSettings: the speculative window policy of a served request (mode17 defaults, `LELEKA_SPEC_*` and +//! `LELEKA_SPEC_ARMS` overrides, adaptive or fixed window, window cap), and `serve_request`, the per-request loop. +//! The loop runs begin, verify/commit, emit, finish round until the request stops; `emit` runs only after the commit. use super::{ ADAPTIVE_DEFAULT, AdaptiveConfig, EnvSource, MAX_T, NanGuard, OriginalServeSettings, OriginalSpecController, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs index 532074f8..78498f83 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs @@ -1,5 +1,6 @@ -//! Implements `OriginalServePort for TracePort`. Functions: `serve_rounds`, `serve_round`, `tr_port`. -//! Split out of `round_tally` to keep its files under the line limit. +//! The round loop of a served request (`serve_rounds`, `serve_round`: verify and commit, emit, finish) and the +//! timing wrappers that trace each port call under the bring-up trace (`TracePort`, `tr_port`). +//! A failed emit still finishes its round (drain and join) before the error is reported. use super::{ CommittedWindow, DraftCompletion, DraftLimits, FirstDraftSeed, OriginalServePort, OriginalSpecController, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs index 6494bad2..9b31660b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Test world of the serve engine: a scripted port (`Fake`) with an event log and a deterministic model, and the +//! helpers that drive a request through the engine and the controller. The scenarios sit in the submodules. use super::super::original_spec_controller::{NanGuard, OriginalSpecController, SpecConfig, SpecError, SpecWindow}; use super::super::original_spec_draft::{DraftPreparation, DraftSampling, VerifiedWindow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs index 7db09501..905ca612 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs @@ -1,6 +1,5 @@ -//! Tests of `tests` by topic: constructor_validates_dimensions, -//! verify_returns_all_t_outputs_and_requires_a_drained_window, out_of_range_tokens_never_reach_the_port, -//! a_short_or_invalid_window_is_drained_not_leaked .... +//! Pins the engine's admission rules: constructor dimension checks, a verify returning all T outputs only over a +//! drained window, out-of-range tokens never reaching the port, and short or invalid windows drained, not leaked. use super::{ Error, Fake, OriginalDraftEngine, OriginalServeEngine, OriginalSpecEngine, VOCAB, engine, events, idx, model, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs index a2834156..098dc35b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs @@ -1,7 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! restore_attempts_do_not_depend_on_engine_health_and_reset_draft_state, -//! a_refused_window_is_taken_back_only_after_it_drained_and_a_failed_take_back_poisons, -//! first_draft_path_is_cached_and_drains, controller_over_the_engine_emits_the_greedy_continuation .... +//! Pins restore and draft behaviour: restore attempts independent of engine health, a refused window taken back only +//! after it drained (a failed take-back poisons), the cached first-draft path and the greedy end-to-end continuation. use super::{ ADAPTIVE_DEFAULT, AdaptiveConfig, DraftPreparation, DraftSampling, Error, Fake, OriginalDraftEngine, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs index 9dce20ea..b960bfb6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs @@ -1,5 +1,5 @@ -//! Implements `NativeServeHost for OriginalServeHost`. -//! Split out of `original_serve_host` to keep its files under the line limit. +//! The `NativeServeHost` face of OriginalServeHost: lineage checkpoints and restores, the verified-window run, commit +//! and publication, the adaptive swaps around the commit, and the MTP draft launch and drain, in generate.cpp order. use super::{ AcceptedWindow, DraftCompletion, DraftLaunch, Error, LedgerCheckpoint, MtpDraftOwners, NativeServeHost, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs index 7ca6ca10..29434adb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs @@ -1,5 +1,6 @@ -//! Methods of `RequestSampling`: `new`, `enabled`. -//! Methods of `OriginalServeHost`: `new`, `from_owners`, `position`, `settle_state` and 10 more. +//! The state OriginalServeHost carries for one request: sampling setup (`RequestSampling`), construction from the +//! session owners, the position and token lineage it ends on, and the settle of the recurrent GDN and PLE priors. +//! Also the A/B switches of the publication (`LELEKA_SERVE_PUBLISH`, `LELEKA_SERVE_ADAPT_DEFER`) and the draft cap. use super::{ BoundLayerKind, DraftCompletion, Error, GdnPrior, HostOutcome, HostOwners, OriginalNativeHeadGraphResources, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs index 10f5d4b7..f3fac337 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the host's request setup: a greedy request without penalties keeps the plain argmax head, invalid sampler +//! parameters are refused before any window, and the host outcome carries the four things the stack decides on. use super::{HostOutcome, RequestSampling, SamplerParams, SamplerPath}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs index 642e2022..f8c0d336 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs @@ -1,5 +1,5 @@ -//! Implements `OriginalServePort for NativeServePort`. Functions: `start_foreign`, `check_completed`. -//! Split out of `original_serve_native` to keep its files under the line limit. +//! The `OriginalServePort` face of NativeServePort: every port call mapped onto the driver Verifier and the host +//! owners, with the driver's own window receipt as the authority for what ran and what may be committed. use super::{ CommittedWindow, DraftCompletion, DraftLimits, Error, FirstDraftSeed, NativeServeHost, NativeServePort, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs index 1c4c78e9..8c7bb2cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs @@ -1,5 +1,6 @@ -//! Methods of `NativeWindow`: `generation`. -//! Methods of `NativeServePort`: `new`, `verifier`, `verifier_mut`, `host` and 13 more. +//! NativeServePort's window life cycle: commit wait and publication of the accepted prefix to the session, receipt +//! admission, and the overlapped or serialized draft launched behind the commit event. +//! Also the bring-up traces of windows and drafts and the `LELEKA_SERVE_OVERLAP` A/B switch. use super::{ DraftCompletion, DraftLimits, Error, NativeCommittedWindow, NativeServeHost, NativeServePort, NativeWindow, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs index cf28cdb8..1576ca38 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `CpuExpertPool`: `run_entries`, `admit_rows`, `plan_group`, `run_direct` and 6 more. -//! Functions: `legacy_batch`, `prepare_legacy_jobs`, `validate_legacy_job`, `compare_rows` and 1 more. +//! CpuExpertPool: computing one group of routed experts on the CPU (admission of the rows, planning, the direct +//! dispatch and the legacy per-expert batches) and writing every slot of the mapped sink, zeros for entries it skips. +//! The legacy path re-validates each finished job against a re-opened source and can be compared bit for bit. use super::{ BATCH_ALLOWANCE, ComputeSample, CpuExpertPool, CpuMissWorkspace, Error, ExpertJob, GroupTraceInfo, GroupWork, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs index b6c812aa..75545922 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs @@ -1,5 +1,6 @@ -//! Methods of `DirectTier`: `admit_all`, `start_lookahead`, `layer_layout`, `index` and 7 more. -//! Methods of `CpuExpertPool`: `new`, `with_path`. Implements `OriginalServePool for CpuExpertPool`. +//! DirectTier: the direct CPU path's expert admission, i.e. opening a layer group's experts under one source fence, +//! checking their gate/up/down spans and caching them so later groups pay nothing; and the pool constructors. +//! Eager admission at stack open takes the first-use cost out of the first decode. use super::{ ComputeSample, CpuExpertPool, CpuMissWorkspace, CrosscheckCounts, DirectCpuPool, DirectTier, EXPERTS, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs index d51d6204..6d09ea6a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs @@ -1,5 +1,5 @@ -//! Implements `Drop for DirectTier`. Functions: `admit_eager`, `sink_result`, `native_cpu_error`, `selection`. -//! Split out of `original_serve_pool` to keep its files under the line limit. +//! Closing of the direct tier (its Drop) and the small helpers of the direct path: the `LELEKA_CPU_ADMIT_EAGER` +//! switch, sink-write result mapping, native CPU error mapping and the per-row top-k selection check. use super::{DirectTier, Error, Result, TOP_K}; 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 fa1e207c..9c22108b 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 @@ -1,5 +1,6 @@ -//! Methods of `PoolPath`: `from_env`. -//! Functions: `prefetch_off_file_exists`, `plan_experts`, `plan_experts_where`, `plan_row` and 7 more. +//! Planning of a CPU expert group and the per-job source checks: router ids grouped by expert in first-use order, +//! scatter of one expert's rows into the group output, and open/admit of an expert's matrices (`open_job`). +//! Also the `LELEKA_CPU_PREFETCH_OFF_FILE` bring-up switch that skips the page-touch pass. use super::{ EXPERTS, Error, ExpertJob, HIDDEN, ModelBinding, MoeMatrixRole, MoeRoutedSourceScope, Opened, PoolPath, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs index 790b9fd9..c5350e6b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the expert group plan: every (row, slot) pair planned once with experts in first-use order, masked GPU +//! entries left out but still validated, bad router output refused, and scatter offsets of each output slot. use super::{Error, ExpertJob, HIDDEN, TOP_K, output_offset, plan_experts_where, scatter, selection}; #[cfg(test)] 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 e0b02ba8..64e81f0b 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 @@ -1,4 +1,5 @@ -//! Unit tests of `original_serve_request`. +//! Pins the request flow of the serve layer: the stop set, reset and resume rules for fresh, used and resumed +//! stacks, admission as in generate.cpp, untouched owners on refusal, error classes and emit failure handling. use super::super::original_serve_engine::ServeStop; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs index 7eb4931e..0f0b7f46 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs @@ -1,5 +1,5 @@ -//! Methods of `GpuExpertPool`: `admit_group`, `note_usage`, `split_group`, `current_pcie_num` and 7 more. -//! Implements `OriginalServePool for GpuExpertPool`. +//! GpuExpertPool as an `OriginalServePool`: runs a window group (split into VRAM, PCIe and CPU shares, plan published +//! before the CPU starts), applies and begins the adaptive swaps, and fetches the source spans of PCIe experts. use super::{ CpuExpertPool, EXPERTS, Error, GpuExpertPool, GroupSplit, LAYERS, MappedExpertBank, ModelBinding, MoeWeightCache, 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/span_cache_and_pcie_lag.rs index 0ee82e2a..9087401f 100644 --- 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/span_cache_and_pcie_lag.rs @@ -1,5 +1,5 @@ -//! Methods of `SpanCache`: `key`, `get`, `contains`, `insert`. -//! Methods of `PcieLag`: `from_environment`, `pcie_num`, `measure`, `round`. Implements `Debug for SpanCache`. +//! Small stateful helpers of the VRAM expert tier: the span cache of bank spans per (layer, expert), the PCIe share +//! controllers (`PcieLag` from copy lateness, `PcieAuto`) and ResidencyState (usage counts, round marks). use super::{ EXPERTS, ExpertTierConfig, GpuExpertPool, LAYERS, PcieAuto, PcieLag, ResidencyState, ResidencyStats, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs index 1c6688b9..b390084a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs @@ -1,5 +1,6 @@ -//! Methods of `RoutedGroup`: `new`. Methods of `PcieShare`: `takes`. -//! Functions: `split_group_pcie`, `is_valid_expert`, `is_miss`, `group_firsts` and 14 more. +//! The window split of one expert group: distinct experts in routing order become VRAM groups, the last eligible +//! misses up to the PCIe share go over PCIe, the rest stay with the CPU, with the route tail skip applied first. +//! Pure planning over ids and residency; it touches no device and no source. use super::{ ADAPT_DECAY_DEFAULT, EXPERTS, Error, GroupSplit, LAYERS, MAX_WINDOW_ENTRIES, ORIGINAL_VERIFY_MAX_PCIE_FETCHES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs index 594a7c04..0124f481 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs @@ -1,5 +1,5 @@ -//! Methods of `PcieMode`: `graph_mode`. -//! Methods of `ExpertTierConfig`: `decode_headroom_mib`, `off`, `enabled`, `effective_slots` and 14 more. +//! Configuration of the VRAM expert tier: ExpertTierConfig (slots, reserves, PCIe share and mode, adaptation, seed; +//! defaults, validation, `LELEKA_ORIGINAL_SERVE_*` switches) and the route tail-skip rank of a decode phase. use super::{ AtomicU32, EXPERTS, EnvSource, Error, ExpertTierConfig, GroupSplit, LAYERS, Ordering, OriginalExpertCache, PathBuf, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs index 0fc54c52..a6556578 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the expert tier rules: reserves and decode headroom, the selection-based swap ranking, the window split +//! (residents, PCIe share, tail skip, invalid ids), the lag controller, the PCIe mode and the off-by-default config. use super::{ EXPERTS, ExpertTierConfig, GroupSplit, LAYERS, PcieLag, PcieMode, PcieSplitPolicy, ResidencyState, RoutedGroup, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs index 20f401d6..e7617ff2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the serve conversation policy over a fake stack: a continuing request resumes at its last turn, a settled +//! session continues live, cancel and failure keep or drop checkpoints, the chain is bounded and reread mode works. use super::{ConversationConfig, Error, PromptOptions, RequestStart, ResumeDevice, ServeConversation, TURN_TOKEN}; use crate::backend::original_prompt::{PlanLimits, PromptPath, PromptPlan, ResumePoint}; 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 f154bb10..ad4b52a8 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 @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `settle_lent_refills`, `report_tier_request`, `pcie_num_for_report`, `report_req... -//! Implements `PrefixDevice for OriginalServeStack`, `RequestOwners for OriginalServeStack` and 1 more. +//! The ports OriginalServeStack implements for its callers: the prefix cache's device side (`PrefixDevice`), the +//! request flow (`RequestOwners`) and the serve device (`ServeDevice`), plus lent-slot refill and tier reports. use super::{ Clock, Error, OriginalServeStack, PARKED_BYTES_PER_TOKEN, PARKED_STATE_ESTIMATE, ParkedBlock, PrefixDevice, 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/original_serve_stack_methods/original_serve_stack_decode_phase.rs index d9fda73c..ec4ba579 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/original_serve_stack_methods/original_serve_stack_decode_phase.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `decode_phase`. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! OriginalServeStack::decode_phase: hands the twelve QSA owners to a fresh verifier and runs the request's decode. +//! The steps and the read-only view of the phase are in the submodules `decode_steps` and `decode_view`. use super::{ AssembleFailure, AssembleInputs, Began, Context, CpuExpertPool, DecodeGraphKey, DecodeResources, DenseWeightCache, 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/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs index e31a0eb7..988db864 100644 --- 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/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs @@ -1,6 +1,5 @@ -//! The phases of `OriginalServeStack::decode_phase` (STRA-338 size4): the request's start, the assembly of the verifier -//! window, the settlement of its outcome and the serve step. The order of the operations, the error paths and the -//! log lines are those of the single function they were taken from. +//! The phases of `OriginalServeStack::decode_phase`: the request's start, the assembly of the verifier window, the +//! settlement of its outcome and the serve step. Operation order, error paths and log lines are the decode's own. use super::decode_view::{Book, DecodeView, Extra, Ids, Owners, Policy, Reads, Refill, Tier}; use super::{ 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/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs index 9976d2aa..e5a9ea72 100644 --- 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/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs @@ -1,4 +1,4 @@ -//! The stack's fields a decode works on, borrowed one by one and grouped by who reads or writes them (STRA-338 size4). +//! The stack's fields a decode works on, borrowed one by one and grouped by who reads or writes them. //! The stack's own layout is flat and the verifier window resources of an assembly borrow its caches for the whole //! phase, so the phases cannot be `&mut self` methods of the stack; each phase is a method of this view instead. 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/original_serve_stack_methods/original_serve_stack_memory_classes.rs index 09005434..0365def4 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/original_serve_stack_methods/original_serve_stack_memory_classes.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `health`, `serve`, `apply_memory_directive`, `note_memory` and 23 more. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! Request-level surface of OriginalServeStack: stack health, `serve`, following the memory governor between +//! requests, registering allocation classes with the memory inventory, and the speculative window arms. use super::{ Error, ExpertTierConfig, OriginalServeStack, PLE_HISTORY_BYTES, PLE_SCRATCH_BYTES, PrefixMatch, PrefixSummary, 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/original_serve_stack_methods/original_serve_stack_metrics_close.rs index f35e044a..fccfed7f 100644 --- 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/original_serve_stack_methods/original_serve_stack_metrics_close.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `prefix_metrics`, `prefix_bytes`, `prefix_budget_bytes`, `retire_held` and 2 more. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! Prefix cache metrics of OriginalServeStack, retirement of kept decode graphs, closing of every owner in dependency +//! order (the first failure is reported after all were attempted) and marking the stack broken. use super::{Error, ModelBinding, OriginalServeStack, Result, retire_kept}; 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/original_serve_stack_methods/original_serve_stack_open.rs index ddfd5a34..4f578b87 100644 --- 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/original_serve_stack_methods/original_serve_stack_open.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `open`. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! OriginalServeStack::open: the generate.cpp start-up over the model binding (embedding, native head, dense weights, +//! MoE cache, session, prompt executor with MTP drafter, prefill arena, per-request stages). use super::{ Context, CpuExpertPool, DenseWeightCache, DeviceRef, Error, ExecutorOpening, ExpertBlobSizes, GraphReuse, 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/original_serve_stack_methods/original_serve_stack_open/assemble.rs index 5804f06a..762f9f38 100644 --- 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/original_serve_stack_methods/original_serve_stack_open/assemble.rs @@ -1,5 +1,5 @@ -//! The start and the end of `OriginalServeStack::open`, moved out of it by STRA-338 (size): the config-derived values -//! computed before any allocation and the final assembly of the stack from the opened parts. +//! The two ends of `OriginalServeStack::open`: the config-derived values computed before any allocation and the +//! final assembly of the stack from the opened parts. use super::open_phases::{Buffers, Core, TierParts}; use super::{ 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/original_serve_stack_methods/original_serve_stack_open/open_phases.rs index 6c212676..365fc7cf 100644 --- 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/original_serve_stack_methods/original_serve_stack_open/open_phases.rs @@ -1,5 +1,5 @@ -//! Phases of `OriginalServeStack::open`, moved out of it by STRA-338 (size): each helper runs one step of the startup -//! in the order `open` called it, with the same stage marks, notes and error context. +//! The steps of `OriginalServeStack::open`: each helper runs one step of the start-up in order, with its stage +//! marks, notes and error context. use super::{ Context, CpuExpertPool, DenseWeightCache, DeviceRef, ExecutorOpening, KarPleCache, LoanTier, ModelBinding, 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/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs index 7ea70044..3396e3c5 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/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `prefill_chunk`, `prefix_after_prefill`, `prefix_after_decode`, `prefix_after_re... -//! Functions: `report_decode_tail`, `lend_tail`. +//! One published prompt chunk of OriginalServeStack (with or without a loan of the expert cache's last slots) and +//! the prefix and conversation checkpoints taken after a chunk, at the end of prefill and of decode, or on a cancel. use super::{ ChunkOutcome, Error, OriginalExpertCache, OriginalPrefillArena, OriginalPromptInput, OriginalServeStack, 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/original_serve_stack_methods/original_serve_stack_prefill_phase.rs index 701296b1..c8818d05 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/original_serve_stack_methods/original_serve_stack_prefill_phase.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `prefill_phase`, `refill_deferred`, `begin_prefill`, `refill_after_read` and 8 m... -//! Functions: `trace_action`, `seed_rows_capped`, `trace_seed_report`, `coverage_by_layer`. +//! The prefill phase of OriginalServeStack: conditions prompt[resume..n-1] chunk by chunk, refills lent expert +//! slots, seeds the expert tier from the prompt's routing and sets up the MTP actor and prompt options. use super::{ Clock, Error, ModelBinding, OriginalPromptInput, OriginalServeStack, PlanLimits, PromptOptions, PromptPath, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs index 20d4ac6d..a293cd40 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixConfig`: `auto`, `validate`, `resolved_block`, `resolve_budget`. -//! Functions: `admission_reading`, `lcp`. +//! PrefixConfig: auto defaults, validation, block size and host byte budget of the cross-session prefix cache, +//! and the memory reading a checkpoint is admitted against (re-judged once after the governor trims pages). use super::{Error, PolicyParams, PrefixBudget, PrefixConfig, TailMode, budget}; 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 ce52860e..ed353f1a 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `prefix_serve_after_phase_parking`, `prefix_serve_store_and_shedding`. -//! Split out of `prefix` to keep its files under the line limit. +//! PrefixServe: the per-stack prefix cache policy, split into its store, clock and shedding side and the side that +//! plans, parks and imports checkpoints around the prefill and decode phases. use super::{ AnyClock, ByteSize, ChunkOutcome, Clock, Consider, Error, PendingTail, PrefixConfig, PrefixDevice, PrefixMatch, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs index 241c511c..99378cda 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixServe`: `after_chunk`, `plan_chunk`, `park_chunk`, `park_missing` and 16 more. Defines `Point`. -//! Split out of `prefix_serve` to keep its files under the line limit. +//! The checkpoint side of PrefixServe: after a published chunk, at the end of prefill and of decode (or deferred +//! until after the response) it plans, parks and admits a checkpoint; a failure costs the cache, never the request. use super::{ ByteSize, ChunkOutcome, Clock, Consider, Error, PendingTail, PrefixDevice, PrefixServe, PrefixStore, TailMode, 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/prefix_serve_store_and_shedding.rs index 0112cd61..3710ff9f 100644 --- 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/prefix_serve_store_and_shedding.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixServe`: `new`, `new_store`, `with_clock`, `wall_ms` and 23 more. Defines `ImportPlan`. -//! Split out of `prefix_serve` to keep its files under the line limit. +//! The store side of PrefixServe: construction over a namespace and clock, shedding to the memory governor's +//! directive, bypass mode, and read-only accessors (bytes, budget, nodes, blocks, summary, `prefix_match`). use super::{ AnyClock, ByteSize, Clock, Error, PrefixConfig, PrefixDevice, PrefixMatch, PrefixServe, PrefixStore, PrefixSummary, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs index bc5792ca..f59a1559 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Test fixture of the stack prefix cache: a fake device with parked state and blocks, prompt and session generators +//! and helpers that drive a request through `PrefixServe` (begin, read chunks, turn). The scenarios are submodules. use super::{ByteSize, ChunkOutcome, Error, PrefixBudget, PrefixConfig, PrefixDevice, PrefixServe, Start, TailMode}; use crate::backend::original_prompt::{PlanLimits, PromptOptions, PromptPath, PromptPlan, ResumePoint}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs index d3a8198e..cd9568f1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs @@ -1,8 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_one_token_prompt_reads_nothing_and_claims_nothing, -//! a_failed_import_is_an_error_for_the_caller_and_invalidate_forgets_everything, -//! the_budget_bounds_the_store_and_the_newest_frontier_survives, -//! a_memory_shed_evicts_to_the_target_and_the_configured_budget_comes_back .... +//! Pins the prefix cache edge cases: a one-token prompt reads and claims nothing, a failed import is the caller's +//! error and invalidate forgets everything, the budget bounds the store, and a memory shed evicts then restores. use super::{ Block, ChunkOutcome, Fake, G, PrefixBudget, PrefixConfig, PrefixServe, State, cfg, doc, full_digest, governor, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs index c1c82681..a21acf45 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs @@ -1,8 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_second_session_with_the_same_system_prompt_resumes_from_the_shared_blocks_and_ends_in_the_full_reads_state, -//! interleaved_sessions_each_resume_from_their_own_deepest_checkpoint, -//! a_miss_resets_the_owners_so_nothing_is_claimed_even_if_the_request_is_cancelled_before_its_first_chunk, -//! a_checkpoint_at_the_end_of_the_prefill_lets_the_next_turn_resume_at_the_exact_position .... +//! Pins prefix reuse across sessions: a second session with the same system prompt resumes from the shared blocks, +//! interleaved sessions use their own deepest checkpoint, a miss resets the owners, a turn resumes at its exact end. use super::{ Block, Fake, G, PrefixServe, State, TailMode, cfg, doc, full_digest, request, serve, session, tail_serve, turn, 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 01bc1ede..9a58c1fe 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 @@ -1,5 +1,5 @@ -//! Methods of `PromptChunk`: `run`. Methods of `OriginalServeStack`: `prefix_resume`, `prefix_begin`. -//! Implements `ResumeDevice for OriginalServeStack`. +//! PromptChunk::run (one prefill forward over a chunk, then publication), the conversation cache's device side +//! (`ResumeDevice`) over the stack owners, and the bring-up notes (VRAM ledger, kernel selection, logs). use super::{ ChunkCaches, ChunkDraft, Context, DBG_T0, Error, OriginalPrefillArena, OriginalServeStack, PrefixServe, 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_and_ttft_marks.rs index 04758a9b..a95c73bc 100644 --- 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_and_ttft_marks.rs @@ -1,5 +1,5 @@ -//! Methods of `TtftMarks`: `start`, `since`, `note_first_round`, `as_array`. -//! Methods of `StackConfig`: `new`, `kv_footprint`, `capacity_invalid`, `context_invalid` and 1 more. +//! StackConfig (defaults, KV footprint, capacity and context validation), TtftMarks (the time-to-first-token marks of +//! a request), the prefill loan ladder helpers and the byte sizes of parked stack state and blocks. use super::{ ADMITTED_CAPACITIES, AnyClock, ByteSize, CPU_WORKERS, Clock, ConversationConfig, DEFAULT_CAPACITY, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs index 67232669..e1df5ea1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs @@ -1,5 +1,5 @@ -//! Groups of cohesive plain-data fields of `OriginalServeStack`, moved out of it by STRA-338 (size). None owns a -//! device resource; each is declared at the position of its first member, so the stack's drop order is unchanged. +//! Groups of cohesive plain-data fields of `OriginalServeStack`. None owns a device resource; each is declared at +//! the position of its first member, so the stack's drop order is unchanged. use super::{ Error, ExpertBlobSizes, LoanTier, OriginalMtpFullPolicy, OriginalMtpScalarPolicy, OriginalServeSettings, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs index f2a4bbe0..8031996a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the stack configuration rules: chunk loans take the smallest rung that holds them, the default chunk is an +//! admitted capacity, the conversation cache is on by default, KV defaults to INT8 and plan errors keep their class. use super::{ ADMITTED_CAPACITIES, Error, ExpertBlobSizes, KvFormat, LoanTier, PlanError, PrefillLayoutOptions, StackConfig, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs index cba5d972..83742994 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the verifier assembly fallback: a graph out-of-memory names the widest window worth recording, assembly is +//! retried with narrower windows until one fits, any other failure stops at once, and the PLE image has nine slots. use super::{ Error, PLE_HISTORY_BYTES, PLE_HISTORY_VALUES, ServeFailure, Stage, assemble_with_window_fallback, window_cap_after, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs index e96db58b..e48c9f7c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalSpecController`: `finish_round`, `finish_request`. -//! Split out of `original_spec_controller` to keep its files under the line limit. +//! The end of a speculative round and of a request: `finish_round` runs after the committed tokens were emitted +//! (drafts the next window, joins adaptive work, drains the verified owner) and `finish_request` waits the last +//! commit. EOS and length skip drafting; a later draft error never un-commits what was already emitted. use super::{ CommittedRound, DraftBatch, Error, OriginalSpecController, OriginalSpecEngine, Result, RoundFacts, SpecResult, 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/original_spec_controller_methods/original_spec_controller_start_request.rs index 5aacf40b..a005843f 100644 --- 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/original_spec_controller_methods/original_spec_controller_start_request.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalSpecController`: `planned_host_bytes`, `new`, `set_final_draft`, `begin_request` and 11 more. -//! Split out of `original_spec_controller_methods` to keep its files under the line limit. +//! Start of a request for OriginalSpecController: construction and host byte accounting, `begin_request` (precharge +//! of all append capacity, reset of the suffix state per request), read-only views, round stats and `abort`. Window +//! policy and the adaptive cadence survive across requests; the prompt history does not. use super::{ AdaptivePolicy, DraftBatch, DraftPolicy, Error, MAX_T, OriginalSpecController, OriginalSpecEngine, PrefixMemo, Rc, 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/original_spec_controller_methods/original_spec_controller_verify_commit.rs index 249028bf..4fa13d01 100644 --- 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/original_spec_controller_methods/original_spec_controller_verify_commit.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalSpecController`: `verify_commit`. -//! Split out of `original_spec_controller_methods` to keep its files under the line limit. +//! `OriginalSpecController::verify_commit`: one round entry point, the verify half then the commit half, with the +//! steps in `verify_round_steps` and `commit_round_steps`. use super::{CommittedRound, Error, OriginalSpecController, OriginalSpecEngine, Round, SpecResult, window_inputs}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs index d1b8c306..4b26e395 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Test world of the speculative controller: a scripted engine (`Fake`) with a deterministic model and fault trips, +//! and helpers that drive requests through the controller. The scenarios are submodules and the golden transcripts. use super::super::original_spec_draft::{DraftPick, FirstSeedPoint, OriginalFirstDraftEngine, TargetSeedRow}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs index 85ce291a..dd7a8672 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs @@ -1,7 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! adaptation_join_failure_is_reported_even_after_a_good_draft, -//! finish_round_refuses_a_receipt_from_another_controller, a_request_cannot_restart_while_a_draft_is_pending, -//! policy_and_adaptive_cadence_survive_across_requests .... +//! Pins round bookkeeping: a failed adaptation join is reported even after a good draft, a receipt from another +//! controller is refused, a request cannot restart with a draft pending, and policy and cadence survive requests. use super::{ DraftPick, DraftPreparation, DraftSampling, Error, Fake, FirstSeedPoint, OriginalFirstDraftEngine, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs index 59862f8f..d3224760 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs @@ -1,7 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! config_rejects_out_of_range_and_mtp_zero_means_max_t, host_budget_is_checked_and_grows_with_the_request, -//! begin_request_validates_tokens_and_rejects_a_live_request, -//! the_adaptive_window_emits_the_same_text_as_a_fixed_one_under_any_drafter .... +//! Pins the controller's admission rules: out-of-range config refused (mtp zero means max T), host budget checked and +//! growing with the request, request tokens validated, and adaptive output equal to a fixed window's under any +//! drafter. use super::{ AdaptiveConfig, EndRunSetup, Error, Fake, NanGuard, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, begin, config, drive, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs index 39e23214..24727893 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs @@ -1,7 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_non_finite_window_is_run_again_from_its_checkpoint_and_the_request_completes, -//! the_guard_costs_nothing_when_nothing_is_wrong, a_window_that_stays_non_finite_fails_the_request_after_the_retries, -//! only_a_non_finite_failure_is_retried_and_a_guard_that_is_off_retries_nothing .... +//! Pins the non-finite window guard: a bad window is run again from its checkpoint and the request completes, the +//! guard costs nothing when nothing is wrong, a persistent failure fails the request, and only a non-finite one is +//! retried. use super::{ Error, Fake, NanGuard, OriginalSpecController, OriginalSpecEngine, SpecError, VOCAB, begin, config, drive, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs index 8a3f322c..524ec46d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs @@ -1,5 +1,5 @@ -//! Methods of `NanGuard`: `off`, `with_retries`, `with_injection`, `parse_switch` and 5 more. -//! Methods of `SpecConfig`: `new`, `with_nan_guard`, `with_adaptive`. Implements `From for SpecError`. +//! Settings of the speculative controller: NanGuard (non-finite window retry policy and its injection), SpecConfig +//! (window, context, suffix and adaptive options), the round accessors, and the `LELEKA_SPEC_TRACE/STATS` switches. use super::{AdaptiveConfig, CommittedRound, Error, MAX_T, NanGuard, Result, SpecConfig, SpecError, SpecWindow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs index 7d2d242e..31d7e2fc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptSample`: `greedy`, `conditioning`, `validate`, `matches_final` and 3 more. -//! Methods of `FiniteLogits`: `validate_for`. +//! OriginalPromptSample: the authentic head result of the prompt's final row (greedy next token or the known +//! conditioning token) tied to one pending final phase, checked again before MTP uses it; and +//! FiniteLogits::validate_for. use super::{ BindingIdentity, Error, FiniteLogits, LogitValues, ModelBinding, OriginalPromptSample, Position, Result, TokenId, 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 3b504d18..2cef1f5a 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `output_stage_load_and_logits`, `output_stage_sampling_projection`. -//! Split out of `output` to keep its files under the line limit. +//! OutputStage: the loaded Q6_K output head, split into loading and logits (`output_stage_load_and_logits`) and the +//! sampling and projection of a mixed residual (`output_stage_sampling_projection`). use super::{ ACTIVATION_BYTES, BindingIdentity, Context, DeviceBuffer, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, 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/output_stage_load_and_logits.rs index 78a90181..88669491 100644 --- 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/output_stage_load_and_logits.rs @@ -1,5 +1,5 @@ -//! Methods of `OutputStage`: `logits_original_prompt`, `finite_final_mix`, `certify_prompt_logits`, `load` and 13 more. -//! Split out of `output_stage` to keep its files under the line limit. +//! OutputStage loading and logits: uploads the fixed Q6_K head once per context, the compact (device argmax) variant, +//! the logits entry points for prompt, decode and MTP greedy, step checks and arming the per-request sampler. use super::{ BindingIdentity, Context, Dimension, EMBEDDING, Error, FiniteLogits, GrStage, HEAD_GREEDY_WORKSPACE_BYTES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs index ea80ea78..76b1e352 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs @@ -1,5 +1,6 @@ -//! Methods of `OutputStage`: `sampler_wants`, `sample_complete`, `check_projection`, `with_projected` and 8 more. -//! Split out of `output_stage` to keep its files under the line limit. +//! OutputStage projection and sampling: uploads the mixed residual, projects it through the Q6_K head into a +//! candidate logit buffer, selects greedily on the device or reads the full vector, and applies the armed request +//! sampler. Short-lived buffers are accounted before the result is published; the first error stays primary. use super::{ ACTIVATION_BYTES, BindingIdentity, Context, DeviceBuffer, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs index c4f9ece8..023dcf37 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs @@ -1,5 +1,5 @@ -//! Methods of `OutputStage`: `test_prefix_begin_target`, `test_reset_replay_record`, `test_reset_replay_capture`, `s... -//! Functions: `greedy`, `selected_token`, `validate_weight_owner`, `encode_activation` and 4 more. +//! Test-only replay hooks of OutputStage (record logits of a reset or prefix replay, count compact completions) and +//! the shared helpers of the stage: greedy pick, activation and logit encoding, weight-owner check and error mapping. use super::{ ACTIVATION_BYTES, BindingIdentity, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, HeadGreedySelection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs index d7cb62f7..423b2ab9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the output head's rules: weights refused across bindings before extents, greedy ties take the lowest id, a +//! late strictly greater logit wins, incomplete or non-finite vectors are refused and cleanup errors take precedence. use super::{ BindingIdentity, Dimension, Error, FiniteF32, FiniteLogits, LOGIT_BYTES, LogitValues, OutputWeights, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs index 6425e09e..3f79bd2a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `produce_original_gdn`, `read_completion`. -//! Split out of `prompt_device_rows` to keep its files under the line limit. +//! PromptDeviceRead: a read of the prompt chunk's device rows at one GR role, split into producing the Original GDN +//! and QSA layers (`produce_original_gdn`) and validating and completing the read (`read_completion`). use super::{ Context, DenseWeightCache, Dimension, Error, GrRole, InputReady, LayerId, ModelBinding, OriginalDeviceBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs index 87f2787c..9948fc63 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs @@ -1,5 +1,6 @@ -//! Methods of `Lap`: `new`, `off`, `at`. Methods of `GdnLayer`: `enter`, `compute`, `leave`. -//! Functions: `produce_original_gdn`, `produce_original_qsa`, `normed_gamma`, `produce_block` and 1 more. +//! Producers of one prompt layer on the device: the full GDN layer (state in, compute, state out) and the resident +//! QSA layer (setup, projections, indexer, attention, seal), plus the layer lap timing of the command profile. +//! End state enters the journal only from the completed whole-layer producer. use super::{ Context, DenseWeightCache, Error, GrRole, InputReady, LayerId, ModelBinding, OriginalDeviceBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs index 511314a3..6fe797da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptDeviceRead`: `validate_original_rows`, `validate_row`, `device`, `attention_layer` and 8 more. -//! Split out of `prompt_device_read` to keep its files under the line limit. +//! Completion of a PromptDeviceRead: validates the chunk's rows against the phase, runs the GDN, FFN and GR steps +//! over the same physical arena, and checks the next role. Every current row must pass chronological validation. use super::super::super::gdn::PromptSource; use super::produce_original_gdn::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs index 45667a80..79351a38 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptPleHistory`: `from_prior`, `into_completed`, `close`. -//! Functions: `micro_driver_error`, `run_transfer`. +//! PromptPleHistory: the device copy of the PLE history a prefill chunk advances, seeded from the session's prior and +//! returned as the completed history; plus the transfer helper and GR driver error mapping of the PLE micro path. use super::{ BindingIdentity, Context, Error, ModelBinding, OriginalPleHistory, OriginalPromptDevice, PlePrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs index cbdb16d7..c16c1aa6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `prompt_device_rows`, `prompt_device_rows_ple_read`, `source_input_deref`. -//! Split out of `prompt_device_rows` to keep its files under the line limit. +//! PromptDeviceRows: the prompt chunk's physical device rows, with its final-row preview, PLE application and device +//! reads (`prompt_device_rows`, `prompt_device_rows_ple_read`) and the source input views (`source_input_deref`). use super::{ BindingIdentity, Context, DenseWeightCache, Dimension, Error, FinalProduct, GrRole, InputReady, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs index 3f8ec7d5..b69b2de3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs @@ -1,5 +1,6 @@ -//! Methods of `PromptDeviceRows`: `final_point`, `preview_conditioning`, `preview_final`, `with_final_residual` and ... -//! Split out of `std_ops_deref` to keep its files under the line limit. +//! PromptDeviceRows: initial staging of the chunk's rows to the device, the final point of the phase, and the +//! conditioning and final previews that keep the all-row residual for the shifted MTP input. +//! Only the final-phase owner can lend the retained residual to the MTP producer. use super::{ Context, DenseWeightCache, Error, FinalProduct, GrRole, ModelBinding, OriginalDeviceResidual, OriginalPromptDevice, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs index 4ce3a820..0aff481c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptDeviceRows`: `apply_ple`, `check_ple`, `ple_weights`, `read` and 1 more. -//! Split out of `std_ops_deref` to keep its files under the line limit. +//! PromptDeviceRows PLE and read: applies the per-layer PLE step to the staged rows, checks and resolves the PLE +//! weights of the binding, and reads the rows to the device for a GR role. use super::{ Context, DenseWeightCache, Error, GrRole, ModelBinding, OriginalDeviceGrRead, OriginalDeviceResidual, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs index 4eda4dab..507c96d0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptDeviceSource`: `from_current`, `check_input_values`, `from_original`. -//! Methods of `PromptDeviceFinal`: `validate`, `token`, `position`, `streams` and 1 more. +//! Sources of the prompt rows: PromptDeviceSource (from the current input or the Original key), PromptDeviceFinal +//! accessors, and the checks that the sources are the ones validated before staging, a read or completion. use super::{ BindingIdentity, Context, DenseWeightCache, Dimension, Error, FinalProduct, GrRole, InputReady, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs index d4180e19..bc95cf35 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs @@ -1,5 +1,6 @@ -//! Methods of `RowFactory`: `row`. -//! Functions: `check_inputs`, `check_row`, `check_successor`, `gdn_matrix_of` and 8 more. Defines `RowFactory`. +//! Q6_K projection of attention input columns (GDN QKV or a QSA role) for a run of consecutive rows: validates that +//! every input is a certified attention input of its layer, then projects and returns rows on the host or retained +//! on the device (GDN QKV only). use super::{ Cell, ColumnKey, ColumnTarget, Context, DenseWeightCache, DeviceBuffer, Error, GdnMatrixKind, GdnMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs index 0e1ad339..5bc3731c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs @@ -1,5 +1,6 @@ -//! Methods of `Role`: `rows`, `qsa`. Methods of `RetainedColumns`: `buffer`. Implements `Drop for RetainedColumns`. -//! Functions: `project`, `project_retained`. +//! The row types of the Q6 attention-column adapter: `ProjectionRow` (host row, taken once), `RetainedRow` and +//! `RetainedColumns` (device output shared by the rows of a batch). Each is checked against the binding, session +//! and input; a host row cannot be converted into a retained one or back. use super::{ ColumnKey, ColumnTarget, Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs index ca1ff099..4dde2d5a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs @@ -1,5 +1,6 @@ -//! Methods of `Q6Job`: `fence_refusal`, `admit_budget`, `project`, `download` and 1 more. -//! Functions: `numeric`, `numeric`, `numeric_retained`, `numeric_retained` and 1 more. Defines `Q6Buffers`, `Q6Job`. +//! The device run of one Q6_K column projection: upload, activation quantization, projection, readback or retention +//! of the output, and cleanup. Admission and quantization are identical for both ends; every failure marks the +//! shared fence failed and the first error is returned. use super::{Cell, Context, DeviceBuffer, Error, Result, download, driver_error}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs index e9f83e52..469f76db 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs @@ -1,5 +1,6 @@ -//! Methods of `AttendBuffers`: `upload`, `launch`. -//! Functions: `decode_selected_cached`, `attend_selected`, `settle_retained`, `attend_retained` and 8 more. +//! QSA attention over the selected cells with the retained device cache: upload query, keys and values, launch the +//! attend kernel, read the output back whole and gate it. The finite boundary stays before gating, so the gate +//! cannot mask a bad value; a failed launch or cleanup marks the shared fence failed. use super::{ Cell, Context, DenseWeightCache, DeviceBuffer, Error, ModelBinding, Q, QsaAttendBuffers, QsaAttended, QsaGated, 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 2c4681be..1dba59a8 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 @@ -1,5 +1,6 @@ -//! Methods of `NativeAttended`: `identity`, `values`, `gate`, `validate` and 4 more. -//! Methods of `NativePromptAttentionBatch`: `complete`, `owner`, `publish_row`, `locate` and 6 more. +//! The attended row of native prompt QSA attention (`NativeAttended`) and the chunk batch that completes it +//! (`NativePromptAttentionBatch`). Rows are published to the causal session one at a time, never as a batch-final +//! relabel, and each is checked against its chunk, layer and transaction first. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::qsa_index::QsaPending; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs index 654ad129..981cfb73 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaReady`: `identity`, `output`, `validate_origin`. -//! Methods of `QsaAttentionStage`: `decode_native`, `complete_native`, `decode`, `decode_selected` and 4 more. +//! `QsaReady` (the output of one attention layer step) and the `QsaAttentionStage` decode entry points: native decode +//! on the device, the selected-cache path and the uncached host path. Only the native completion reaches the pending +//! journal; the joint transaction still owns publication. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs index 54fe6a15..46505962 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaOwner`: `new`, `matches`. -//! Methods of `QsaPrior`: `oracle_capture_parts`, `test_reset_replay_numeric_eq`, `same_native_kv`, `same_pages` and... +//! The immutable QSA state handles: `QsaOwner` (identity of one session's QSA state family) and `QsaPrior` (one +//! layer's KV pages, pooled index keys and tail at a position), with their equality, extent and gather checks. +//! Also the serving context size and the device headroom a QSA step requires. use super::{ BindingIdentity, Directory, Error, KV, LayerId, PackedKv, Position, QsaOwner, QsaPrior, Rc, Result, Stage, State, 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/qsa_directory_sdet.rs index f93fc3a2..688be25f 100644 --- 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/qsa_directory_sdet.rs @@ -1,3 +1,6 @@ +//! Pins the persistent `Directory` at its 65536-entry limit: successors share their retained roots and payloads +//! (Rc identity), and iteration, replacement and fork of any earlier version leave the other versions unchanged. + use super::{Directory, Error, MAX_ENTRIES}; use std::rc::Rc; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs index 75bb6d83..9198eed9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs @@ -1,5 +1,5 @@ -//! Functions: `norm`, `upload_gamma`, `release_gamma`, `run_norm` and 15 more. Defines `BlockQuery`. -//! Split out of `qsa_index` to keep its files under the line limit. +//! Kernel runners of the QSA index path: norm, RoPE, query/gate split, K/V pack, index-key append, block scoring and +//! top-k selection, and the index-side projection. Every output is read back and checked finite or in range. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, KV, ModelBinding, Norm, PackedKv, Q, QGate, QsaLayerProjection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs index 8970e88c..e784d4c2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaIndexKeyCache`: `layer_bytes`, `new`, `with_eager`, `admit_mirror` and 9 more. -//! Functions: `max_rows`, `update`, `append_rows`, `capacity` and 2 more. +//! Legacy device mirror of the pooled index keys (`QsaIndexKeyCache`, one entry per attention layer) and the plan +//! that brings it from one `QsaPrior` to its successor: reload, append one pooled row, or change only the spare row. +//! Reset, replay and speculative branches are misses. A layer's mirror is allocated on its first selection. use super::{ BindingIdentity, BlockQuery, Cell, Context, Entry, Error, QsaIndexKeyCache, QsaPrior, QsaSelectionRequest, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs index 436d28fd..194430f0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs @@ -1,5 +1,4 @@ -//! Functions: `synthetic_late_prior`, `synthetic_late_prior_for`. -//! Split out of `index_resident` to keep its files under the line limit. +//! Test fixture: a `QsaPrior` of one zeroed KV page at a late position, bound to a given or test identity. #[cfg(test)] use super::{BindingIdentity, Directory, KvPage, LayerId, PAGE, QsaOwner, QsaPrior, Rc, State}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs index 38fbfce0..2d2067f8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaCompleted`: `first`, `rows`, `layer`, `validate_rows` and 7 more. -//! Defines `ResidentSealOwners`. +//! `ResidentQsaCompleted`: the rows a resident QSA layer completed in one prompt window, before they are sealed. +//! Checks the rows against the inputs and the session, finds a transaction's row, then seals the accepted prefix +//! (index and mapped K/V commit) or aborts. `ResidentSealOwners` names the owners a seal commits through. use super::resident_qsa_layer::mint; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs index 1b9f3f5e..aae0da9c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaLayer`: `new`, `empty_guards`, `current`, `validate` and 11 more. -//! Functions: `check_empty`, `mint`, `rehome`, `resident_identities` and 1 more. +//! `ResidentQsaLayer` lifecycle: construction from an empty lineage, validation of a prior, prepare of a prompt +//! window, prefix prefetch, publication of a seal and restore to a session checkpoint. Holds the resident index +//! image and mapped K/V journal; rows are provenance only, never a host image. use super::{ BindingIdentity, Context, DenseWeightCache, Error, InputReady, LayerId, ModelBinding, NativeBatchWorkspace, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs index 262a2bed..4974d8cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaPrior`: `next_position`, `layer`, `same_prior`, `validate_for_session` and 5 more. -//! Methods of `ParkedLayerSpan`: `bytes`. +//! `ResidentQsaPrior`: the lineage witness of a resident QSA layer (index checkpoint plus mapped K/V prefix at one +//! position). Checks it against a session or model identity and re-stamps it: empty lineage onto a new branch, +//! a checkpoint onto the current branch generation, or advanced after the verifier committed rows. use super::{ BindingIdentity, Error, LayerId, ModelBinding, OriginalQsaIndexCheckpoint, OriginalQsaMappedPrefix, 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/resident_qsa_span_export_and_seal.rs index 7147ada6..bfcc2a00 100644 --- 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/resident_qsa_span_export_and_seal.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaLayer`: `export_span`, `export_kv`, `export_index`, `export_tail` and 5 more. -//! Methods of `ResidentQsaPublication`: `publish_validated`. Functions: `span_views`. Defines `SpanViews`. +//! Moving a resident QSA layer's state: export of a prefix span and tail for the prefix cache, import of a parked +//! prefix, the one-way handoff of the index and mapped K/V owners to the native verifier (and back), and the seal +//! and publication types that make a completed window canonical. use super::resident_qsa_layer::rehome; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs index 3fc2e878..ae9f5f54 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs @@ -1,5 +1,5 @@ -//! Functions: `out_matrix`, `project_gated_out`, `release_gate_buffers`, `gate_and_out`. -//! Split out of `scalar` to keep its files under the line limit. +//! The gate and Out projection of the scalar QSA continuation: the attended tensor is gated, then projected by the +//! layer's quantized Out matrix. Both the attended and the gated tensors are checked finite before Out runs. use super::{ BoundDense, Context, DenseWeightCache, DeviceBuffer, Error, GateBuffers, GateDevices, GateRows, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs index 212c632a..c1a30c86 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs @@ -1,5 +1,5 @@ -//! Methods of `ScalarHost`: `gather`, `select`. -//! Methods of `ResidentQsaLayer`: `scalar_guards`, `check_scalar_prior`, `prepare_scalar`. +//! Admission of one scalar row (target or MTP) on a resident QSA layer: host gather and block selection, the guards +//! of the step, the lineage and the weights, and `prepare_scalar`, before any device work. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, NativeBatchWorkspace, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs index 75d8fa5d..91dce652 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs @@ -1,5 +1,5 @@ -//! Methods of `ResidentQsaScalar`: `validate`, `check_identity`, `attend`, `gate_out` and 3 more. -//! Methods of `ResidentQsaScalarReady`: `into_parts`, `check_identity`. +//! Run of one scalar row on a resident QSA layer: append, attend over the selected blocks, gate and Out project, +//! then seal or abort. `ResidentQsaScalarReady` is consumed once, after an identity check. use super::{ BoundDense, Cell, Context, DenseWeightCache, Error, GateBuffers, GateDevices, GateRows, GrRole, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs index 666be817..baaa73bf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaIndexStage`: `prepare`, `prepare_projected`, `prepare_impl`, `prepare_host_rows` and 4 more. -//! Methods of `QsaPrep`: `layer_projection`, `project`, `project_column`, `key_stage` and 5 more. Defines `QsaPrep`. +//! `QsaIndexStage::prepare`: the QSA preparation of one token step (query, gate, KV append, selected block ids). +//! Projects the host rows or the native prompt row, then builds the next prior as a pending candidate that is +//! published only at token commit. Admission checks the binding, layer, position and residual input first. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, Norm, Position, ProjectionSources, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs index 44765953..97b79c78 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs @@ -1,5 +1,5 @@ -//! Methods of `QsaPending`: `new`, `next_pooled`, `admit`, `next_page` and 5 more. -//! Methods of `QsaPrepared`: `identity`, `validate_for`, `validate_binding`, `validate_origin` and 7 more. +//! The QSA successor candidate: `QsaPending` builds the next `QsaPrior` (one more KV cell, pooled key, tail) from a +//! prior; `QsaPrepared` carries the query, gate, selected ids and pending state to attention, with origin checks. use super::{ BindingIdentity, Directory, Error, KV, KvPage, LayerId, PAGE, PackedKv, Position, QsaPending, QsaPrepared, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs index c32ace55..1980b7b7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs @@ -1,5 +1,5 @@ -//! Functions: `dispatch_projection`, `project_input`, `project_input_numeric`, `project_cached_out` and 4 more. -//! Defines `QsaMatrixLayout`, `QsaLayerProjection`, `ProjectionSources`. +//! Device projections of the QSA index path: dispatch by matrix layout, project an input column through the lease, +//! the resident cache or an uploaded matrix, and the Out projection. A device failure marks the transport failed. use super::{ Bf16ProjectionShape, Cell, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DriverError, Error, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs index f3e52a4e..f9732e8b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of the selected-cell cache (moved out of the file by STRA-338; the test ids are unchanged). +//! Pins the selected-cell plan: page lineage, tail checkpoints, reset, refusals and order, and that weak entries +//! retire without retaining reset pages or speculative branch payloads. use super::{ BindingIdentity, Error, KV, LayerDirectory, LayerId, Plan, Position, QsaOwner, QsaPending, QsaPrior, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs index 3b1a0ee5..5588f8fb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs @@ -1,5 +1,5 @@ -//! Functions: `validate_ids`, `validate_half`, `validate_values`, `reserve` and 10 more. -//! Split out of `qsa_index` to keep its files under the line limit. +//! Checks and device helpers shared by the QSA index path: finite and range checks of ids, halfwords and values, +//! bounded allocation, upload and download of device buffers, and driver/binding error mapping. use super::{ Context, DenseWeightCache, DeviceBuffer, DriverError, Error, InputBindingError, ModelBinding, QsaMatrixKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs index a3ad4853..4eef2e3d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs @@ -1,5 +1,6 @@ -//! Methods of `NativeProjectionRow`: `validate`, `same_row`, `check_values`, `validate_fresh` and 7 more. -//! Functions: `native_error`, `native`, `project`, `chunk_owners` and 4 more. +//! One row of the native QSA prompt projections: the five projections (K, V, Q, index K, index Q) of a whole +//! micro-batch, split into per-row capabilities. Every row is checked as the chunk's own attention row, finite, +//! at consecutive positions. use super::{ AttentionRow, ChunkAttentionSlot, Context, DenseWeightCache, Error, GrRole, LayerId, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs index a155312c..9984b500 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs @@ -1,5 +1,5 @@ -//! Methods of `NativeOutRow`: `take`. -//! Functions: `concat_mixed`, `check_batches`, `check_shapes`, `retained_matrices` and 6 more. +//! The Out projection of the native QSA prompt batch: gather the attended rows and gates, project them together +//! and hand each row its slice, with the batch shapes, finite checks and retained matrices checked on the way. use super::{ AttendedRows, BindingIdentity, Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs index d1a886c0..4970af3d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs @@ -1,5 +1,6 @@ -//! Methods of `Report`: `guard`, `compare`. -//! Functions: `valid_product`, `float_bytes`, `close_all`, `finish` and 12 more. +//! Original reference chain and result tally of the router scratch proof (GPU tests only). +//! Runs the original per-call projection and route with independent transport owners, snapshots the retained slots, +//! and records guards and comparisons in a `Report`. use super::{ Bf16ProjectionShape, Context, DeviceBuffer, Error, MATRIX_BYTES, Report, Result, RouterBuffers, map_driver_error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs index 31ae8110..3771af48 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs @@ -1,5 +1,6 @@ -//! Methods of `Env`: `reset`, `project_refused`, `route_refused`, `project_refused_late`. Methods of `Held`: `release`. -//! Functions: `valid_reset`, `stage_buffers`, `install_workspace`, `open_proof` and 1 more. +//! Proof that the retained router scratch resets after valid, repeated and refused calls (GPU tests only). +//! Runs the original products first and the candidate over the repeat and reset order; refused inputs (non-finite, +//! wrong dimension, late NaN, foreign matrix, over budget) must leave every retained slot byte untouched. use super::{ Cell, Context, DeviceBuffer, EXTENTS, Error, MATRIX_BYTES, ROUTER_BYTES, Rc, Report, Result, RouterBuffers, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs index 79bd2f2b..3cb0b173 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnChunkStart`: `prior`, `count`, `binding`, `validate_binding` and 2 more. -//! Methods of `GdnChunkRow`: `ordinal`, `identity`, `readout_key`, `matches_readout` and 1 more. +//! Accessors and validation of the capabilities a prefill chunk mints around the rolling GDN state: the chunk anchor, +//! its rows, micro windows and seal, and their construction from an Original prompt transaction. Each is checked +//! against the binding, layer extent and row cursor before the chunk accepts it. use super::{ BindingIdentity, ChunkAttentionRow, ChunkCommit, ChunkFfnRow, Error, GdnChunkAnchor, GdnChunkMicro, GdnChunkRow, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs index 9848d78b..39409dea 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs @@ -1,5 +1,6 @@ -//! Functions: `host_charge_bounded`. -//! Split out of `chunk` to keep its files under the line limit. +//! Host-memory charge of a prefill chunk of `tokens` rows ending at `end`: rolling state, attention and column +//! temporaries, row metadata and the MTP half-window readback. Refused above the caller's row limit or beyond the +//! served cells. use super::{Error, Rc, Result}; 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 4a368b2b..1fca2742 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 @@ -1,5 +1,6 @@ -//! Groups the submodules `qwen_chunk_txn_attention_sources`, `qwen_chunk_txn_begin`, `qwen_chunk_txn_ffn_after_atten... -//! Split out of `chunk` to keep its files under the line limit. +//! The `QwenChunkTxn` impl family, split by phase: begin, attention sources, layer batch, micro windows and inputs, +//! GDN micro windows, FFN after attention, rows and witnesses, finish and publish. The children share this import +//! list. use super::{ ActiveMicroWindow, AttentionProgress, AttentionSource, BatchProgress, ChunkAttentionRow, ChunkCommit, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs index b0308c5c..051c4925 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `check_attention_column`, `open_attention_sources`, `admit_row_ple`, `publish_attentio... -//! Defines `DeviceGdnFfn`. +//! Attention reads of a chunk layer: opens the per-row source slots, admits layer-one PLE history, mints the row +//! capability of each completed read and prepares the batch and FFN steps (host and device GDN) that consume it. use super::super::super::super::gr::DetachedGrRead; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs index e2532473..5213dba6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `native_prefill_host_charge`, `begin`, `begin_windowed256`, `begin_bounded` and 9 more. -//! Functions: `prompt_origin`, `prompt_end`, `check_vocab`, `admit_prompt_host` and 1 more. Defines `PromptAdmission`. +//! Admission and start of a prefill chunk transaction: vocabulary, host-byte and device-budget checks, the rows with +//! their two predecessor tokens, and the phase queries. Normal serving caps a chunk at 64 rows; the windowed 256 form +//! is private. use super::{ AttentionProgress, BatchProgress, ChunkRowResidual, Dimension, Error, MicroProgress, ModelBinding, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs index 9d5b6a47..77d3c021 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `ffn_after_attention_step`, `prepare_ffn_after_attention`, `check_edge_step`, `check_e... -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! The FFN step after an attention row: validates the row's batch proof, rolls the pending PLE, GDN and QSA history +//! into the next priors (or the device GDN edge) and prepares the FFN injection. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::{gr::DetachedGrRead, moe_expert::PreparedMoeRow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs index f091b984..b11f5878 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `finish`, `check_finishable`, `witness_for`, `run_head` and 7 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! End of a prefill chunk: every layer of every row must be complete, then the output head (or the known next token), +//! one finite residual witness per row, state slots valid at the end position and the joint target and draft +//! publication. use super::{ ChunkCommit, ChunkDraftPublication, ChunkRowResidual, Dimension, Error, GrRole, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs index 9c54ed57..93b066a1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `prepare_attention_device_gdn`, `gdn_micro_cursors_off`, `gdn_micro_start`, `build_gdn... -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! GDN micro windows of a prefill layer: the whole prompt GDN window completes before any row edge advances, then its +//! per-row products enter the journal; also the check and enlisting of prepared attention-output rows against their +//! causal proofs. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::{gdn::chunk_device::ChunkEdge, gr::DetachedGrRead}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs index 0ed34d29..b83f4edd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `row_step`, `check_layer_row`, `layer`, `prepare_layer_batch` and 13 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Batched layer passes of a chunk: the row cursor of the unwindowed layer pass, opening and completing the batch of +//! a layer, minting `PreparedLayerRow` capabilities and checking batch outputs and FFN rows against their seals. use super::super::super::super::gdn::chunk_device::ChunkEdge; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs index faa83151..edafd15f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `input`, `settle_failure`, `ple_micro_cursors_off`, `check_ple_micro` and 11 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Inputs of a micro window: the layer-one PLE window and the attention window, prepared row by row in causal order +//! while the GR reads complete as one device batch. No row capability is published until the whole batch has +//! completed. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::gr::{DetachedGrRead, GrMicroInput}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs index 53f727f2..cb2fe6d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `check_micro_open`, `micro_misaligned`, `phase_in_flight`, `micro_width` and 19 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Lifecycle of a micro window in a windowed chunk: open on an idle transaction at the cursor, close with the exact +//! minted capability once the range is computed, advance the cursors, and the QSA priors at the start of a window. use super::{ ActiveMicroWindow, ChunkMicroWindow, Context, Error, LayerId, Position, QsaIndexPrior, QwenChunkTxn, Rc, Result, 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/qwen_chunk_txn_rows_and_witness.rs index e7c676cc..ade75d12 100644 --- 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/qwen_chunk_txn_rows_and_witness.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `qsa_prior_mismatch`, `validate_prompt_qsa_prior`, `original_session`, `rows` and 16 m... -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Row ids, positions and residual witnesses of a chunk transaction (what an MTP draft reads), the begin and finish +//! of a GDN chunk, and the stage view of one row. use super::{ ChunkRowResidual, Error, GdnChunkAnchor, GdnChunkJournal, GdnChunkSeal, GdnChunkStart, GdnPrior, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs index 45411d88..afc02aad 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs @@ -1,5 +1,5 @@ -//! Methods of `TestGdnComponentRows`: `new`, `start`, `row`, `seal`. -//! Split out of `chunk` to keep its files under the line limit. +//! Test-only GDN chunk journal of 65 fabricated rows over a given prior, so the chunk capabilities (start, row, seal) +//! can be exercised without a real chunk transaction. #[cfg(all(test, target_arch = "x86_64"))] use super::TestGdnComponentRows; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs index 14df878a..c8edd789 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs @@ -1,5 +1,5 @@ -//! Groups of cohesive fields of `QwenChunkTxn`, moved out of it by STRA-338 (size): the fields keep their declaration -//! order inside the transaction, so the drop order is unchanged. +//! Field groups of `QwenChunkTxn` by meaning (batch, attention and micro progress). Their order inside the +//! transaction fixes the drop order, so it must not change. use super::{ActiveMicroWindow, AttentionSource, LayerId, Rc}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs index 7e54be3a..0c4d8f60 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `qwen_chunk_txn_begin_verification`, `qwen_chunk_txn_verification_state`, `qwen_chunk_txn_v... -//! Split out of `verify` to keep its files under the line limit. +//! The `QwenChunkTxn` methods of MTP verification: starting a bounded window with its device GDN lease, the journal +//! of complete row states, and selecting and publishing the verified prefix. use super::{ ChunkCommit, ChunkRowResidual, Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, GrRole, HOST_LIMIT, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs index e23ed76b..7ac97543 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `validate_verification_source`, `preflight_mtp_verification`, `begin_mtp_verification`... -//! Functions: `verification_total_charge`. Defines `ReplayInputs`. +//! Start of a verification window: validates the source target step, preflights the host charge and the device GDN +//! workspace, records the device GDN proofs and replays them into the canonical prior; also the layer-one PLE row +//! checks. use super::{ Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, HOST_LIMIT, LayerId, ModelBinding, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs index 5bcdf675..70eb3bda 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `record_gdn_prior`, `record_qsa_prior`, `record_verification_prior`, `validate_state_g... -//! Functions: `journal_state`, `journal_state_mut`. +//! Journal of the complete per-row states of a verification window (GDN, QSA, PLE priors at each row end), their +//! validation, and the window finish: the head on the actual row state and one residual witness per row. use super::{ ChunkRowResidual, Dimension, Error, GrRole, InjectedResidual, LayerId, Position, PrefixState, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs index 645db8a8..d47acc17 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `verified_prefix_seed`, `verified_rows`, `select_verified_prefix`, `prefix_mismatch` a... -//! Functions: `copy_streams`, `install_prefix`. +//! Selection and publication of the verified prefix: rows are accepted while their tokens follow the greedy heads +//! from the seed (a rejected tail is dropped), and the matching journaled state is installed in the session and the +//! draft. use super::{ ChunkCommit, ChunkRowResidual, Dimension, Error, LayerId, ModelBinding, Position, PrefixState, QwenChunkTxn, 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 09432b25..ab4401cc 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 @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the greedy accept rule (stops at the first rejection or EOS), the 512 MiB refusal of the verification journal +//! charge and that the PLE journal admits only the current layer-one GDN attention phase. use super::{ Dimension, Error, GdnChunkAnchor, GdnChunkStart, HOST_LIMIT, LayerId, PlePrior, Position, PrefixState, PromptInit, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs index e329e133..168b1746 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs @@ -1,5 +1,5 @@ -//! Methods of `VerifiedTargetPrefix`: `count`. Functions: `verification_extra_charge`, `greedy_prefix`. -//! Split out of `verify` to keep its files under the line limit. +//! The accepted-prefix decision of a verification window: the count, the extra host charge of the journaled states +//! and the pure greedy rule (a row is accepted while its token equals the previous head and is not EOS). use super::{Error, PrefixState, Rc, Result, TokenId, VerifiedTargetPrefix}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs index 4524ef8a..662a947e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalDraftCheckpoint`: `host_bytes`. -//! Methods of `OriginalDraftSession`: `new`, `from_original_ring`, `validate`, `checkpoint` and 7 more. +//! The Original MTP draft session: its INT8 ring owner and immutable checkpoint, construction from the shared ring +//! layout, and lending the ring to the draft producer. Only a matching target origin may borrow it; it never advances +//! target state. use super::{ CompletedOriginalMtpDraft, Context, Error, ModelBinding, MtpInt8Snapshot, MtpOriginalInt8, OriginalDraftCheckpoint, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs index 6a929b89..6b2fc50b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalDraftSession`: `with_mtp_current_ring`, `check_publication`, `prepare_publication`, `restore_... -//! Methods of `OriginalDraftPublication`: `publish_validated`. Implements `Drop for OriginalDraftSession`. +//! Publication and rollback of the draft ring: the receipt check of a completed MTP window, restore to a checkpoint, +//! reset to the empty prompt, conversation resume and rebinding to the target branch. An uncertain restore poisons +//! the owner. use super::{ CompletedDraftKv, DenseWeightCache, Error, ModelBinding, MtpInt8Snapshot, MtpOriginalInt8, OriginalDraftCheckpoint, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs index e5344008..c15fb17b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs @@ -1,5 +1,5 @@ -//! Functions: `published_first_materialized`, `draft_driver_error`. -//! Split out of `draft` to keep its files under the line limit. +//! Ring bookkeeping after a prompt chunk: the lower bound of the cells the draft ring has materialized (a chunk that +//! continues the range keeps the earlier bound), and the mapping of driver errors of the draft. use super::{Error, Stage}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs index e0f11dad..a53e428a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `original_prompt_input_qsa_seed`, `qwen_session`. -//! Split out of `original_prompt` to keep its files under the line limit. +//! The request input of an Original prompt and the session's checkpoint, park and restore over the resident QSA +//! layers. use super::{ DenseWeightCache, Dimension, Error, GdnPrior, LayerId, ModelBinding, OriginalPromptInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs index 008ff5ca..e01a528a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptInput`: `from_tokenized`, `len`, `window`. -//! Methods of `QwenSession`: `validate_resident_qsa_owner`, `original_qsa_seed`, `install_original_qsa_seed`, `seed_... +//! The tokenized request owner and the QSA seed of a session: prompt windows, installing the empty seed set into an +//! untouched session, and re-stamping checkpoints onto the session's current branch generation. use super::{ Dimension, Error, LayerId, ModelBinding, OriginalPromptInput, OriginalSessionCheckpoint, QsaIndexPrior, QsaOwner, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs index 4d2ec955..6d710f8f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenSession`: `check_resident_states`, `original_checkpoint`, `check_restore_slot`, `check_restore_sl... -//! Methods of `ParkedSession`: `next_position`, `host_bytes`. Defines `RestoredLayers`. +//! Checkpoint, restore and park of a `QwenSession` over its twelve resident QSA layers: saved witnesses are +//! validated, every layer is rolled back (all attempted, the first failure returned), and prefix-cache points and +//! blocks are exported or imported. use super::{ DenseWeightCache, Dimension, Error, GdnPrior, LayerId, ModelBinding, OriginalSessionCheckpoint, ParkedBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs index 5db83df4..f80e781d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptPhase`: `validate_role`, `initialize`, `read`, `prepare_read` and 5 more. -//! Methods of `OriginalPromptRowKey`: `validate_initial`, `validate`, `phase`, `ordinal`. +//! The phase journal of an Original prompt window (which GR role may be read, injected or sealed next) and the row +//! keys that bind a source row to it. Shared only by authentic source rows and their producers. use super::{ BindingIdentity, DevicePhase, Dimension, Error, GrRole, InputReady, LayerId, OriginalPromptPhase, 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 e1709bbb..c6bbdf5b 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 @@ -1,5 +1,4 @@ -//! Groups the submodules `original_prompt_txn_begin`, `original_prompt_txn_prior_and_abort`, `original_prompt_txn_pu... -//! Split out of `original_prompt` to keep its files under the line limit. +//! The `OriginalPromptTxn` impl family: begin and queries, prior staging and abort, publication. use super::{ Cell, Context, DenseWeightCache, DevicePhase, Dimension, DraftRollback, Error, GdnPrior, GrRole, InputReady, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs index 67809fef..a93c3ce7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptTxn`: `begin`, `check`, `original_session`, `origin` and 14 more. -//! Methods of `OriginalPromptPhase`: `start`. +//! Start of an Original prompt transaction: checks of the session, window and vocabulary, its queries (origin, +//! positions, full prompt length, row keys) and the staging of input rows with the true token predecessors. use super::{ Cell, Context, DevicePhase, Dimension, Error, GrRole, InputReady, LayerId, ModelBinding, OriginalPromptInput, 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/original_prompt_txn_prior_and_abort.rs index f0fa27f2..4a56faf4 100644 --- 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/original_prompt_txn_prior_and_abort.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptTxn`: `gdn_start_prior`, `gdn_prior`, `stage_gdn`, `validate_ple_at` and 9 more. -//! Split out of `original_prompt_txn` to keep its files under the line limit. +//! Rolling GDN, PLE and QSA priors of a prompt transaction and their staging, and the abort: both physical restores +//! are attempted and the accepted target branch is read back from the session, never inferred. use super::{ DenseWeightCache, DraftRollback, Error, GdnPrior, GrRole, InputReady, LayerId, ModelBinding, OriginalPromptTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs index 3bc72e0d..0e0530da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptTxn`: `validate_publish_inputs`, `publish_gdn_slot`, `check_qsa_seal`, `publish_qsa_slo... -//! Split out of `original_prompt_txn` to keep its files under the line limit. +//! Publication of a prompt transaction into the session: every GDN and QSA slot must stand at the end position with +//! its seal, and permits are prepared first so the state installation is infallible assignment. use super::super::super::super::qsa_index::prompt_device::resident_device::ResidentQsaPublication; use super::{ 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 fbeff6cb..1093ce3f 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 @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the verified-window publication: a refused one leaves the session untouched, rounds advance the lineage while +//! the recurrent state lags until the end-of-phase publication closes it, and priors of another owner or layer are +//! refused. use super::{Error, GdnPrior, OriginalVerifiedLineage, PlePrior, QwenSession, STATE_CAPACITY, predecessors_after}; use crate::model_binding::qwen4exp_input::BindingIdentity; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs index 5078e109..6d7c7a66 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenSession`: `note_mtp_failure`, `finish_mtp_device`, `new`, `for_binding` and 11 more. -//! Functions: `layers_of_kind`. +//! `QwenSession` itself: the constructors (unbound, on a device), `begin` of a step transaction, the single commit +//! path `transact`, reset after CUDA completion and the MTP failure notes. use super::{ BindingIdentity, BoundLayerKind, Context, Error, GdnOwner, ModelBinding, PleOwner, Position, QsaOwner, QwenSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs index 5ad862ad..f735cd47 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `qwen_step_txn_inputs`, `qwen_step_txn_prior_finish`. -//! Split out of `session` to keep its files under the line limit. +//! The `QwenStepTxn` impl family: the inputs and priors of a step, and its finish and commit. use super::{ BindingIdentity, Context, Dimension, Error, FiniteLogits, GdnPending, GdnPrior, GrRole, InjectedResidual, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs index 0a12d9c6..92af6e45 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenStepTxn`: `token`, `position`, `residual_handoff_owner`, `validate_projection_branch` and 18 more. -//! Split out of `qwen_step_txn` to keep its files under the line limit. +//! Inputs and priors of one step transaction: token, position, binding checks, the staged input, and the PLE, GDN and +//! QSA priors with their staging. Nothing here updates committed history. use super::{ BindingIdentity, Context, Dimension, Error, GdnPending, GdnPrior, InputReady, LayerId, PlePending, PlePrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs index fd95e9c2..5331cecb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenStepTxn`: `qsa_prior`, `initial_qsa_prior`, `validate_qsa_prior`, `stage_qsa` and 8 more. -//! Functions: `next_ple`, `next_gdn`, `next_qsa`, `check_forward_output` and 1 more. +//! Completion of a step: QSA priors, layer-completion proofs, the finite-logits (or known-next prefill) finish and +//! `commit`, which alone publishes the next priors and advances one position, after the executor callback succeeded. use super::{ Dimension, Error, FiniteLogits, GdnPending, GdnPrior, GrRole, InjectedResidual, LayerId, PlePending, PlePrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs index 006c184a..5af738bc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs @@ -1,5 +1,6 @@ -//! Methods of `ResetReplaySnapshot`: `has_prefix`, `numeric_eq`, `same_shape`, `retained_bytes`. -//! Methods of `QwenSession`: `oracle_capture_committed`, `validate_reset_states`, `validate_reset_ple`, `validate_re... +//! `ResetReplaySnapshot`, the retained numerical copy of a session used by the reset-replay proofs, with its +//! comparison, and the session's oracle capture of the committed state and validation of the retained priors after a +//! reset. #[cfg(all(test, target_arch = "x86_64"))] use super::ResetReplaySnapshot; 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 bcd7ac97..e5e06d4b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the single-step session: commit advances every owner once, failure leaves the committed state untouched, and +//! the PLE, GDN and QSA priors keep their exact identity (child modules); the helpers build tokens and positions. use super::{ Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs index 4a8ea199..c62b2b80 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs @@ -1,8 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! gdn_session_commit_advances_all_state_once_and_failed_reset_preserves_owner, -//! full_forward_guard_refuses_skipped_layers_missing_logits_and_wrong_callback_token, -//! context_seam_missing_owner_refuses_after_identity_checks, context_seam_wrong_thread_refuses_before_backend_access -//! .... +//! Pins session commit semantics: a commit advances all GDN state once, a failed reset keeps the owner, the +//! full-forward guard and the context seam refuse skipped layers, wrong tokens, threads and CUDA failures, and +//! predecessors advance oldest first. use super::{ BindingIdentity, Dimension, Error, GdnPending, InputReady, LayerId, QwenSession, Rc, Stage, TokenId, TokenLayer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs index f35ba114..e72c1cc8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs @@ -1,8 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! retained_gr_handoff_identity_is_lazy_and_refuses_same_position_rebegin, -//! headfree_prefill_refuses_metadata_completion_without_actual_final_producer, -//! headfree_prefill_refuses_zero_layer_fixture_and_preserves_history, -//! qsa_session_prior_is_private_and_required_state_cannot_be_skipped .... +//! Pins prior identity in the session: the retained GR handoff is lazy and refuses a same-position rebegin, head-free +//! prefill needs a real final producer, priors are private, a late failure discards candidates and a reset fences old +//! generations. use super::{ BindingIdentity, Dimension, Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, diff --git a/crates/engine-qwen35-cuda/src/serve_meta/tests.rs b/crates/engine-qwen35-cuda/src/serve_meta/tests.rs index 7dcb9731..2446146e 100644 --- a/crates/engine-qwen35-cuda/src/serve_meta/tests.rs +++ b/crates/engine-qwen35-cuda/src/serve_meta/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the start-up meta lines: they match the golden sample byte for byte, each is one section of single-blank +//! separated key=value tokens, an unset profile prints as `none`, values cannot split a token, the values hash +//! follows only the values, model files are statted and never read, and formatting is deterministic. use super::{ BuildInfo, CacheFacts, ConfigFacts, MODEL_DIGEST_MAPPING, ModelFile, ModelInfo, Path, ProfileInfo, cache_line, diff --git a/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs b/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs index c7c5c7ac..d478f834 100644 --- a/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs +++ b/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs @@ -1,3 +1,7 @@ +//! Pins run-time tuning: an empty or unknown document is refused, valid values apply and name the changed members, +//! invalid values change nothing, the resident K/V window is accepted only at its value in force, the prefix cache +//! can be switched off and on, and `describe` reports the engine's defaults. + use super::{OriginalServeOptions, PrefixCacheOptions, PrefixTail, Tuning, describe}; fn base() -> (OriginalServeOptions, u32) { diff --git a/crates/engine-qwen35-cuda/src/settings/capture_tests.rs b/crates/engine-qwen35-cuda/src/settings/capture_tests.rs index 9b9ea93b..567bf617 100644 --- a/crates/engine-qwen35-cuda/src/settings/capture_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/capture_tests.rs @@ -1,3 +1,7 @@ +//! Pins the settings capture: only the operator namespace of the environment is captured, raw values are kept, an +//! empty environment gives every topic's defaults, and the conversation-cache and memory-governor keys are read +//! from the capture. + use super::{EnvSource, MapEnv, ServeSettings, Settings}; #[test] From f62f1762e2dc500c86b3e80229535da8c48eed91 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 21:23:09 +0100 Subject: [PATCH 6/7] engine crates: open_cache_steps split off open_phase_steps, rustfmt, engine-core without #[allow(unused_imports)], baselines lowered (glob 70 -> 0, allow 166 -> 0 in the engine, 18 -> 0 in engine-core) Co-Authored-By: Claude Sonnet 5.5 --- architecture-baseline.json | 3 - crates/engine-core/src/conversation/cache.rs | 2 - crates/engine-core/src/conversation/kv.rs | 14 -- .../engine-core/src/conversation/manager.rs | 3 - .../src/conversation/manager_tests.rs | 14 -- .../src/conversation/snapshot_tests.rs | 16 -- crates/engine-core/src/prefix_cache/store.rs | 1 - .../src/prefix_cache/store/decayed.rs | 1 - .../prefix_store_evict_and_budget.rs | 2 +- crates/engine-core/src/prompt.rs | 3 - crates/engine-core/src/spec/adaptive.rs | 4 - .../combined_changed_boundary_proof.rs | 4 +- .../combined_changed_boundary_proof/rig.rs | 4 +- .../src/backend/native_down_public_pair.rs | 4 +- .../long_public_preflight.rs | 2 +- .../original_serve/runner/owner_run_steps.rs | 10 +- .../src/backend/original_serve_laptop.rs | 4 +- .../src/backend/original_serve_replay.rs | 4 +- .../src/backend/original_serve_smoke.rs | 4 +- .../original_serve_smoke/smoke_long.rs | 4 +- .../original_serve_smoke/smoke_main.rs | 4 +- .../original_serve_smoke/smoke_main/corpus.rs | 2 +- .../src/backend/original_serve_ttft.rs | 4 +- .../src/backend/serve_generate.rs | 4 +- .../src/conversation/memory.rs | 1 - .../engine-qwen35-cuda/src/memory_governor.rs | 4 +- .../qwen4exp_input/mtp/backing.rs | 2 +- .../qwen4exp_input/mtp/mtp_kind_types.rs | 1 - .../qwen4exp_input/mtp/mtp_weight_reads.rs | 6 +- .../qwen4exp_input/mtp/read_expert_rows.rs | 2 +- .../qwen4exp_input/validate_ple_descriptor.rs | 4 +- .../qwen4exp_kar_ple/inherited_kar_archive.rs | 4 +- .../load_pinned_inherited_archive.rs | 4 +- .../qwen4exp_kar_ple/pinned_profile.rs | 6 +- .../qwen4exp_kar_ple/pinned_profile_tests.rs | 2 +- .../private_copy/checked_reader.rs | 2 +- .../qwen4exp_kar_ple/private_copy/inode.rs | 4 +- .../dense_weight_cache/workspaces.rs | 4 +- .../original_prompt/staged_input_enabled.rs | 1 - .../qwen_forward/executor/prefill_chunk.rs | 4 +- .../prefill_chunk/qwen_forward/joint_chunk.rs | 4 +- .../prefill_chunk_cached_windowed.rs | 4 +- .../qwen_forward/prefill_chunk_planned.rs | 8 +- .../prefill_chunk_planned/chunk_layer.rs | 4 +- .../prefill_chunk_planned/chunk_setup.rs | 4 +- .../prefill_chunk_planned/window_attention.rs | 8 +- .../prefill_chunk/read_chunk_attention_ffn.rs | 2 +- .../src/qwen_forward/executor/qwen_forward.rs | 2 +- .../src/qwen_forward/executor/step_layers.rs | 4 +- .../src/qwen_forward/gdn.rs | 1 - .../src/qwen_forward/gdn/cached_step.rs | 4 +- .../chunk_device/gdn_chunk_device_methods.rs | 9 +- .../chunk_device_batch_compute.rs | 4 +- .../gdn/chunk_device/numeric_gpu.rs | 6 +- .../src/qwen_forward/gdn/driver_error.rs | 2 +- .../src/qwen_forward/gr/retained_handoff.rs | 4 +- .../ple_transport/ple_inner_composition.rs | 4 +- .../ple_transport/ple_key_retained_gpu.rs | 4 +- .../ple_key_retained_gpu/bf16.rs | 4 +- .../moe_expert/expert_matrix_projection.rs | 8 +- .../moe_expert/grouped/bound_rows.rs | 4 +- .../moe_expert/grouped/direct_gpu.rs | 4 +- .../moe_expert/grouped/direct_packets_fns.rs | 4 +- .../grouped/ordered_down_refusal.rs | 4 +- .../packet_run_project_group_direct.rs | 4 +- .../grouped/project_group_source_consumers.rs | 4 +- .../src/qwen_forward/moe_expert/tests.rs | 2 +- .../src/qwen_forward/moe_weight_cache.rs | 4 +- .../moe_weight_cache/cache_lru_index/tests.rs | 2 +- .../moe_weight_cache/cache_profile_fill.rs | 4 +- .../cache_profile_fill/moe_weight_cache.rs | 4 +- .../pinned_triplet_preload.rs | 8 +- .../cache_profile_fill/profile_build.rs | 4 +- .../shared_quartet_preload.rs | 4 +- .../src/qwen_forward/mtp/kv_only.rs | 2 +- .../mtp/state/prefix_draft_snapshot.rs | 2 +- .../mtp_decode/batch_gpu/check_loaded.rs | 4 +- .../mtp_decode/first_seed_reuse_enabled.rs | 2 +- .../qwen_forward/mtp_decode/mtp_decoder.rs | 6 +- .../mtp_decoder/batched_window_plan.rs | 4 +- .../fixed_workspace/fixed_workspace_gpu.rs | 27 +-- .../mtp_experts/fixed_workspace/role.rs | 4 +- .../fixed_workspace/transport_drop.rs | 4 +- .../mtp_expert_transport_gpu.rs | 4 +- .../mtp_expert_transport_gpu/exact.rs | 4 +- .../mtp_expert_transport/shared_project.rs | 8 +- .../original_serve_config/tests.rs | 4 +- .../original_serve_engine/draft_completion.rs | 2 +- .../src/qwen_forward/original_serve_host.rs | 4 +- .../original_serve_pool/pool_layer_trace.rs | 2 +- .../qwen_forward/original_serve_pool/tests.rs | 2 +- .../qwen_forward/original_serve_request.rs | 2 +- .../qwen_forward/original_serve_residency.rs | 4 +- .../original_serve_residency/open_tier.rs | 10 +- .../conversation/tests.rs | 3 +- .../original_serve_stack_methods.rs | 5 +- .../open_cache_steps.rs | 157 +++++++++++++++++ .../open_phase_steps.rs | 160 +----------------- .../original_spec_controller/tests.rs | 4 +- .../tests/config_rejects_out_of_range.rs | 4 +- .../output/output_stage_test_replay.rs | 4 +- .../src/qwen_forward/qsa_attention.rs | 2 +- .../src/qwen_forward/qsa_index/context.rs | 8 +- .../qwen_forward/qsa_index/index_resident.rs | 4 +- .../qsa_index/index_resident/max_rows.rs | 4 +- .../qwen_forward/qsa_index/qsa_index_stage.rs | 4 +- .../qwen_forward/session/original_prompt.rs | 6 +- .../src/qwen_forward/session/tests.rs | 4 +- 108 files changed, 359 insertions(+), 425 deletions(-) create mode 100644 crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_cache_steps.rs diff --git a/architecture-baseline.json b/architecture-baseline.json index 70adb3d2..1ec22606 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -5,8 +5,6 @@ "source": { "allow-unused-imports:leleka-cpu-sys": 35, "allow-unused-imports:leleka-cuda-driver": 410, - "allow-unused-imports:leleka-engine-core": 18, - "allow-unused-imports:leleka-engine-qwen35-cuda": 166, "allow-unused-imports:leleka-experimental-ref": 1, "allow-unused-imports:leleka-harmony": 2, "allow-unused-imports:leleka-igpu": 2, @@ -47,7 +45,6 @@ "env-read:leleka-tokenizer": 2, "env-read:strata-control": 3, "glob-super-import:leleka-cuda-driver": 3, - "glob-super-import:leleka-engine-qwen35-cuda": 70, "instant-now:leleka-cpu-worker": 9, "instant-now:leleka-cuda-driver": 25, "instant-now:leleka-engine-qwen35-cuda": 16, diff --git a/crates/engine-core/src/conversation/cache.rs b/crates/engine-core/src/conversation/cache.rs index fc713640..14df98fa 100644 --- a/crates/engine-core/src/conversation/cache.rs +++ b/crates/engine-core/src/conversation/cache.rs @@ -120,8 +120,6 @@ pub struct ConversationCache { mod tests; mod conversation_checkpoint; -#[allow(unused_imports)] pub use conversation_checkpoint::conversation_prefix; -#[allow(unused_imports)] pub use conversation_checkpoint::prefix_len; mod conversation_cache; diff --git a/crates/engine-core/src/conversation/kv.rs b/crates/engine-core/src/conversation/kv.rs index 45b44a82..5b2522b9 100644 --- a/crates/engine-core/src/conversation/kv.rs +++ b/crates/engine-core/src/conversation/kv.rs @@ -45,29 +45,15 @@ struct Verifier<'a> { } mod layout; -#[allow(unused_imports)] pub use layout::kv_bytes; -#[allow(unused_imports)] pub use layout::kv_capture_bytes; -#[allow(unused_imports)] -use layout::kv_q4_bytes_per_head; -#[allow(unused_imports)] use layout::layout; -#[allow(unused_imports)] use layout::region; -#[allow(unused_imports)] use layout::transfer_err; -#[allow(unused_imports)] use layout::valid; -#[allow(unused_imports)] -use layout::valid_extent; mod kv_image_save_restore; -#[allow(unused_imports)] pub use kv_image_save_restore::kv_restore; -#[allow(unused_imports)] pub use kv_image_save_restore::kv_save; -#[allow(unused_imports)] pub use kv_image_save_restore::kv_validate; mod kv_image_readback; -#[allow(unused_imports)] pub use kv_image_readback::kv_verify; diff --git a/crates/engine-core/src/conversation/manager.rs b/crates/engine-core/src/conversation/manager.rs index 70a11c90..d5da37e4 100644 --- a/crates/engine-core/src/conversation/manager.rs +++ b/crates/engine-core/src/conversation/manager.rs @@ -113,10 +113,7 @@ pub struct ConversationManager { } mod conversation_options_default; -#[allow(unused_imports)] pub use conversation_options_default::images_below; -#[allow(unused_imports)] use conversation_options_default::is_allocation; -#[allow(unused_imports)] pub use conversation_options_default::starts_with; mod conversation_manager; diff --git a/crates/engine-core/src/conversation/manager_tests.rs b/crates/engine-core/src/conversation/manager_tests.rs index 8a5968f2..7db74a4a 100644 --- a/crates/engine-core/src/conversation/manager_tests.rs +++ b/crates/engine-core/src/conversation/manager_tests.rs @@ -61,24 +61,10 @@ mod continuing_chat_reuses; mod random_traffic_resumes_into_exact_prefix_state; mod hash; -#[allow(unused_imports)] -use hash::hash; -#[allow(unused_imports)] use hash::idx; -#[allow(unused_imports)] -use hash::pat; -#[allow(unused_imports)] -use hash::pattern; mod sim_device_session_device; -#[allow(unused_imports)] use sim_device_session_device::ReplayedRequest; -#[allow(unused_imports)] use sim_device_session_device::chat; -#[allow(unused_imports)] use sim_device_session_device::gen_tokens; -#[allow(unused_imports)] use sim_device_session_device::options; -#[allow(unused_imports)] -use sim_device_session_device::prompt_options; -#[allow(unused_imports)] use sim_device_session_device::world; diff --git a/crates/engine-core/src/conversation/snapshot_tests.rs b/crates/engine-core/src/conversation/snapshot_tests.rs index ea1811bb..dd77699a 100644 --- a/crates/engine-core/src/conversation/snapshot_tests.rs +++ b/crates/engine-core/src/conversation/snapshot_tests.rs @@ -57,34 +57,18 @@ struct Pools { mod layer_snapshots_are_byte_exact; mod kv_region; -#[allow(unused_imports)] use kv_region::equal; -#[allow(unused_imports)] pub(super) use kv_region::kv_region; -#[allow(unused_imports)] use kv_region::mk_view; -#[allow(unused_imports)] use kv_region::q4_per_head; mod kv_level; -#[allow(unused_imports)] use kv_level::kv_level; mod full_session; -#[allow(unused_imports)] use full_session::full_session; mod fixture; mod pools; -#[allow(unused_imports)] use fixture::fixture; mod golden_state; -#[allow(unused_imports)] -use golden_state::assert_checkpoint; -#[allow(unused_imports)] use golden_state::assert_image; -#[allow(unused_imports)] use golden_state::assert_kv; -#[allow(unused_imports)] -use golden_state::fnv; -#[allow(unused_imports)] -use golden_state::fnv_buf; -#[allow(unused_imports)] use golden_state::golden_state; diff --git a/crates/engine-core/src/prefix_cache/store.rs b/crates/engine-core/src/prefix_cache/store.rs index 7a09fb52..b895c66f 100644 --- a/crates/engine-core/src/prefix_cache/store.rs +++ b/crates/engine-core/src/prefix_cache/store.rs @@ -201,5 +201,4 @@ mod tests; mod decayed; mod policy_params_default; mod prefix_store; -#[allow(unused_imports)] use decayed::decayed; diff --git a/crates/engine-core/src/prefix_cache/store/decayed.rs b/crates/engine-core/src/prefix_cache/store/decayed.rs index ac306720..3b0bf7b9 100644 --- a/crates/engine-core/src/prefix_cache/store/decayed.rs +++ b/crates/engine-core/src/prefix_cache/store/decayed.rs @@ -1,6 +1,5 @@ //! Half-life decay of a hit mass or prior with age, shared by the store's value estimate. - pub(super) fn decayed(value: f64, age: u64, half_life: f64) -> f64 { if value == 0.0 { 0.0 } else { value * 0.5f64.powf(age as f64 / half_life) } } 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/prefix_store_evict_and_budget.rs index 8cd67ed9..5bc56679 100644 --- 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/prefix_store_evict_and_budget.rs @@ -1,9 +1,9 @@ //! Removal from the prefix store: enforcing the byte budget, aborting a candidate, evicting a node together with the //! blocks only it covered, orphan release, clearing, and the invariant check. -use super::{ByteSize, Candidate, HashSet, Node, PrefixStore}; #[cfg(any(test, feature = "testing"))] use super::HashMap; +use super::{ByteSize, Candidate, HashSet, Node, PrefixStore}; impl PrefixStore { pub(in super::super) fn enforce_budget(&mut self, fresh: u64) { diff --git a/crates/engine-core/src/prompt.rs b/crates/engine-core/src/prompt.rs index 25ad9e49..8c291099 100644 --- a/crates/engine-core/src/prompt.rs +++ b/crates/engine-core/src/prompt.rs @@ -139,9 +139,6 @@ mod grid_tests; #[path = "prompt/prompt_options.rs"] mod prompt_options; -#[allow(unused_imports)] pub use prompt_options::choose_auto_capacity; -#[allow(unused_imports)] pub use prompt_options::drive; -#[allow(unused_imports)] pub use prompt_options::request_capacity; diff --git a/crates/engine-core/src/spec/adaptive.rs b/crates/engine-core/src/spec/adaptive.rs index 09209276..f41220cb 100644 --- a/crates/engine-core/src/spec/adaptive.rs +++ b/crates/engine-core/src/spec/adaptive.rs @@ -192,13 +192,9 @@ pub struct SpecStats { mod tests; mod adaptive_config; -#[allow(unused_imports)] use adaptive_config::logit; -#[allow(unused_imports)] use adaptive_config::m_bucket; -#[allow(unused_imports)] use adaptive_config::p_bucket; -#[allow(unused_imports)] use adaptive_config::sigmoid; mod adaptive_policy; mod decide; diff --git a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs index b9ca28c8..5edc3b16 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof.rs @@ -1,10 +1,10 @@ //! Private sole new changed-path model gate; actual source identity/load preserved. +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenForward, QwenSession}; use super::{ Driver, EvaluationExecution, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile, }; -#[cfg(feature = "preview-path")] -use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenForward, QwenSession}; use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners as LoadedTarget; use std::env; pub(super) mod rig; diff --git a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs index e09f59d2..3126edcd 100644 --- a/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs +++ b/crates/engine-qwen35-cuda/src/backend/combined_changed_boundary_proof/rig.rs @@ -1,11 +1,11 @@ //! The loaded real owners the single-load GPU proofs share: the pinned binding over the inherited sealed archive, //! the device owners built on one bounded Context, a phase run on a fresh target owner, and the teardown whose //! results are asserted only after every attempt was made. Opening and scheduling stay with each proof. +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; use super::{ InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile, }; -#[cfg(feature = "preview-path")] -use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; use std::{ env, panic::{AssertUnwindSafe, catch_unwind}, diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs index 94be2c58..07f0b859 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair.rs @@ -1,4 +1,6 @@ //! One-load private PUBLIC generation pair; actual owner timings, never HTTP timings. +#[cfg(test)] +use super::prepare_prompt; use super::{ AtomicBool, CacheCounts, Digest, Driver, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, @@ -8,8 +10,6 @@ use super::{ }; #[cfg(feature = "preview-path")] use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession}; -#[cfg(test)] -use super::prepare_prompt; use serde_json::{Value, json}; use std::{ env, diff --git a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs index eb3e3e64..9d28f1a3 100644 --- a/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs +++ b/crates/engine-qwen35-cuda/src/backend/native_down_public_pair/long_public_preflight.rs @@ -1,5 +1,6 @@ //! Offline/private producer; call with the actual already-bound model tokenizer. //! No asset opening, model hash scan, GPU allocation or inference occurs here. +use leleka_gateway_text::prompt as public_renderer; use leleka_tokenizer::Tokenizer; use serde_json::{Value, json}; use sha2::{Digest, Sha256}; @@ -9,7 +10,6 @@ use std::{ os::unix::fs::OpenOptionsExt, path::Path, }; -use leleka_gateway_text::prompt as public_renderer; const BYTE_CAP: usize = 1024 * 1024; const ARTIFACT_CAP: usize = 16 * 1024 * 1024; const CONTEXT: usize = 262144; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs index f740d369..e95d15bd 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/owner_run_steps.rs @@ -2,11 +2,11 @@ //! sweep idle sessions and close everything; early exits stay in `run`. use super::{ - QUEUE, ActiveGuard, AtomicBool, BackendError, ClientLink, DeferredTail, ErrorCode, GenerationFailure, - GenerationRequest, GenerationSink, GenerationTerminal, IdleSweep, LoadedModel, LoadPhase, ModelBinding, Ordering, - OriginalServeOptions, OriginalServeStack, PathBuf, Rc, Reply, RequestToServe, Shared, SystemClock, Tokenizer, - TokenVocabulary, context_fits, emit_terminal, exhausted, generate, invalid, load_failure, meta_facts, open_error, - prepare_prompt, publish_prefix_summary, stack_config, unavailable, + ActiveGuard, AtomicBool, BackendError, ClientLink, DeferredTail, ErrorCode, GenerationFailure, GenerationRequest, + GenerationSink, GenerationTerminal, IdleSweep, LoadPhase, LoadedModel, ModelBinding, Ordering, + OriginalServeOptions, OriginalServeStack, PathBuf, QUEUE, Rc, Reply, RequestToServe, Shared, SystemClock, + TokenVocabulary, Tokenizer, context_fits, emit_terminal, exhausted, generate, invalid, load_failure, meta_facts, + open_error, prepare_prompt, publish_prefix_summary, stack_config, unavailable, }; use leleka_backend_api::GenerationStream; use leleka_cuda_driver::Context; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs index 3b521e32..5edc97f3 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_laptop.rs @@ -27,7 +27,9 @@ //! //! Run: `cargo test -p leleka-engine-qwen35-cuda --features cuda-driver[,sm86] --release -- --ignored --nocapture //! original_serve_laptop_bench`. -use super::{Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile}; +use super::{ + Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile, +}; use crate::qwen_forward::{ original_serve_engine::ServeOutcome, original_serve_request::{ServeError, ServeRequest}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs index 42ab06d4..0d5f3300 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay.rs @@ -30,7 +30,9 @@ //! //! Run (inside a holder job): ` --ignored --nocapture original_serve_replay_smoke`. use super::super::qwen_forward::original_serve_stack::dbg_el; -use super::{Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile}; +use super::{ + Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile, +}; use crate::qwen_forward::{ original_serve_request::{ServeError, ServeRequest}, original_serve_stack::{OriginalServeStack, PrefixBudget, PrefixConfig, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs index 1db20934..49346a98 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke.rs @@ -25,12 +25,12 @@ //! While the verifier window producers listed in `UNBOUND_PRODUCERS` are unbound the stack refuses to open //! with the first missing producer's name; that refusal is the expected result of this smoke until they land. use super::super::qwen_forward::original_serve_stack::dbg_el; +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; use super::{ Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::original_serve_arms; use crate::qwen_forward::{ original_serve_request::{RequestSampling, ServeError, ServeRequest}, original_serve_stack::{OriginalServeStack, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs index 5e2c4335..d6bea2b6 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_long.rs @@ -1,11 +1,11 @@ //! Long-context smoke of the streamed INT8 KV: one greedy request over a prompt far longer than the resident //! window (documented on `original_serve_long_context_streamed_kv_smoke`). +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; use super::{ OriginalServeStack, PathBuf, ServeRequest, StackConfig, Tokenizer, collect, dbg_el, env, env_or, ids, number, open_pinned, open_stack, request, with_context, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::original_serve_arms; use std::time::Instant; const COLORS: [&str; 8] = ["amber", "blue", "crimson", "green", "grey", "ivory", "orange", "violet"]; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs index 017e513c..5fe4d668 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main.rs @@ -1,11 +1,11 @@ //! The main smoke: greedy twice across a reset, a sampled request, a cancellation, the optional parity corpus //! and a short prompt on the scalar draft-KV path. +#[cfg(all(test, target_arch = "x86_64"))] +use super::original_serve_arms; use super::{ OriginalServeStack, PROMPT, PathBuf, ServeError, ServeRequest, StackConfig, Tokenizer, agent_sampler, collect, dbg_el, env, env_or, open_pinned, open_stack, optin, report_timing, request, with_context, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::original_serve_arms; mod corpus; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs index 7219897f..a79db841 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_smoke/smoke_main/corpus.rs @@ -1,9 +1,9 @@ //! The parity corpus of the main smoke: every line of `LELEKA_SMOKE_PROMPTS` is tokenized with the verified //! tokenizer, served greedily for `LELEKA_SMOKE_MAX_NEW` tokens (default 64) and printed as ids so the Original //! can be run on the same ids. -use super::{ServeError, ServeRequest, Smoke, Tokenizer, agent_sampler, env, env_or, report_timing}; #[cfg(all(test, target_arch = "x86_64"))] use super::original_serve_arms; +use super::{ServeError, ServeRequest, Smoke, Tokenizer, agent_sampler, env, env_or, report_timing}; use crate::qwen_forward::{ original_serve_engine::ServeOutcome, original_serve_request::{RequestSampling, original_stop_tokens}, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs index cd760f86..a7fc296c 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_ttft.rs @@ -11,7 +11,9 @@ //! Inputs: those of the replay (`LELEKA_ORIGINAL_SERVE_REPLAY=yes`, model, expert tier, `LELEKA_REPLAY_CAPACITY`, //! `LELEKA_REPLAY_PREFIX_MIB`, `LELEKA_ORIGINAL_SERVE_RT_DIR`), `LELEKA_SWEEP_MAX_NEW` (4). use super::super::qwen_forward::original_serve_stack::dbg_el; -use super::{Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile}; +use super::{ + Driver, InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, VerifiedGgufFile, +}; use crate::qwen_forward::{ original_serve_request::ServeRequest, original_serve_stack::{OriginalServeStack, PrefixBudget, PrefixConfig, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/backend/serve_generate.rs b/crates/engine-qwen35-cuda/src/backend/serve_generate.rs index 72906a83..fc80c128 100644 --- a/crates/engine-qwen35-cuda/src/backend/serve_generate.rs +++ b/crates/engine-qwen35-cuda/src/backend/serve_generate.rs @@ -1,4 +1,6 @@ //! One Generate command of the serve loop: admit it, resume or start a session, generate, publish the terminal. +#[cfg(feature = "preview-path")] +use super::QwenSession; use super::{ ActiveGuard, Arc, AtomicBool, BackendError, Conversations, Counters, GenerationRequest, GenerationSink, GenerationStream, LoadedModel, ModelBinding, MtpContinuation, Ordering, Outcome, PrefixSession, QUEUE, Rc, Reply, @@ -6,8 +8,6 @@ use super::{ log_conversation_events, log_generation_cache, measurement, prepare_prompt, run_generation, terminal_admit, terminal_of, unavailable, verdict, }; -#[cfg(feature = "preview-path")] -use super::QwenSession; use std::cell::RefCell; /// One Generate command as it arrived. diff --git a/crates/engine-qwen35-cuda/src/conversation/memory.rs b/crates/engine-qwen35-cuda/src/conversation/memory.rs index d56a4d7a..739c2013 100644 --- a/crates/engine-qwen35-cuda/src/conversation/memory.rs +++ b/crates/engine-qwen35-cuda/src/conversation/memory.rs @@ -5,7 +5,6 @@ //! every ambiguity (malformed, duplicated, wrongly-united, I/O failure) //! reads as unknown so admission fails closed. - pub use leleka_engine_core::memory::{mem_available, memory_admit}; /// Available host physical memory right now; `None` when unknown (any diff --git a/crates/engine-qwen35-cuda/src/memory_governor.rs b/crates/engine-qwen35-cuda/src/memory_governor.rs index 5885f621..ee3320c6 100644 --- a/crates/engine-qwen35-cuda/src/memory_governor.rs +++ b/crates/engine-qwen35-cuda/src/memory_governor.rs @@ -9,8 +9,8 @@ use crate::settings::{EnvSource, Settings}; use leleka_backend_api::BackendError; use leleka_memory::ledger::{DeviceSample, OpenStage}; use leleka_memory::{ - CacheWish, Entry, FixedItem, Governor, GovernorConfig, HostFacts, KarForm, PlanInput, SamplerGuard, - Space, VramFacts, When, + CacheWish, Entry, FixedItem, Governor, GovernorConfig, HostFacts, KarForm, PlanInput, SamplerGuard, Space, + VramFacts, When, }; use leleka_memory_os::{HostProc, real_governor}; use std::sync::Mutex; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs index 8708bb4b..dc31258b 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/backing.rs @@ -1,9 +1,9 @@ //! 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. -use super::{File, InputBindingError, InputResult, Path}; #[cfg(test)] use super::{EXPERT_BLOB, MtpExpertMatrix, MtpKind, read_exact_range, read_expert_rows}; +use super::{File, InputBindingError, InputResult, Path}; use sha2::{Digest, Sha256}; use std::io::Read; use std::os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt, PermissionsExt}; 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/qwen4exp_input/mtp/mtp_kind_types.rs index 66e8346e..73253e58 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs @@ -1,7 +1,6 @@ //! The vocabulary of the MTP pack: storage kinds, expert matrices, the roles of its tensors, and the `Descriptor` //! and `Dense` records that describe one tensor. - #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) enum MtpKind { Q8_0, 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/qwen4exp_input/mtp/mtp_weight_reads.rs index e356776b..adb749ef 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_weight_reads.rs @@ -1,9 +1,9 @@ //! The reads of the MTP weights: dense rows, expert rows and the binding identity check. use super::{ - DENSE_BYTES, DESCRIPTORS, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, INDEX_BYTES, MAX_ROWS, BindingIdentity, - InputBindingError, InputResult, ModelBinding, MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, - Path, backing, descriptor, read_exact_range, read_expert_rows, row_range, validate_numeric, + BindingIdentity, DENSE_BYTES, DESCRIPTORS, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, INDEX_BYTES, InputBindingError, + InputResult, MAX_ROWS, ModelBinding, MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing, + descriptor, read_exact_range, read_expert_rows, row_range, validate_numeric, }; impl MtpWeights { 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/qwen4exp_input/mtp/read_expert_rows.rs index bc32d4a8..3c75033f 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/read_expert_rows.rs @@ -1,9 +1,9 @@ //! 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. -use super::{EXPERT_BLOB, MAX_READ, MAX_ROWS, File, InputBindingError, InputResult, MtpExpertMatrix, MtpKind, MtpRows}; #[cfg(not(target_os = "linux"))] use super::backing; +use super::{EXPERT_BLOB, File, InputBindingError, InputResult, MAX_READ, MAX_ROWS, MtpExpertMatrix, MtpKind, MtpRows}; pub(super) fn read_expert_rows( experts: &File, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs index 63e755c1..6eecb9b7 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs @@ -1,12 +1,12 @@ //! Bind-time admission of a Qwen4Exp artifact: the per-layer token-embedding (PLE) descriptor and the ordered list of //! bound layers with their kinds. Also the test fixtures for `InputConstants` and `BindingIdentity`. +#[cfg(test)] +use super::{BindingIdentity, InputConstants, Rc}; use super::{ BoundLayer, BoundLayerKind, GlobalRole, InputBindingError, InputResult, LayerRole, PLE_ROWS, Qwen4ExpArtifact, TensorRole, }; -#[cfg(test)] -use super::{BindingIdentity, InputConstants, Rc}; pub(super) fn validate_ple_descriptor(artifact: &Qwen4ExpArtifact) -> InputResult<()> { let ple = artifact 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/qwen4exp_kar_ple/inherited_kar_archive.rs index a320d75d..5521d204 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/inherited_kar_archive.rs @@ -2,8 +2,8 @@ //! Functions: `open_sealed_archive_fd`, `open_read_only_archive`, `check_read_only_archive`, `reopen_read_only_archi... use super::{ - ARCHIVE_DIGEST, PINNED_ARCHIVE_BYTES, PROVENANCE_DIGEST, File, InheritedKarArchive, InputBindingError, - InputResult, Path, PathBuf, SparseArchive, private_copy, + ARCHIVE_DIGEST, File, InheritedKarArchive, InputBindingError, InputResult, PINNED_ARCHIVE_BYTES, PROVENANCE_DIGEST, + Path, PathBuf, SparseArchive, private_copy, }; use leleka_model_format::weight_source::{BackingKind, FileWeightSource, Verification, WeightIdentity}; 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/qwen4exp_kar_ple/load_pinned_inherited_archive.rs index 8f8bcde2..afa36b82 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/qwen4exp_kar_ple/load_pinned_inherited_archive.rs @@ -2,8 +2,8 @@ //! Functions: `open_archive_reader`, `load_pinned_inherited_archive`, `log_startup_read`, `load_pinned_inherited_arc... use super::{ - NATIVE_DIGESTS, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, BindingIdentity, File, InheritedKarArchive, - InputBindingError, InputResult, KarError, KarPleBinding, KarRowPacket, KarRowReader, LoadPhase, RefCell, + BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPleBinding, KarRowPacket, + KarRowReader, LoadPhase, NATIVE_DIGESTS, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, RefCell, VerifiedKarPleArtifact, open_sealed_archive_fd, pinned_profile, reopen_read_only_archive, verify_open_provenance, }; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs index b3588b0d..136c70bf 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile.rs @@ -2,9 +2,9 @@ //! Functions: `pinned_profile`, `pinned_parts`, `pinned_profile_spec`, `load_pinned_archive` and 3 more. use super::{ - ARCHIVE_DIGEST, NATIVE_DIGESTS, PART0_F32_DIGEST, PART1_F32_DIGEST, PROVENANCE_DIGEST, VIRTUAL_F32_DIGEST, File, - InheritedKarArchive, InputBindingError, InputResult, KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, - LoadPhase, Path, VerifiedKarPleArtifact, error, input_failure, kar_failure, private_copy, + ARCHIVE_DIGEST, File, InheritedKarArchive, InputBindingError, InputResult, KarPlePartProvenance, KarPleProfile, + KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PART0_F32_DIGEST, PART1_F32_DIGEST, PROVENANCE_DIGEST, Path, + VIRTUAL_F32_DIGEST, VerifiedKarPleArtifact, error, input_failure, kar_failure, private_copy, }; /// Candidate expectations from independently verified v4 conversion receipts 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/qwen4exp_kar_ple/pinned_profile_tests.rs index fb64dc2c..fc20946a 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/pinned_profile_tests.rs @@ -2,7 +2,7 @@ //! Functions: `diagnostic_cases`, `assert_kar_diagnostic_redacts`, `assert_input_diagnostic_survives_broken_sink`, `... use super::{ - NATIVE_DIGESTS, PLE_ROWS, InputBindingError, KarError, LoadPhase, error, input_diagnostic, kar_diagnostic, + InputBindingError, KarError, LoadPhase, NATIVE_DIGESTS, PLE_ROWS, error, input_diagnostic, kar_diagnostic, pinned_profile, pinned_profile_spec, }; 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/qwen4exp_kar_ple/private_copy/checked_reader.rs index f3886295..e4b13051 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/qwen4exp_kar_ple/private_copy/checked_reader.rs @@ -3,7 +3,7 @@ use super::{COPY_BUFFER, InputBindingError, InputResult, IoPhase, LoadPhase, Read, Write, input_failure, report_io}; #[cfg(not(target_os = "linux"))] -use super::{SOURCE_FLAGS, File, Metadata, MetadataExt, OpenOptions, OpenOptionsExt, Seek, inode, phase_error}; +use super::{File, Metadata, MetadataExt, OpenOptions, OpenOptionsExt, SOURCE_FLAGS, Seek, inode, phase_error}; #[cfg(target_os = "macos")] pub(super) fn checked_reader(own: &OwnedCopy, bytes: u64) -> InputResult { 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/qwen4exp_kar_ple/private_copy/inode.rs index b6afbfbe..22418bf1 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_kar_ple/private_copy/inode.rs @@ -2,8 +2,8 @@ //! Functions: `inode`, `diagnostic`, `report_io`, `phase_error` and 8 more. use super::{ - SOURCE_FLAGS, File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, - OpenOptions, OpenOptionsExt, Path, Seek, Write, copy_exact, input_failure, + File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions, + OpenOptionsExt, Path, SOURCE_FLAGS, Seek, Write, copy_exact, input_failure, }; #[cfg(not(target_os = "linux"))] use super::{Read, checked_reader}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs index 4fe9d212..1ce1c86a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs @@ -2,12 +2,12 @@ //! GDN state buffers), all empty at construction and filled on first use. The fields are declared in the order the //! cache drops them, so the drop order is unchanged. +#[cfg(test)] +use super::Cell; use super::{ DeviceBuffer, GdnInputScratch, GrBatchInjectWorkspace, GrScratch, QkScratch, QsaAttentionScratch, QsaIndexKeyCache, QsaInputScratch, QsaSelectedCache, Rc, RefCell, RouterScratch, }; -#[cfg(test)] -use super::Cell; /// Every scratch owner of the cache that starts empty (`None` or an empty list) and is filled on first use. #[derive(Default)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs index 172eb120..56b18179 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs @@ -1,6 +1,5 @@ //! The `prefill_staged_input` switch: staged chunk input, or the per-token host path of the KAR inputs (the A/B arm). - /// `LELEKA_PREFILL_STAGED_INPUT=0` keeps the per-token host path of the KAR inputs (the A/B arm). pub(super) fn staged_input_enabled() -> bool { crate::settings::process().kv.prefill_staged_input diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs index c19701ab..bdf57656 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk.rs @@ -6,8 +6,8 @@ use super::super::session::chunk::QwenChunkTxn; use super::{ BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, - Position, QsaAttentionStage, QsaIndexStage, QwenForward, QwenSession, QwenStepTxn, Result, Stage, TargetStepProduct, - TokenId, diagnose, prepare_layer_attention_micro, read_layer_attention, validate_layer_plan, + Position, QsaAttentionStage, QsaIndexStage, QwenForward, QwenSession, QwenStepTxn, Result, Stage, + TargetStepProduct, TokenId, diagnose, prepare_layer_attention_micro, read_layer_attention, validate_layer_plan, }; #[cfg(test)] use super::{StepCaches, StepRequest}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs index 501f8aff..4b2db0cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs @@ -1,11 +1,11 @@ //! The inputs and the joint target+draft publication shared by the prefill chunk entry points. +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use super::{ ChunkMoePolicy, DenseWeightCache, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, QwenForward, QwenSession, Result, Stage, TargetStepProduct, TokenId, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::window_numeric; use crate::qwen_forward::mtp_decode::MtpDecoder; #[cfg(test)] use leleka_cuda_driver::Context; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs index 090a2c7a..c5c4bad6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs @@ -1,12 +1,12 @@ //! Entry points of `QwenForward` for the cached prefill chunk: MMQ joint, cached joint and the private outer256 //! windowed experiments (plain and retained-GR transport). Normal serving stays on outer64 with the host transport. +#[cfg(all(test, target_arch = "x86_64"))] +use super::check_chunk_on_loaded; use super::{ ChunkMoePolicy, MoeWeightCache, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, QwenSession, Result, TargetStepProduct, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::check_chunk_on_loaded; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs index 474fa71a..f8ecf175 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs @@ -2,16 +2,16 @@ //! and the layer loop that ends in the output head. The phases are the child modules (setup, layer, window attention, //! FFN, experts). +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use super::{ AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, PrefillChunkPlan, QsaAttentionStage, QsaIndexStage, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, Stage, TokenId, chunk_diagnostic, - diagnose, prepare_layer_attention_micro, prepare_micro_ffn_rows, prepare_q6_layer_columns, read_chunk_attention_ffn, - read_layer_attention, validate_layer_plan, + diagnose, prepare_layer_attention_micro, prepare_micro_ffn_rows, prepare_q6_layer_columns, + read_chunk_attention_ffn, read_layer_attention, validate_layer_plan, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::window_numeric; use leleka_cuda_driver::Context; mod chunk_layer; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs index fef33659..ed548294 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs @@ -2,12 +2,12 @@ use super::window_experts::ExpertRun; use super::window_ffn::WindowOwners; +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use super::{ BoundLayerKind, ChunkEnv, ChunkRun, Context, Dimension, Error, GdnPlan, InjectedResidual, LayerId, MoeWeightCache, NativeMoe, QwenChunkTxn, QwenForward, Result, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::window_numeric; use crate::qwen_forward::gdn::chunk_device::GdnChunkDevice; use crate::qwen_forward::moe_expert::ChunkFfnLayer; use crate::qwen_forward::session::chunk::{ChunkFfnRow, ChunkMicroWindow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs index 0d720bb1..d2e6d6a0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs @@ -1,12 +1,12 @@ //! Admission, transaction begin, input rows and output head of one prefill chunk. +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use super::{ ChunkEnv, ChunkMoePolicy, ChunkOpening, Context, DenseWeightCache, Error, InjectedResidual, InputStage, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, Stage, chunk_diagnostic, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::window_numeric; /// The MMQ actor context, and the contexts of the recurrence and verification GDN owners when they are in use. type ChunkContexts<'ctx, 'driver> = diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs index 2fb5da02..b2f5069f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs @@ -1,13 +1,13 @@ //! The attention reads of one window of a prefill layer. +#[cfg(test)] +use super::QwenStepTxn; +#[cfg(all(test, target_arch = "x86_64"))] +use super::window_numeric; use super::{ ChunkEnv, ChunkRun, Error, GrStage, InjectedResidual, InputStage, LayerEntry, LayerId, MicroBank, QwenChunkTxn, QwenForward, Result, Stage, chunk_diagnostic, prepare_layer_attention_micro, read_layer_attention, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::window_numeric; -#[cfg(test)] -use super::QwenStepTxn; use crate::qwen_forward::session::chunk::ChunkAttentionRow; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs index 006ebbdb..1d3b104c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs @@ -2,12 +2,12 @@ //! go to the retained GR bank. Also the layer-0 pair diagnostic, whose four-row chunk must refuse with the executor //! error. -use super::{DenseWeightCache, ForwardPhase, GrStage, ModelBinding, Result, diagnose}; #[cfg(test)] use super::{ ChunkMoePolicy, Dimension, Error, KarPleCache, MoeWeightCache, OutputStage, PrefillChunkInputs, QwenForward, QwenSession, Stage, TokenId, }; +use super::{DenseWeightCache, ForwardPhase, GrStage, ModelBinding, Result, diagnose}; use crate::qwen_forward::gr::AttentionBlockOutput; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward.rs index 57f3bebc..f4b9b428 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward.rs @@ -6,6 +6,6 @@ use super::{ Stage, StepCaches, StepCoreResult, StepPurpose, StepRequest, TargetStepProduct, TokenId, }; -mod qwen_forward_reset; mod forward_step_body; +mod qwen_forward_reset; mod step_entries; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs index 8947e066..dbb5e1d6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs @@ -11,11 +11,11 @@ use crate::qwen_forward::gdn::GdnLayerInput; use crate::qwen_forward::moe_expert::ExpertRowRequest; use crate::qwen_forward::qsa_attention::QsaReady; -#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use crate::qwen_forward::oracle_capture; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::step_residual_capture::capture_input; pub(super) use super::step_residual_capture::capture_streams; +#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] +use crate::qwen_forward::oracle_capture; /// The per-step identity every layer phase validates against. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs index 6783fc0e..86897271 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn.rs @@ -196,7 +196,6 @@ mod tests { } } - #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod four_borrow_gpu; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs index a0548099..e60c0a1f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs @@ -2,13 +2,13 @@ //! Runs on a step-local `Chain`, then publishes the next recurrent state through the mirror only if the whole step //! succeeded; on failure the computed candidate is discarded and the chain is cleaned up. +#[cfg(all(test, target_arch = "x86_64"))] +use super::four_borrow_gpu; use super::{ CandidatePair, Context, DEVICE_PEAK, DenseWeightCache, DeviceBuffer, Error, GdnInputLease, GdnLayerInput, GdnMatrixKind, GdnMatrixRole, GdnPrior, GdnReady, GdnStateMirror, GdnWeights, LeaseClaim, LeasedProjection, MirrorStep, ModelBinding, ProjectedQkvSource, QwenStepTxn, ResidualReady, Result, chain, mirror, validate_values, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::four_borrow_gpu; use crate::qwen_forward::dense_weight_cache::GdnResident; use std::{cell::Cell, rc::Rc}; 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/gdn_chunk_device_methods.rs index 6ad48c03..4a38a2c2 100644 --- 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/gdn_chunk_device_methods.rs @@ -1,10 +1,11 @@ //! The `GdnChunkDevice` methods by phase: construction and admission, per-row and batch compute, finish and cleanup. use super::{ - BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, ChunkReadout, Context, DenseWeightCache, DeviceBuffer, Error, - GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnPrior, GdnRowQueue, HISTORY_ELEMENTS, - ModelBinding, Rc, ReadoutDownload, Result, STATE_ELEMENTS, VALUES, allocate, download, download_unchecked, - driver_error, micro_rows, mirror_reuse_enabled, pool_enabled, preflight_budget, upload, validate_values, + BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, ChunkReadout, Context, DenseWeightCache, DeviceBuffer, + Error, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnPrior, GdnRowQueue, + HISTORY_ELEMENTS, ModelBinding, Rc, ReadoutDownload, Result, STATE_ELEMENTS, VALUES, allocate, download, + download_unchecked, driver_error, micro_rows, mirror_reuse_enabled, pool_enabled, preflight_budget, upload, + validate_values, }; mod chunk_device_batch_compute; 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/gdn_chunk_device_methods/chunk_device_batch_compute.rs index 5eca8118..1a76cf5f 100644 --- 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/gdn_chunk_device_methods/chunk_device_batch_compute.rs @@ -2,12 +2,12 @@ //! read the readout back and mint the row edges. The earliest full-state refusal precedes the readout and any user. //! Also adopts the final state of a batch that drained clean. +#[cfg(test)] +use super::upload; use super::{ ChunkEdge, ChunkReadout, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, HISTORY_ELEMENTS, Rc, ReadoutDownload, Result, VALUES, allocate, download, driver_error, preflight_budget, validate_values, }; -#[cfg(test)] -use super::upload; impl<'ctx> GdnChunkDevice<'ctx> { /// Adopt the final state of a batch that drained clean: the separate `next` diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs index 0f8a3a3e..2b8aae8f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu.rs @@ -4,9 +4,9 @@ use super::super::super::contract::{Dimension, LayerId}; use super::super::super::session::chunk::TestGdnComponentRows; use super::super::{RecurrenceOperands, convolve, recur}; use super::{ - BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkReadout, Context, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, - GdnChunkSeal, GdnChunkStart, GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, Rc, Result, STATE_ELEMENTS, allocate, - download, driver_error, preflight_budget, upload, validate_values, + BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkReadout, Context, DeviceBuffer, Error, GdnChunkDevice, + GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, Rc, Result, + STATE_ELEMENTS, allocate, download, driver_error, preflight_budget, upload, validate_values, }; use leleka_cuda_driver::Driver; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs index c0082b22..81465cae 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs @@ -1,9 +1,9 @@ //! Maps CUDA driver errors to the GDN `Error` and holds the GDN state addressing checks (`state_index`, `key_head`). //! The state address is the exact native layout, never a head-major reinterpretation. -use super::{DriverError, Error, KEY_HEADS, Result, Stage, VALUE_HEADS, WIDTH}; #[cfg(test)] use super::CandidateFixture; +use super::{DriverError, Error, KEY_HEADS, Result, Stage, VALUE_HEADS, WIDTH}; #[cfg(test)] use super::{HISTORY_ELEMENTS, STATE_ELEMENTS, TokenLayer, validate_values}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs index b3621bc8..f2b56769 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/retained_handoff.rs @@ -2,6 +2,8 @@ //! The actual finite host witness remains canonical; only its duplicate H2D //! is removed. No device-only host proof or changed arithmetic is introduced. use super::read_cached_cuda::borrow_injection; +#[cfg(test)] +use super::{BindingIdentity, inject_cached_cuda, upload_bf16, upload_f32}; use super::{ Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Error, GrMicroAttentionBank, GrMicroAttentionBlock, GrPhase, GrRead, GrRole, GrScratch, GrStage, InjectedResidual, LayerId, ModelBinding, QwenStepTxn, @@ -9,8 +11,6 @@ use super::{ copy_cached_f32, diagnose, download_f32, driver_error, read_cached_cuda, validate_layer, validate_streams, validate_values, }; -#[cfg(test)] -use super::{BindingIdentity, inject_cached_cuda, upload_bf16, upload_f32}; /// The attention block output an attention residual is injected with, and the token and layer it was computed for. #[derive(Clone, Copy)] pub(in crate::qwen_forward) struct AttentionBlockOutput<'a> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_inner_composition.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_inner_composition.rs index faae1d76..2a355e6c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_inner_composition.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_inner_composition.rs @@ -1,12 +1,12 @@ //! The composition of one PLE row: project key and value, gate, normalise, convolve the history and finish the //! residual streams. Separate from `ple_transport`, which holds the transport and its row types. +#[cfg(test)] +use super::ObservedOutput; use super::{ Bf16ProjectionShape, Cell, Context, DeviceBuffer, Error, Finite, PLE_HC, PLE_HISTORY, PleCandidate, PleRows, Rc, Result, Role, Transport, admit, at, ple_driver_error, ple_values, }; -#[cfg(test)] -use super::ObservedOutput; use leleka_cuda_driver::PleClosedWeights; pub(super) fn compose_inner( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs index 0abad6b0..c54c9c5f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu.rs @@ -2,8 +2,8 @@ #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{ple_upload, ple_upload_f32}; use super::{ - Bf16ProjectionShape, Cell, Context, DeviceBuffer, Error, Finite, PleCandidate, PleRows, Rc, Result, Role, Transport, - at, compose, ple_download, ple_driver_error, + Bf16ProjectionShape, Cell, Context, DeviceBuffer, Error, Finite, PleCandidate, PleRows, Rc, Result, Role, + Transport, at, compose, ple_download, ple_driver_error, }; #[cfg(test)] use super::{Observations, compose_observed}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs index 57ab95cc..c35f51ab 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs @@ -1,12 +1,12 @@ //! Test support for the retained-PLE proof: synthetic BF16 PLE matrices and the legacy chain (one key projection and //! forty ephemeral value tiles) that the whole-matrix retained path must reproduce bit for bit. +#[cfg(test)] +use super::Observations; use super::{ Bf16ProjectionShape, Context, DeviceBuffer, Finite, Matrices, Role, Transport, at, ple_download, ple_driver_error, ple_upload, ple_upload_f32, }; -#[cfg(test)] -use super::Observations; pub(super) fn bf16(rows: usize, columns: usize, seed: usize) -> Vec { (0..rows) 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 86e3e2a4..ee97474a 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 @@ -3,16 +3,16 @@ //! routed prepared Q8 or cached MMQ), and a kind without a plan is refused. The uncached diagnostic path uploads the //! raw matrix here. +#[cfg(test)] +use super::TILE; +#[cfg(test)] +use super::validate_values; use super::{ BoundExpert, CachedMoeMatrix, Context, DEVICE_PEAK, DenseFormat, DeviceBuffer, Error, FF, ModelBinding, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, N, ProjectionKind, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, Result, RoutedFormat, RoutedGateUpQ8, Stage, binding_error, download_f32, driver_error, upload_bytes, }; -#[cfg(test)] -use super::TILE; -#[cfg(test)] -use super::validate_values; /// Shape and format of one expert matrix as the binding declares it. #[derive(Clone, Copy)] 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 d540abb7..1c3d2d5c 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,5 +1,7 @@ //! The uploaded rows of one chunk and their ungrouped/grouped execution (STRA-338 size: extract-method only). +#[cfg(all(test, target_arch = "x86_64"))] +use super::direct_gpu; use super::direct_packets_fns::PacketRun; use super::finish_shared_with::RowTail; use super::{ @@ -8,8 +10,6 @@ use super::{ TransportBuffer, adaptive, execute_cuda_cached, finish_shared, grouped_pairs, project_group, prompt_finish, use_direct_packets, uses_adaptive, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::direct_gpu; /// The uploaded rows of one chunk: activations and Q8 owners all alive for the whole execution. pub(super) struct BoundRows<'a, 'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs index 082188af..7416d7c9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu.rs @@ -2,8 +2,8 @@ //! session advancement, standalone Load or full-model qualification is minted. use super::{ ChunkFfnLayer, ChunkFfnRow, Context, DEVICE_PEAK, DeviceBuffer, DownScope, DownSelection, DriverError, Error, - ExpertReady, FF, GrStage, K, LayerId, ModelBinding, MoeExpertStage, MoeWeightCache, N, PreparedMoeRow, QwenChunkTxn, - Rc, Result, Stage, TransportBuffer, download_f32, driver_error, validate_values, + ExpertReady, FF, GrStage, K, LayerId, ModelBinding, MoeExpertStage, MoeWeightCache, N, PreparedMoeRow, + QwenChunkTxn, Rc, Result, Stage, TransportBuffer, download_f32, driver_error, validate_values, }; use crate::qwen_forward::gr::DetachedGrRead; use crate::qwen_forward::session::{QwenStepTxn, ResetReplaySnapshot, chunk::ChunkAttentionRow}; 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 e28173f3..8d843f83 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,5 +1,7 @@ //! Phases of the direct-packet layer batch (STRA-338 size: extract-method only). +#[cfg(all(test, target_arch = "x86_64"))] +use super::direct_gpu; use super::finish_shared_with::RowTail; use super::ordered_down_refusal::close_packets; use super::packet_run_project_group_direct::DirectRun; @@ -8,8 +10,6 @@ use super::{ Pair, PreparedMoeRow, QwenChunkTxn, Rc, Result, RoutedGateUpQ8, Stage, TransportBuffer, adaptive_packets, finish_shared_queued, finish_shared_with, prompt_finish, use_shared_tail, uses_adaptive, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::direct_gpu; /// The sealed rows, their origins, expert groups and shared activations of one direct-packet layer batch. pub(super) struct PacketRun<'a, 'session, 'ctx, 'l, 'd, 'q> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs index 7550d988..f25207c5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs @@ -3,6 +3,8 @@ //! quantizer refusal must not overtake an earlier column's Down NonFinite, so the refusal is replayed ascending; //! every packet is closed whatever the first failure was. +#[cfg(all(test, target_arch = "x86_64"))] +use super::direct_gpu; use super::finish_shared_with::RowTail; use super::packet_run_project_group_direct::{DownProjection, RefusalReplay}; use super::{ @@ -10,8 +12,6 @@ use super::{ MatrixDims, ModelBinding, MoeWeightCache, N, PackedDown, Pair, QwenChunkTxn, Rc, Result, SharedTailRow, Stage, finish_shared_with, launch_cached_projection, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::direct_gpu; pub(super) fn ordered_down_refusal( context: &Context<'_>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs index d23a38fb..f3afb872 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs @@ -3,6 +3,8 @@ //! direct and source paths share. Origins of all rows are validated before any packet is mutably loaned, and every //! group buffer is closed whatever the outcome. +#[cfg(all(test, target_arch = "x86_64"))] +use super::direct_gpu; use super::direct_packets_fns::PacketRun; use super::project_group_shared_fns::*; use super::{ @@ -11,8 +13,6 @@ use super::{ MoeWeightCache, PacketGroupMembers, Pair, QwenChunkTxn, Rc, Result, RoutedFormat, RoutedGateUpQ8, Stage, TransportBuffer, binding_error, download_f32, driver_error, ordered_down_refusal, validate_packet_pairs, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::direct_gpu; impl<'ctx> PacketRun<'_, '_, 'ctx, '_, '_, '_> { /// Project one expert group of the batch through the plain device path (no source fence), filling the slot 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 d9a78724..cbb20df1 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 @@ -2,6 +2,8 @@ //! The scope ends after the last private consumer and before any packet coverage or group acceptance; a failure //! discards every copied private packet. Also checks that the source members match the group descriptors. +#[cfg(all(test, target_arch = "x86_64"))] +use super::direct_gpu; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::packet_run_project_group_direct::{ DirectGroup, DirectRun, DownBuffers, DownProjection, GroupBuffers, RefusalReplay, @@ -16,8 +18,6 @@ use super::{ PacketGroupMembers, Result, RoutedFormat, RoutedGateUpQ8, SourceMatrix, Stage, TransportBuffer, binding_error, download_f32, driver_error, dual_routed_format, ordered_down_refusal, validate_packet_pairs, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::direct_gpu; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::model_binding::qwen4exp_input::MoeRoutedSourceScope; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs index 7ccaf69b..d9146f67 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs @@ -1,9 +1,9 @@ //! Pins the expert-row collection and finite checks: completed tiles keep all rows, a late failure withholds the //! candidate, and a non-finite last expert output is refused while a signed zero is retained. -use super::{DEVICE_PEAK, Error, FF, N, admit_budget}; #[cfg(test)] use super::collect_rows; +use super::{DEVICE_PEAK, Error, FF, N, admit_budget}; #[test] fn completed_tiles_keep_all_rows_and_late_failure_withholds_candidate() { let values = collect_rows(N, |first, count| { 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 b01ff389..c38846c9 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 @@ -34,10 +34,10 @@ mod cache_routed_outputs; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] mod cache_strata_adaptive; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -pub(in crate::qwen_forward) use cache_original_prompt::PromptWeightOwners; -#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] #[cfg(test)] pub(crate) use cache_original_prompt::PREFILL_STREAM_OVERRIDE; +#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] +pub(in crate::qwen_forward) use cache_original_prompt::PromptWeightOwners; #[cfg(test)] pub(crate) use cache_original_prompt::set_span_cache_override; pub(crate) use cache_profile::{LearnedMainWitness, SharedPermanentWitness}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs index b6a82219..ae76e405 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs @@ -1,9 +1,9 @@ //! Pins the bounded LRU index against a scan oracle: oldest-first order with protected keys, atomic batch refusals, //! descriptor collisions, a full index and long deterministic churn. Literal descriptors carry no model or device //! authority, so these tests run without a GPU. -use super::{LruIndex, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, slot}; #[cfg(any(test))] use super::HOST_LIMIT; +use super::{LruIndex, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, slot}; use std::collections::HashMap; type Oracle = HashMap; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs index dcf4b789..de87e1ac 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill.rs @@ -1,12 +1,12 @@ //! Binding-authenticated constructor; metadata alone cannot produce weights. +#[cfg(test)] +use super::room_fits; use super::{ Context, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, Rc, RefCell, Result, WORKING_RESERVE, WeightCacheCounters, binding_error, cache_profile, cache_strata_adaptive, driver_error, }; #[cfg(test)] -use super::room_fits; -#[cfg(test)] use cache_profile::ProfileWitness; use cache_profile::{HOST_CAP, PROFILE_SHA, PinnedPool, PrefixPlan, ProfileLimits, RankedProfile}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 cf672050..37e4e154 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 @@ -1,13 +1,13 @@ //! The `MoeWeightCache` constructors of the profile fill: the ranked fill with its pinned pool and the pinned triplet //! preload. +#[cfg(test)] +use super::ProfileWitness; use super::{ Context, DeviceRef, EncodedWeight, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, PROFILE_SHA, PinnedPool, PrefixPlan, ProfileLimits, RankedProfile, Result, WORKING_RESERVE, binding_error, driver_error, profile_window_spill_with_floor, }; -#[cfg(test)] -use super::ProfileWitness; mod pinned_triplet_preload; mod profile_ranked_fill_and_pool; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs index 46ddd439..65d186a9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs @@ -2,14 +2,14 @@ //! its three raw blocks from the binding, upload them (dual or mixed layout) and commit them as pinned main entries //! with the traffic counters. Also the profile witness that reads those counters back for tests. +#[cfg(test)] +use super::PinnedPool; +#[cfg(test)] +use super::ProfileWitness; use super::{ DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, WORKING_RESERVE, binding_error, driver_error, }; -#[cfg(test)] -use super::ProfileWitness; -#[cfg(test)] -use super::PinnedPool; /// Layouts, charges and the checked next counters of one pinned triplet upload. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs index 5d90efa4..0485a802 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_build.rs @@ -1,7 +1,5 @@ -//! The shared-permanent profile build behind the fixed-prefix and learned-main constructors (STRA-338 size: -//! extract-method only). +//! The shared-permanent profile build behind the fixed-prefix and learned-main constructors. -// Stays a glob on purpose: the file is at the 400-line limit and the explicit list would put it over. use super::{ Context, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, PinnedPool, PrefixPlan, ProfileLimits, RankedProfile, Result, WORKING_RESERVE, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs index 627bff67..9d1d79d4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs @@ -5,12 +5,12 @@ #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] #[cfg(test)] use super::profile_build::{ProfileFile, ProfileKind, ProfileRequest}; +#[cfg(test)] +use super::{Context, PROFILE_SHA, RankedProfile}; use super::{ DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, WORKING_RESERVE, binding_error, cache_profile, driver_error, }; -#[cfg(test)] -use super::{Context, PROFILE_SHA, RankedProfile}; /// The room a shared quartet upload must leave free: the spill allowance and the main pool size once the quartet is /// inserted. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs index 7f659162..cbf97fc1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/kv_only.rs @@ -1,7 +1,7 @@ //! Private canonical cell producer. It never represents a ready draft/residual. -use super::{Error, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, QwenSession, Result}; #[cfg(test)] use super::{Cell, MtpSession, Rc}; +use super::{Error, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, QwenSession, Result}; use crate::qwen_forward::session::chunk::{ChunkRowResidual, QwenChunkTxn}; // The same validated frame and canonical packed K/V tuple. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs index 74f6aae7..c2ef55a6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs @@ -2,9 +2,9 @@ //! the admission checks of its owner and frame. Also keeps the live-checkpoint count honest: dropping an //! `MtpCheckpoint` releases its slot against the cap. -use super::{CellPair, Error, HALF_ROW, MtpCheckpoint, MtpFrame, Rc, Result}; #[cfg(all(test, target_arch = "x86_64"))] use super::PrefixDraftSnapshot; +use super::{CellPair, Error, HALF_ROW, MtpCheckpoint, MtpFrame, Rc, Result}; #[cfg(test)] use super::{ModelBinding, MtpSession}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs index ea9edd93..e0c7f5d1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs @@ -3,8 +3,8 @@ use super::{ Collection, DenseWeightCache, Dimension, Error, Expected, KarPleCache, ModelBinding, MoeWeightCache, MtpDecoder, - MtpWindowError, MtpWindowSpec, OutputStage, Position, PostcommitCancellation, QwenForward, QwenSession, ROW_CAP, Rc, - Report, ResetReplaySnapshot, Result, SNAPSHOT_CAP, Stage, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, + MtpWindowError, MtpWindowSpec, OutputStage, Position, PostcommitCancellation, QwenForward, QwenSession, ROW_CAP, + Rc, Report, ResetReplaySnapshot, Result, SNAPSHOT_CAP, Stage, TRANSACTION_CAP, TargetStepProduct, TokenId, VOCAB, different_token, mtp, observe, row_matches, }; use crate::qwen_forward::mtp_decode::MtpVerifiedWindow; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs index 16afe095..b5aff2b2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs @@ -3,9 +3,9 @@ //! adaptive expert policy and no numerical observer active. The seed already fills slot zero, so the bounds change //! speculative work only; verification and accepted-prefix limits are unchanged. -use super::{Error, MoeWeightCache, MtpWindowError, Result}; #[cfg(all(test, target_arch = "x86_64"))] use super::batch_gpu; +use super::{Error, MoeWeightCache, MtpWindowError, Result}; // Only the selected adaptive policy, with numerical observer paths unchanged. pub(super) fn first_seed_reuse_enabled(cache: &MoeWeightCache<'_>) -> bool { 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 e7f5b514..54ebfb97 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 @@ -1,6 +1,8 @@ //! The methods of `MtpDecoder` that run a window: the batched window (with its plan), the scalar window and the //! draft warm-up. Separate from `mtp_decode`, which holds the decoder itself. +#[cfg(all(test, target_arch = "x86_64"))] +use super::batch_gpu; use super::{ DenseWeightCache, Dimension, DraftHeadOwners, Error, KnownNext, ModelBinding, MoeWeightCache, MtpDecoder, MtpInput, MtpSession, MtpVerifiedWindow, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, Position, @@ -8,10 +10,8 @@ use super::{ VerificationSource, WindowCaches, WindowOwners, first_seed_reuse_enabled, kv_prefill_host_charge, mtp, needed_draft_predictions, reserve, window_limit, window_stage_error, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::batch_gpu; -mod batched_window_plan; mod batched_window; +mod batched_window_plan; mod draft_warm_and_window; mod scalar_window; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs index 98b16cc6..5bb0dbe1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs @@ -1,12 +1,12 @@ //! The plan, the context and the head of one batched MTP window. Separate from `batched_window`, which runs the //! window, so that what a window is made of reads apart from how it runs. +#[cfg(all(test, target_arch = "x86_64"))] +use super::batch_gpu; use super::{ DenseWeightCache, Error, ModelBinding, MoeWeightCache, MtpInput, MtpWindowError, MtpWindowRequest, MtpWindowSpec, OutputStage, Result, TargetStepProduct, TokenId, mtp, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::batch_gpu; use crate::qwen_forward::mtp::{MtpCheckpoint, RetainedFirstSeed}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs index 378fdfa5..7b7d6d9e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs @@ -3,14 +3,14 @@ //! cleanly. use super::super::mtp_expert_transport::{ExpertWeights, FixedReference, SelectedRoute, fixed_reference}; +#[cfg(test)] +use super::Observations; +#[cfg(all(test, target_arch = "x86_64"))] +use super::ObservedOutput; use super::{ ALLOCATED_BYTES, CHARGES, Cell, Context, DeviceBuffer, Error, ExpertInputs, FF, FixedBuffers, K, N, Rc, Result, Role, Slot, Transport, at, compose, compose_inner, download, moe_driver_error, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::ObservedOutput; -#[cfg(test)] -use super::Observations; use leleka_cuda_driver::Driver; const BANK_BYTES: usize = 707_788_800; const BLOB_BYTES: usize = 1_382_400; @@ -47,9 +47,7 @@ fn bank_fixture() -> Vec { bank } fn fill_blob(blob: &mut [u8], expert: usize) { - for (rows, columns, codes, scales, chunks) in - [(1280, 640, 0, 1_228_800, 40), (2560, 160, 819_200, 1_331_200, 10)] - { + for (rows, columns, codes, scales, chunks) in [(1280, 640, 0, 1_228_800, 40), (2560, 160, 819_200, 1_331_200, 10)] { fill_blob_matrix(blob, expert, &BlobMatrix { rows, columns, codes, scales, chunks }); } } @@ -185,12 +183,8 @@ impl<'ctx> Rig<'ctx> { .produce(Role::RoutedGu(0, IDS[0]), |inputs, out| { let input = leleka_cuda_driver::MtpQuantizedInput { values: at(inputs, q)?, scales: at(inputs, scales)? }; - ctx.mtp_s2_gate_up_full( - leleka_cuda_driver::MtpS2SelectedExpert { bank, expert: IDS[0] }, - input, - out, - ) - .map_err(moe_driver_error) + ctx.mtp_s2_gate_up_full(leleka_cuda_driver::MtpS2SelectedExpert { bank, expert: IDS[0] }, input, out) + .map_err(moe_driver_error) }) .unwrap(); assert_eq!(t.validate(&gu, Role::RoutedGu(1, IDS[1])).err(), Some(Error::IdentityMismatch)); @@ -199,12 +193,7 @@ impl<'ctx> Rig<'ctx> { assert_eq!(t.finish::<()>(Err(Error::IdentityMismatch)), Err(Error::IdentityMismatch)); } // Late actual expert GU nonfinite: both original and fixed must refuse. - fn refuse_late_nonfinite( - &mut self, - storage: &mut FixedBuffers<'ctx>, - corpus: &mut [u8], - mixed: &[f32], - ) -> usize { + fn refuse_late_nonfinite(&mut self, storage: &mut FixedBuffers<'ctx>, corpus: &mut [u8], mixed: &[f32]) -> usize { let at = IDS[9] as usize * BLOB_BYTES + 1_228_800 + (1279 * 40 + 39) * 2; let saved: [u8; 2] = corpus[at..at + 2].try_into().unwrap(); corpus[at..at + 2].copy_from_slice(&0x7c00u16.to_le_bytes()); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs index 44c02fc0..213d4123 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs @@ -3,12 +3,12 @@ //! Also runs the original FP32-scale quantizers, whose completed scales are inspected before any grouped dot uses //! them. +#[cfg(test)] +use super::K; use super::{ Cell, DEVICE_PEAK, DeviceBuffer, Error, FF, Finite, FixedBuffers, N, Rc, Result, Role, Slot, Transport, at, download, moe_driver_error, preflight, validate_values, }; -#[cfg(test)] -use super::K; impl Role { pub(super) fn slot(self) -> Slot { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs index 2c100937..47c14348 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs @@ -2,13 +2,13 @@ //! scaled by its scalar), the packed routed Downs and the final combine in router slot order. Also releases every //! leased buffer when a transport drops; the first failure stops before any later expert runs. +#[cfg(test)] +use super::download; use super::{ CHARGES, Cell, DenseFormat, DeviceBuffer, Error, ExpertInputs, FF, Finite, FixedBuffers, K, N, Packed, ProjectionKind, ProjectionSpec, QuantizedIndices, Rc, Result, Role, RouteSlot, Slot, Transport, moe_driver_error, preflight, validate_route, validate_values, }; -#[cfg(test)] -use super::download; impl Drop for Transport<'_, '_> { fn drop(&mut self) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs index c02d7bfb..4ac9e14c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu.rs @@ -1,13 +1,13 @@ //! New lossless MTP expert transport proof, not an S2 arithmetic requalification. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::qsa_index::{allocate, download_bytes, release, upload}; +#[cfg(test)] +use super::compose_observed; use super::{ Cell, Context, DEVICE_PEAK, DenseFormat, DeviceBuffer, Error, ExpertWeights, FF, K, N, Packed, ProjectionKind, ProjectionSpec, Rc, Result, Role, RoutedExpert, SelectedRoute, Transport, compose, download, routed, shared, shared_project, }; -#[cfg(test)] -use super::compose_observed; use leleka_cuda_driver::Driver; const BANK_BYTES: usize = 707_788_800; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs index e08d9cd4..80bafc0f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs @@ -2,13 +2,13 @@ //! Builds a synthetic expert bank, runs each routed expert and the shared expert through the original stages with //! every stage read back, and checks the retained transport matches that baseline bit for bit. +#[cfg(test)] +use super::compose_observed; use super::{ BANK_BYTES, BLOB_BYTES, Cell, Context, DenseFormat, DeviceBuffer, Env, Error, ExpertWeights, FF, IDS, N, Original, ProjectionKind, ProjectionSpec, ROUTE, Result, Role, SelectedRoute, allocate, download, download_bytes, release, upload, }; -#[cfg(test)] -use super::compose_observed; pub(super) fn exact(a: &[f32], b: &[f32]) { assert_eq!(a.len(), b.len()); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs index b6041e1a..b0e2acae 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs @@ -2,16 +2,16 @@ //! the routed Downs packed in slot order, and the weighted combine. Entry points `compose` and `compose_observed` run //! a whole block; the first failure stops before any later expert runs. -use super::{ - Cell, Context, DenseFormat, DeviceBuffer, Error, FF, Finite, K, N, Packed, ProjectionKind, ProjectionSpec, Rc, - Result, Role, RoutedExpert, Transport, at, moe_driver_error, preflight, routed, validate_route, validate_values, -}; #[cfg(all(test, target_arch = "x86_64"))] use super::FixedReference; #[cfg(test)] use super::ObservedOutput; #[cfg(test)] use super::download; +use super::{ + Cell, Context, DenseFormat, DeviceBuffer, Error, FF, Finite, K, N, Packed, ProjectionKind, ProjectionSpec, Rc, + Result, Role, RoutedExpert, Transport, at, moe_driver_error, preflight, routed, validate_route, validate_values, +}; pub(super) fn shared_project( transport: &mut Transport<'_>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs index e5a50f94..d27eb645 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs @@ -1,13 +1,13 @@ //! Pins the Mode17 values derived for the Original serve path: pack expert bank and footprint switches, blob sizes, //! rope theta scale, MTP policies, sampler path flags, request parameter mapping and the geometry and prefill carve. +#[cfg(test)] +use super::legacy_footprint_from; use super::{ Error, ExpertBlobSizes, OriginalMtpGrVariant, RopeConstants, SamplerPath, driver_sampler_params, greedy_params, legacy_footprint, mtp_full_policy, mtp_pack_experts_needed, mtp_scalar_policy, prefill_layout_options, sampler_path, verify_geometry, }; -#[cfg(test)] -use super::legacy_footprint_from; #[test] fn the_pack_expert_bank_is_needed_only_without_an_rt_directory() { // pack-driven draft (no RT directory): the pack's experts are the draft layer's experts diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs index dece4ef9..b33b630e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs @@ -7,5 +7,5 @@ use super::{ TargetSeedRow, }; -mod spec_engine_for_serve_engine; mod serve_engine_draft_commit; +mod spec_engine_for_serve_engine; 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 56c0b7b7..2b61a4f7 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 @@ -40,8 +40,8 @@ use super::{ use crate::model_binding::qwen4exp_input::{BoundLayerKind, ModelBinding}; use leleka_cuda_driver::{ AcceptedWindow, Context, DeviceBuffer, OriginalGpuEvent, OriginalMtpFullPolicy, OriginalNativeHeadGraphResources, - OriginalVerifier, OriginalVerifyGraphResources, OriginalVerifyQsaJournal, OriginalVerifyWindowResult, SamplerParams, - SamplerPath, + OriginalVerifier, OriginalVerifyGraphResources, OriginalVerifyQsaJournal, OriginalVerifyWindowResult, + SamplerParams, SamplerPath, }; use std::rc::Rc; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/pool_layer_trace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/pool_layer_trace.rs index 442646fd..6adb94e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/pool_layer_trace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/pool_layer_trace.rs @@ -4,7 +4,7 @@ //! tasks spread over the threads and how long a task took. All times are microseconds from the publication of the //! phase; `[a,b,c,d]` is min, p50, p90, max over the threads (`task`: over the tasks). -use leleka_native_cpu_expert::{PhaseTrace, POOL_TIMING_STAGES}; +use leleka_native_cpu_expert::{POOL_TIMING_STAGES, PhaseTrace}; /// What the engine knows about the group the pool just computed. pub(super) struct GroupTraceInfo { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs index c5350e6b..c5a7dcf7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs @@ -1,9 +1,9 @@ //! Pins the expert group plan: every (row, slot) pair planned once with experts in first-use order, masked GPU //! entries left out but still validated, bad router output refused, and scatter offsets of each output slot. -use super::{Error, ExpertJob, HIDDEN, TOP_K, output_offset, plan_experts_where, scatter, selection}; #[cfg(test)] use super::plan_experts; +use super::{Error, ExpertJob, HIDDEN, TOP_K, output_offset, plan_experts_where, scatter, selection}; fn ids(rows: &[[i32; TOP_K]]) -> Vec { rows.iter().flatten().copied().collect() 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 48ec360a..07c84687 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 @@ -10,9 +10,9 @@ use super::{contract::Error, original_serve_engine::ServeOutcome, original_spec_controller::SpecError}; use leleka_cuda_driver::{SamplerParams, SamplerPath}; -pub(crate) use leleka_engine_core::request::{Admission, original_stop_tokens}; #[cfg(test)] pub(crate) use leleka_engine_core::request::ENDOFTEXT_TOKEN; +pub(crate) use leleka_engine_core::request::{Admission, original_stop_tokens}; /// How a request ended when it did not complete, over this stack's forward error. pub(crate) type ServeError = leleka_engine_core::request::ServeError; 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 0f01bbbd..f4515ec8 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 @@ -286,21 +286,21 @@ mod split_group_pcie; #[cfg(test)] use split_group_pcie::adapt_decay; use split_group_pcie::adapt_tuning; -pub(in crate::qwen_forward) use split_group_pcie::{choose_swaps, choose_swaps_by}; #[cfg(test)] use split_group_pcie::choose_swaps_reference; pub(in crate::qwen_forward) use split_group_pcie::pcie_locked_only; pub(in crate::qwen_forward) use split_group_pcie::split_group_pcie; pub(in crate::qwen_forward) use split_group_pcie::{PcieSplitPolicy, RoutedGroup}; +pub(in crate::qwen_forward) use split_group_pcie::{choose_swaps, choose_swaps_by}; mod cross_layer_potential; mod swap_tie_order; 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; #[cfg(test)] mod strata_pcie_auto_tests; -mod span_cache_and_pcie_lag; use span_cache_and_pcie_lag::span_cache_enabled; mod source_spans; pub(super) use source_spans::source_spans; 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 4c659764..4293ca74 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 @@ -1,13 +1,13 @@ //! Functions: `open_tier`, `fill_and_pin`, `read_profile`, `warn_decode_headroom` and 15 more. //! Split out of `original_serve_residency` to keep its files under the line limit. -use super::{ - LOAN_FLOOR, VANILLA_FREE_FLOOR_MIB, VERIFIER_ASSEMBLY_MIB, Context, Error, ExpertTierConfig, ModelBinding, - MoeWeightCache, OriginalCacheOptions, OriginalExpertCache, OriginalRankedExperts, Rc, ResidentExpertBankSpan, - Result, SpanCache, driver_error, original_cache_startup, span_cache_enabled, -}; #[cfg(not(target_os = "linux"))] use super::MappedExpertBank; +use super::{ + Context, Error, ExpertTierConfig, LOAN_FLOOR, ModelBinding, MoeWeightCache, OriginalCacheOptions, + OriginalExpertCache, OriginalRankedExperts, Rc, ResidentExpertBankSpan, Result, SpanCache, VANILLA_FREE_FLOOR_MIB, + VERIFIER_ASSEMBLY_MIB, driver_error, original_cache_startup, span_cache_enabled, +}; use leleka_cuda_driver::RefillBatchOptions; /// generate.cpp startup of the tier for the serve stack: size and open the cache after every other owner, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs index e7617ff2..eb7f65a1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs @@ -1,5 +1,4 @@ -//! Pins the serve conversation policy over a fake stack: a continuing request resumes at its last turn, a settled -//! session continues live, cancel and failure keep or drop checkpoints, the chain is bounded and reread mode works. +//! Pins the serve conversation policy over a fake stack: resume, settle, cancel, failure, bounded chain, reread. use super::{ConversationConfig, Error, PromptOptions, RequestStart, ResumeDevice, ServeConversation, TURN_TOKEN}; use crate::backend::original_prompt::{PlanLimits, PromptPath, PromptPlan, ResumePoint}; 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/original_serve_stack_methods.rs index ad95b9d4..58ca4811 100644 --- 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/original_serve_stack_methods.rs @@ -33,9 +33,10 @@ mod executor_opening; use executor_opening::ExecutorOpening; mod open_phase_steps; use open_phase_steps::{ - Policies, Weights, check_open, load_weights, loan_ladder, log_open_inventory, open_executor, open_expert_cache, - open_prefix, serve_policies, share_rt_dense_roles, + Policies, Weights, check_open, load_weights, open_executor, serve_policies, share_rt_dense_roles, }; +mod open_cache_steps; +use open_cache_steps::{loan_ladder, log_open_inventory, open_expert_cache, open_prefix}; mod serve_request_step; use serve_request_step::{ServeEnv, serve_over_host}; mod original_serve_stack_decode_phase; 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/original_serve_stack_methods/open_cache_steps.rs new file mode 100644 index 00000000..a37918c3 --- /dev/null +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_cache_steps.rs @@ -0,0 +1,157 @@ +//! The caches `open` sizes from what the host has: the cross-session prefix cache (budget from the memory governor), +//! the VRAM expert tier with its loan ladder, and the governor's startup inventory log. + +use super::{ + Context, LOAN_TIER_ROWS, LoanTier, ModelBinding, MoeWeightCache, OriginalExpertCache, PARKED_BYTES_PER_TOKEN, + PARKED_STATE_ESTIMATE, PINNED_MODEL, PrefillLayoutOptions, PrefixServe, ServeFailure, StackBlock, StackConfig, + StackState, at, operator_note, original_serve_residency, prefill_bytes, +}; + +/// The cross-session prefix cache of the config, sized from the memory governor's budget; `None` when it is off or has +/// no budget. +pub(super) fn open_prefix(config: &StackConfig) -> Option> { + let prefix_config = config.prefix.as_ref()?; + let available = crate::conversation::memory::available_memory(); + // the budget comes from the memory governor (what is left above the floors), not from an independent default + let complement_pending = (config.expert_tier.resident_budget_gib.max(0.0) * (1u64 << 30) as f64) as u64; + let bytes = crate::memory_governor::resolve_prefix_budget(prefix_config.budget, available, complement_pending) + .unwrap_or_else(|| prefix_config.resolve_budget(available)); + let mut prefix_config = prefix_config.clone(); + if let Some(g) = leleka_memory::Governor::global() { + // stop admitting before anything has to be shed: soft floor + reserve (the real CRM session sat 4.4 GiB above + // a 3 GiB floor) + prefix_config.memory_floor = prefix_config.memory_floor.max(g.policy().admit_floor()); + } + let prefix_config = &prefix_config; + if bytes == 0 { + operator_note(&format!( + "prefix cache off (budget {:?}, available host memory {:?} MiB)", + prefix_config.budget, + available.map(|b| b >> 20) + )); + return None; + } + let identity = format!("qwen4exp:{PINNED_MODEL}:kv={:?}:resident={}", config.kv_format, config.kv_resident); + let clock = config.clock.clone(); + let serve = PrefixServe::new(prefix_config.clone(), config.capacity, bytes, &identity).with_clock(clock); + note_prefix_on(&serve, bytes, available); + Some(serve) +} + +fn note_prefix_on(serve: &PrefixServe, bytes: u64, available: Option) { + operator_note(&format!( + "prefix cache on: block/grid {} tokens, budget {} MiB, state ~{} MiB + {} B per token, \ + host memory available {:?} MiB, namespace {}", + serve.block_tokens(), + bytes >> 20, + PARKED_STATE_ESTIMATE >> 20, + PARKED_BYTES_PER_TOKEN, + available.map(|b| b >> 20), + crate::prefix_cache::summary::hex(serve.namespace()) + )); +} + +/// The VRAM expert tier and the number of its last slots the prompt path borrows (`None`: it allocates its own +/// buffers). +pub(super) fn open_expert_cache<'ctx>( + binding: &ModelBinding, + context: &'ctx Context<'ctx>, + moe: &MoeWeightCache<'ctx>, + config: &StackConfig, + layout: PrefillLayoutOptions, +) -> std::result::Result<(Option>, Option), ServeFailure> { + let mut loan = None; + let tier_open = staged!( + "expert tier (VRAM slots + profile fill)", + context, + original_serve_residency::open_tier(binding, context, moe, &config.expert_tier, config.capacity) + .map_err(at("expert tier"))? + ); + let expert_cache = match tier_open { + Some((cache, filled)) => { + if config.expert_tier.prefill_borrow && config.expert_tier.profile.is_some() { + loan = + original_serve_residency::loan_slots(&cache, prefill_bytes(layout).map_err(at("prefill bytes"))?) + .map_err(at("expert-cache loan"))?; + } + note_expert_cache(&cache, filled, loan); + note_tier_adaptation(&config.expert_tier); + Some(cache) + } + None => None, + }; + Ok((expert_cache, loan)) +} + +/// The tier's adaptation settings on the operator log (an A/B arm that sets them can show the engine got them). +fn note_tier_adaptation(tier: &original_serve_residency::ExpertTierConfig) { + operator_note(&format!( + "expert tier adaptation: every {} rounds, up to {} swaps", + tier.adapt_every, tier.adapt_swaps + )); +} + +fn note_expert_cache(cache: &OriginalExpertCache<'_>, filled: usize, loan: Option) { + operator_note(&format!( + "expert cache {} slots ({:.2} GiB, {}), {filled} filled from the profile; the prompt path {}; \ + GPU experts round differently from the CPU's (bench/results/2026-09-27-cache-parity)", + cache.slots(), + cache.bytes() as f64 / f64::from(1u32 << 30), + if cache.per_layer_admission() { "per layer" } else { "global" }, + match loan { + Some(k) => format!("borrows its last {k} slots"), + None => "allocates its own buffers".to_owned(), + } + )); +} + +/// Smaller loans for smaller chunks (`LELEKA_PREFILL_LOAN_TIERS=1`), ascending by rows; empty when the ladder is off. +pub(super) fn loan_ladder( + config: &StackConfig, + layout: PrefillLayoutOptions, + loan: Option, + expert_cache: Option<&OriginalExpertCache<'_>>, +) -> std::result::Result, ServeFailure> { + let mut loan_tiers: Vec = Vec::new(); + if let (Some(full), Some(cache), true) = (loan, expert_cache, config.loan_tiers) { + for rows in LOAN_TIER_ROWS.into_iter().filter(|&r| r < config.capacity) { + let tier_layout = PrefillLayoutOptions { capacity: rows, ..layout }; + let slots = original_serve_residency::loan_slots( + cache, + prefill_bytes(tier_layout).map_err(at("prefill bytes (tier)"))?, + ) + .map_err(at("expert-cache loan (tier)"))?; + if let Some(slots) = slots.filter(|&s| s < full && loan_tiers.last().is_none_or(|t| s > t.slots)) { + loan_tiers.push(LoanTier { rows, layout: tier_layout, slots }); + } + } + if !loan_tiers.is_empty() { + note_loan_ladder(&loan_tiers, full, config.capacity); + } + } + Ok(loan_tiers) +} + +fn note_loan_ladder(loan_tiers: &[LoanTier], full: usize, capacity: usize) { + operator_note(&format!( + "prompt loan ladder: {}, up to {capacity} rows {full} slots", + loan_tiers.iter().map(|t| format!("up to {} rows {} slots", t.rows, t.slots)).collect::>().join(", ") + )); +} + +/// The governor's startup log: the inventory of allocation classes and the load ledger. +pub(super) fn log_open_inventory() { + if let Some(governor) = leleka_memory::Governor::global() { + governor.log(&format!( + "stack open; inventory of allocation classes (accounted by their owners): +{}", + governor.inventory().table() + )); + governor.log(&format!( + "load ledger (measured: kernel and driver deltas per opening step): +{}", + governor.ledger().table() + )); + governor.publish(); + } +} 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/original_serve_stack_methods/open_phase_steps.rs index 48b42a19..cd6af9b2 100644 --- 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/original_serve_stack_methods/open_phase_steps.rs @@ -1,15 +1,12 @@ //! The steps of `OriginalServeStack::open`: check the model shape, resolve the policies, load the weights (KAR, //! embedding), in the order `open` runs them. Each step keeps its stage marks, notes and error context. -// Stays a glob on purpose: the file is at the 400-line limit and the explicit list would put it over. use super::{ Context, DenseWeightCache, DraftAttachmentTables, DraftAttachmentTarget, Error, ExecutorOpening, ExecutorSizing, - ExecutorTarget, KarPleCache, LOAN_TIER_ROWS, LoanTier, ModelBinding, MoeWeightCache, NativeHeadDispatch, - OriginalExpertCache, OriginalMtpFullOwner, OriginalNativeOutput, OriginalPromptEmbedding, OriginalPromptExecutor, - OriginalServeSettings, OriginalSpecController, PARKED_BYTES_PER_TOKEN, PARKED_STATE_ESTIMATE, PINNED_MODEL, - PrefillLayoutOptions, PrefixServe, PromptWeights, QwenSession, Rc, RtMtpLoad, ServeFailure, StackBlock, - StackConfig, StackState, VOCABULARY, at, dbg_el, failure, operator_note, original_serve_residency, prefill_bytes, - vram_note, + ExecutorTarget, KarPleCache, ModelBinding, MoeWeightCache, NativeHeadDispatch, OriginalMtpFullOwner, + OriginalNativeOutput, OriginalPromptEmbedding, OriginalPromptExecutor, OriginalServeSettings, + OriginalSpecController, PrefillLayoutOptions, PromptWeights, QwenSession, Rc, RtMtpLoad, ServeFailure, StackConfig, + VOCABULARY, at, dbg_el, failure, operator_note, vram_note, }; use crate::qwen_forward::session::original_prompt::draft::OriginalDraftSession; @@ -256,152 +253,3 @@ pub(super) fn share_rt_dense_roles<'ctx>( } Ok(()) } - -/// The cross-session prefix cache of the config, sized from the memory governor's budget; `None` when it is off or has -/// no budget. -pub(super) fn open_prefix(config: &StackConfig) -> Option> { - let prefix_config = config.prefix.as_ref()?; - let available = crate::conversation::memory::available_memory(); - // the budget comes from the memory governor (what is left above the floors), not from an independent default - let complement_pending = (config.expert_tier.resident_budget_gib.max(0.0) * (1u64 << 30) as f64) as u64; - let bytes = crate::memory_governor::resolve_prefix_budget(prefix_config.budget, available, complement_pending) - .unwrap_or_else(|| prefix_config.resolve_budget(available)); - let mut prefix_config = prefix_config.clone(); - if let Some(g) = leleka_memory::Governor::global() { - // stop admitting before anything has to be shed: soft floor + reserve (the real CRM session sat 4.4 GiB above - // a 3 GiB floor) - prefix_config.memory_floor = prefix_config.memory_floor.max(g.policy().admit_floor()); - } - let prefix_config = &prefix_config; - if bytes == 0 { - operator_note(&format!( - "prefix cache off (budget {:?}, available host memory {:?} MiB)", - prefix_config.budget, - available.map(|b| b >> 20) - )); - return None; - } - let identity = format!("qwen4exp:{PINNED_MODEL}:kv={:?}:resident={}", config.kv_format, config.kv_resident); - let clock = config.clock.clone(); - let serve = PrefixServe::new(prefix_config.clone(), config.capacity, bytes, &identity).with_clock(clock); - note_prefix_on(&serve, bytes, available); - Some(serve) -} - -fn note_prefix_on(serve: &PrefixServe, bytes: u64, available: Option) { - operator_note(&format!( - "prefix cache on: block/grid {} tokens, budget {} MiB, state ~{} MiB + {} B per token, \ - host memory available {:?} MiB, namespace {}", - serve.block_tokens(), - bytes >> 20, - PARKED_STATE_ESTIMATE >> 20, - PARKED_BYTES_PER_TOKEN, - available.map(|b| b >> 20), - crate::prefix_cache::summary::hex(serve.namespace()) - )); -} - -/// The VRAM expert tier and the number of its last slots the prompt path borrows (`None`: it allocates its own -/// buffers). -pub(super) fn open_expert_cache<'ctx>( - binding: &ModelBinding, - context: &'ctx Context<'ctx>, - moe: &MoeWeightCache<'ctx>, - config: &StackConfig, - layout: PrefillLayoutOptions, -) -> std::result::Result<(Option>, Option), ServeFailure> { - let mut loan = None; - let tier_open = staged!( - "expert tier (VRAM slots + profile fill)", - context, - original_serve_residency::open_tier(binding, context, moe, &config.expert_tier, config.capacity) - .map_err(at("expert tier"))? - ); - let expert_cache = match tier_open { - Some((cache, filled)) => { - if config.expert_tier.prefill_borrow && config.expert_tier.profile.is_some() { - loan = - original_serve_residency::loan_slots(&cache, prefill_bytes(layout).map_err(at("prefill bytes"))?) - .map_err(at("expert-cache loan"))?; - } - note_expert_cache(&cache, filled, loan); - note_tier_adaptation(&config.expert_tier); - Some(cache) - } - None => None, - }; - Ok((expert_cache, loan)) -} - -/// The tier's adaptation settings on the operator log (an A/B arm that sets them can show the engine got them). -fn note_tier_adaptation(tier: &original_serve_residency::ExpertTierConfig) { - operator_note(&format!( - "expert tier adaptation: every {} rounds, up to {} swaps", - tier.adapt_every, tier.adapt_swaps - )); -} - -fn note_expert_cache(cache: &OriginalExpertCache<'_>, filled: usize, loan: Option) { - operator_note(&format!( - "expert cache {} slots ({:.2} GiB, {}), {filled} filled from the profile; the prompt path {}; \ - GPU experts round differently from the CPU's (bench/results/2026-09-27-cache-parity)", - cache.slots(), - cache.bytes() as f64 / f64::from(1u32 << 30), - if cache.per_layer_admission() { "per layer" } else { "global" }, - match loan { - Some(k) => format!("borrows its last {k} slots"), - None => "allocates its own buffers".to_owned(), - } - )); -} - -/// Smaller loans for smaller chunks (`LELEKA_PREFILL_LOAN_TIERS=1`), ascending by rows; empty when the ladder is off. -pub(super) fn loan_ladder( - config: &StackConfig, - layout: PrefillLayoutOptions, - loan: Option, - expert_cache: Option<&OriginalExpertCache<'_>>, -) -> std::result::Result, ServeFailure> { - let mut loan_tiers: Vec = Vec::new(); - if let (Some(full), Some(cache), true) = (loan, expert_cache, config.loan_tiers) { - for rows in LOAN_TIER_ROWS.into_iter().filter(|&r| r < config.capacity) { - let tier_layout = PrefillLayoutOptions { capacity: rows, ..layout }; - let slots = original_serve_residency::loan_slots( - cache, - prefill_bytes(tier_layout).map_err(at("prefill bytes (tier)"))?, - ) - .map_err(at("expert-cache loan (tier)"))?; - if let Some(slots) = slots.filter(|&s| s < full && loan_tiers.last().is_none_or(|t| s > t.slots)) { - loan_tiers.push(LoanTier { rows, layout: tier_layout, slots }); - } - } - if !loan_tiers.is_empty() { - note_loan_ladder(&loan_tiers, full, config.capacity); - } - } - Ok(loan_tiers) -} - -fn note_loan_ladder(loan_tiers: &[LoanTier], full: usize, capacity: usize) { - operator_note(&format!( - "prompt loan ladder: {}, up to {capacity} rows {full} slots", - loan_tiers.iter().map(|t| format!("up to {} rows {} slots", t.rows, t.slots)).collect::>().join(", ") - )); -} - -/// The governor's startup log: the inventory of allocation classes and the load ledger. -pub(super) fn log_open_inventory() { - if let Some(governor) = leleka_memory::Governor::global() { - governor.log(&format!( - "stack open; inventory of allocation classes (accounted by their owners): -{}", - governor.inventory().table() - )); - governor.log(&format!( - "load ledger (measured: kernel and driver deltas per opening step): -{}", - governor.ledger().table() - )); - governor.publish(); - } -} diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs index 4b26e395..c447f0a2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs @@ -3,8 +3,8 @@ use super::super::original_spec_draft::{DraftPick, FirstSeedPoint, OriginalFirstDraftEngine, TargetSeedRow}; use super::{ - AdaptiveConfig, DraftPreparation, DraftSampling, Error, NanGuard, OriginalDraftEngine, OriginalSpecController, OriginalSpecEngine, - Result, SpecConfig, SpecError, SpecWindow, + AdaptiveConfig, DraftPreparation, DraftSampling, Error, NanGuard, OriginalDraftEngine, OriginalSpecController, + OriginalSpecEngine, Result, SpecConfig, SpecError, SpecWindow, }; mod golden; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs index d3224760..f9ee0902 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs @@ -3,8 +3,8 @@ //! drafter. use super::{ - AdaptiveConfig, EndRunSetup, Error, Fake, NanGuard, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, begin, config, drive, - expected, prompt, run_to_the_end, + AdaptiveConfig, EndRunSetup, Error, Fake, NanGuard, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, begin, + config, drive, expected, prompt, run_to_the_end, }; #[test] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs index 023dcf37..aeab5ce9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs @@ -1,13 +1,13 @@ //! Test-only replay hooks of OutputStage (record logits of a reset or prefix replay, count compact completions) and //! the shared helpers of the stage: greedy pick, activation and logit encoding, weight-owner check and error mapping. +#[cfg(test)] +use super::OutputStage; use super::{ ACTIVATION_BYTES, BindingIdentity, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, HeadGreedySelection, LOGIT_BYTES, LogitValues, OUTPUT_WEIGHT_BYTES, OutputBindingError, OutputWeights, Result, Stage, TokenId, VOCABULARY, }; -#[cfg(test)] -use super::OutputStage; // The real ignored reset test opts in explicitly. Other test callers retain // no extra values; production builds have neither this storage nor a reader. 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 90e5ec92..6a0580b1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention.rs @@ -100,8 +100,8 @@ pub(super) struct NativePromptAttentionBatch<'source, 'lease, 'ctx> { provider: Rc, } -mod qsa_ready; mod decode_selected_cached; +mod qsa_ready; use decode_selected_cached::SelectedKvBytes; use decode_selected_cached::attend_retained; use decode_selected_cached::attention_driver_error; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs index 46505962..a8c3655e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs @@ -2,14 +2,14 @@ //! layer's KV pages, pooled index keys and tail at a position), with their equality, extent and gather checks. //! Also the serving context size and the device headroom a QSA step requires. -use super::{ - BindingIdentity, Directory, Error, KV, LayerId, PackedKv, Position, QsaOwner, QsaPrior, Rc, Result, Stage, State, - reserve, validate_half, validate_ids, validate_values, -}; #[cfg(all(test, target_arch = "x86_64"))] use super::OracleQsaParts; #[cfg(test)] use super::PAGE; +use super::{ + BindingIdentity, Directory, Error, KV, LayerId, PackedKv, Position, QsaOwner, QsaPrior, Rc, Result, Stage, State, + reserve, validate_half, validate_ids, validate_values, +}; /// The serving context in cells (262144 unless configured; see `contract::serving_cells`). pub(super) fn context() -> usize { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs index e49029f6..3a7d26da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident.rs @@ -1,13 +1,13 @@ //! Actor-owned bounded index-key mirror; host QsaPrior remains canonical. //! Only exact immutable parent identity permits incremental device publication. +#[cfg(all(test, target_arch = "x86_64"))] +use super::combined_qsa_observer; use super::{ BindingIdentity, BlockQuery, Context, DeviceBuffer, Error, QsaPrior, QsaSelectionRequest, Rc, Result, admit_budget, context, device_peak, driver_error, reserve, select_with_keys, validate_values, }; #[cfg(test)] use super::{Directory, KvPage, LayerId, PAGE, Position, QsaOwner, State, TokenLayer}; -#[cfg(all(test, target_arch = "x86_64"))] -use super::combined_qsa_observer; #[cfg(test)] use super::{KV, QsaPending, select}; use std::cell::Cell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs index e784d4c2..1536ddc7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs @@ -2,13 +2,13 @@ //! that brings it from one `QsaPrior` to its successor: reload, append one pooled row, or change only the spare row. //! Reset, replay and speculative branches are misses. A layer's mirror is allocated on its first selection. +#[cfg(all(test, target_arch = "x86_64"))] +use super::combined_qsa_observer; use super::{ BindingIdentity, BlockQuery, Cell, Context, Entry, Error, QsaIndexKeyCache, QsaPrior, QsaSelectionRequest, ROW_BYTES, Rc, Result, Update, admit_budget, context, device_peak, driver_error, reserve, select_with_keys, validate_values, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::combined_qsa_observer; /// Pooled key rows of the serving context (`65537` at 262144 cells). pub(super) fn max_rows() -> usize { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs index baaa73bf..8940076d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs @@ -2,14 +2,14 @@ //! Projects the host rows or the native prompt row, then builds the next prior as a pending candidate that is //! published only at token commit. Admission checks the binding, layer, position and residual input first. +#[cfg(all(test, target_arch = "x86_64"))] +use super::combined_qsa_observer; use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, Norm, Position, ProjectionSources, QGate, QsaIndexStage, QsaLayerProjection, QsaMatrixRole, QsaPending, QsaPrepareRequest, QsaPrepared, QsaPrior, QsaSelectionRequest, QsaWeights, QwenStepTxn, Rc, ResidualReady, Result, admit_budget, append, binding_error, context, norm, pack, project_input, rope, select, split, validate_ids, validate_values, }; -#[cfg(all(test, target_arch = "x86_64"))] -use super::combined_qsa_observer; use crate::qwen_forward::prompt_device_rows::PromptWeights; use crate::qwen_forward::q6_attention_columns::{ColumnKey, RowAdmission}; use crate::qwen_forward::qsa_prefill_batch::AttentionRow; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs index 2718068b..92c6c426 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt.rs @@ -7,9 +7,9 @@ use super::super::qsa_index::prompt_device::resident_device::{ ParkedLayerSpan, ParkedPrefix, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, ResidentQsaSeal, SpanExport, }; use super::{ - BindingIdentity, Context, Dimension, Error, GdnPrior, GrRole, InputReady, LayerId, ModelBinding, PlePrior, Position, - QsaIndexPrior, QsaOwner, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, TokenId, - TokenLayer, + BindingIdentity, Context, Dimension, Error, GdnPrior, GrRole, InputReady, LayerId, ModelBinding, PlePrior, + Position, QsaIndexPrior, QsaOwner, QwenSession, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, + TokenId, TokenLayer, }; use std::cell::{Cell, RefCell}; pub(in crate::qwen_forward) mod draft; 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 e5e06d4b..56ff33ff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs @@ -2,8 +2,8 @@ //! the PLE, GDN and QSA priors keep their exact identity (child modules); the helpers build tokens and positions. use super::{ - Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, - QsaOwner, QwenSession, Rc, Stage, TokenId, TokenLayer, + 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::qwen_forward::contract::Dimension; From fbca47bd75250243a93bc5e45b1645fb1f63490c Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 21:31:39 +0100 Subject: [PATCH 7/7] engine-qwen35-cuda tests: bringup_prints_gated finds test-only children in parent/name.rs (modules no longer use #[path]) Co-Authored-By: Claude Sonnet 5.5 --- crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs b/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs index c03d7cf8..2836bc78 100644 --- a/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs +++ b/crates/engine-qwen35-cuda/tests/bringup_prints_gated.rs @@ -92,6 +92,11 @@ fn push_declared_files(gated: &mut Vec, file: &Path, name: &str, above: let dir = file.parent().unwrap(); gated.push(dir.join(format!("{name}.rs"))); gated.push(dir.join(name).join("mod.rs")); + // an ordinary child of `parent.rs` lives in `parent/name.rs` + if let Some(stem) = file.file_stem() { + gated.push(dir.join(stem).join(format!("{name}.rs"))); + gated.push(dir.join(stem).join(name).join("mod.rs")); + } // `#[path = "other_name.rs"] mod name;` if let Some(path) = above.split("#[path = \"").nth(1).and_then(|rest| rest.split('"').next()) { gated.push(dir.join(path));