diff --git a/architecture-baseline.json b/architecture-baseline.json index ae0c3be4..760bdc3b 100644 --- a/architecture-baseline.json +++ b/architecture-baseline.json @@ -7,7 +7,7 @@ "allow-unused-imports:leleka-cpu-sys": 48, "allow-unused-imports:leleka-cuda-driver": 863, "allow-unused-imports:leleka-engine-core": 18, - "allow-unused-imports:leleka-engine-qwen35-cuda": 396, + "allow-unused-imports:leleka-engine-qwen35-cuda": 224, "allow-unused-imports:leleka-experimental-ref": 1, "allow-unused-imports:leleka-gateway-text": 4, "allow-unused-imports:leleka-gguf": 5, @@ -23,7 +23,7 @@ "allow-unused-imports:leleka-openvino": 5, "allow-unused-imports:leleka-runtime-client": 3, "allow-unused-imports:leleka-tokenizer": 3, - "allow-unused-imports:strata-control": 63, + "allow-unused-imports:strata-control": 48, "allow-unused-imports:strata-desktop-core": 9, "dyn-trait:leleka-backend-api": 1, "dyn-trait:leleka-cpu-worker": 4, @@ -65,15 +65,14 @@ "env-read:leleka-npu-worker": 1, "env-read:leleka-obs": 2, "env-read:leleka-tokenizer": 2, - "env-read:strata-control": 19, - "env-read:strata-desktop-core": 15, + "env-read:strata-control": 14, + "env-read:strata-desktop-core": 13, "glob-super-import:leleka-cpu-kernels": 2, "glob-super-import:leleka-cpu-sys": 13, "glob-super-import:leleka-cpu-worker": 1, "glob-super-import:leleka-cuda-driver": 571, - "glob-super-import:leleka-deploy": 79, - "glob-super-import:leleka-engine-qwen35-cuda": 328, - "glob-super-import:leleka-gateway-domain": 2, + "glob-super-import:leleka-deploy": 15, + "glob-super-import:leleka-engine-qwen35-cuda": 70, "glob-super-import:leleka-gguf": 5, "glob-super-import:leleka-gptoss": 17, "glob-super-import:leleka-gptoss-igpu": 2, @@ -85,8 +84,8 @@ "glob-super-import:leleka-native-cpu-expert": 15, "glob-super-import:leleka-openvino": 5, "glob-super-import:leleka-tokenizer": 1, - "glob-super-import:strata-control": 37, - "glob-super-import:strata-desktop-core": 16, + "glob-super-import:strata-control": 9, + "glob-super-import:strata-desktop-core": 12, "instant-now:leleka-backend-api": 2, "instant-now:leleka-cpu-worker": 9, "instant-now:leleka-cuda-driver": 25, diff --git a/control-plane/src/config.rs b/control-plane/src/config.rs index 4d46917c..780b5052 100644 --- a/control-plane/src/config.rs +++ b/control-plane/src/config.rs @@ -168,6 +168,6 @@ pub use control_vector::*; mod methods; #[allow(unused_imports)] pub use methods::*; -mod optional_env; +mod process_env; #[allow(unused_imports)] -pub use optional_env::*; +pub use process_env::*; diff --git a/control-plane/src/config/methods.rs b/control-plane/src/config/methods.rs index 07c4b545..2dba85f9 100644 --- a/control-plane/src/config/methods.rs +++ b/control-plane/src/config/methods.rs @@ -1,14 +1,14 @@ //! The methods of `Config`: loading the file and environment, provisioning assets, host checks. use super::{ - Config, Duration, FileConfig, FileEngine, FileExtraWorker, OsString, Path, PathBuf, SocketAddr, WorkerConfig, env, - fs, optional_env, + Config, Duration, FileConfig, FileEngine, FileExtraWorker, OsString, Path, PathBuf, SocketAddr, WorkerConfig, fs, + optional_env, optional_env_os, }; mod load; mod load_checks; mod load_engine; -mod load_parts; +mod config_assembly; mod load_sections; mod load_with_path; mod provision; diff --git a/control-plane/src/config/methods/load_parts.rs b/control-plane/src/config/methods/config_assembly.rs similarity index 100% rename from control-plane/src/config/methods/load_parts.rs rename to control-plane/src/config/methods/config_assembly.rs diff --git a/control-plane/src/config/methods/load_checks.rs b/control-plane/src/config/methods/load_checks.rs index 79f3f389..1380150d 100644 --- a/control-plane/src/config/methods/load_checks.rs +++ b/control-plane/src/config/methods/load_checks.rs @@ -1,8 +1,8 @@ //! The stages of `Config::load_with_path` that check one part of the file against the engine section, in the order //! the single function used to run them. Each fails with the same message as before. -use super::load_parts::{EngineSide, Identity, Surface}; -use super::{Config, FileConfig, Path, PathBuf, WorkerConfig, env, fs, optional_env}; +use super::config_assembly::{EngineSide, Identity, Surface}; +use super::{Config, FileConfig, Path, PathBuf, WorkerConfig, fs, optional_env, optional_env_os}; /// The file named by the CLI path or the environment, parsed, with its asset bundles and native model validated. pub(super) fn read_checked_file( @@ -20,7 +20,7 @@ pub(super) fn read_checked_file( fn read_file(path: Option<&Path>) -> Result<(Option, FileConfig), crate::BoxError> { let config_path = path .map(|p| p.as_os_str().to_owned()) - .or_else(|| env::var_os("STRATA_CONFIG")) + .or_else(|| optional_env_os("STRATA_CONFIG")) .map(PathBuf::from); let file = match &config_path { Some(path) => serde_json::from_str::(&fs::read_to_string(path)?)?, @@ -39,7 +39,7 @@ fn tokenizer_setting( file: &FileConfig, worker: Option<&WorkerConfig>, ) -> Result, crate::BoxError> { - let mut tokenizer_dir = env::var_os("STRATA_TOKENIZER_DIR") + let mut tokenizer_dir = optional_env_os("STRATA_TOKENIZER_DIR") .map(PathBuf::from) .or_else(|| { file.engine @@ -96,7 +96,7 @@ fn gptoss_setting( worker: Option<&WorkerConfig>, tokenizer_dir: Option<&PathBuf>, ) -> Result, crate::BoxError> { - let gptoss_gguf = env::var_os("STRATA_GPTOSS_GGUF") + let gptoss_gguf = optional_env_os("STRATA_GPTOSS_GGUF") .map(PathBuf::from) .or_else(|| { file.engine @@ -176,7 +176,7 @@ fn model_id(from_file: Option) -> Result, crate::BoxError fn api_key_setting( from_file: Option, ) -> Result>, crate::BoxError> { - let key = env::var_os("STRATA_API_KEY_FILE") + let key = optional_env_os("STRATA_API_KEY_FILE") .map(PathBuf::from) .or(from_file) .map(|path| crate::auth::ApiKey::from_file(&path).map(std::sync::Arc::new)) @@ -186,7 +186,7 @@ fn api_key_setting( /// `STRATA_RESPONSE_HISTORY_DIR` or the file's: absolute, not the root, no `..`. fn history_dir_setting(from_file: Option) -> Result, crate::BoxError> { - let dir = env::var_os("STRATA_RESPONSE_HISTORY_DIR") + let dir = optional_env_os("STRATA_RESPONSE_HISTORY_DIR") .map(PathBuf::from) .or(from_file); if dir.as_ref().is_some_and(|p| { diff --git a/control-plane/src/config/methods/load_sections.rs b/control-plane/src/config/methods/load_sections.rs index e55ff2fa..5e13601f 100644 --- a/control-plane/src/config/methods/load_sections.rs +++ b/control-plane/src/config/methods/load_sections.rs @@ -3,7 +3,7 @@ //! same order as when it was one function. use super::load_engine as engine; -use super::{Config, FileConfig, OsString, Path, SocketAddr, WorkerConfig, env, optional_env}; +use super::{Config, FileConfig, OsString, Path, SocketAddr, WorkerConfig, optional_env, optional_env_os}; pub(super) struct Limits { pub(super) bind: SocketAddr, @@ -102,7 +102,7 @@ impl Config { } pub(super) fn read_engine(file: &FileConfig) -> Result { - let executable = env::var_os("STRATA_ENGINE_EXE").or_else(|| { + let executable = optional_env_os("STRATA_ENGINE_EXE").or_else(|| { file.engine .as_ref() .map(|engine| OsString::from(&engine.executable)) diff --git a/control-plane/src/config/methods/load_with_path.rs b/control-plane/src/config/methods/load_with_path.rs index 1b80e92e..6e879f25 100644 --- a/control-plane/src/config/methods/load_with_path.rs +++ b/control-plane/src/config/methods/load_with_path.rs @@ -1,7 +1,7 @@ //! `Config::load_with_path`: the file, the environment, and the cross-checks between the sections. use super::load_checks as check; -use super::load_parts::CheckedSections; +use super::config_assembly::CheckedSections; use super::{Config, Path}; impl Config { diff --git a/control-plane/src/config/optional_env.rs b/control-plane/src/config/optional_env.rs deleted file mode 100644 index b98f6151..00000000 --- a/control-plane/src/config/optional_env.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Functions: `optional_env`. -//! Split out of `config` to keep its files under the line limit. - -use super::env; - -pub(super) fn optional_env(name: &str) -> Result, env::VarError> { - match env::var(name) { - Ok(value) => Ok(Some(value)), - Err(env::VarError::NotPresent) => Ok(None), - Err(error) => Err(error), - } -} diff --git a/control-plane/src/config/process_env.rs b/control-plane/src/config/process_env.rs new file mode 100644 index 00000000..636d60d9 --- /dev/null +++ b/control-plane/src/config/process_env.rs @@ -0,0 +1,20 @@ +//! The only place the run configuration reads the process environment (`STRATA_*`): one reader, so the keys the +//! operator can set are all asked here and a test can see where they enter. Separate from `config` for that reason. + +use std::ffi::OsString; + +use super::env; + +/// The value of the variable; `Ok(None)` when it is unset, an error when it is set but not valid Unicode. +pub(super) fn optional_env(name: &str) -> Result, env::VarError> { + match env::var(name) { + Ok(value) => Ok(Some(value)), + Err(env::VarError::NotPresent) => Ok(None), + Err(error) => Err(error), + } +} + +/// The value of the variable as an OS string (a path); `None` when it is unset. +pub(super) fn optional_env_os(name: &str) -> Option { + env::var_os(name) +} diff --git a/control-plane/src/kar_overlay.rs b/control-plane/src/kar_overlay.rs index 97882489..3ce7499b 100644 --- a/control-plane/src/kar_overlay.rs +++ b/control-plane/src/kar_overlay.rs @@ -180,9 +180,9 @@ pub struct Summary { pub provenance_path: PathBuf, } -mod shared; +mod sidecar_and_tensor_locations; #[allow(unused_imports)] -pub use shared::*; +pub use sidecar_and_tensor_locations::*; mod base_provenance; #[allow(unused_imports)] pub use base_provenance::*; diff --git a/control-plane/src/kar_overlay/base_provenance.rs b/control-plane/src/kar_overlay/base_provenance.rs index 7b6dcb89..5c2b1b8b 100644 --- a/control-plane/src/kar_overlay/base_provenance.rs +++ b/control-plane/src/kar_overlay/base_provenance.rs @@ -10,11 +10,11 @@ impl BaseProvenance { match (self.schema.as_str(), self.ple_part_elements) { ("strata-next/sharded-stream-provenance-v4", None) => true, ("strata-next/sharded-stream-provenance-v5", Some(limit)) => { - (32..=crate::stream_parts::MAX_PART_ELEMENTS).contains(&limit) + (32..=crate::kar_shard_plan::MAX_PART_ELEMENTS).contains(&limit) && self .partitioned_tensors .iter() - .any(|tensor| tensor.parent_name == crate::stream_parts::PLE_TENSOR_NAME) + .any(|tensor| tensor.parent_name == crate::kar_shard_plan::PLE_TENSOR_NAME) } _ => false, } diff --git a/control-plane/src/kar_overlay/shared.rs b/control-plane/src/kar_overlay/sidecar_and_tensor_locations.rs similarity index 100% rename from control-plane/src/kar_overlay/shared.rs rename to control-plane/src/kar_overlay/sidecar_and_tensor_locations.rs diff --git a/control-plane/src/kar_quality.rs b/control-plane/src/kar_quality.rs index 9c2be083..59e546f8 100644 --- a/control-plane/src/kar_quality.rs +++ b/control-plane/src/kar_quality.rs @@ -9,7 +9,7 @@ use crate::{ derived_mixed, gguf, gguf_f32_stream, kar::{self, VerifiedRangeDecoder}, model::Manifest, - prepare_preview, stream_parts, + prepare_preview, kar_shard_plan, }; const SAMPLE_ELEMENTS: u64 = 4096; diff --git a/control-plane/src/kar_quality/analyze.rs b/control-plane/src/kar_quality/analyze.rs index a70711de..57555285 100644 --- a/control-plane/src/kar_quality/analyze.rs +++ b/control-plane/src/kar_quality/analyze.rs @@ -2,8 +2,8 @@ //! Split out of `kar_quality` to keep its files under the line limit. use super::{ - File, Manifest, Path, Report, SourceShards, VerifiedRangeDecoder, derived_mixed, prepare_preview, previous, - sample_records, stream_parts, + File, Manifest, Path, Report, SourceShards, VerifiedRangeDecoder, derived_mixed, kar_shard_plan, prepare_preview, + previous, sample_records, }; pub fn analyze( @@ -19,7 +19,7 @@ pub fn analyze( if summary.source_digest != identity.derived_sha256 { return Err("KAR source digest changed after verification".into()); } - let parts = stream_parts::plan_shards(&identity, source_dir)?; + let parts = kar_shard_plan::plan_shards(&identity, source_dir)?; let source = SourceShards { dir: source_dir, identity: &identity, diff --git a/control-plane/src/kar_quality/parse_digest.rs b/control-plane/src/kar_quality/parse_digest.rs index 12b42c53..0a74097b 100644 --- a/control-plane/src/kar_quality/parse_digest.rs +++ b/control-plane/src/kar_quality/parse_digest.rs @@ -3,7 +3,7 @@ use super::{ File, Path, RecordError, Report, SAMPLE_ELEMENTS, SampleWindow, VerifiedRangeDecoder, Write, derived_mixed, gguf, - sample, stream_parts, + kar_shard_plan, sample, }; pub(super) fn parse_digest(value: &str) -> Result<[u8; 32], String> { @@ -18,7 +18,7 @@ pub(super) fn parse_digest(value: &str) -> Result<[u8; 32], String> { pub(super) struct SourceShards<'a> { pub(super) dir: &'a Path, pub(super) identity: &'a derived_mixed::ShardedIdentity, - pub(super) parts: &'a [Vec], + pub(super) parts: &'a [Vec], } fn sample_all( diff --git a/control-plane/src/kar_quality/previous.rs b/control-plane/src/kar_quality/previous.rs index 7d101cd6..e72a5f1c 100644 --- a/control-plane/src/kar_quality/previous.rs +++ b/control-plane/src/kar_quality/previous.rs @@ -3,11 +3,11 @@ use super::{ File, HashMap, Manifest, Path, Provenance, ProvenancePart, ProvenancePartition, ProvenanceShard, ProvenanceTensor, - derived_mixed, gguf, kar, parse_digest, stream_parts, + derived_mixed, gguf, kar, kar_shard_plan, parse_digest, }; use crate::model::ModelFile; -type Groups = Vec>; +type Groups = Vec>; type Partitions<'a> = HashMap<&'a str, &'a ProvenancePartition>; /// The recorded provenance with the identity and part layout rebuilt from it and the source shards. @@ -209,8 +209,8 @@ fn check_tensor_metadata( fn recorded_part( tensor: &gguf::TensorInfo, part: &ProvenancePart, -) -> Result { - Ok(stream_parts::PartIdentity { +) -> Result { + Ok(kar_shard_plan::PartIdentity { name: part.name.clone(), parent_name: tensor.name.clone(), parent_dimensions: tensor.dimensions.clone(), @@ -228,8 +228,8 @@ fn recorded_part( fn whole_part( tensor: &gguf::TensorInfo, recorded: &derived_mixed::TensorIdentity, -) -> stream_parts::PartIdentity { - stream_parts::PartIdentity { +) -> kar_shard_plan::PartIdentity { + kar_shard_plan::PartIdentity { name: tensor.name.clone(), parent_name: tensor.name.clone(), parent_dimensions: tensor.dimensions.clone(), @@ -248,7 +248,7 @@ fn part_group( tensor: &gguf::TensorInfo, recorded: &derived_mixed::TensorIdentity, partitioned: &Partitions<'_>, -) -> Result, String> { +) -> Result, String> { let Some(split) = partitioned.get(tensor.name.as_str()) else { return Ok(vec![whole_part(tensor, recorded)]); }; @@ -263,7 +263,7 @@ fn part_group( } fn check_group_cover( - group: &[stream_parts::PartIdentity], + group: &[kar_shard_plan::PartIdentity], tensor: &gguf::TensorInfo, recorded: &derived_mixed::TensorIdentity, ) -> Result<(), String> { diff --git a/control-plane/src/kar_quality/sample.rs b/control-plane/src/kar_quality/sample.rs index 7c53e068..6eca13f0 100644 --- a/control-plane/src/kar_quality/sample.rs +++ b/control-plane/src/kar_quality/sample.rs @@ -1,7 +1,7 @@ //! Per-part sampling of the original GGUF payload against the KAR reconstruction. use super::{ - File, RecordError, SampleWindow, VerifiedRangeDecoder, gguf, gguf_f32_stream, sample_windows, stream_parts, + File, RecordError, SampleWindow, VerifiedRangeDecoder, gguf, gguf_f32_stream, kar_shard_plan, sample_windows, }; /// Open source shard and archive decoder used while sampling the parts of one shard. @@ -39,7 +39,7 @@ impl Sums { fn window_offset( tensor_start: Option, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, window: &SampleWindow, block: (u64, u64), ) -> Result { @@ -52,7 +52,7 @@ fn window_offset( impl Sampler<'_> { fn original( &mut self, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, window: &SampleWindow, absolute: u64, source_bytes: u64, @@ -82,7 +82,7 @@ impl Sampler<'_> { fn reconstructed( &mut self, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, window: &SampleWindow, expected_len: usize, ) -> Result, String> { @@ -101,7 +101,7 @@ impl Sampler<'_> { fn window( &mut self, tensor_start: Option, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, window: &SampleWindow, block: (u64, u64), ) -> Result<(Vec, Vec), String> { @@ -116,7 +116,7 @@ impl Sampler<'_> { pub(super) fn shard( &mut self, index: &gguf::TensorIndex, - parts: &[Vec], + parts: &[Vec], records: &mut Vec, ) -> Result<(), String> { for (number, tensor) in index.tensors.iter().enumerate() { @@ -133,7 +133,7 @@ impl Sampler<'_> { pub(super) fn record( &mut self, tensor_start: Option, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, ) -> Result { let block = gguf::block_geometry(part.source_kind).ok_or("unsupported GGUF source kind")?; let elements = part.derived_bytes / 4; diff --git a/control-plane/src/stream_parts.rs b/control-plane/src/kar_shard_plan.rs similarity index 100% rename from control-plane/src/stream_parts.rs rename to control-plane/src/kar_shard_plan.rs diff --git a/control-plane/src/stream_parts/layout.rs b/control-plane/src/kar_shard_plan/layout.rs similarity index 100% rename from control-plane/src/stream_parts/layout.rs rename to control-plane/src/kar_shard_plan/layout.rs diff --git a/control-plane/src/stream_parts/plan.rs b/control-plane/src/kar_shard_plan/plan.rs similarity index 100% rename from control-plane/src/stream_parts/plan.rs rename to control-plane/src/kar_shard_plan/plan.rs diff --git a/control-plane/src/kar_writer.rs b/control-plane/src/kar_writer.rs index 3d121802..093525ee 100644 --- a/control-plane/src/kar_writer.rs +++ b/control-plane/src/kar_writer.rs @@ -105,9 +105,9 @@ mod archive_plan; mod write_archive; #[allow(unused_imports)] pub use write_archive::*; -mod write_archive_inner; +mod archive_write_steps; #[allow(unused_imports)] -pub use write_archive_inner::*; +pub use archive_write_steps::*; mod write_nested_section; #[allow(unused_imports)] pub use write_nested_section::*; diff --git a/control-plane/src/kar_writer/write_archive_inner.rs b/control-plane/src/kar_writer/archive_write_steps.rs similarity index 91% rename from control-plane/src/kar_writer/write_archive_inner.rs rename to control-plane/src/kar_writer/archive_write_steps.rs index ccf5bb60..b9ca5945 100644 --- a/control-plane/src/kar_writer/write_archive_inner.rs +++ b/control-plane/src/kar_writer/archive_write_steps.rs @@ -1,5 +1,5 @@ -//! Functions: `write_archive_inner`, `check_request`, `temporary_path`, `publish`. -//! Split out of `kar_writer` to keep its files under the line limit. +//! `write_archive_inner`: check the request, write the archive to a `.part` file, verify it and publish it with a hard +//! link that never replaces an existing destination. Separate from `kar_writer` so that order reads on its own. #[allow(unused_imports)] use super::archive_file::write_archive_file; diff --git a/control-plane/src/key_init/linux.rs b/control-plane/src/key_init/linux.rs index fcee53de..0dfbbba0 100644 --- a/control-plane/src/key_init/linux.rs +++ b/control-plane/src/key_init/linux.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{Path, USAGE}; use std::{ ffi::CString, fs::{File, OpenOptions}, diff --git a/control-plane/src/lib.rs b/control-plane/src/lib.rs index 0729d670..87663631 100644 --- a/control-plane/src/lib.rs +++ b/control-plane/src/lib.rs @@ -82,7 +82,7 @@ pub mod responses; pub mod runtime_config; pub mod service_install; pub mod service_unit; -pub mod stream_parts; +pub mod kar_shard_plan; pub mod tensor_export; pub use leleka_tokenizer as tokenizer; pub mod tokenizer_assets; diff --git a/control-plane/src/messages/adapt.rs b/control-plane/src/messages/adapt.rs index e62aa303..f8588932 100644 --- a/control-plane/src/messages/adapt.rs +++ b/control-plane/src/messages/adapt.rs @@ -1,8 +1,10 @@ //! Methods of `Blocks`: `event`, `message_start`, `open_text`, `text_delta` and 4 more. //! Functions: `adapt`, `stream_response`. Defines `Step`, `Blocks`. -#[allow(unused_imports)] -use super::*; +use super::{ + Body, Event, Events, IntoResponse, NativeEvents, Response, Sse, StatusCode, Value, close_text, error_value, json, + message, mpsc, send, stop, tool, usage, +}; use std::ops::ControlFlow; type Step = Result, &'static str>; diff --git a/control-plane/src/messages/count_tokens.rs b/control-plane/src/messages/count_tokens.rs index 305c3af2..31e1c827 100644 --- a/control-plane/src/messages/count_tokens.rs +++ b/control-plane/src/messages/count_tokens.rs @@ -1,7 +1,9 @@ //! `POST /v1/messages/count_tokens`: the Messages request counted through the native token counter. -#[allow(unused_imports)] -use super::*; +use super::{ + AppState, CountRequest, IntoResponse, Json, JsonRejection, Response, State, StatusCode, Value, error, json, + responses, to_bytes, +}; pub async fn count_tokens( State(state): State, diff --git a/control-plane/src/messages/error_type.rs b/control-plane/src/messages/error_type.rs index 77fae289..759974c4 100644 --- a/control-plane/src/messages/error_type.rs +++ b/control-plane/src/messages/error_type.rs @@ -1,7 +1,10 @@ //! The Messages route layers and error envelope, the handler of `POST /v1/messages` and the stream of its events. -#[allow(unused_imports)] -use super::*; +use super::{ + AppState, Context, Event, Events, HttpRequest, Infallible, IntoResponse, Json, JsonRejection, MAX_EVENT, Next, Pin, + Poll, Request, Response, State, StatusCode, Stream, Value, header, json, message, mpsc, responses, stream_response, + to_bytes, +}; pub(crate) fn error_value(status: StatusCode, message: &str) -> Value { leleka_gateway_domain::messages::error_value(status.as_u16(), message) } diff --git a/control-plane/src/model/manifest_fetch.rs b/control-plane/src/model/manifest_fetch.rs index d0584f5d..4c0575f9 100644 --- a/control-plane/src/model/manifest_fetch.rs +++ b/control-plane/src/model/manifest_fetch.rs @@ -1,7 +1,9 @@ //! Model manifest handling: verify, fetch with retry, the HTTP client and the Hugging Face request rules. -#[allow(unused_imports)] -use super::*; +use super::{ + ACCEPT_ENCODING, Client, Component, Duration, Error, FETCH_ATTEMPTS, Manifest, ModelFile, Path, RANGE, + RequestBuilder, Result, StatusCode, fetch_one, fs, io, preflight_space, verify_one, +}; impl Manifest { pub async fn load(path: &Path) -> Result { diff --git a/control-plane/src/model_pipeline.rs b/control-plane/src/model_pipeline.rs index ad167b43..71734256 100644 --- a/control-plane/src/model_pipeline.rs +++ b/control-plane/src/model_pipeline.rs @@ -6,7 +6,7 @@ use std::{ path::{Component, Path}, }; -use crate::{gguf, kar, model, prepare_preview, stream_parts}; +use crate::{gguf, kar, model, prepare_preview, kar_shard_plan}; pub enum PreviewOutcome { Created(prepare_preview::PreviewSummary), @@ -164,7 +164,7 @@ fn require_streamed_request( "streamed sharded preparation requires 1..=8 KAR levels", )?; if let Some(limit) = ple_part_elements { - stream_parts::validate_ple_limit(limit)?; + kar_shard_plan::validate_ple_limit(limit)?; } Ok(()) } diff --git a/control-plane/src/prepare_preview.rs b/control-plane/src/prepare_preview.rs index e5609e5e..1a22e17c 100644 --- a/control-plane/src/prepare_preview.rs +++ b/control-plane/src/prepare_preview.rs @@ -14,7 +14,7 @@ use crate::{ derived_iq3, derived_mixed, gguf, gguf_f32_stream, iq3_s, kar, kar_codec, kar_sample, kar_stream_encode, kar_writer, model::{self, Manifest}, - stream_parts, + kar_shard_plan, }; const MAX_SOURCE_BYTES: u64 = 64 * 1024 * 1024; @@ -100,11 +100,11 @@ pub use encode_preview_tensor::*; mod verify_derived; #[allow(unused_imports)] pub use verify_derived::*; -mod preview_common; -use preview_common::*; +mod staging_and_raw_tensor_reads; +use staging_and_raw_tensor_reads::*; mod sharded_encode; use sharded_encode::*; mod streamed_encode; use streamed_encode::*; -mod verify_sharded_parts; -use verify_sharded_parts::*; +mod sharded_archive_verification; +use sharded_archive_verification::*; diff --git a/control-plane/src/prepare_preview/encode_preview_tensor.rs b/control-plane/src/prepare_preview/encode_preview_tensor.rs index 480947f9..3ed07617 100644 --- a/control-plane/src/prepare_preview/encode_preview_tensor.rs +++ b/control-plane/src/prepare_preview/encode_preview_tensor.rs @@ -2,9 +2,9 @@ //! Functions: `relative_l2_error`, `prepared_tensor`, `encode_preview_tensor`, `verify_iq3` and 5 more. use super::{ - Manifest, PartLimits, Path, PreparedTensor, PreviewKind, StreamPolicy, derived_mixed, kar, kar_codec, kar_writer, - plan_verified_parts, require_sharded_header, require_sharded_provenance, require_sharded_sources, stream_parts, - verify_derived, + Manifest, PartLimits, Path, PreparedTensor, PreviewKind, StreamPolicy, derived_mixed, kar, kar_codec, + kar_shard_plan, kar_writer, plan_verified_parts, require_sharded_header, require_sharded_provenance, + require_sharded_sources, verify_derived, }; /// The calibrated planes of one tensor, before they are written as a section. @@ -145,7 +145,7 @@ pub fn verify_sharded( archive_path: &Path, ) -> Result { let limits = PartLimits { - max_part_elements: stream_parts::MAX_PART_ELEMENTS, + max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS, ple_part_elements: None, }; verify_sharded_inner(manifest, source_dir, archive_path, None, limits) @@ -161,7 +161,7 @@ pub fn verify_sharded_streamed( return Err("streamed sharded verification requires 1..=8 KAR levels".into()); } let limits = PartLimits { - max_part_elements: stream_parts::MAX_PART_ELEMENTS, + max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS, ple_part_elements: None, }; verify_sharded_inner(manifest, source_dir, archive_path, Some(levels), limits) @@ -174,12 +174,12 @@ pub fn verify_sharded_streamed_ple( levels: u8, ple_part_elements: u64, ) -> Result { - stream_parts::validate_ple_limit(ple_part_elements)?; + kar_shard_plan::validate_ple_limit(ple_part_elements)?; if !(1..=8).contains(&levels) { return Err("streamed sharded verification requires 1..=8 KAR levels".into()); } let limits = PartLimits { - max_part_elements: stream_parts::MAX_PART_ELEMENTS, + max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS, ple_part_elements: Some(ple_part_elements), }; verify_sharded_inner(manifest, source_dir, archive_path, Some(levels), limits) diff --git a/control-plane/src/prepare_preview/prepare_sharded.rs b/control-plane/src/prepare_preview/prepare_sharded.rs index 7dcc2409..b4db427d 100644 --- a/control-plane/src/prepare_preview/prepare_sharded.rs +++ b/control-plane/src/prepare_preview/prepare_sharded.rs @@ -3,8 +3,8 @@ use super::{ MAX_SOURCE_BYTES, MAX_TENSORS, Manifest, PartLimits, Path, PreviewSummary, ShardedEncoding, derived_mixed, - encode_shards, hash_file, kar_writer, nested_tensors, prepare_sharded_streamed_with_policy, require_architecture, - require_levels, sharded_provenance_value, staging_dir, stream_parts, write_sibling_provenance, + encode_shards, hash_file, kar_shard_plan, kar_writer, nested_tensors, prepare_sharded_streamed_with_policy, + require_architecture, require_levels, sharded_provenance_value, staging_dir, write_sibling_provenance, }; pub fn prepare_sharded( @@ -88,7 +88,7 @@ pub fn prepare_sharded_streamed( source_dir, destination, levels, - stream_parts::MAX_PART_ELEMENTS, + kar_shard_plan::MAX_PART_ELEMENTS, ) } @@ -99,14 +99,14 @@ pub fn prepare_sharded_streamed_ple( levels: u8, ple_part_elements: u64, ) -> Result { - stream_parts::validate_ple_limit(ple_part_elements)?; + kar_shard_plan::validate_ple_limit(ple_part_elements)?; prepare_sharded_streamed_with_policy( manifest, source_dir, destination, levels, PartLimits { - max_part_elements: stream_parts::MAX_PART_ELEMENTS, + max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS, ple_part_elements: Some(ple_part_elements), }, ) diff --git a/control-plane/src/prepare_preview/prepare_sharded_streamed_with_policy.rs b/control-plane/src/prepare_preview/prepare_sharded_streamed_with_policy.rs index adcb0231..16d9e3e4 100644 --- a/control-plane/src/prepare_preview/prepare_sharded_streamed_with_policy.rs +++ b/control-plane/src/prepare_preview/prepare_sharded_streamed_with_policy.rs @@ -3,8 +3,8 @@ use super::{ Manifest, PartLimits, Path, PreviewSummary, StreamedEncoding, StreamedRun, StreamedTensor, apply_stream_policy, - derived_mixed, fs, hash_file, kar, kar_writer, minimum_part_payload_bytes, model, nested_file_data, - provenance_path, require_architecture, require_levels, sharded_provenance_value, staging_dir, stream_parts, + derived_mixed, fs, hash_file, kar, kar_shard_plan, kar_writer, minimum_part_payload_bytes, model, nested_file_data, + provenance_path, require_architecture, require_levels, sharded_provenance_value, staging_dir, write_sibling_provenance, }; @@ -49,16 +49,16 @@ fn plan_stream_parts( identity: &derived_mixed::ShardedIdentity, source_dir: &Path, limits: PartLimits, -) -> Result>, String> { +) -> Result>, String> { if let Some(limit) = limits.ple_part_elements { - stream_parts::plan_shards_with_ple_limit(identity, source_dir, limit) + kar_shard_plan::plan_shards_with_ple_limit(identity, source_dir, limit) } else { - stream_parts::plan_shards_with_limit(identity, source_dir, limits.max_part_elements) + kar_shard_plan::plan_shards_with_limit(identity, source_dir, limits.max_part_elements) } } fn require_stream_budget( - archive_parts: &[Vec], + archive_parts: &[Vec], archive_tensor_count: usize, destination: &Path, levels: u8, diff --git a/control-plane/src/prepare_preview/verify_sharded_parts.rs b/control-plane/src/prepare_preview/sharded_archive_verification.rs similarity index 86% rename from control-plane/src/prepare_preview/verify_sharded_parts.rs rename to control-plane/src/prepare_preview/sharded_archive_verification.rs index 58e9a5df..74ef6374 100644 --- a/control-plane/src/prepare_preview/verify_sharded_parts.rs +++ b/control-plane/src/prepare_preview/sharded_archive_verification.rs @@ -1,11 +1,12 @@ -//! Stages of the sharded archive verification (STRA-338 size-fn). +//! The stages of verifying a sharded archive: the header, the recorded sources and parts, and the stream policy. +//! Separate from `prepare_preview`, which prepares archives; this is the read-back side. use super::{ - Path, apply_stream_policy, derived_mixed, hash_file, kar, read_recorded_provenance, sharded_provenance_value, - stream_parts, + Path, apply_stream_policy, derived_mixed, hash_file, kar, kar_shard_plan, read_recorded_provenance, + sharded_provenance_value, }; -type Parts = [Vec]; +type Parts = [Vec]; /// The streamed-preparation policy a sharded archive is verified against. #[derive(Clone, Copy)] @@ -25,11 +26,11 @@ pub(super) fn plan_verified_parts( identity: &derived_mixed::ShardedIdentity, source_dir: &Path, limits: PartLimits, -) -> Result>, String> { +) -> Result>, String> { if let Some(limit) = limits.ple_part_elements { - stream_parts::plan_shards_with_ple_limit(identity, source_dir, limit) + kar_shard_plan::plan_shards_with_ple_limit(identity, source_dir, limit) } else { - stream_parts::plan_shards_with_limit(identity, source_dir, limits.max_part_elements) + kar_shard_plan::plan_shards_with_limit(identity, source_dir, limits.max_part_elements) } } @@ -80,7 +81,7 @@ pub(super) fn require_sharded_sources( fn require_part_source( record: &kar::TensorSource, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, ) -> Result<(), String> { let record_bytes = record_source_bytes(record)?; if record.name != part.name diff --git a/control-plane/src/prepare_preview/preview_common.rs b/control-plane/src/prepare_preview/staging_and_raw_tensor_reads.rs similarity index 94% rename from control-plane/src/prepare_preview/preview_common.rs rename to control-plane/src/prepare_preview/staging_and_raw_tensor_reads.rs index 1de9d979..83a21c0d 100644 --- a/control-plane/src/prepare_preview/preview_common.rs +++ b/control-plane/src/prepare_preview/staging_and_raw_tensor_reads.rs @@ -1,8 +1,9 @@ -//! Helpers shared by the preview preparation and verification paths (STRA-338 size-fn). +//! What the preview preparation and verification share: the staging directory, the checked sizes and offsets, raw +//! tensor reads and their digests. Separate from `prepare_preview` so both directions use one set of checks. use super::{ Digest, File, Path, PathBuf, PreparedTensor, Read, Seek, SeekFrom, Sha256, StagingDir, derived_mixed, fs, gguf, - hash_file, kar_writer, partitioned_provenance, provenance_path, stream_parts, write_provenance, + hash_file, kar_shard_plan, kar_writer, partitioned_provenance, provenance_path, write_provenance, }; pub(super) fn require_levels(levels: u8, message: &str) -> Result<(), String> { @@ -164,7 +165,7 @@ pub(super) fn require_shard_unchanged( pub(super) fn apply_stream_policy( value: &mut serde_json::Value, levels: u8, - parts: &[Vec], + parts: &[Vec], ple_part_elements: Option, ) { value["schema"] = serde_json::json!(if ple_part_elements.is_some() { diff --git a/control-plane/src/prepare_preview/streamed_encode.rs b/control-plane/src/prepare_preview/streamed_encode.rs index 53fcf158..cb2ada32 100644 --- a/control-plane/src/prepare_preview/streamed_encode.rs +++ b/control-plane/src/prepare_preview/streamed_encode.rs @@ -2,11 +2,11 @@ use super::{ File, Path, PathBuf, PreparedTensor, StagingDir, StreamedTensor, TensorDistortion, checked_offset, derived_mixed, - gguf, gguf_f32_stream, kar_codec, kar_sample, kar_stream_encode, open_shard, require_shard_unchanged, - spool_raw_f32, stream_parts, tensor_elements, + gguf, gguf_f32_stream, kar_codec, kar_sample, kar_shard_plan, kar_stream_encode, open_shard, + require_shard_unchanged, spool_raw_f32, tensor_elements, }; -type Parts = [Vec]; +type Parts = [Vec]; pub(super) struct StreamedEncoding { pub(super) prepared: Vec, @@ -34,7 +34,7 @@ struct EncodedPart { impl StreamedEncoding { fn record( &mut self, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, section_path: PathBuf, done: EncodedPart, ) { @@ -131,7 +131,7 @@ impl StreamedRun<'_> { } /// Where the part's source bytes sit in the shard file, and how many elements they decode to. -fn part_span(absolute: u64, part: &stream_parts::PartIdentity) -> gguf_f32_stream::TensorSpan { +fn part_span(absolute: u64, part: &kar_shard_plan::PartIdentity) -> gguf_f32_stream::TensorSpan { gguf_f32_stream::TensorSpan { absolute_offset: absolute, source_kind: part.source_kind, @@ -143,7 +143,7 @@ fn part_span(absolute: u64, part: &stream_parts::PartIdentity) -> gguf_f32_strea fn encode_part( source: &mut File, absolute: u64, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, section_path: &Path, levels: u8, ) -> Result { @@ -163,7 +163,7 @@ fn encode_part( fn encode_nested_part( source: &mut File, absolute: u64, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, calibration: &kar_codec::Calibration, section_path: &Path, ) -> Result { @@ -190,7 +190,7 @@ fn encode_nested_part( fn encode_raw_part( source: &mut File, absolute: u64, - part: &stream_parts::PartIdentity, + part: &kar_shard_plan::PartIdentity, section_path: &Path, ) -> Result { let result = spool_raw_f32( diff --git a/control-plane/src/prepare_preview/tests/ple_partition.rs b/control-plane/src/prepare_preview/tests/ple_partition.rs index e602d3ad..494c8f27 100644 --- a/control-plane/src/prepare_preview/tests/ple_partition.rs +++ b/control-plane/src/prepare_preview/tests/ple_partition.rs @@ -11,7 +11,7 @@ fn ple_shard(payload: &[u8]) -> Vec { string(&mut gguf, "general.architecture"); gguf.extend_from_slice(&8u32.to_le_bytes()); string(&mut gguf, "qwen35"); - string(&mut gguf, stream_parts::PLE_TENSOR_NAME); + string(&mut gguf, kar_shard_plan::PLE_TENSOR_NAME); gguf.extend_from_slice(&2u32.to_le_bytes()); gguf.extend_from_slice(&32u64.to_le_bytes()); gguf.extend_from_slice(&16u64.to_le_bytes()); diff --git a/control-plane/src/prepare_preview/verify_derived.rs b/control-plane/src/prepare_preview/verify_derived.rs index 35df6935..66dd8add 100644 --- a/control-plane/src/prepare_preview/verify_derived.rs +++ b/control-plane/src/prepare_preview/verify_derived.rs @@ -3,7 +3,7 @@ use super::{ DerivedIdentity, Digest, File, Path, PathBuf, PreviewKind, Read, Sha256, derived_iq3, derived_mixed, fs, iq3_s, - kar, kar_codec, read_recorded_provenance, stream_parts, + kar, kar_codec, kar_shard_plan, read_recorded_provenance, }; fn load_derived_identity(source_path: &Path, kind: PreviewKind) -> Result { @@ -203,7 +203,7 @@ pub(super) fn sharded_provenance_value( } pub(super) fn partitioned_provenance( - parts: &[Vec], + parts: &[Vec], ) -> serde_json::Value { serde_json::json!( parts diff --git a/control-plane/src/prometheus/series.rs b/control-plane/src/prometheus/series.rs index 50e1f0bd..c89511d8 100644 --- a/control-plane/src/prometheus/series.rs +++ b/control-plane/src/prometheus/series.rs @@ -1,6 +1,6 @@ //! The series table: every Prometheus metric the control plane exposes and where its value comes from. -use super::*; +use super::{Series, counter, gauge, labelled, labelled_counter}; pub(super) const SERIES: &[Series] = &[ counter( diff --git a/control-plane/src/responses/create.rs b/control-plane/src/responses/create.rs index 5a2efd66..4f35c8cf 100644 --- a/control-plane/src/responses/create.rs +++ b/control-plane/src/responses/create.rs @@ -2,8 +2,13 @@ // The error value is the finished HTTP response: the handler returns it as it is, so it is large by design. #![allow(clippy::result_large_err)] -#[allow(unused_imports)] -use super::*; +use super::{ + AppState, CONTEXT_MARGIN_TOKENS, CreateRequest, Event, Finish, Generate, GenerationCommand, GenerationResult, + IntoResponse, Json, JsonRejection, NEXT_RESPONSE_ID, Ordering, OutputItem, Prepared, Response, ResponseIdentity, + ResponseTrace, SharedCodec, State, StatusCode, StreamEnv, Usage, Value, WorkerState, api_error, at_end_plan, + drop_unsupported_samplers, finish_generation, log_generation_failure, mpsc, oneshot, parse_request, + prepare_input_tokens, queue_error, reasoning_plan, stream_live_text, unsupported_sampler, validate_live_subset, +}; mod admit; mod answer; diff --git a/control-plane/src/responses/create/admit.rs b/control-plane/src/responses/create/admit.rs index dc21d807..2dd67916 100644 --- a/control-plane/src/responses/create/admit.rs +++ b/control-plane/src/responses/create/admit.rs @@ -3,7 +3,10 @@ // The error value is the finished HTTP response: the handler returns it as it is, so it is large by design. #![allow(clippy::result_large_err)] -use super::*; +use super::{ + AppState, CONTEXT_MARGIN_TOKENS, CreateRequest, Generate, Prepared, Response, SharedCodec, StatusCode, WorkerState, + api_error, drop_unsupported_samplers, reasoning_plan, unsupported_sampler, validate_live_subset, +}; pub(super) fn server_refusal(code: &'static str, message: &str, status: StatusCode) -> Response { api_error(status, "server_error", code, None, message) diff --git a/control-plane/src/responses/create/answer.rs b/control-plane/src/responses/create/answer.rs index af4eee2f..4b7e69f8 100644 --- a/control-plane/src/responses/create/answer.rs +++ b/control-plane/src/responses/create/answer.rs @@ -2,7 +2,12 @@ // The error value is the finished HTTP response: the handler returns it as it is, so it is large by design. #![allow(clippy::result_large_err)] -use super::*; +use super::{ + AppState, CreateRequest, Event, Finish, Generate, GenerationCommand, GenerationResult, IntoResponse, Json, + NEXT_RESPONSE_ID, Ordering, OutputItem, Response, ResponseIdentity, ResponseTrace, SharedCodec, StatusCode, + StreamEnv, Usage, Value, api_error, at_end_plan, finish_generation, log_generation_failure, mpsc, oneshot, + queue_error, stream_live_text, +}; use crate::{ports::engine::SharedEngine, wire::Done}; use leleka_gateway_domain::output::{OutputError, OutputEvent, output_items}; diff --git a/control-plane/src/responses/errors.rs b/control-plane/src/responses/errors.rs index e8bb25d9..3636eeb5 100644 --- a/control-plane/src/responses/errors.rs +++ b/control-plane/src/responses/errors.rs @@ -1,7 +1,6 @@ //! The error answers of the Responses handlers: the JSON error body, and the queue, vision and lookup failures. -#[allow(unused_imports)] -use super::*; +use super::{IntoResponse, Json, Response, StatusCode, json}; pub(super) fn api_error( status: StatusCode, diff --git a/control-plane/src/responses/golden.rs b/control-plane/src/responses/golden.rs index 6106ae1d..bbc792fa 100644 --- a/control-plane/src/responses/golden.rs +++ b/control-plane/src/responses/golden.rs @@ -3,7 +3,9 @@ //! the code as it was before it moved from this crate to `leleka-gateway-domain` (STRA-338 S21), and are compared //! as text, so the JSON key order and the SSE framing are part of what is checked. -use super::*; +use super::{CreateRequest, Finish, OutputItem, ResponseIdentity, ResponseTrace, Usage, Value, json, render_request}; +#[cfg(test)] +use super::tests; use std::{fs, path::PathBuf}; fn fixture_path() -> PathBuf { diff --git a/control-plane/src/responses/history.rs b/control-plane/src/responses/history.rs index e47d7262..019f7706 100644 --- a/control-plane/src/responses/history.rs +++ b/control-plane/src/responses/history.rs @@ -1,8 +1,7 @@ //! The in-memory response history (64 entries, a byte limit) and its checksummed disk snapshot, and the paging of a //! stored response's input items. -#[allow(unused_imports)] -use super::*; +use super::{Arc, Deserialize, HashMap, InputItemsQuery, Query, Serialize, Value, VecDeque, json}; mod pages; mod restore; diff --git a/control-plane/src/responses/history/pages.rs b/control-plane/src/responses/history/pages.rs index cdcee458..793d071d 100644 --- a/control-plane/src/responses/history/pages.rs +++ b/control-plane/src/responses/history/pages.rs @@ -1,6 +1,6 @@ //! Paging a stored response's input items: where a page starts and how one stored item is projected for the client. -use super::*; +use super::{StoredResponse, Value, json}; impl StoredResponse { /// The position of the first item of the page: after the cursor `after` in the requested order. diff --git a/control-plane/src/responses/history/restore.rs b/control-plane/src/responses/history/restore.rs index 7b420786..22b61185 100644 --- a/control-plane/src/responses/history/restore.rs +++ b/control-plane/src/responses/history/restore.rs @@ -1,6 +1,6 @@ //! Reading the checksummed disk snapshot back: the decode, the per-entry checks and the rebuild. -use super::*; +use super::{Deserialize, MAX_STORED_RESPONSES, ResponseHistory, StoredResponse, Value}; #[derive(Deserialize)] #[serde(deny_unknown_fields)] diff --git a/control-plane/src/responses/history_adapter.rs b/control-plane/src/responses/history_adapter.rs index 84abd1b1..5642064d 100644 --- a/control-plane/src/responses/history_adapter.rs +++ b/control-plane/src/responses/history_adapter.rs @@ -2,7 +2,7 @@ //! (`history_store`). The history keeps the rules (64 entries, byte limit, snapshot checksum); this file only puts it //! behind the port and decides which calls may block (a durable commit runs on the blocking pool). -use super::*; +use super::{Arc, ResponseHistory, RwLock, Value}; use crate::ports::{ BoxFuture, ResponseStore, SharedResponseStore, response_store::InputItemsQuery, }; diff --git a/control-plane/src/responses/intake.rs b/control-plane/src/responses/intake.rs index abaeba83..9532afd3 100644 --- a/control-plane/src/responses/intake.rs +++ b/control-plane/src/responses/intake.rs @@ -1,11 +1,14 @@ //! Request intake: the body read as traced JSON, the decode, validation and model check of a create request, and the //! prompt prepared for the engine (token ids, with every picture expanded to its rows). -#[allow(unused_imports)] -use super::*; +use super::{ + AppState, Arc, CreateRequest, Family, IntoResponse, Json, JsonRejection, Response, SharedCodec, State, StatusCode, + TextCodec, Tokenizer, Value, api_error, append_input, harmony_prompt, json, render_request, validate_live_subset, + vision_error, +}; -mod parts; -use parts::{ +mod intake_stages; +use intake_stages::{ check_model, decode_request, image_marks, invalid_prompt, no_encoder, refuse, render_prompt, resolve_previous, tokenize_prompt, }; diff --git a/control-plane/src/responses/intake/parts.rs b/control-plane/src/responses/intake/intake_stages.rs similarity index 96% rename from control-plane/src/responses/intake/parts.rs rename to control-plane/src/responses/intake/intake_stages.rs index 3e9a9b07..06fb74e5 100644 --- a/control-plane/src/responses/intake/parts.rs +++ b/control-plane/src/responses/intake/intake_stages.rs @@ -1,7 +1,10 @@ //! The stages of request intake: the body decode, the model check, the previous-response transcript, the render and the //! tokenization, and the picture marks. -use super::*; +use super::{ + AppState, CreateRequest, Family, IMAGE_PAD, Response, SharedCodec, StatusCode, Tokenizer, VISION_START, Value, + api_error, append_input, harmony_prompt, render_request, +}; /// An error answer as the `Box` the intake stages return. pub(super) fn refuse( diff --git a/control-plane/src/responses/render.rs b/control-plane/src/responses/render.rs index 2f56478e..0fc6e127 100644 --- a/control-plane/src/responses/render.rs +++ b/control-plane/src/responses/render.rs @@ -1,7 +1,6 @@ //! The prompt of a request. The rendering is `leleka-gateway-domain`; this crate adds the `render_template` stage span. -#[allow(unused_imports)] -use super::*; +use super::{CreateRequest, LiteralMarks, render_request_with}; /// The rendered prompt and the sources of its pictures, in prompt order; see /// [`leleka_gateway_domain::responses::render_request_with`] for how control-token text is kept literal. diff --git a/control-plane/src/responses/resources.rs b/control-plane/src/responses/resources.rs index ce5ba615..6c2e4724 100644 --- a/control-plane/src/responses/resources.rs +++ b/control-plane/src/responses/resources.rs @@ -1,7 +1,9 @@ //! The stored-response routes: retrieve, list input items and delete. -#[allow(unused_imports)] -use super::*; +use super::{ + AppState, InputItemsQuery, IntoResponse, Json, Path, RawQuery, Response, State, StatusCode, api_error, json, + resource_not_found, +}; pub(super) fn resource_query_error(query: Option) -> Option { query.filter(|value| !value.is_empty()).map(|_| { diff --git a/control-plane/src/responses/route.rs b/control-plane/src/responses/route.rs index 31936075..8406eeea 100644 --- a/control-plane/src/responses/route.rs +++ b/control-plane/src/responses/route.rs @@ -1,7 +1,6 @@ //! `POST /v1/responses` as the route sees it: the handler `create` behind the admission and API key layers. -#[allow(unused_imports)] -use super::*; +use super::{AppState, JsonRejection, Response, State, TracedJson, create}; /// The `/v1/responses` route: [`create`] with the body read and parse timed. pub async fn create_route( diff --git a/control-plane/src/responses/stream.rs b/control-plane/src/responses/stream.rs index f9e8a254..09981145 100644 --- a/control-plane/src/responses/stream.rs +++ b/control-plane/src/responses/stream.rs @@ -1,7 +1,12 @@ //! Server-sent-event streaming of a Responses API generation: plain text, buffered and tool calls. //! Moved out of responses.rs (STRA-338 S6); everything here is private to the `responses` module tree. -use super::*; +use super::{ + Catalog, Context, CreateRequest, Event, Finish, Infallible, IntoResponse, NEXT_RESPONSE_ID, Ordering, OutputItem, + Pin, Poll, Response, ResponseIdentity, ResponseTrace, SharedClock, SharedCodec, SharedResponseStore, Sse, SseEvent, + Stream, Usage, Value, at_end_plan, debug_failed_output, finish_generation, is_structured, json, + log_generation_failure, log_tool_notes, mpsc, reasoning_enabled, text_part, tool_call_recovery, +}; /// What a stream fails with when its model has no live reading of its output (it always reasons). pub(super) const NO_LIVE_READING: &str = "the output of this model cannot be read live"; diff --git a/control-plane/src/responses/stream/buffered.rs b/control-plane/src/responses/stream/buffered.rs index 0991c1ec..2f201145 100644 --- a/control-plane/src/responses/stream/buffered.rs +++ b/control-plane/src/responses/stream/buffered.rs @@ -1,6 +1,11 @@ //! Buffered streaming for structured output and reasoning (moved from responses.rs, STRA-338 S6). -use super::*; +use super::{ + Collected, CreateRequest, Event, Finish, Flow, Next, OutputItem, Response, ResponseIdentity, ResponseTrace, + SharedCodec, StreamEnv, Usage, Value, at_end_plan, classify, done_usage, failed_response, failure_message, + finish_generation, json, log_generation_failure, mpsc, response_id, send_prelude, send_stream_event, + send_trace_tail, sse_response, store_response, zero_usage, +}; use crate::wire::Done; use leleka_gateway_domain::output::{AtEndDecoder, GENERATION_ENDED, OutputEvent, output_items}; diff --git a/control-plane/src/responses/stream/text.rs b/control-plane/src/responses/stream/text.rs index 802efd86..deaa3fd5 100644 --- a/control-plane/src/responses/stream/text.rs +++ b/control-plane/src/responses/stream/text.rs @@ -1,6 +1,11 @@ //! Plain-text streaming of a Responses API generation (moved from responses.rs, STRA-338 S6). -use super::*; +use super::{ + Collected, CreateRequest, Event, Finish, Flow, NO_LIVE_READING, Next, OutputItem, Response, ResponseIdentity, + ResponseTrace, SharedCodec, StreamEnv, Value, classify, done_usage, failed_response, failure_message, + is_structured, json, log_generation_failure, mpsc, reasoning_enabled, response_id, send_prelude, send_stream_event, + send_trace_tail, sse_response, store_response, stream_live_buffered, stream_live_tools, zero_usage, +}; use crate::wire::Done; use leleka_gateway_domain::output::{LiveDecoder, LivePlan, OutputEvent}; diff --git a/control-plane/src/responses/stream/tool_run.rs b/control-plane/src/responses/stream/tool_run.rs index e337b38b..fdb901e1 100644 --- a/control-plane/src/responses/stream/tool_run.rs +++ b/control-plane/src/responses/stream/tool_run.rs @@ -1,7 +1,12 @@ //! Streaming of a response whose request declares tools: text and calls are published as the worker produces them. use super::tools::ToolStream; -use super::*; +use super::{ + Catalog, Collected, CreateRequest, Event, Finish, Flow, NO_LIVE_READING, Next, OutputItem, Response, + ResponseIdentity, ResponseTrace, SharedCodec, StreamEnv, Value, classify, debug_failed_output, done_usage, + failed_response, failure_message, json, log_generation_failure, log_tool_notes, mpsc, response_id, send_prelude, + sse_response, store_response, tool_call_recovery, zero_usage, +}; use crate::wire::Done; use leleka_gateway_domain::output::{LiveDecoder, LivePlan, OutputEvent}; diff --git a/control-plane/src/responses/stream/tools.rs b/control-plane/src/responses/stream/tools.rs index 9be6af71..5c60a521 100644 --- a/control-plane/src/responses/stream/tools.rs +++ b/control-plane/src/responses/stream/tools.rs @@ -1,6 +1,9 @@ //! Streaming of tool calls (moved from responses.rs, STRA-338 S6). -use super::*; +use super::{ + Catalog, CreateRequest, OutputItem, ResponseIdentity, ResponseTrace, Value, json, mpsc, send_stream_event, + text_part, zero_usage, +}; use leleka_gateway_domain::output::OutputEvent; pub(super) struct ToolStream { diff --git a/control-plane/src/responses/tool_recovery.rs b/control-plane/src/responses/tool_recovery.rs index e65dc086..1c3eb371 100644 --- a/control-plane/src/responses/tool_recovery.rs +++ b/control-plane/src/responses/tool_recovery.rs @@ -1,8 +1,7 @@ //! Reading tool calls out of the model's text: the process-wide switch of the experimental recovery, and the wrappers //! that give the domain parsers that switch and write the log lines for calls accepted beyond the template form. -#[allow(unused_imports)] -use super::*; +use super::{CreateRequest, Finish, Ordering, TextCodec, debug_failed_output, flat_tools, reasoning_enabled}; use leleka_gateway_domain::output::{AtEndDecoder, AtEndPlan, OutputError, OutputEvent}; /// EXPERIMENTAL `tool_call_recovery` (config key or `STRATA_TOOL_CALL_RECOVERY`): off unless `main` turns it on at diff --git a/control-plane/src/service_install/parse.rs b/control-plane/src/service_install/parse.rs index 184fbdb6..a76fcbac 100644 --- a/control-plane/src/service_install/parse.rs +++ b/control-plane/src/service_install/parse.rs @@ -1,8 +1,7 @@ //! Methods of `SplitFlags`: `take`. Functions: `parse`, `options_from`, `validate_name`, `install_options` and 5 more. //! Defines `SplitFlags`. -#[allow(unused_imports)] -use super::*; +use super::{CONTROL_USAGE, INSTALL_READY_USAGE, Options, PathBuf, USAGE}; pub(super) fn parse(args: &[String]) -> Result { let mut values = std::collections::BTreeMap::new(); diff --git a/control-plane/src/service_switch/provision_budget.rs b/control-plane/src/service_switch/provision_budget.rs index a86c7e40..1e14718a 100644 --- a/control-plane/src/service_switch/provision_budget.rs +++ b/control-plane/src/service_switch/provision_budget.rs @@ -1,8 +1,8 @@ //! Methods of `Profile`: `readiness`, `control`. //! Functions: `provision_budget`, `ready_budget`, `check_profile_ids`, `arguments` and 8 more. -#[allow(unused_imports)] -use super::*; +use super::{BTreeMap, Catalog, Duration, PathBuf, Profile, USAGE, Value, storage}; +#[cfg(unix)] pub(super) fn provision_budget() -> u64 { 3600 diff --git a/control-plane/src/service_switch/transaction.rs b/control-plane/src/service_switch/transaction.rs index fb76e599..6fbde7ee 100644 --- a/control-plane/src/service_switch/transaction.rs +++ b/control-plane/src/service_switch/transaction.rs @@ -1,7 +1,10 @@ //! The unix body of `service-switch`: one transaction between two installed native user services (STRA-338). -#[allow(unused_imports)] -use super::*; +use super::{ + BTreeMap, Catalog, Digest, Path, Profile, Sha256, Value, discover, inactive, json, pid, prepare, storage, + validate_auto, +}; +#[cfg(unix)] use crate::wait_ready::Waiter; use storage::{Journal, digest, read}; diff --git a/control-plane/src/worker/tests/deadlines.rs b/control-plane/src/worker/tests/deadlines.rs index 8ee57384..cf6fdc9b 100644 --- a/control-plane/src/worker/tests/deadlines.rs +++ b/control-plane/src/worker/tests/deadlines.rs @@ -1,6 +1,9 @@ //! Execution deadline, startup timeout and the stall watchdog. -use super::*; +use super::{ + Arc, Duration, Event, Generate, GenerationResult, RwLock, WorkerState, WorkerStatus, answer_within, fixture_config, + generate_command, join_within, mpsc, oneshot, run, start_rig, supervise, timeout, wait_for, watch, +}; #[tokio::test] async fn execution_deadline_covers_blocked_engine_stdin() { diff --git a/control-plane/src/worker/tests/generation.rs b/control-plane/src/worker/tests/generation.rs index c6d8ed76..32a6eee3 100644 --- a/control-plane/src/worker/tests/generation.rs +++ b/control-plane/src/worker/tests/generation.rs @@ -1,6 +1,10 @@ //! One generation through the supervisor: exchange, cancellation, shutdown and stop. -use super::*; +use super::{ + Duration, Event, GenerationResult, Rig, STOP_DRAIN_TIMEOUT, WorkerState, answer_within, + assert_one_request_cancelled, assert_worker_is_ready, command, first_streamed_token, fixture_config, + generate_command, join_within, marker_config, mpsc, oneshot, start_rig, wait_for_file, +}; /// A sampled generation of two prompt tokens: three events plus DONE, and the metrics that follow. async fn exchange_sampled_generation(rig: &Rig) { diff --git a/control-plane/src/worker/tests/handshake.rs b/control-plane/src/worker/tests/handshake.rs index 799f60fa..8012ff04 100644 --- a/control-plane/src/worker/tests/handshake.rs +++ b/control-plane/src/worker/tests/handshake.rs @@ -1,6 +1,8 @@ //! The READY handshake, shutdown and readiness revocation. -use super::*; +use super::{ + Arc, Duration, RwLock, WorkerState, WorkerStatus, fixture_config, parse_ready, run, timeout, wait_for, watch, +}; #[tokio::test] async fn ready_requires_handshake_and_shutdown_sends_quit() { diff --git a/control-plane/src/worker/tests/harness.rs b/control-plane/src/worker/tests/harness.rs index 6e66c03c..7c256b39 100644 --- a/control-plane/src/worker/tests/harness.rs +++ b/control-plane/src/worker/tests/harness.rs @@ -1,6 +1,9 @@ //! The rig the supervisor tests share: a worker task on the mock engine with a request channel, and small waits. -use super::*; +use super::{ + Arc, Duration, Event, Generate, GenerationCommand, GenerationResult, Path, RwLock, WorkerConfig, WorkerState, + WorkerStatus, command, fixture_config, mpsc, oneshot, run_with_requests, timeout, wait_for, watch, +}; type Buffered = oneshot::Receiver, String>>; diff --git a/control-plane/src/worker/tests/lifecycle.rs b/control-plane/src/worker/tests/lifecycle.rs index 3329152d..44337f45 100644 --- a/control-plane/src/worker/tests/lifecycle.rs +++ b/control-plane/src/worker/tests/lifecycle.rs @@ -1,6 +1,9 @@ //! Load and unload: unload, lazy start, idle unload, the before-load command. -use super::*; +use super::{ + BeforeLoad, Duration, Event, RwLock, SessionExit, Supervised, WorkerConfig, WorkerState, WorkerStatus, + fixture_config, lifecycle_request, lines_of, scratch, supervise, wait_for, watch, +}; async fn assert_context_survives_unload(worker: &Supervised) { let status = worker.status.read().await; diff --git a/control-plane/src/worker/tests/reasoning.rs b/control-plane/src/worker/tests/reasoning.rs index 325060bd..80d03f49 100644 --- a/control-plane/src/worker/tests/reasoning.rs +++ b/control-plane/src/worker/tests/reasoning.rs @@ -1,6 +1,6 @@ //! Reasoning-budget wrap-up through the supervisor. -use super::*; +use super::{Event, Path, Supervised, WorkerState, budget_request, fixture_config, scratch, supervise, wait_for, wire}; /// A supervised mock engine in budget mode, logging its requests under a scratch directory. async fn budget_worker(name: &str) -> (Supervised, std::path::PathBuf) { diff --git a/control-plane/src/worker/tests/restart.rs b/control-plane/src/worker/tests/restart.rs index 25ba0a67..d2ad9cab 100644 --- a/control-plane/src/worker/tests/restart.rs +++ b/control-plane/src/worker/tests/restart.rs @@ -1,6 +1,9 @@ //! Crash handling: restart budget, backoff, startup failure, drain guard. -use super::*; +use super::{ + Arc, Duration, Event, GenerationResult, Path, Rig, RwLock, WorkerState, WorkerStatus, answer_within, command, + generate_command, mpsc, restart_fixture, run, start_rig, timeout, wait_for, wait_for_file, watch, +}; /// How many times the mock engine booted (one line per boot in the fixture directory). fn boot_count(root: &Path) -> usize { diff --git a/crates/context/src/rope_scaling.rs b/crates/context/src/rope_scaling.rs index 365641c6..2a961dda 100644 --- a/crates/context/src/rope_scaling.rs +++ b/crates/context/src/rope_scaling.rs @@ -171,6 +171,6 @@ pub use rope_scaling_type::*; mod fill_rope_table; #[allow(unused_imports)] pub use fill_rope_table::*; -mod setup_rope_error_display_error; +mod setup_rope_error_and_resolve; #[allow(unused_imports)] -pub use setup_rope_error_display_error::*; +pub use setup_rope_error_and_resolve::*; diff --git a/crates/context/src/rope_scaling/setup_rope_error_display_error.rs b/crates/context/src/rope_scaling/setup_rope_error_and_resolve.rs similarity index 90% rename from crates/context/src/rope_scaling/setup_rope_error_display_error.rs rename to crates/context/src/rope_scaling/setup_rope_error_and_resolve.rs index 599fb902..87d81cda 100644 --- a/crates/context/src/rope_scaling/setup_rope_error_display_error.rs +++ b/crates/context/src/rope_scaling/setup_rope_error_and_resolve.rs @@ -1,5 +1,5 @@ -//! Implements `Display for SetupRopeError`, `Error for SetupRopeError`. Functions: `setup_resolve_rope`. -//! Split out of `rope_scaling` to keep its files under the line limit. +//! `SetupRopeError` (`Display`, `Error`) and `setup_resolve_rope`, the setup's resolution of the rope scaling. +//! Separate from `rope_scaling` so the error and its one producer read together. use super::{RopeScalingType, SetupRopeError, derived_factor, fmt}; diff --git a/crates/deploy/src/app/install_flow.rs b/crates/deploy/src/app/install_flow.rs index a55b582e..830dfd17 100644 --- a/crates/deploy/src/app/install_flow.rs +++ b/crates/deploy/src/app/install_flow.rs @@ -1,6 +1,9 @@ //! `leleka up`: run the plan, then print or serialize the summary of the installed service. -use super::*; +use super::{ + Context, Mode, Step, StepState, UnitScopeTag, UpOptions, Value, env_var, gather, gather_fs, json, json_plan, + plan_steps, print_report, render_plan, say, steps, supervisor, +}; pub async fn up(opts: UpOptions) -> i32 { let ctx = gather(&opts, &env_var); diff --git a/crates/deploy/src/app/machine_view.rs b/crates/deploy/src/app/machine_view.rs index d1901a40..145fbcaf 100644 --- a/crates/deploy/src/app/machine_view.rs +++ b/crates/deploy/src/app/machine_view.rs @@ -1,6 +1,6 @@ //! The human view of the engine telemetry (`machine` of `/v1/status`). -use super::*; +use super::{Value, render_settings}; fn gib(mib: &Value) -> String { mib.as_f64() diff --git a/crates/deploy/src/app/quick_health.rs b/crates/deploy/src/app/quick_health.rs index 6a454fd8..46a6ca6f 100644 --- a/crates/deploy/src/app/quick_health.rs +++ b/crates/deploy/src/app/quick_health.rs @@ -1,6 +1,6 @@ //! The sections of `leleka verify --quick`: model files, service, logs and requests. -use super::*; +use super::{Value, render_supervisor, steps, unix_now}; use crate::{config::RunConfig, layout::Paths, profile::KarSource}; use leleka_model_format::verify_stamp::{FileIdentity, VerifyStamps}; use std::path::Path; diff --git a/crates/deploy/src/app/settings_change.rs b/crates/deploy/src/app/settings_change.rs index 73581739..54e7100f 100644 --- a/crates/deploy/src/app/settings_change.rs +++ b/crates/deploy/src/app/settings_change.rs @@ -1,6 +1,6 @@ //! `leleka reconfigure`: ask the supervisor, persist the settings or restart, and render the effective values. -use super::*; +use super::{PersistTarget, ReconfigureArgs, UpOptions, Value, json}; /// `leleka reconfigure`. /// diff --git a/crates/deploy/src/app/status_report.rs b/crates/deploy/src/app/status_report.rs index 3cc7e157..98167694 100644 --- a/crates/deploy/src/app/status_report.rs +++ b/crates/deploy/src/app/status_report.rs @@ -1,6 +1,6 @@ //! `leleka status`: the installed scope, the supervisor document and its human rendering. -use super::*; +use super::{PathBuf, UnitScopeTag, UpOptions, Value, json, render_machine, steps, supervisor}; /// Which systemd unit of this deployment exists (system first), judged by the unit file. pub(super) fn installed_scope(paths: &crate::layout::Paths) -> Option { diff --git a/crates/deploy/src/app/verify_flow.rs b/crates/deploy/src/app/verify_flow.rs index d0690ab3..99fc29a3 100644 --- a/crates/deploy/src/app/verify_flow.rs +++ b/crates/deploy/src/app/verify_flow.rs @@ -1,7 +1,7 @@ //! `leleka verify`: the quick offline check and the full verification against a running engine. use super::quick_health::{Health, report_logs_and_requests, report_model_files, report_service}; -use super::*; +use super::{PathBuf, UpOptions, say}; use crate::{config::RunConfig, layout::Paths}; use leleka_model_format::verify_stamp::{FileIdentity, VerifyStamps, sha256_of_file}; use std::path::Path; diff --git a/crates/deploy/src/cli/dispatch.rs b/crates/deploy/src/cli/dispatch.rs index 259eeff5..9d25a109 100644 --- a/crates/deploy/src/cli/dispatch.rs +++ b/crates/deploy/src/cli/dispatch.rs @@ -1,6 +1,9 @@ //! The command line parser: picks the command and hands the rest to it. -use super::*; +use super::{ + Command, Environment, PathBuf, ServiceAction, logs_command, number, parse_flags, reconfigure_command, + report_command, text, up_options, +}; pub fn parse(args: &[String], env: &Environment) -> Result { let Some((command, rest)) = args.split_first() else { diff --git a/crates/deploy/src/cli/flag_parsing.rs b/crates/deploy/src/cli/flag_parsing.rs index a1d48f00..3e7231f4 100644 --- a/crates/deploy/src/cli/flag_parsing.rs +++ b/crates/deploy/src/cli/flag_parsing.rs @@ -1,6 +1,6 @@ //! Flag parsing shared by the commands: values, ranges, ports and the `up` options. -use super::*; +use super::{Dirs, Environment, Flags, ModeChoice, PathBuf, Ports, ReconfigureArgs, UP_FLAGS, UpOptions}; impl ReconfigureArgs { /// The budget and the preset are fixed when the CUDA context is created. diff --git a/crates/deploy/src/cli/tests/reconfigure_args.rs b/crates/deploy/src/cli/tests/reconfigure_args.rs index f204fde8..840f30df 100644 --- a/crates/deploy/src/cli/tests/reconfigure_args.rs +++ b/crates/deploy/src/cli/tests/reconfigure_args.rs @@ -1,6 +1,6 @@ //! The `reconfigure` arguments: settings, budget, preset and persist taken out of the `up` flags. -use super::*; +use super::{Command, parse_as}; #[test] fn reconfigure_collects_the_settings_and_locates_the_service_with_the_up_flags() { diff --git a/crates/deploy/src/config/engine_launch.rs b/crates/deploy/src/config/engine_launch.rs index 214e74fd..1937e746 100644 --- a/crates/deploy/src/config/engine_launch.rs +++ b/crates/deploy/src/config/engine_launch.rs @@ -1,6 +1,6 @@ //! What the engine process is started with: arguments, verify arguments, archive argument, MTP profile and environment. -use super::*; +use super::{BTreeMap, KarArg, KarSource, MTP_PROFILE, NATIVE_MTP_PROFILE, Paths, RUNTIME_TOKEN_ENV, RunConfig}; impl RunConfig { /// Arguments of `leleka-inference`, in the order its parser requires (seven fixed pairs first, then the diff --git a/crates/deploy/src/config/service_documents.rs b/crates/deploy/src/config/service_documents.rs index 9a756d17..935007ae 100644 --- a/crates/deploy/src/config/service_documents.rs +++ b/crates/deploy/src/config/service_documents.rs @@ -1,6 +1,6 @@ //! The JSON documents the service writes for the daemon and the gateway. -use super::*; +use super::{GATEWAY_TOKEN_ENV, RUNTIME_TOKEN_ENV, RunConfig, Value, json}; impl RunConfig { pub fn daemon_json(&self) -> Value { diff --git a/crates/deploy/src/expert_profile/provisioning.rs b/crates/deploy/src/expert_profile/provisioning.rs index 67ef282a..1c683231 100644 --- a/crates/deploy/src/expert_profile/provisioning.rs +++ b/crates/deploy/src/expert_profile/provisioning.rs @@ -1,6 +1,9 @@ //! Digests, file states and the provisioning of the ranked expert table. -use super::*; +use super::{ + Digest, EMBEDDED, EMBEDDED_ORIGIN, FileState, MAX_BYTES, Outcome, PINNED_BYTES, PINNED_SHA256, Path, PathBuf, + Profile, Request, RunConfig, Sha256, SystemTime, TierReport, UNIX_EPOCH, tier_report_with, +}; /// The embedded table when it is the one with digest `expected` (a profile that pins another digest gets `None`). pub fn embedded_for(expected: &str) -> Option<&'static [u8]> { diff --git a/crates/deploy/src/expert_profile/tests/embedded_table.rs b/crates/deploy/src/expert_profile/tests/embedded_table.rs index 8103ee9d..499e1f53 100644 --- a/crates/deploy/src/expert_profile/tests/embedded_table.rs +++ b/crates/deploy/src/expert_profile/tests/embedded_table.rs @@ -1,6 +1,11 @@ //! The pinned numbers and the table embedded in the binary: installed offline before any download. -use super::*; +use super::{ + EMBEDDED, EMBEDDED_ORIGIN, FIXTURE, FileState, MAX_BYTES, Outcome, PINNED_BYTES, PINNED_SHA256, Path, Request, + SOURCES, UPSTREAM_COMMIT, embedded_for, file_state, fixture_digest, provision, sha256_hex, short_digest, temp, +}; +#[cfg(test)] +use super::with_suffix; #[test] fn the_pinned_numbers_are_consistent() { diff --git a/crates/deploy/src/expert_profile/tests/report.rs b/crates/deploy/src/expert_profile/tests/report.rs index 15302248..30673bf6 100644 --- a/crates/deploy/src/expert_profile/tests/report.rs +++ b/crates/deploy/src/expert_profile/tests/report.rs @@ -1,6 +1,9 @@ //! The on/off report of the expert tier and the table the engine receives. -use super::*; +use super::{ + FIXTURE, FileState, PROFILE_ENV, Path, SLOTS_ENV, config, fixture_digest, short_digest, start_environment, temp, + tier_report, tier_report_with, +}; #[test] fn the_report_says_on_with_the_digest_or_off_with_the_reason() { diff --git a/crates/deploy/src/expert_profile/tests/sources.rs b/crates/deploy/src/expert_profile/tests/sources.rs index 1869c9d1..13daa1d9 100644 --- a/crates/deploy/src/expert_profile/tests/sources.rs +++ b/crates/deploy/src/expert_profile/tests/sources.rs @@ -1,6 +1,8 @@ //! Downloads, local files and wrong files: verified, installed or refused, never deleted. -use super::*; +use super::{FIXTURE, Outcome, Path, RefCell, Request, fixture_digest, provision, temp}; +#[cfg(test)] +use super::with_suffix; #[test] fn a_download_is_verified_then_installed_and_a_present_file_is_left_alone() { diff --git a/crates/deploy/src/expert_profile/tier_report.rs b/crates/deploy/src/expert_profile/tier_report.rs index b1f15dbe..57d3e788 100644 --- a/crates/deploy/src/expert_profile/tier_report.rs +++ b/crates/deploy/src/expert_profile/tier_report.rs @@ -1,6 +1,9 @@ //! The expert-tier report and the engine's start environment. -use super::*; +use super::{ + BTreeMap, FileState, PROFILE_ENV, Path, RunConfig, SLOTS_ENV, TierReport, expected_digest, short_digest, + tier_report, +}; /// [`tier_report`] with the file's state supplied by the caller (`shown` is the path to print; `state` is only called /// when needed). diff --git a/crates/deploy/src/facts/linux.rs b/crates/deploy/src/facts/linux.rs index 8d276bee..16b84d5b 100644 --- a/crates/deploy/src/facts/linux.rs +++ b/crates/deploy/src/facts/linux.rs @@ -1,6 +1,11 @@ //! Linux probe of the host facts: /proc, nvidia-smi, ports and the CUDA libraries in the loader path. -use super::*; +use super::{ + DirFact, Facts, Path, PathBuf, ProbeRequest, count_physical_cores, find_library, fs_type_for, is_wsl, + parse_cgroup_max, parse_meminfo, parse_nvidia_smi, +}; +#[cfg(target_os = "linux")] +use super::lab_holder_running; use std::{net::TcpListener, process::Command}; fn read(path: &str) -> String { diff --git a/crates/deploy/src/logview/collection.rs b/crates/deploy/src/logview/collection.rs index 11bf261d..64e65c71 100644 --- a/crates/deploy/src/logview/collection.rs +++ b/crates/deploy/src/logview/collection.rs @@ -1,6 +1,9 @@ //! Collecting, joining and summarizing the log entries and request records. -use super::*; +use super::{ + Entry, Filter, Map, Path, RECORDS_SCAN_BYTES, TAIL_SCAN_BYTES, Value, VecDeque, for_each_line, format_utc_ms, + generations, json, parse_duration_ms, parse_line, parse_utc_ms, sources_in, +}; /// The entries of the log directory that pass `filter`, oldest first, at most `filter.tail` (the newest ones). pub fn collect(dir: &Path, filter: &Filter) -> Vec { diff --git a/crates/deploy/src/logview/entries.rs b/crates/deploy/src/logview/entries.rs index 5850cab0..d1af3dee 100644 --- a/crates/deploy/src/logview/entries.rs +++ b/crates/deploy/src/logview/entries.rs @@ -1,6 +1,8 @@ //! Parsing and rendering one log line, the rotated generations and the entry filter. -use super::*; +use super::{ + BufRead, Entry, Filter, Level, Map, Path, PathBuf, SOURCES, Seek, SeekFrom, Value, format_utc_ms, parse_utc_ms, +}; pub(super) fn legacy_level(raw: &str) -> Level { let lower = raw.to_ascii_lowercase(); diff --git a/crates/deploy/src/logview/logs_command.rs b/crates/deploy/src/logview/logs_command.rs index c67e0108..f80e6f8e 100644 --- a/crates/deploy/src/logview/logs_command.rs +++ b/crates/deploy/src/logview/logs_command.rs @@ -1,6 +1,10 @@ //! `leleka logs`: the filter, the printing, following and the redaction of a report. -use super::*; +use super::{ + Entry, Filter, Level, LogsArgs, Path, PathBuf, Read, ReportArgs, ReportInputs, Seek, SeekFrom, UpOptions, Value, + Write, collect, format_utc_ms, generations, join_requests, json, now_ms, parse_line, parse_since, redact, + render_entry, sources_in, summarize, +}; pub fn filter_from(args: &LogsArgs, now: u64) -> Result { let mut filter = Filter { diff --git a/crates/deploy/src/plan/expert_table_step.rs b/crates/deploy/src/plan/expert_table_step.rs index 728c67fc..32dfa8db 100644 --- a/crates/deploy/src/plan/expert_table_step.rs +++ b/crates/deploy/src/plan/expert_table_step.rs @@ -2,7 +2,7 @@ //! `--expert-profile-file`) and verified before any large download, so that a failure costs seconds and the //! configuration is never written without it. -use super::*; +use super::{Context, ExpertProfileState, Step, StepState, step}; use crate::expert_profile::{ PINNED_BYTES, PINNED_SHA256, SOURCES, embedded_for, expected_digest, short_digest, }; diff --git a/crates/deploy/src/plan/host_steps.rs b/crates/deploy/src/plan/host_steps.rs index 4ac4f920..16a7320a 100644 --- a/crates/deploy/src/plan/host_steps.rs +++ b/crates/deploy/src/plan/host_steps.rs @@ -1,6 +1,8 @@ //! The plan steps that prepare the host: checks, directories, binaries, cuBLAS and the secrets. -use super::*; +use super::{ + BINARIES, CUBLAS_BYTES, CUBLAS_SHA256, CUBLAS_URL, CUBLAS_VERSION, Context, FsState, Step, StepState, step, +}; pub(super) fn preflight_step(ctx: &Context) -> Step { let state = match &ctx.report { diff --git a/crates/deploy/src/plan/model_steps.rs b/crates/deploy/src/plan/model_steps.rs index 698d60fa..d653e0cd 100644 --- a/crates/deploy/src/plan/model_steps.rs +++ b/crates/deploy/src/plan/model_steps.rs @@ -1,6 +1,9 @@ //! The plan steps that bring the model in: the shards, the KAR archive, the MTP pack, the tokenizer and the configs. -use super::*; +use super::{ + ARCHIVE_BYTES, Context, FsState, KarSource, MANIFEST, MTP_FILES, Step, StepState, gib_text, step, strata_next, + windows_shards_present, +}; /// The archive is accepted as it is (`--trust-archive`): the engine verifies it at each load. pub(super) fn trusts_archive(ctx: &Context, fs: &FsState) -> bool { diff --git a/crates/deploy/src/plan/render.rs b/crates/deploy/src/plan/render.rs index 24b48a15..cc01b0b9 100644 --- a/crates/deploy/src/plan/render.rs +++ b/crates/deploy/src/plan/render.rs @@ -1,6 +1,6 @@ //! The text of a plan for `--dry-run` and `preflight`. -use super::*; +use super::{Context, KarArg, KarSource, RunConfig, Step, StepState}; /// A human rendering of the plan, with the engine command the service will run. pub fn render_plan(ctx: &Context, steps: &[Step]) -> String { diff --git a/crates/deploy/src/plan/scope.rs b/crates/deploy/src/plan/scope.rs index 0f20222e..89279829 100644 --- a/crates/deploy/src/plan/scope.rs +++ b/crates/deploy/src/plan/scope.rs @@ -1,6 +1,6 @@ //! Unit scope and run mode: how the mode follows from the options and the host. -use super::*; +use super::{Facts, Mode, ModeChoice, UnitScope, UnitScopeTag}; impl UnitScopeTag { pub fn scope(self) -> UnitScope { diff --git a/crates/deploy/src/plan/service_steps.rs b/crates/deploy/src/plan/service_steps.rs index d3f3b8b3..3dc24147 100644 --- a/crates/deploy/src/plan/service_steps.rs +++ b/crates/deploy/src/plan/service_steps.rs @@ -1,6 +1,6 @@ //! The plan steps that run the service: the unit, the start and the readiness wait. -use super::*; +use super::{Context, FsState, Mode, Step, StepState, UnitScopeTag, step}; /// The `service` and `start` steps of the chosen mode. pub(super) fn service_steps(ctx: &Context, fs: &FsState) -> [Step; 2] { diff --git a/crates/deploy/src/plan/step_plan.rs b/crates/deploy/src/plan/step_plan.rs index 2b065ae4..cd575209 100644 --- a/crates/deploy/src/plan/step_plan.rs +++ b/crates/deploy/src/plan/step_plan.rs @@ -1,6 +1,10 @@ //! The ordered install plan: every step the `up` command may run, with its state. -use super::*; +use super::{ + Context, FsState, Paths, Step, StepState, binaries_step, config_step, cublas_step, expert_profile_step, kar_state, + kar_step, layout_step, model_step, mtp_pack_step, preflight_step, ready_step, secrets_step, service_steps, + tokenizer_step, trusts_archive, +}; pub fn plan_steps(ctx: &Context, fs: &FsState) -> Vec { let mut steps = vec![ diff --git a/crates/deploy/src/plan/step_state.rs b/crates/deploy/src/plan/step_state.rs index 5957d7f2..69680f58 100644 --- a/crates/deploy/src/plan/step_state.rs +++ b/crates/deploy/src/plan/step_state.rs @@ -1,6 +1,6 @@ //! The state of one plan step and the constructor of a step. -use super::*; +use super::{Step, StepState}; impl StepState { pub fn tag(&self) -> &'static str { diff --git a/crates/deploy/src/plan/tests/expert_profile_steps.rs b/crates/deploy/src/plan/tests/expert_profile_steps.rs index 5f5a738d..8f8303f8 100644 --- a/crates/deploy/src/plan/tests/expert_profile_steps.rs +++ b/crates/deploy/src/plan/tests/expert_profile_steps.rs @@ -1,6 +1,9 @@ //! The expert-profile step: its place in the plan, its states and the digest that decides a download. -use super::*; +use super::{ + Context, ExpertProfileState, FsState, Mode, Profile, StepState, context, expert_profile_state, expert_step, gather, + options, plan_steps, state_of, +}; #[test] fn the_expert_profile_is_planned_before_the_big_downloads() { diff --git a/crates/deploy/src/plan/tests/install_steps.rs b/crates/deploy/src/plan/tests/install_steps.rs index 4417c91b..7840a0f2 100644 --- a/crates/deploy/src/plan/tests/install_steps.rs +++ b/crates/deploy/src/plan/tests/install_steps.rs @@ -1,6 +1,9 @@ //! Which steps a fresh, finished, blocked or re-verified deployment plans, and with what command. -use super::*; +use super::{ + Context, ExpertProfileState, FsState, Mode, Step, StepState, UnitScopeTag, context, options, plan_steps, + render_plan, state_of, +}; /// The steps a fresh server plans: every one of them but the preflight. const EVERY_STEP: [&str; 11] = [ diff --git a/crates/deploy/src/plan/tests/mode_resolution.rs b/crates/deploy/src/plan/tests/mode_resolution.rs index 4f1fdb96..19be9a13 100644 --- a/crates/deploy/src/plan/tests/mode_resolution.rs +++ b/crates/deploy/src/plan/tests/mode_resolution.rs @@ -1,6 +1,6 @@ //! Run mode resolution. -use super::*; +use super::{Dirs, Facts, Mode, ModeChoice, UnitScopeTag, resolve_mode}; #[test] fn mode_resolution() { diff --git a/crates/deploy/src/preflight/cuda_libraries.rs b/crates/deploy/src/preflight/cuda_libraries.rs index 437f7cb4..fb88010d 100644 --- a/crates/deploy/src/preflight/cuda_libraries.rs +++ b/crates/deploy/src/preflight/cuda_libraries.rs @@ -1,6 +1,6 @@ //! The CUDA libraries: cuBLAS 12 (found, downloadable or missing) and the driver library. -use super::*; +use super::{Check, Facts, Level, Needs, check, pass}; /// The file names the engine loads on this OS: (cuBLAS, cuBLASLt, CUDA driver library). fn library_names(windows: bool) -> (&'static str, &'static str, &'static str) { diff --git a/crates/deploy/src/preflight/disk.rs b/crates/deploy/src/preflight/disk.rs index 0693a66b..edac7c6a 100644 --- a/crates/deploy/src/preflight/disk.rs +++ b/crates/deploy/src/preflight/disk.rs @@ -1,6 +1,6 @@ //! The disk space check: what the first run needs on the assets, state and prefix volumes. -use super::*; +use super::{ARCHIVE_BYTES, Check, Facts, GIB, Level, Needs, check, gib, pass}; /// One volume: its label, the bytes the run needs there and the bytes free. type Volume = (String, u64, u64); diff --git a/crates/deploy/src/preflight/download_hints.rs b/crates/deploy/src/preflight/download_hints.rs index b403eba0..d96aef45 100644 --- a/crates/deploy/src/preflight/download_hints.rs +++ b/crates/deploy/src/preflight/download_hints.rs @@ -1,6 +1,6 @@ //! Hints about what the first run downloads: the Hugging Face token and the VRAM expert tier. -use super::*; +use super::{Check, ExpertProfileState, Facts, Level, Needs, Profile, check}; pub(super) fn check_hf_token(facts: &Facts, needs: &Needs, checks: &mut Vec) { if needs.shard_bytes_missing > 0 && !facts.hf_token_set { diff --git a/crates/deploy/src/preflight/evaluation.rs b/crates/deploy/src/preflight/evaluation.rs index 0988d8e9..c8cd5879 100644 --- a/crates/deploy/src/preflight/evaluation.rs +++ b/crates/deploy/src/preflight/evaluation.rs @@ -1,6 +1,9 @@ //! The preflight run: every check in order, over the host facts, the profile and what the plan needs. -use super::*; +use super::{ + Check, Facts, Needs, Profile, Report, cuda_libraries, disk, download_hints, gpu, kar_source, memory, platform, + resource_preset, service_host, wsl_filesystem, +}; pub fn evaluate(facts: &Facts, profile: &Profile, needs: &Needs) -> Report { let mut checks = Vec::new(); diff --git a/crates/deploy/src/preflight/gpu.rs b/crates/deploy/src/preflight/gpu.rs index d29b725f..5638fdf4 100644 --- a/crates/deploy/src/preflight/gpu.rs +++ b/crates/deploy/src/preflight/gpu.rs @@ -1,6 +1,6 @@ //! The GPU checks: presence, driver version, architecture and memory. -use super::*; +use super::{Check, Facts, Gpu, Level, Needs, Profile, check, gib, pass}; /// Pushes the GPU check and, when the GPU is there, the driver, architecture and memory checks. pub(super) fn check_gpu(facts: &Facts, profile: &Profile, needs: &Needs, checks: &mut Vec) { diff --git a/crates/deploy/src/preflight/kar_source.rs b/crates/deploy/src/preflight/kar_source.rs index 067bcb90..763fc443 100644 --- a/crates/deploy/src/preflight/kar_source.rs +++ b/crates/deploy/src/preflight/kar_source.rs @@ -1,6 +1,6 @@ //! The KAR source prerequisites: a sealed memfd on Linux, a read-only archive file elsewhere. -use super::*; +use super::{Check, ExpertSource, Facts, KarSource, Level, Profile, check, pass}; pub(super) fn check_kar_source(facts: &Facts, profile: &Profile, checks: &mut Vec) { if facts.os == "windows" { diff --git a/crates/deploy/src/preflight/memory.rs b/crates/deploy/src/preflight/memory.rs index 978a6833..f32ceae2 100644 --- a/crates/deploy/src/preflight/memory.rs +++ b/crates/deploy/src/preflight/memory.rs @@ -1,6 +1,6 @@ //! The RAM check: the total, the available memory and the cgroup limit against what the profile needs to start. -use super::*; +use super::{Check, Facts, GIB, KarSource, Level, Needs, Profile, check, gib}; pub(super) fn check_ram(facts: &Facts, profile: &Profile, needs: &Needs, checks: &mut Vec) { let ram = &facts.memory; diff --git a/crates/deploy/src/preflight/platform.rs b/crates/deploy/src/preflight/platform.rs index 4224f832..5c196d95 100644 --- a/crates/deploy/src/preflight/platform.rs +++ b/crates/deploy/src/preflight/platform.rs @@ -1,6 +1,6 @@ //! The platform check: the CUDA runtime runs on Linux x86_64 (or WSL2) and on Windows x86_64 only. -use super::*; +use super::{Check, Facts, Level, check, pass}; /// Pushes the platform check; `false` when nothing else can be judged on this OS. pub(super) fn check_platform(facts: &Facts, checks: &mut Vec) -> bool { diff --git a/crates/deploy/src/preflight/report.rs b/crates/deploy/src/preflight/report.rs index fafa7456..0d5cd67c 100644 --- a/crates/deploy/src/preflight/report.rs +++ b/crates/deploy/src/preflight/report.rs @@ -1,6 +1,6 @@ //! The preflight report: its text rendering and the constructors of a check. -use super::*; +use super::{Check, GIB, Level, Report}; impl Report { pub fn failed(&self) -> bool { diff --git a/crates/deploy/src/preflight/resource_preset.rs b/crates/deploy/src/preflight/resource_preset.rs index f45e648c..63a21a05 100644 --- a/crates/deploy/src/preflight/resource_preset.rs +++ b/crates/deploy/src/preflight/resource_preset.rs @@ -1,6 +1,6 @@ //! The resource preset: its numbers, and its shortfalls and warnings as checks. -use super::*; +use super::{Check, Level, Needs, check, pass}; use crate::resources::ResourcePlan; pub(super) fn check_resource_preset(needs: &Needs, checks: &mut Vec) { diff --git a/crates/deploy/src/preflight/service_host.rs b/crates/deploy/src/preflight/service_host.rs index 2b7be8b1..d2b01001 100644 --- a/crates/deploy/src/preflight/service_host.rs +++ b/crates/deploy/src/preflight/service_host.rs @@ -1,6 +1,6 @@ //! The service host: systemd, the loopback ports, the API bind address and the runtime binaries. -use super::*; +use super::{Check, Facts, Level, Needs, check, pass}; pub(super) fn check_systemd(facts: &Facts, needs: &Needs, checks: &mut Vec) { if !needs.wants_systemd { diff --git a/crates/deploy/src/preflight/tests/gpu_and_driver.rs b/crates/deploy/src/preflight/tests/gpu_and_driver.rs index 13890dff..b72f9cdc 100644 --- a/crates/deploy/src/preflight/tests/gpu_and_driver.rs +++ b/crates/deploy/src/preflight/tests/gpu_and_driver.rs @@ -1,6 +1,6 @@ //! The GPU, driver, binaries and CUDA library checks of a healthy and an unhealthy server. -use super::*; +use super::{ExpertProfileState, Level, Profile, evaluate, level_of, needs, server_facts}; #[test] fn the_expert_tier_is_always_reported_on_or_off() { diff --git a/crates/deploy/src/preflight/tests/host_resources.rs b/crates/deploy/src/preflight/tests/host_resources.rs index 38d177ae..528408f2 100644 --- a/crates/deploy/src/preflight/tests/host_resources.rs +++ b/crates/deploy/src/preflight/tests/host_resources.rs @@ -1,6 +1,6 @@ //! Memory, disk, ports, WSL and systemd checks. -use super::*; +use super::{Facts, GIB, Gpu, Level, Memory, Profile, evaluate, level_of, needs, server_facts}; fn wsl_laptop_with_12_gib() -> Facts { let mut facts = server_facts(); diff --git a/crates/deploy/src/preflight/tests/windows_host.rs b/crates/deploy/src/preflight/tests/windows_host.rs index 6529d568..990aa2bf 100644 --- a/crates/deploy/src/preflight/tests/windows_host.rs +++ b/crates/deploy/src/preflight/tests/windows_host.rs @@ -1,6 +1,6 @@ //! A native Windows laptop is judged with DLL names and without systemd or memfd. -use super::*; +use super::{Facts, Gpu, Level, Needs, Profile, evaluate, level_of, needs}; /// The RTX 3080 laptop as `facts::probe` sees it natively on Windows (nvidia-smi.exe, Win32 memory, DLL search). pub(super) fn windows_laptop() -> Facts { diff --git a/crates/deploy/src/preflight/wsl_filesystem.rs b/crates/deploy/src/preflight/wsl_filesystem.rs index 630de733..8c3b8eb8 100644 --- a/crates/deploy/src/preflight/wsl_filesystem.rs +++ b/crates/deploy/src/preflight/wsl_filesystem.rs @@ -1,6 +1,6 @@ //! The WSL2 file system check: the model volume must not sit on a Windows or network mount. -use super::*; +use super::{Check, Facts, Level, check, is_slow_foreign_fs, pass}; pub(super) fn check_wsl_filesystem(facts: &Facts, checks: &mut Vec) { if !facts.wsl { diff --git a/crates/deploy/src/profile/catalog.rs b/crates/deploy/src/profile/catalog.rs index 3460e25f..ab0a5d7d 100644 --- a/crates/deploy/src/profile/catalog.rs +++ b/crates/deploy/src/profile/catalog.rs @@ -1,6 +1,6 @@ //! The built-in profiles, loading a profile file and picking the profile that fits a GPU. -use super::*; +use super::{BUILTIN, Gpu, Path, Profile}; impl Profile { pub fn builtin(name: &str) -> Option { diff --git a/crates/deploy/src/profile/memory_budget.rs b/crates/deploy/src/profile/memory_budget.rs index 080edd4c..d355fbf8 100644 --- a/crates/deploy/src/profile/memory_budget.rs +++ b/crates/deploy/src/profile/memory_budget.rs @@ -1,6 +1,6 @@ //! The memory budget of a profile: validation, engine arguments, environment and the prefix-cache cap. -use super::*; +use super::{BTreeMap, MemoryBudget}; const SHARE_ENV: &str = "LELEKA_MEMORY_CACHE_SHARE_PERCENT"; const RETENTION_ENV: &str = "LELEKA_PREFIX_RETENTION_S"; diff --git a/crates/deploy/src/profile/profile_limits.rs b/crates/deploy/src/profile/profile_limits.rs index 196eb644..93d9ede8 100644 --- a/crates/deploy/src/profile/profile_limits.rs +++ b/crates/deploy/src/profile/profile_limits.rs @@ -1,6 +1,6 @@ //! What a profile needs from the host: the sealed-archive size, the free RAM floor and its validation. -use super::*; +use super::{ARCHIVE_BYTES, KarSource, MemfdExtents, PREFILL_CAPACITIES, Profile, SPARSE_MEMFD_BYTES_ESTIMATE}; impl Profile { /// Host RAM the sealed memfd holds for the life of the service (0 for a file-backed archive). diff --git a/crates/deploy/src/profile/tests/budget_arguments.rs b/crates/deploy/src/profile/tests/budget_arguments.rs index 882b2c03..8434c564 100644 --- a/crates/deploy/src/profile/tests/budget_arguments.rs +++ b/crates/deploy/src/profile/tests/budget_arguments.rs @@ -1,6 +1,6 @@ //! The memory budget in the engine arguments and environment, and the prefix-cache cap. -use super::*; +use super::{KarSource, Profile}; #[test] fn the_builtin_profiles_carry_the_memory_budget_into_engine_arguments_and_environment() { diff --git a/crates/deploy/src/profile/tests/builtin_profiles.rs b/crates/deploy/src/profile/tests/builtin_profiles.rs index aface2df..34d92dae 100644 --- a/crates/deploy/src/profile/tests/builtin_profiles.rs +++ b/crates/deploy/src/profile/tests/builtin_profiles.rs @@ -1,6 +1,6 @@ //! The built-in profiles parse, validate and differ only where their form says so. -use super::*; +use super::{ARCHIVE_BYTES, BUILTIN, ExpertSource, KarSource, Profile, gpu, resolve}; /// The field `$($field).+` of both profiles is the same. macro_rules! assert_same { diff --git a/crates/deploy/src/profile/tests/selection.rs b/crates/deploy/src/profile/tests/selection.rs index b46d6efc..b9a789b8 100644 --- a/crates/deploy/src/profile/tests/selection.rs +++ b/crates/deploy/src/profile/tests/selection.rs @@ -1,6 +1,6 @@ //! Picking a profile from the detected GPU or an explicit name. -use super::*; +use super::{KarSource, gpu, resolve}; #[test] fn auto_selection_picks_the_server_and_the_laptop_profile() { diff --git a/crates/deploy/src/profile/tests/sparse_memfd.rs b/crates/deploy/src/profile/tests/sparse_memfd.rs index c55f7c34..d350b2f2 100644 --- a/crates/deploy/src/profile/tests/sparse_memfd.rs +++ b/crates/deploy/src/profile/tests/sparse_memfd.rs @@ -1,6 +1,9 @@ //! The sparse memfd form of the server profile: its pin, its RAM floor and what is serialized. -use super::*; +use super::{ + ARCHIVE_BYTES, KarSource, MemfdExtents, PinSource, Profile, SPARSE_MEMFD_BYTES_ESTIMATE, extents_sha256, + sparse_server, +}; #[test] fn only_the_5090_profile_uses_a_sparse_memfd_and_full_is_never_serialized() { diff --git a/crates/deploy/src/reconfigure/plan_and_persist.rs b/crates/deploy/src/reconfigure/plan_and_persist.rs index 607297e4..c2d167f1 100644 --- a/crates/deploy/src/reconfigure/plan_and_persist.rs +++ b/crates/deploy/src/reconfigure/plan_and_persist.rs @@ -1,6 +1,9 @@ //! Planning a reconfigure against the host, persisting it and the request and answer files. -use super::*; +use super::{ + CPU_WORKERS_ENV, Facts, GIB, Gpu, MIB, Map, Outcome, Paths, Planned, Preset, Profile, Request, ResourcePlan, + RunConfig, Serialize, Value, apply_settings, gpu_of, resources, to_file_text, +}; /// The new configuration for `request`, or why the host cannot take it. /// diff --git a/crates/deploy/src/reconfigure/settings.rs b/crates/deploy/src/reconfigure/settings.rs index 03a0e99d..90064441 100644 --- a/crates/deploy/src/reconfigure/settings.rs +++ b/crates/deploy/src/reconfigure/settings.rs @@ -1,6 +1,9 @@ //! Applying runtime settings to a profile and the effective numbers in force. -use super::*; +use super::{ + CPU_WORKERS_ENV, DEFAULT_PREFILL_CHUNK, Facts, GIB, Gpu, Map, PREFILL_CAPACITIES, Profile, Request, RunConfig, + SETTINGS, Value, json, +}; impl Request { /// A budget or preset change needs a new engine process. diff --git a/crates/deploy/src/reconfigure/tests/planning.rs b/crates/deploy/src/reconfigure/tests/planning.rs index ede38753..478444f1 100644 --- a/crates/deploy/src/reconfigure/tests/planning.rs +++ b/crates/deploy/src/reconfigure/tests/planning.rs @@ -1,6 +1,8 @@ //! A budget change or a preset is planned against the host and keeps everything else. -use super::*; +use super::{ + CPU_WORKERS_ENV, GIB, KarSource, Preset, RunConfig, gpu, host, json, plan, plan_on_big_host, request, server_config, +}; #[test] fn a_budget_change_is_planned_against_the_host_and_keeps_everything_else() { diff --git a/crates/deploy/src/reconfigure/tests/recording.rs b/crates/deploy/src/reconfigure/tests/recording.rs index 230fc837..795c66ae 100644 --- a/crates/deploy/src/reconfigure/tests/recording.rs +++ b/crates/deploy/src/reconfigure/tests/recording.rs @@ -1,6 +1,10 @@ //! Recording the settings, the request and answer files, persisting the config and the effective summary. -use super::*; +use super::{ + CPU_WORKERS_ENV, Dirs, Outcome, Paths, Preset, Request, RunConfig, State, Value, big_host, effective, json, + persist, persist_offline, plan, plan_on_big_host, read_outcome, record_settings, request, server_config, + take_request, write_outcome, write_request, +}; #[test] fn recording_settings_updates_the_profile_and_the_base_and_lets_an_explicit_worker_count_win() { diff --git a/crates/deploy/src/reconfigure/tests/settings_ranges.rs b/crates/deploy/src/reconfigure/tests/settings_ranges.rs index e477a4fc..3b009039 100644 --- a/crates/deploy/src/reconfigure/tests/settings_ranges.rs +++ b/crates/deploy/src/reconfigure/tests/settings_ranges.rs @@ -1,6 +1,9 @@ //! Runtime settings become profile fields within the engine's ranges; invalid and unsafe values change nothing. -use super::*; +use super::{ + BTreeMap, CPU_WORKERS_ENV, Dirs, Facts, Ports, Preset, Profile, Request, RunConfig, apply_settings, big_host, gpu, + host, json, optimistic, plan, request, server_config, +}; #[test] fn runtime_settings_become_profile_fields_with_the_engines_ranges() { diff --git a/crates/deploy/src/resources/sizing.rs b/crates/deploy/src/resources/sizing.rs index 7db1e3fe..468ef3ef 100644 --- a/crates/deploy/src/resources/sizing.rs +++ b/crates/deploy/src/resources/sizing.rs @@ -1,6 +1,12 @@ //! Sizing the resource plan from the host facts and applying a preset to a profile. -use super::*; +use super::{ + ARCHIVE_BYTES, BTreeMap, CPU_WORKERS_ENV, DEFAULT_RESERVE_BYTES, ENGINE_EXTRA_BYTES, ENGINE_FIXED_RESIDENT_BYTES, + ExpertSource, Facts, GIB, Gpu, KarSource, MAPPED_ENGINE_FIXED_BYTES, MAPPED_MIN_AVAILABLE_BYTES, + MAPPED_OVERHEAD_BYTES, MAPPED_WORKING_SET_ENV, MAX_USEFUL_WORKERS, MIB, Preset, Profile, RESIDENT_BANK_GIB, + ResourcePlan, WINDOWS_DESKTOP_RESERVE_BYTES, WINDOWS_WORKSTATION_DESKTOP_RESERVE_BYTES, + WINDOWS_WORKSTATION_RAM_TARGET_BYTES, WINDOWS_WORKSTATION_WORKING_SET_GIB, WORKSTATION_VRAM_MARGIN_MIB, gib_text, +}; /// The largest prompt chunk an expert cache of this GPU budget can lend to the prompt path (measured on the 3080 laptop /// with the pinned Qwen3.8 IQ3_S pack: a budget of 13 GiB holds 2,234 expert slots of 1.97 MiB, about 520 more per GiB; diff --git a/crates/deploy/src/resources/tests/presets_and_workers.rs b/crates/deploy/src/resources/tests/presets_and_workers.rs index 21753eeb..f9d64dcc 100644 --- a/crates/deploy/src/resources/tests/presets_and_workers.rs +++ b/crates/deploy/src/resources/tests/presets_and_workers.rs @@ -1,6 +1,9 @@ //! Presets, the prompt chunk and the worker count that a host and a preset allow. -use super::*; +use super::{ + BTreeMap, CPU_WORKERS_ENV, GIB, MIB, Preset, apply, compute, gpu, host, laptop, prefill_capacity_for_budget, + server, server_plan, +}; #[test] fn the_prompt_chunk_follows_what_the_gpu_budget_can_lend() { diff --git a/crates/deploy/src/resources/tests/ram_fit.rs b/crates/deploy/src/resources/tests/ram_fit.rs index b7701fff..57819737 100644 --- a/crates/deploy/src/resources/tests/ram_fit.rs +++ b/crates/deploy/src/resources/tests/ram_fit.rs @@ -1,6 +1,10 @@ //! How the archive form is charged to the RAM footprint and what a small or low-RAM host falls back to. -use super::*; +use super::{ + ARCHIVE_BYTES, BTreeMap, ENGINE_FIXED_RESIDENT_BYTES, ExpertSource, GIB, KarSource, Preset, Profile, + SPARSE_MEMFD_BYTES_ESTIMATE, apply, compute, gpu, host, server, server_plan, with_resident_archive, + with_resident_bytes, +}; #[test] fn a_sparse_memfd_fits_a_host_the_full_copy_does_not_and_a_resident_one_is_credited_by_its_own_size() diff --git a/crates/deploy/src/resources/tests/windows_presets.rs b/crates/deploy/src/resources/tests/windows_presets.rs index 2ff7afdb..f7d0a589 100644 --- a/crates/deploy/src/resources/tests/windows_presets.rs +++ b/crates/deploy/src/resources/tests/windows_presets.rs @@ -1,6 +1,6 @@ //! The Windows forms: page-locked experts from the free RAM and the workstation preset. -use super::*; +use super::{BTreeMap, Facts, MAPPED_WORKING_SET_ENV, Preset, ResourcePlan, apply, compute, gpu, host, laptop}; #[test] fn the_windows_file_backed_form_sizes_its_page_locked_experts_from_the_free_ram() { diff --git a/crates/deploy/src/sealed/exec_arguments.rs b/crates/deploy/src/sealed/exec_arguments.rs index 408ef86c..acf94b55 100644 --- a/crates/deploy/src/sealed/exec_arguments.rs +++ b/crates/deploy/src/sealed/exec_arguments.rs @@ -1,7 +1,7 @@ //! The portable parts of `leleka seal-exec`: the sparse serve extents, the argument parser and the descriptor //! substitution. -use super::*; +use super::{PLACEHOLDER, SealExecPlan}; /// The page-aligned ranges of the archive file at `kar` that the serve path reads, from its header and directory (about /// a megabyte of reads, none of the payload). Refuses a file that is not a valid KAR archive of `expect_bytes`. diff --git a/crates/deploy/src/steps/downloads.rs b/crates/deploy/src/steps/downloads.rs index 6e32c212..dee50857 100644 --- a/crates/deploy/src/steps/downloads.rs +++ b/crates/deploy/src/steps/downloads.rs @@ -1,6 +1,10 @@ //! The small downloads and writes of `up`: expert table, cuBLAS, secrets and the API key. -use super::*; +use super::{ + CUBLAS_SHA256, CUBLAS_URL, CUBLAS_VERSION, Context, ENV_HEADER, GATEWAY_TOKEN_ENV, Path, RUNTIME_TOKEN_ENV, Stdio, + desired_ld_library_path, merge_env, new_token, parse_env_file, run_tool, say, sha256_file, valid_token, + write_private, +}; /// The command line of the download: `wget` or `curl`, https only, at most 1 MiB. fn small_download_args<'a>(tool: &str, url: &'a str, part_text: &'a str) -> Vec<&'a str> { diff --git a/crates/deploy/src/steps/preparation.rs b/crates/deploy/src/steps/preparation.rs index ae1ea6ef..cb3c401e 100644 --- a/crates/deploy/src/steps/preparation.rs +++ b/crates/deploy/src/steps/preparation.rs @@ -1,6 +1,10 @@ //! Preparing and re-planning the steps of `up`. -use super::*; +use super::{ + Changes, Context, Instant, RunConfig, Step, StepState, ensure_kar, extract_tokenizer, fetch_and_verify_model, + gather_fs, import_mtp_pack, init_api_key, install_binaries, install_cublas, kar_runs_tool, make_dirs, plan_steps, + provision_expert_profile, say, write_configs, write_secrets_and_env, +}; pub async fn prepare(ctx: &Context, steps: &[Step]) -> Result { let mut changes = Changes::default(); diff --git a/crates/deploy/src/steps/probes_and_tools.rs b/crates/deploy/src/steps/probes_and_tools.rs index 8c26d05d..028b300c 100644 --- a/crates/deploy/src/steps/probes_and_tools.rs +++ b/crates/deploy/src/steps/probes_and_tools.rs @@ -1,6 +1,9 @@ //! Readiness probes, the status fetch, unit text, tool runs and the directory and binary install. -use super::*; +use super::{ + AsyncReadExt, AsyncWriteExt, BINARIES, Command, Context, Duration, Path, PathBuf, Paths, Stdio, UnitScopeTag, http, + say, sha256_file, units, +}; /// `GET /ready` with the key of `paths`. False on any failure (no key, nothing listening, 503). pub async fn probe_ready_at(paths: &Paths, api: &str) -> bool { diff --git a/crates/deploy/src/steps/service_unit.rs b/crates/deploy/src/steps/service_unit.rs index b49117f6..da85e102 100644 --- a/crates/deploy/src/steps/service_unit.rs +++ b/crates/deploy/src/steps/service_unit.rs @@ -1,6 +1,11 @@ //! The service user, the systemd unit, the start and the readiness wait. -use super::*; +use super::{ + ARCHIVE_BYTES, Changes, Command, Context, Duration, Instant, Mode, Path, Stdio, Step, StepState, UnitScopeTag, + probe_ready, run_tool, say, unit_text, +}; +#[cfg(unix)] +use super::lookup_user; #[cfg(unix)] pub async fn ensure_service_user(ctx: &Context) -> Result<(), String> { diff --git a/crates/deploy/src/steps/stamps_and_state.rs b/crates/deploy/src/steps/stamps_and_state.rs index ee4aa134..31e847f9 100644 --- a/crates/deploy/src/steps/stamps_and_state.rs +++ b/crates/deploy/src/steps/stamps_and_state.rs @@ -1,6 +1,10 @@ //! Progress lines, file stamps, checksums and the current state of the binaries and configs. -use super::*; +use super::{ + ARCHIVE_BYTES, BINARIES, Context, Digest, FileStamp, FsState, GATEWAY_TOKEN_ENV, MTP_FILES, Mode, Path, PathBuf, + Paths, RUNTIME_TOKEN_ENV, Read, Sha256, StampFile, SystemTime, UNIX_EPOCH, parse_env_file, probe_ready_at, + to_file_text, unit_text, valid_token, write_private, +}; pub fn say(message: &str) { eprintln!("leleka: {message}"); diff --git a/crates/deploy/src/supervisor/api.rs b/crates/deploy/src/supervisor/api.rs index 4519fdee..f5b23bbe 100644 --- a/crates/deploy/src/supervisor/api.rs +++ b/crates/deploy/src/supervisor/api.rs @@ -1,6 +1,6 @@ //! The public API process: readiness wait, answers to the operator and restart. -use super::*; +use super::{Child, ChildSpec, Duration, Flow, Instant, ServiceSupervisor, fail, http, reconfigure}; impl ServiceSupervisor { pub(super) async fn wait_api_ready(&mut self, api: &mut Child) -> Result<(), Flow> { diff --git a/crates/deploy/src/supervisor/archive.rs b/crates/deploy/src/supervisor/archive.rs index d1b70900..2c0324c2 100644 --- a/crates/deploy/src/supervisor/archive.rs +++ b/crates/deploy/src/supervisor/archive.rs @@ -1,6 +1,9 @@ //! The sealed archive the engine inherits: opened from a descriptor, copied into a memfd, or absent. -use super::*; +use super::{ + ARCHIVE_BYTES, Child, Failure, File, FileIdentity, Flow, Instant, KarSource, MemfdExtents, Path, Phase, + ServiceSupervisor, archive_sha256, fail, sealed, +}; type SealedCopy = Result< ( diff --git a/crates/deploy/src/supervisor/cli_output.rs b/crates/deploy/src/supervisor/cli_output.rs index 962ee05a..51651e12 100644 --- a/crates/deploy/src/supervisor/cli_output.rs +++ b/crates/deploy/src/supervisor/cli_output.rs @@ -1,6 +1,6 @@ //! Parsers of what `leleka-cli` and the gateway print (runtime status, operation records, log tails, token rule). -use super::*; +use super::{File, Path}; /// `model_ready` of the runtime `id` in `leleka-cli status` output; `connected` is the second value. pub fn parse_runtime_status(text: &str, id: &str) -> Option<(bool, bool)> { diff --git a/crates/deploy/src/supervisor/engine.rs b/crates/deploy/src/supervisor/engine.rs index 27e01537..86b3e134 100644 --- a/crates/deploy/src/supervisor/engine.rs +++ b/crates/deploy/src/supervisor/engine.rs @@ -1,6 +1,9 @@ //! Starting the engine, waiting for its port, the `leleka-cli` calls and recovering a dead engine. -use super::*; +use super::{ + BTreeMap, Child, ChildSpec, Command, Duration, Failure, File, FileIdentity, Flow, Instant, KarArg, KarSource, + Phase, ServiceSupervisor, SocketAddr, Stdio, archive_sha256, fail, timeout, unix_now, +}; impl ServiceSupervisor { /// Engine process -> port -> gateway connected -> typed load -> model_ready. diff --git a/crates/deploy/src/supervisor/live_reconfigure.rs b/crates/deploy/src/supervisor/live_reconfigure.rs index 52092c82..ce6d3a3d 100644 --- a/crates/deploy/src/supervisor/live_reconfigure.rs +++ b/crates/deploy/src/supervisor/live_reconfigure.rs @@ -1,6 +1,6 @@ //! Applying a reconfigure request to the running service (budget changes restart only the engine). -use super::*; +use super::{Child, Duration, Flow, Phase, RunConfig, ServiceSupervisor, reconfigure}; /// How to undo a refused reconfigure: the settings that ran before, and why the new ones were refused. struct Rollback { diff --git a/crates/deploy/src/supervisor/load.rs b/crates/deploy/src/supervisor/load.rs index 02e51263..09bbf180 100644 --- a/crates/deploy/src/supervisor/load.rs +++ b/crates/deploy/src/supervisor/load.rs @@ -1,6 +1,9 @@ //! Loading the model into a started engine through `leleka-cli` and waiting until it is ready. -use super::*; +use super::{ + Child, Duration, Flow, Instant, OPERATION_FAILED, OPERATION_INDETERMINATE, Phase, ServiceSupervisor, fail, + parse_operation, parse_operation_state, parse_runtime_status, tail_of, +}; /// The id and epoch of a `load-mtp` operation, as the CLI reports them. type Operation = (String, String); diff --git a/crates/deploy/src/supervisor/logfile.rs b/crates/deploy/src/supervisor/logfile.rs index ce65a600..bd6ac51a 100644 --- a/crates/deploy/src/supervisor/logfile.rs +++ b/crates/deploy/src/supervisor/logfile.rs @@ -1,6 +1,6 @@ //! The supervisor's own log file: UTC time stamps, rotation and private (mode 0600) appends. -use super::*; +use super::{File, LOG_ROTATE_BYTES, Log, Path, PathBuf, SystemTime, UNIX_EPOCH, Write}; /// Seconds since the epoch. pub(super) fn unix_now() -> u64 { diff --git a/crates/deploy/src/supervisor/sparse.rs b/crates/deploy/src/supervisor/sparse.rs index 3e3d5690..5c89a885 100644 --- a/crates/deploy/src/supervisor/sparse.rs +++ b/crates/deploy/src/supervisor/sparse.rs @@ -1,6 +1,9 @@ //! The sparse archive: shard stamps, the pre-verification process and the served extents. -use super::*; +use super::{ + ARCHIVE_BYTES, Child, ChildSpec, FileIdentity, Flow, MemfdExtents, Path, PinSource, ServiceSupervisor, + extents_sha256, fail, sealed, +}; impl ServiceSupervisor { /// Are both shards stamped as verified in their present state? (Then an engine start hashes neither.) diff --git a/crates/deploy/src/supervisor/status.rs b/crates/deploy/src/supervisor/status.rs index 1d31f3f5..5e6c95ad 100644 --- a/crates/deploy/src/supervisor/status.rs +++ b/crates/deploy/src/supervisor/status.rs @@ -1,6 +1,6 @@ //! The status document, its phases and the health notes of the running supervisor. -use super::*; +use super::{Phase, ServiceSupervisor, StatusDoc, logs, unix_now, write_private}; impl ServiceSupervisor { pub(super) fn set_phase(&mut self, phase: Phase, message: &str) { diff --git a/crates/deploy/src/supervisor/supervise.rs b/crates/deploy/src/supervisor/supervise.rs index b0b06afe..9ce211a2 100644 --- a/crates/deploy/src/supervisor/supervise.rs +++ b/crates/deploy/src/supervisor/supervise.rs @@ -1,6 +1,9 @@ //! The supervision loop of a running service and its health sampling. -use super::*; +use super::{ + Child, ChildSpec, Duration, Flow, Instant, Phase, RunConfig, ServiceSupervisor, fail, http, logs, reconfigure, + unix_now, watchdog, +}; use std::process::ExitStatus; /// What a branch of the supervision loop decided: carry on, or leave with this result (after the drain). diff --git a/crates/deploy/src/winfront/commands.rs b/crates/deploy/src/winfront/commands.rs index ca944542..0cb9a12b 100644 --- a/crates/deploy/src/winfront/commands.rs +++ b/crates/deploy/src/winfront/commands.rs @@ -1,6 +1,9 @@ //! The Windows front's `status`, `reconfigure` and `down`. -use super::*; +use super::{ + Bridge, Duration, PathBuf, Session, StatusReport, Value, fetch_status_with_key, forward, linux_to_unc, note, + open_session, print_status, probe_ready_with_key, send_reconfigure, split_reconfigure, +}; pub(super) async fn status(args: &[String]) -> i32 { let session = match open_session(args, false) { diff --git a/crates/deploy/src/winfront/doctor_command.rs b/crates/deploy/src/winfront/doctor_command.rs index 3ce4641a..2aaa7c63 100644 --- a/crates/deploy/src/winfront/doctor_command.rs +++ b/crates/deploy/src/winfront/doctor_command.rs @@ -1,6 +1,9 @@ //! `leleka doctor` on Windows. -use super::*; +use super::{ + Bridge, BridgeState, PathBuf, ProbeRequest, find_repo, list_distros, local_app_data, parse_wslconfig, pick_distro, + probe, wsl_exe, wslconfig_advice, +}; use crate::{facts::Facts, layout::Paths, wsl::Distro}; use std::path::Path; diff --git a/crates/deploy/src/winfront/routing.rs b/crates/deploy/src/winfront/routing.rs index 7d5e843f..011ff7fd 100644 --- a/crates/deploy/src/winfront/routing.rs +++ b/crates/deploy/src/winfront/routing.rs @@ -1,6 +1,8 @@ //! Which commands run natively and which are routed to WSL. -use super::*; +use super::{ + Bridge, BridgeState, PathBuf, Route, Session, doctor, list_distros, pick_distro, translate_args, wsl_exe, wsl_route, +}; /// Remove `--wsl` / `--native` from `args`; the flag wins over `LELEKA_ROUTE`. pub fn split_route( diff --git a/crates/deploy/src/winfront/session.rs b/crates/deploy/src/winfront/session.rs index f1fc8a12..1f4f0f77 100644 --- a/crates/deploy/src/winfront/session.rs +++ b/crates/deploy/src/winfront/session.rs @@ -1,6 +1,10 @@ //! A session with the WSL bridge: routing a command, forwarding it and announcing readiness. -use super::*; +use super::{ + Bridge, BridgeState, Duration, PathBuf, ProbeRequest, Session, Value, down, effective_wsl_memory, is_drvfs, + linux_to_unc, local_app_data, note, open_session, parse_wslconfig, probe, probe_ready_with_key, reconfigure, + status, wslconfig_advice, +}; impl Session { pub(super) fn state_dir(&self) -> String { diff --git a/crates/deploy/src/wsl/bridge.rs b/crates/deploy/src/wsl/bridge.rs index c048c26d..9419250c 100644 --- a/crates/deploy/src/wsl/bridge.rs +++ b/crates/deploy/src/wsl/bridge.rs @@ -1,6 +1,9 @@ //! .wslconfig parsing and the WSL bridge process. -use super::*; +use super::{ + Bridge, BridgeState, Distro, FIND_LELEKA, GIB, Path, PathBuf, WslConfig, decode_console_text, parse_distro_list, + parse_size, +}; /// The `[wsl2]` section of `%UserProfile%\.wslconfig`. pub fn parse_wslconfig(text: &str) -> WslConfig { diff --git a/crates/deploy/src/wsl/distros_and_paths.rs b/crates/deploy/src/wsl/distros_and_paths.rs index ce62984e..3d6d2cb8 100644 --- a/crates/deploy/src/wsl/distros_and_paths.rs +++ b/crates/deploy/src/wsl/distros_and_paths.rs @@ -1,6 +1,6 @@ //! WSL console text, the distribution list and the translation of paths and arguments. -use super::*; +use super::{Distro, FOREIGN_DISTROS, Forwarded, GIB, PATH_FLAGS}; // --------------------------------------------------------------------------------------------------------------- // wsl.exe text diff --git a/crates/engine-core/src/conversation/manager_tests.rs b/crates/engine-core/src/conversation/manager_tests.rs index bdd1ec34..8a5968f2 100644 --- a/crates/engine-core/src/conversation/manager_tests.rs +++ b/crates/engine-core/src/conversation/manager_tests.rs @@ -57,8 +57,8 @@ struct Rng(u64); mod byte_budget_and_slot; #[path = "manager_tests/continuing_chat_reuses.rs"] mod continuing_chat_reuses; -#[path = "manager_tests/random_conversation_traffic_always_resum.rs"] -mod random_conversation_traffic_always_resum; +#[path = "manager_tests/random_traffic_resumes_into_exact_prefix_state.rs"] +mod random_traffic_resumes_into_exact_prefix_state; mod hash; #[allow(unused_imports)] diff --git a/crates/engine-core/src/conversation/manager_tests/random_conversation_traffic_always_resum.rs b/crates/engine-core/src/conversation/manager_tests/random_traffic_resumes_into_exact_prefix_state.rs similarity index 96% rename from crates/engine-core/src/conversation/manager_tests/random_conversation_traffic_always_resum.rs rename to crates/engine-core/src/conversation/manager_tests/random_traffic_resumes_into_exact_prefix_state.rs index b1774220..3a3bed8a 100644 --- a/crates/engine-core/src/conversation/manager_tests/random_conversation_traffic_always_resum.rs +++ b/crates/engine-core/src/conversation/manager_tests/random_traffic_resumes_into_exact_prefix_state.rs @@ -1,5 +1,5 @@ -//! Tests of manager_tests by topic (moved out of the test file by STRA-338): -//! random_conversation_traffic_always_resumes_into_the_exact_prefix_state. +//! Property test of the conversation manager: random conversation traffic always resumes into the exact prefix state. +//! Its own file because it carries the generators of the random world and the traffic. use super::{MAX_CELLS, ReplayedRequest, RequestStart, Rng, TURN, World, chat, gen_tokens, options, world}; diff --git a/crates/engine-qwen35-cuda/src/backend/config.rs b/crates/engine-qwen35-cuda/src/backend/config.rs index 65badddf..6a7c01bc 100644 --- a/crates/engine-qwen35-cuda/src/backend/config.rs +++ b/crates/engine-qwen35-cuda/src/backend/config.rs @@ -1,5 +1,8 @@ //! Pinned model identity, resource limits and the operator-facing configuration types of the CUDA owner. -use super::*; +use super::{ + AtomicBool, AtomicU64, Duration, ExperimentalConfig, InheritedKarArchive, KarExpertSourceConfig, ModelDescriptor, + PathBuf, original_serve, +}; pub(super) const SHARD0: &str = "sha256:4c1eb2ceb4915e1192f4f386021897bde56a97f40a0bb78bb86465e0f7d2aca3"; pub(super) const SHARD1: &str = "sha256:316b46f3a2dbd68c900f43136ab9449f9dcc3725dfd8c794847c204bc161e113"; diff --git a/crates/engine-qwen35-cuda/src/backend/digests.rs b/crates/engine-qwen35-cuda/src/backend/digests.rs index 50fbe81d..1b4208cf 100644 --- a/crates/engine-qwen35-cuda/src/backend/digests.rs +++ b/crates/engine-qwen35-cuda/src/backend/digests.rs @@ -1,5 +1,9 @@ //! Identity digests of the mode a load publishes (mode, execution policy, KAR expert source). -use super::*; +use super::{ + ADAPTIVE_SLOTS_EXECUTION, BackendError, Digest, INTEGER_WINDOWED_EXECUTION, InferenceMode, KAR_PROFILE, + MODE_DIGEST, ModelBinding, OPTIMIZED_EXECUTION, ORIGINAL_SERVE_EXECUTION, QUEUED_OWNERS_EXECUTION, + RESIDENT_OWNERS_EXECUTION, RETAINED_SCRATCH_EXECUTION, STREAMED_SPILL_EXECUTION, Sha256, invalid, requires_kar, +}; /// `sha256:` followed by the lowercase hex of a finished digest: the form of every published identity. fn hex_digest(digest: Sha256) -> String { diff --git a/crates/engine-qwen35-cuda/src/backend/digests_golden.rs b/crates/engine-qwen35-cuda/src/backend/digests_golden.rs index 3fd7782c..c28b49a0 100644 --- a/crates/engine-qwen35-cuda/src/backend/digests_golden.rs +++ b/crates/engine-qwen35-cuda/src/backend/digests_golden.rs @@ -1,6 +1,11 @@ //! Golden values of every identity digest on fixed inputs, taken from the code as it was before the digest functions //! were unified (STRA-338 S5a). A change here is a change of the `mode_identity_digest` a running service publishes. -use super::*; +use super::{ + KAR_MTP_PROFILE, RANKED_EXPERT_PROFILE_SHA, adaptive_slots_execution_digest, execution_mode_digest, + kar_expert_mode_digest, kar_mode_digest, mtp_mode_digest, optimized_execution_digest, + original_serve_execution_digest, queued_owners_execution_digest, resident_owners_execution_digest, + retained_scratch_execution_digest, streamed_spill_execution_digest, +}; const BOUND: &str = "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; diff --git a/crates/engine-qwen35-cuda/src/backend/errors.rs b/crates/engine-qwen35-cuda/src/backend/errors.rs index 4cba36df..f7c64df6 100644 --- a/crates/engine-qwen35-cuda/src/backend/errors.rs +++ b/crates/engine-qwen35-cuda/src/backend/errors.rs @@ -1,5 +1,5 @@ //! Constructors of the fixed `BackendError` refusals. -use super::*; +use super::{BackendError, ErrorCode}; pub(super) fn error(code: ErrorCode, message: &'static str) -> BackendError { BackendError { code, message: message.into(), retryable: false } diff --git a/crates/engine-qwen35-cuda/src/backend/family.rs b/crates/engine-qwen35-cuda/src/backend/family.rs index c06d672b..7c2fa069 100644 --- a/crates/engine-qwen35-cuda/src/backend/family.rs +++ b/crates/engine-qwen35-cuda/src/backend/family.rs @@ -1,6 +1,8 @@ //! The Qwen3.5 CUDA engine as an [`EngineFamily`] of the composition root (STRA-338 S20). Starting it is the existing //! `spawn_backend*` code; this file only gives the choice between its two product entry points a single typed door. -use super::*; +use super::{ + Backend, BackendError, NativeBackendConfig, OriginalServeOptions, spawn_backend, spawn_backend_original_serve, +}; use leleka_engine_core::family::EngineFamily; /// The product engine: Qwen3.5 on the CUDA owner thread. diff --git a/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs b/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs index 254ef2bd..f37392a9 100644 --- a/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs +++ b/crates/engine-qwen35-cuda/src/backend/generate_mtp.rs @@ -1,8 +1,15 @@ //! The MTP speculative generation loop. -use super::*; +use super::{ + Clock, EvaluationExecution, FinishReason, GENERATION_TIMEOUT, Generation, GenerationEvent, GenerationFailure, + MtpContinuation, Ordering, PrefillTile, Usage, Utf8Pending, append_compatible, exhausted, invalid, unavailable, +}; +#[cfg(feature = "preview-path")] +use super::{ + Dimension, Instant, MtpDecoder, MtpWindowError, MtpWindowSpec, TargetStepProduct, TokenId, native_position, +}; use crate::qwen_forward::mtp::KnownNext; -mod tile_parts; -use tile_parts::{begin_decoder, commit_window, emit_token_text, prefill_tiles, verified_window}; +mod prefill_tiles_and_windows; +use prefill_tiles_and_windows::{begin_decoder, commit_window, emit_token_text, prefill_tiles, verified_window}; pub(super) fn generate_mtp( run: Generation<'_, '_, '_, C>, diff --git a/crates/engine-qwen35-cuda/src/backend/generate_mtp/tile_parts.rs b/crates/engine-qwen35-cuda/src/backend/generate_mtp/prefill_tiles_and_windows.rs similarity index 93% rename from crates/engine-qwen35-cuda/src/backend/generate_mtp/tile_parts.rs rename to crates/engine-qwen35-cuda/src/backend/generate_mtp/prefill_tiles_and_windows.rs index 7c5600ac..e7a2e3ab 100644 --- a/crates/engine-qwen35-cuda/src/backend/generate_mtp/tile_parts.rs +++ b/crates/engine-qwen35-cuda/src/backend/generate_mtp/prefill_tiles_and_windows.rs @@ -1,7 +1,12 @@ -//! The prefill tiles and the verified windows of the MTP loop, moved out of `generate_mtp` by STRA-338 (size). +//! The steps the MTP generate loop repeats: start the decoder, prefill the prompt tile by tile, then run, observe and +//! commit each verified window. Kept apart from `generate_mtp` so that loop reads as a sequence of these steps. -#[allow(unused_imports)] -use super::*; +use super::{ + Clock, EvaluationExecution, GENERATION_TIMEOUT, Generation, GenerationEvent, GenerationFailure, MtpContinuation, + Ordering, PrefillTile, Utf8Pending, append_compatible, invalid, unavailable, +}; +#[cfg(feature = "preview-path")] +use super::{Instant, MtpDecoder, MtpWindowError, MtpWindowSpec, TargetStepProduct, TokenId}; use crate::qwen_forward::mtp_decode::{MtpVerifiedWindow, MtpWindowRequest, WindowOwners}; /// The decoder to continue with, the product of the retained prefix, the tokens reused and the committed tokens so far. diff --git a/crates/engine-qwen35-cuda/src/backend/generation_failure.rs b/crates/engine-qwen35-cuda/src/backend/generation_failure.rs index e185b00b..cb697124 100644 --- a/crates/engine-qwen35-cuda/src/backend/generation_failure.rs +++ b/crates/engine-qwen35-cuda/src/backend/generation_failure.rs @@ -1,6 +1,6 @@ //! How one generation ends short of a terminal: cancelled by the caller, or failed with a backend error. Shared by the //! Original serve runner and the preview generation loop. -use super::*; +use super::BackendError; pub(super) enum GenerationFailure { Cancelled, diff --git a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/ends.rs b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/ends.rs index 5631f6dd..97192011 100644 --- a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/ends.rs +++ b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/ends.rs @@ -1,5 +1,5 @@ //! How a request ends other than by completing: client cancel, deadline, device error (STRA-338 S15). -use super::*; +use super::{Ended, ErrorCode, HOUR_MS, NO_EOS, Ordering, Rig, Script, expect, failed, prompt}; const SERVE_FAILED: &str = "Original serve request failed"; const DEADLINE: &str = "generation deadline exceeded"; diff --git a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs index e1ab927e..ca973a62 100644 --- a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs +++ b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/graphs.rs @@ -2,7 +2,7 @@ //! text as re-recording, costs no recording, and is replaced - never replayed - when anything it was recorded over //! changed. These scenarios are the ones the real verify bank (`park` / `rearm`) and the journal's owner loan //! (`lend` / `take_back`) must pass; docs/experiments/decode-graph-reuse.md lists them. -use super::*; +use super::{Ended, NO_EOS, Rig, Script, ServeDevice, expect, prompt, prompt_of}; use crate::qwen_forward::original_serve_stack::decode_graph_reuse::{Armed, DecodeGraphKey, Why}; /// What recording the graph set costs on the manual clock. diff --git a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/prefix.rs b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/prefix.rs index b5aee1e9..65cbf648 100644 --- a/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/prefix.rs +++ b/crates/engine-qwen35-cuda/src/backend/lifecycle_tests/prefix.rs @@ -1,6 +1,6 @@ //! The cross-session prefix cache under the lifecycle: reuse, write-back of another session's cells, and what a //! failed or a cancelled request does to the checkpoints (STRA-338 S15). -use super::*; +use super::{Ended, ErrorCode, NO_EOS, Ordering, Rig, Script, done, expect, failed, prompt, prompt_of}; /// A cache that holds one session (700 tokens), then another: the buffer no longer holds the first one. fn rig_after_two_sessions() -> Rig { diff --git a/crates/engine-qwen35-cuda/src/backend/load_admit.rs b/crates/engine-qwen35-cuda/src/backend/load_admit.rs index b4c71e1c..64ffff0d 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_admit.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_admit.rs @@ -1,5 +1,10 @@ //! Load admission: every refusal that needs no model byte, and the start of the memory governor. -use super::*; +use super::{ + BackendError, EvaluationExecution, InferenceMode, InheritedKarArchive, KAR_MTP_PROFILE, LoadEnv, LoadPhase, + ModelDescriptor, NATIVE_MTP_PROFILE, NativeBackendConfig, RuntimeConfig, exhausted, experimental_error, + experimental_modes, invalid, load_failure, original_serve, unsupported, validate_kar_selection, validate_load, + validate_mtp_selection, +}; use std::io::Write; /// Refuse what cannot be served, before any model byte is read. Returns the experimental plan, if any, diff --git a/crates/engine-qwen35-cuda/src/backend/load_bind.rs b/crates/engine-qwen35-cuda/src/backend/load_bind.rs index 138d5e95..74b93f3c 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_bind.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_bind.rs @@ -1,5 +1,10 @@ //! The first half of a Load, before any CUDA object exists: sources, binding, identity, the expert bank. -use super::*; +use super::{ + BackendError, Identity, InputBindingError, LoadEnv, LoadPhase, ModelBinding, ModelDescriptor, PolicyFlags, + RuntimeConfig, Tokenizer, admit_kar_experts, bind_artifact, bind_selected, check_mtp_context, check_not_cancelled, + effective_identity, exhausted, invalid, load_failure, open_sources, original_serve, policy_digest, read_profile, + unavailable, +}; use leleka_model_format::qwen4exp::ProvisionalExpertSource; /// The host-side result of binding: what the CUDA half and the serve loop work on. diff --git a/crates/engine-qwen35-cuda/src/backend/load_identity.rs b/crates/engine-qwen35-cuda/src/backend/load_identity.rs index eb904c90..a440520a 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_identity.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_identity.rs @@ -1,5 +1,12 @@ //! Load phases that fix the identity a Load publishes: the mode digest chain and the loaded-model handle. -use super::*; +use super::{ + BackendError, EvaluationExecution, InferenceMode, LOAD_CONFIG_VERSION, LoadEnv, LoadPhase, LoadedModel, + ModelBinding, ModelDescriptor, OptimizedBackendConfig, Ordering, PolicyFlags, RuntimeConfig, Shared, + adaptive_slots_execution_digest, execution_mode_digest, experimental_modes, invalid, kar_expert_mode_digest, + load_failure, optimized_execution_digest, original_serve_execution_digest, queued_owners_execution_digest, + read_ranked_expert_profile, resident_owners_execution_digest, retained_scratch_execution_digest, + selected_bound_mode, streamed_spill_execution_digest, unavailable, +}; /// The model, the effective mode and the digest that identify what this Load publishes. pub(super) struct Identity { diff --git a/crates/engine-qwen35-cuda/src/backend/load_moe.rs b/crates/engine-qwen35-cuda/src/backend/load_moe.rs index 98c3e5c3..ff726f69 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_moe.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_moe.rs @@ -1,5 +1,10 @@ //! The MoE weight cache of a native Load: which constructor each execution selects. -use super::*; +use super::{ + BackendError, Bound, EvaluationExecution, LoadEnv, LoadPhase, ModelBinding, PolicyFlags, adaptive_moe, exhausted, + learned_main_moe, +}; +#[cfg(feature = "preview-path")] +use super::{DenseWeightCache, MoeWeightCache, load_forward_failure}; use crate::qwen_forward::contract::Error as ForwardError; use leleka_cuda_driver::Context; diff --git a/crates/engine-qwen35-cuda/src/backend/load_moe_gates.rs b/crates/engine-qwen35-cuda/src/backend/load_moe_gates.rs index 556eea20..51389a92 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_moe_gates.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_moe_gates.rs @@ -1,6 +1,8 @@ //! Witness gates of the adaptive-slots and the learned-main MoE caches (CUDA platforms only): a cache is accepted //! only when its witness shows the state a fresh load must have; otherwise it is closed and refused. -use super::*; +use super::ModelBinding; +#[cfg(feature = "preview-path")] +use super::MoeWeightCache; use crate::qwen_forward::contract::Error as ForwardError; use crate::qwen_forward::moe_weight_cache::{AdaptiveWitness, LearnedMainWitness, SharedPermanentWitness}; use leleka_cuda_driver::Context; diff --git a/crates/engine-qwen35-cuda/src/backend/load_sources.rs b/crates/engine-qwen35-cuda/src/backend/load_sources.rs index 27431728..1228b8b8 100644 --- a/crates/engine-qwen35-cuda/src/backend/load_sources.rs +++ b/crates/engine-qwen35-cuda/src/backend/load_sources.rs @@ -1,5 +1,10 @@ //! Load phases that read the pinned sources: verify the shards, bind the artifact and the selected input providers. -use super::*; +use super::{ + BackendError, InferenceMode, InheritedKarArchive, InputBindingError, InputResultKar, KAR_MTP_PROFILE, + KarExpertSource, LoadEnv, LoadPhase, ModelBinding, NativeBackendConfig, PolicyFlags, Qwen4ExpArtifact, + RuntimeConfig, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile, VerifiedSources, invalid, kar_mtp_requested, + load_failure, selected_binding_failure, unsupported, verify_sources_parallel, +}; use leleka_model_format::qwen4exp::ProvisionalExpertSource; use std::path::Path; diff --git a/crates/engine-qwen35-cuda/src/backend/owner.rs b/crates/engine-qwen35-cuda/src/backend/owner.rs index 2b1cee6f..8d0f2a3d 100644 --- a/crates/engine-qwen35-cuda/src/backend/owner.rs +++ b/crates/engine-qwen35-cuda/src/backend/owner.rs @@ -1,5 +1,9 @@ //! The owner thread loop and the load-failure diagnostics. -use super::*; +use super::{ + BackendError, Command, Duration, EvaluationObserver, InputBindingError, LoadEnv, LoadedModel, ModelDescriptor, + NativeBackendConfig, Ordering, OwnerExecution, Receiver, Reply, RuntimeConfig, Shared, SystemClock, clear_active, + invalid, mpsc, serve_load, +}; #[derive(Clone, Copy, Debug)] pub(super) enum LoadPhase { diff --git a/crates/engine-qwen35-cuda/src/backend/probes.rs b/crates/engine-qwen35-cuda/src/backend/probes.rs index 47b3fd89..63649052 100644 --- a/crates/engine-qwen35-cuda/src/backend/probes.rs +++ b/crates/engine-qwen35-cuda/src/backend/probes.rs @@ -1,5 +1,5 @@ //! Load-time probes of the experimental and KAR level-decode PTX. -use super::*; +use super::{BackendError, ExperimentalConfig, experimental_modes, invalid, unavailable, unsupported}; pub(super) fn experimental_error(error: experimental_modes::ExperimentalError) -> BackendError { match error { diff --git a/crates/engine-qwen35-cuda/src/backend/proxy.rs b/crates/engine-qwen35-cuda/src/backend/proxy.rs index 1b4ec276..f3054bdc 100644 --- a/crates/engine-qwen35-cuda/src/backend/proxy.rs +++ b/crates/engine-qwen35-cuda/src/backend/proxy.rs @@ -1,5 +1,13 @@ //! The caller-side handle of the owner actor: shared state, commands and the `Backend` implementation. -use super::*; +use super::{ + ADAPTIVE_SLOTS_EXECUTION, Arc, AtomicBool, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, + BackendIdentity, Duration, ErrorCode, EvaluationExecution, GenerationRequest, GenerationStream, + INTEGER_WINDOWED_EXECUTION, LoadedModel, ModelDescriptor, Mutex, OPTIMIZED_EXECUTION, ORIGINAL_SERVE_EXECUTION, + Ordering, QUEUED_OWNERS_EXECUTION, RECONFIGURE_TIMEOUT, RECONFIGURING, REPLY_TIMEOUT, RESIDENT_OWNERS_EXECUTION, + RETAINED_SCRATCH_EXECUTION, Receiver, RecentIds, RuntimeConfig, STREAMED_SPILL_EXECUTION, SupportedModelTuple, + SyncSender, exhausted, invalid, load_reply_timeout, mpsc, original_serve, unavailable, unsupported, + validate_handle, validate_kar_selection, validate_load, validate_mtp_selection, validate_request, +}; pub(super) struct Active { pub(super) id: String, diff --git a/crates/engine-qwen35-cuda/src/backend/request.rs b/crates/engine-qwen35-cuda/src/backend/request.rs index 0d528202..c3a3c09a 100644 --- a/crates/engine-qwen35-cuda/src/backend/request.rs +++ b/crates/engine-qwen35-cuda/src/backend/request.rs @@ -1,5 +1,7 @@ //! Request preparation: sampler plan, prompt tokens, positions. -use super::*; +use super::{BackendError, GenerationRequest, Tokenizer, exhausted, invalid, validate_request}; +#[cfg(feature = "preview-path")] +use super::{Dimension, InputConstants, Position}; pub(super) fn request_sampler( request: &GenerationRequest, diff --git a/crates/engine-qwen35-cuda/src/backend/serve_close.rs b/crates/engine-qwen35-cuda/src/backend/serve_close.rs index 5f162090..37c9bf77 100644 --- a/crates/engine-qwen35-cuda/src/backend/serve_close.rs +++ b/crates/engine-qwen35-cuda/src/backend/serve_close.rs @@ -1,5 +1,5 @@ //! The end of a loaded native model: the weights and the context are closed and the Unload caller is answered. -use super::*; +use super::{BackendError, Conversations, Ordering, Rc, Reply, Shared, Weights, unavailable}; use leleka_cuda_driver::Context; /// What closing the weights left to settle with the context. diff --git a/crates/engine-qwen35-cuda/src/backend/serve_generate.rs b/crates/engine-qwen35-cuda/src/backend/serve_generate.rs index 6842a36c..72906a83 100644 --- a/crates/engine-qwen35-cuda/src/backend/serve_generate.rs +++ b/crates/engine-qwen35-cuda/src/backend/serve_generate.rs @@ -1,5 +1,13 @@ //! One Generate command of the serve loop: admit it, resume or start a session, generate, publish the terminal. -use super::*; +use super::{ + ActiveGuard, Arc, AtomicBool, BackendError, Conversations, Counters, GenerationRequest, GenerationSink, + GenerationStream, LoadedModel, ModelBinding, MtpContinuation, Ordering, Outcome, PrefixSession, QUEUE, Rc, Reply, + Serving, Shared, TerminalGates, append_compatible, deliver_measurement, emit_terminal, invalid, + 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/backend/serve_loop.rs b/crates/engine-qwen35-cuda/src/backend/serve_loop.rs index ba94b40f..9312adaa 100644 --- a/crates/engine-qwen35-cuda/src/backend/serve_loop.rs +++ b/crates/engine-qwen35-cuda/src/backend/serve_loop.rs @@ -1,5 +1,10 @@ //! The command loop of a loaded native model: Load and Reconfigure are refused, Unload ends the loop, Generate runs. -use super::*; +use super::{ + BackendError, Bound, Command, Duration, Job, LoadEnv, LoadedModel, Ordering, PrefixSession, Rc, Reply, Weights, + exhausted, handle_generate, invalid, mpsc, unsupported, +}; +#[cfg(feature = "preview-path")] +use super::{ResidentConversations, ResidentPolicy}; use leleka_cuda_driver::Context; /// The resident conversations of one loaded model: the live continuation plus (operator opt-in) parked ones. diff --git a/crates/engine-qwen35-cuda/src/backend/serve_report.rs b/crates/engine-qwen35-cuda/src/backend/serve_report.rs index 6049f185..aad2b226 100644 --- a/crates/engine-qwen35-cuda/src/backend/serve_report.rs +++ b/crates/engine-qwen35-cuda/src/backend/serve_report.rs @@ -1,5 +1,8 @@ //! What one Generate reports: the weight-cache counters, the terminal verdict and the measurement. -use super::*; +use super::{ + CacheCounts, Conversations, Exchange, FinishReason, GenerationFailure, GenerationTerminal, Outcome, Serving, + Weights, measurement, +}; use crate::qwen_forward::dense_weight_cache::DenseCacheCounters; use crate::qwen_forward::moe_weight_cache::WeightCacheCounters; diff --git a/crates/engine-qwen35-cuda/src/backend/session.rs b/crates/engine-qwen35-cuda/src/backend/session.rs index 3f833a5d..d81085e9 100644 --- a/crates/engine-qwen35-cuda/src/backend/session.rs +++ b/crates/engine-qwen35-cuda/src/backend/session.rs @@ -1,5 +1,7 @@ //! The resident numeric prefix kept between generations. -use super::*; +use super::LoadedModel; +#[cfg(feature = "preview-path")] +use super::{MtpDecoder, QwenSession, TargetStepProduct}; /// One actual successful resident numeric prefix. Actor/model lifetime is /// the lifecycle fence; LoadedModel adds handle/mode/config identity. diff --git a/crates/engine-qwen35-cuda/src/backend/sources.rs b/crates/engine-qwen35-cuda/src/backend/sources.rs index 9e0e3b65..9186cb09 100644 --- a/crates/engine-qwen35-cuda/src/backend/sources.rs +++ b/crates/engine-qwen35-cuda/src/backend/sources.rs @@ -1,5 +1,9 @@ //! Verification of the pinned sources (shards, KAR archive, ranked profile) at load time. -use super::*; +use super::{ + BackendError, Clock, Digest, InheritedKarArchive, InputBindingError, NativeBackendConfig, PathBuf, + RANKED_EXPERT_PROFILE_BYTES, RANKED_EXPERT_PROFILE_SHA, RankedExpertProfileSource, SHARD0, SHARD1, Sha256, + SystemClock, VerifiedGgufFile, exhausted, invalid, +}; use leleka_model_format::weight_source::{BackingKind, FileWeightSource, WeightError, WeightSource}; /// What the three source verifications returned. Errors are reduced to text because the verifying threads hand diff --git a/crates/engine-qwen35-cuda/src/backend/spawn.rs b/crates/engine-qwen35-cuda/src/backend/spawn.rs index 5b05dcea..983b3e35 100644 --- a/crates/engine-qwen35-cuda/src/backend/spawn.rs +++ b/crates/engine-qwen35-cuda/src/backend/spawn.rs @@ -1,6 +1,10 @@ //! The common owner-thread spawn of every backend (Original serve and preview alike). The preview factories //! (Native and evaluation-only backends) live in `spawn_preview.rs`, behind the `preview-path` feature. -use super::*; +use super::{ + Arc, AtomicBool, Backend, BackendError, Command, ErrorCode, EvaluationExecution, EvaluationObserver, INSTANCE, + MODE_DIGEST, Mutex, NativeBackendConfig, Ordering, OwnerExecution, OwnerGuard, OwnerThread, PolicyFlags, Proxy, + QUEUE, RecentIds, Shared, SyncSender, invalid, kar_expert_mode_digest, mpsc, thread, unavailable, +}; /// The configuration limits every native spawn checks before any thread or CUDA owner exists. fn admit_native_resources(config: &NativeBackendConfig) -> Result<(), BackendError> { diff --git a/crates/engine-qwen35-cuda/src/backend/spawn_optimized.rs b/crates/engine-qwen35-cuda/src/backend/spawn_optimized.rs index 8569864e..8e8dd65c 100644 --- a/crates/engine-qwen35-cuda/src/backend/spawn_optimized.rs +++ b/crates/engine-qwen35-cuda/src/backend/spawn_optimized.rs @@ -1,5 +1,9 @@ //! Factories of the optimized windowed256 experiments (queued owners .. adaptive slots). -use super::*; +use super::{ + Backend, BackendError, EvaluationExecution, EvaluationObserver, NativeBackendConfig, OptimizedBackendConfig, + OptimizedOwnerPolicy, OwnerExecution, RANKED_EXPERT_PROFILE_SHA, RankedExpertProfileSource, invalid, + spawn_backend_configured, unsupported, +}; /// Separately selected optimized experiment. Default and earlier experiment /// factories remain unchanged; this selection certifies neither speed nor quality. diff --git a/crates/engine-qwen35-cuda/src/backend/spawn_original.rs b/crates/engine-qwen35-cuda/src/backend/spawn_original.rs index 6a0686fd..4a4e0ba3 100644 --- a/crates/engine-qwen35-cuda/src/backend/spawn_original.rs +++ b/crates/engine-qwen35-cuda/src/backend/spawn_original.rs @@ -1,5 +1,9 @@ //! Choice of the Original-literal mode17 serve path and its factories. -use super::*; +use super::{ + Backend, BackendError, EvaluationExecution, NativeBackendConfig, OriginalServeChoice, OriginalServeMode, + OriginalServeOptions, OwnerExecution, RANKED_EXPERT_PROFILE_SHA, RankedExpertProfileSource, invalid, + invalid_dynamic, original_serve, spawn_backend_configured, unsupported, +}; /// The path an operator configuration resolves to for `mode` (see `OriginalServeMode`): pure over the /// configuration and the build's asset probe. `Auto` picks the Original path only when it can start; diff --git a/crates/engine-qwen35-cuda/src/backend/spawn_preview.rs b/crates/engine-qwen35-cuda/src/backend/spawn_preview.rs index 6a90e5e3..2530e2e9 100644 --- a/crates/engine-qwen35-cuda/src/backend/spawn_preview.rs +++ b/crates/engine-qwen35-cuda/src/backend/spawn_preview.rs @@ -1,5 +1,8 @@ //! Factories of the Native and the evaluation-only backends: the Rust-native preview decoder chain (`preview-path`). -use super::*; +use super::{ + Backend, BackendError, EvaluationExecution, EvaluationObserver, NativeBackendConfig, OwnerExecution, invalid, + spawn_backend_configured, +}; pub fn spawn_backend(config: NativeBackendConfig) -> Result, BackendError> { spawn_backend_inner(config, None, EvaluationExecution::Native) diff --git a/crates/engine-qwen35-cuda/src/backend/utf8.rs b/crates/engine-qwen35-cuda/src/backend/utf8.rs index 3ff1bbda..2dd26b95 100644 --- a/crates/engine-qwen35-cuda/src/backend/utf8.rs +++ b/crates/engine-qwen35-cuda/src/backend/utf8.rs @@ -1,5 +1,8 @@ //! Incremental UTF-8 publication of generated tokens and the terminal event. -use super::*; +use super::{ + BACKPRESSURE_TIMEOUT, BackendError, Clock, ContractError, Duration, FRAME_LIMIT, GenerationEvent, + GenerationFailure, GenerationSink, GenerationTerminal, exhausted, thread, unavailable, +}; #[derive(Default)] pub(super) struct Utf8Pending(pub(super) Vec); diff --git a/crates/engine-qwen35-cuda/src/backend/validate.rs b/crates/engine-qwen35-cuda/src/backend/validate.rs index efc48850..ffda430f 100644 --- a/crates/engine-qwen35-cuda/src/backend/validate.rs +++ b/crates/engine-qwen35-cuda/src/backend/validate.rs @@ -1,5 +1,9 @@ //! Admission checks of loads, handles and generation requests. -use super::*; +use super::{ + BackendError, Duration, GenerationRequest, InferenceMode, KAR_LOAD_REPLY_TIMEOUT, KAR_MTP_PROFILE, KAR_PROFILE, + LOAD_CONFIG_VERSION, LoadedModel, MODE_DIGEST, ModelDescriptor, NATIVE_MTP_PROFILE, OUTPUT_LIMIT, PROMPT_LIMIT, + REPLY_TIMEOUT, RuntimeConfig, invalid, pinned_model_descriptor, request_sampler, unsupported, +}; pub(super) fn validate_load(model: &ModelDescriptor, config: &RuntimeConfig) -> Result<(), BackendError> { config.validate().map_err(|_| invalid("invalid load configuration"))?; 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 c3fd96ec..3933e54a 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,8 +1,10 @@ //! Methods of `OriginalServeMode`: `parse`, `as_str`. Methods of `ExpertSource`: `parse`, `as_str`. //! Implements `Default for OriginalServeOptions`. -#[allow(unused_imports)] -use super::*; +use super::{ + BackendError, ConfigFacts, ExpertSource, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, + PREFIX_SUMMARY, PrefixTail, +}; impl OriginalServeMode { pub fn parse(value: &str) -> Option { 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 3d9fe5e9..b304386c 100644 --- a/crates/engine-qwen35-cuda/src/backend_original_serve/runner.rs +++ b/crates/engine-qwen35-cuda/src/backend_original_serve/runner.rs @@ -132,10 +132,10 @@ use owner_run_steps::{ mod command_loop; #[allow(unused_imports)] use command_loop::{LoopCtx, announce, answer_unload, command_loop}; -#[path = "runner/reconfigure_parts.rs"] -mod reconfigure_parts; +#[path = "runner/reconfigure_command.rs"] +mod reconfigure_command; #[allow(unused_imports)] -use reconfigure_parts::{Live, ReopenEnv, reconfigure}; +use reconfigure_command::{Live, ReopenEnv, reconfigure}; #[path = "runner/owner_run.rs"] mod owner_run; #[allow(unused_imports)] diff --git a/crates/engine-qwen35-cuda/src/backend_original_serve/runner/reconfigure_parts.rs b/crates/engine-qwen35-cuda/src/backend_original_serve/runner/reconfigure_command.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/backend_original_serve/runner/reconfigure_parts.rs rename to crates/engine-qwen35-cuda/src/backend_original_serve/runner/reconfigure_command.rs index a967ed22..7a3cbd62 100644 --- a/crates/engine-qwen35-cuda/src/backend_original_serve/runner/reconfigure_parts.rs +++ b/crates/engine-qwen35-cuda/src/backend_original_serve/runner/reconfigure_command.rs @@ -1,5 +1,5 @@ -//! `Command::Reconfigure` of the Original owner loop, moved out of `owner_run_steps` by STRA-338 (size): close the -//! old stack, open one with the new settings, or reopen the previous ones. +//! `Command::Reconfigure` of the Original owner loop: close the old stack, open one with the new settings, or reopen +//! the previous ones when that fails. Separate from `runner` because it is one command with its own roll-back. use super::{ BackendError, Clock, Duration, ErrorCode, ModelBinding, Ordering, OriginalServeOptions, OriginalServeStack, 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 45120f1a..fd89a2f5 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,23 @@ //! //! Run (inside a holder job): ` --ignored --nocapture original_serve_replay_smoke`. 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, 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 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_replay/load.rs b/crates/engine-qwen35-cuda/src/backend_original_serve_replay/load.rs index ffd13ff9..7bb3f6a1 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,5 +1,22 @@ //! The captured requests and the pinned model of the replay. -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, 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, +}; pub(super) fn number(name: &str, default: usize) -> usize { env::var(name).ok().map(|v| v.parse().unwrap_or_else(|_| panic!("{name} must be a count"))).unwrap_or(default) 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 b1570b97..a5cc8693 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,7 +1,24 @@ //! 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::*; +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 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 3b7f62fd..cec55230 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,8 +1,24 @@ //! Functions: `required_path`. //! Split out of `original_serve_replay` to keep its files under the line limit. -#[allow(unused_imports)] -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, 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, +}; 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 122e146a..a5295269 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 @@ -2,7 +2,24 @@ use super::arm_flags::{self, ArmShape}; use super::load::{self, number}; use super::pass::Replay; -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, 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, +}; use crate::qwen_forward::original_serve_stack::TailMode; fn tail_mode(arm: &str) -> TailMode { diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop.rs b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop.rs index 9cb8a999..50ac32ce 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop.rs +++ b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop.rs @@ -27,7 +27,23 @@ //! //! Run: `cargo test -p leleka-engine-qwen35-cuda --features cuda-driver[,sm86] --release -- --ignored --nocapture //! original_serve_laptop_bench`. -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, 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 crate::qwen_forward::{ original_serve_engine::ServeOutcome, original_serve_request::{ServeError, ServeRequest}, diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop/soak.rs b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop/soak.rs index 5f494c49..6fe1fdf3 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop/soak.rs +++ b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_laptop/soak.rs @@ -1,5 +1,22 @@ //! The serving passes of the laptop bench: the sequence, the soak limits and the per-request reports. -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, 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, +}; /// The serving sequence and the soak limits. pub(super) struct Soak { diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_memory_smoke_inventory.rs b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_memory_smoke_inventory.rs index de0680d2..ff162c1e 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_memory_smoke_inventory.rs +++ b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_memory_smoke_inventory.rs @@ -1,6 +1,24 @@ //! The inventory scenario: the allocation inventory and the load ledger at idle, after a long request and with the //! prefix cache full. -use super::*; +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, +}; /// The number after `key` in a prefix metrics line. fn metric(line: &str, key: &str) -> Option { diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_prefix_smoke_workload.rs b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_prefix_smoke_workload.rs index 3baa8363..52fc8ff5 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_prefix_smoke_workload.rs +++ b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_prefix_smoke_workload.rs @@ -1,5 +1,22 @@ //! The knobs and the scripted workload of the prefix-cache smoke (identical for every mode). -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, 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, +}; /// What the operator asked for. pub(super) struct Plan { diff --git a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_ttft.rs b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_ttft.rs index 30720ccf..d901c80a 100644 --- a/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_ttft.rs +++ b/crates/engine-qwen35-cuda/src/gpu_proofs/backend_original_serve_ttft.rs @@ -11,7 +11,23 @@ //! 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::*; +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 crate::qwen_forward::{ original_serve_request::ServeRequest, original_serve_stack::{OriginalServeStack, PrefixBudget, PrefixConfig, StackConfig}, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_inherited_kar_gpu.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_inherited_kar_gpu.rs index afa93e98..64bd0485 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_inherited_kar_gpu.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_inherited_kar_gpu.rs @@ -1,6 +1,12 @@ //! New real Linux seal/FD gate; tiny metadata fixture, no CUDA/model capability. #![cfg(target_os = "linux")] -use super::*; +use super::{ + BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPlePartProvenance, + KarPleProfile, KarPleProfileSpec, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, + VerifiedKarPleArtifact, +}; +#[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}; use std::{ fs::{self, DirBuilder, OpenOptions}, 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 004ada28..7e6f69a0 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input.rs @@ -158,7 +158,7 @@ mod native_output; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_pointer_width = "64"))] pub(crate) use native_output::NativeOutputRole; -mod input_binding_error_display_error; +mod binding_identity_and_input_binding_error; mod model_binding; #[allow(unused_imports)] use model_binding::bind_expert_counts; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/input_binding_error_display_error.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs similarity index 88% rename from crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/input_binding_error_display_error.rs rename to crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs index 492d8f53..f204b1dd 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/input_binding_error_display_error.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs @@ -1,8 +1,10 @@ -//! Methods of `BindingIdentity`: `matches`. Methods of `BoundLayer`: `index`, `kind`. -//! Implements `Display for InputBindingError`, `Error for InputBindingError`. +//! Methods of `BindingIdentity` and `BoundLayer`, and the `Display` and `Error` impls of `InputBindingError`: what a +//! binding says about itself and how its failures read. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, BoundLayer, BoundLayerKind, InputBindingError, InputConstants, InputResult, PLE_ROWS, + Qwen4ExpArtifact, Rc, fmt, +}; impl fmt::Display for InputBindingError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 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 d53eb7d3..01bcc7d2 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,8 +1,11 @@ //! Methods of `ModelBinding`: `bind`, `from_artifact`, `from_artifact_with_kar_ple`, `with_kar_expert_source` and 22... //! Functions: `bind_expert_counts`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingError, BindingIdentity, BoundLayer, EMBEDDING_VALUES, GlobalRole, InputBindingError, InputConstants, + InputResult, ModelBinding, MtpWeights, PLE_ROW_VALUES, PLE_ROWS, Qwen4ExpArtifact, Rc, RefCell, TensorRole, + VOCABULARY, bind_layers, decode, mtp, validate_ple_descriptor, +}; impl ModelBinding { pub(crate) fn bind() -> Result { diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding.rs index c530e0f6..b95229c3 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding.rs @@ -1,8 +1,11 @@ //! Groups the submodules `model_binding_moe_descriptors`, `moe_expert_block_reads`. //! Split out of `moe_expert` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, + MoeMatrixRole, MoeRows, MoeWeightDescriptor, N, SELECTED, TensorRole, descriptor, index, routed_source_role, + validate_range, validate_selected, +}; #[path = "model_binding/model_binding_moe_descriptors.rs"] mod model_binding_moe_descriptors; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/model_binding_moe_descriptors.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/model_binding_moe_descriptors.rs index 03af6212..6a2bfac8 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/model_binding_moe_descriptors.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/model_binding_moe_descriptors.rs @@ -3,8 +3,10 @@ use super::super::routed_source_descriptor::validate_rows_finite; use super::super::routed_source_descriptor::{check_matrix_tensor, check_moe_metadata, selected_expert}; -#[allow(unused_imports)] -use super::*; +use super::{ + E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, + MoeWeightDescriptor, N, SELECTED, TensorRole, descriptor, index, routed_source_role, validate_selected, +}; use leleka_model_format::qwen4exp::{Qwen4ExpArtifact, RowRange}; /// One expert matrix of a layer, admitted against its expected kind, shape and extent. diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/moe_expert_block_reads.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/moe_expert_block_reads.rs index c3b91c46..d9c7a942 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/moe_expert_block_reads.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/model_binding/moe_expert_block_reads.rs @@ -2,8 +2,10 @@ //! streamed block reads. use super::super::routed_source_descriptor::{check_matrix_tensor, selected_expert, validate_rows_finite}; -#[allow(unused_imports)] -use super::*; +use super::{ + E, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, + MoeMatrixRole, MoeRows, MoeWeightDescriptor, N, TensorRole, validate_range, +}; use leleka_model_format::qwen4exp::{Qwen4ExpArtifact, RowRange}; /// A selected expert's rows from the resident bank, finite-checked by the proven encoded validators. diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/moe_routed_source_scope.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/moe_routed_source_scope.rs index 8765a843..9f6078db 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/moe_routed_source_scope.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/moe_routed_source_scope.rs @@ -4,8 +4,10 @@ use super::routed_source_descriptor::check_moe_metadata; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::routed_source_descriptor::run_routed_scope; -#[allow(unused_imports)] -use super::*; +use super::{ + E, EXPERTS, FF, InputResult, LayerRole, ModelBinding, MoeExpertWeights, MoeMatrixRole, MoeRoutedSourceScope, + MoeWeightDescriptor, N, TensorRole, descriptor, routed_source_descriptor, routed_source_role, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl<'group> MoeRoutedSourceScope<'_, 'group> { diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/routed_source_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/routed_source_descriptor.rs index ee312cc1..0465a865 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/routed_source_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_moe_expert/routed_source_descriptor.rs @@ -1,8 +1,11 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, + MoeExpertWeights, MoeMatrixRole, MoeRoutedSourceScope, MoeWeightDescriptor, N, SELECTED, descriptor, + encoded_finite, index, +}; /// The model metadata the native MoE path was written for. pub(super) fn check_moe_metadata(artifact: &leleka_model_format::qwen4exp::Qwen4ExpArtifact) -> InputResult<()> { diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_original_file_source.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_original_file_source.rs index 55ed8fd3..359d5b02 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_original_file_source.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_original_file_source.rs @@ -1,5 +1,5 @@ //! Original immutable file-source admission from this actual selected artifact. -use super::*; +use super::{InputBindingError, InputResult, ModelBinding}; use leleka_model_format::qwen4exp::FileExpertSourceLease; impl ModelBinding { pub(crate) fn original_file_expert_source(&self) -> InputResult { diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_resident_expert_source.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_resident_expert_source.rs index 03b018fa..1dbcd8fe 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_resident_expert_source.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_resident_expert_source.rs @@ -1,5 +1,5 @@ //! Explicit admission on an unpublished selected binding. Raw source bytes only. -use super::*; +use super::{InputBindingError, InputResult, LayerRole, ModelBinding}; use leleka_model_format::qwen4exp::{ResidentExpertSourceError, ResidentExpertSourceReport}; /// EXPERIMENTAL `LELEKA_ORIGINAL_SERVE_GGUF_PLE=1` (profile `rtx5090-32g-gguf-ple`): a binding without a KAR archive diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_learned_main_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_learned_main_sdet.rs index acdea22b..7c9752e1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_learned_main_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_learned_main_sdet.rs @@ -1,6 +1,6 @@ //! Pure current-age bootstrap policy proof; no binding/device/weight certificate. use super::super::cache_lru_index::LruIndex; -use super::*; +use super::{MoeWeightDescriptor, learned_main_slot_bound}; fn key(layer: u32, expert: u32, role: u8) -> MoeWeightDescriptor { MoeWeightDescriptor { layer, expert: Some(expert), role, raw_kind: 18, columns: 2560, rows: 640, bytes: 627_200 } diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index/lru_index_seeding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index/lru_index_seeding.rs index f7e49433..b5df35b6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index/lru_index_seeding.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index/lru_index_seeding.rs @@ -1,8 +1,7 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ABSENT, Error, LruIndex, MAX_KEYS, MoeWeightDescriptor, Node, Result, slot}; impl LruIndex { /// Seed only the already reserved, empty index from completed actual owners. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index_sdet.rs index 9eda728c..790c7145 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_lru_index_sdet.rs @@ -1,5 +1,7 @@ //! Pure metadata proof. Literal descriptors convey no model, weight or device authority. -use super::*; +use super::{LruIndex, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, slot}; +#[cfg(any(test))] +use super::HOST_LIMIT; use std::collections::HashMap; type Oracle = HashMap; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights.rs index 9968e2c1..95b17cee 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights.rs @@ -1,7 +1,10 @@ //! Model-lifetime immutable MTP allocations. Cached CUDA graphs own real Rc //! allocations, so a per-call matrix borrow can never outlive its weight bank. use super::super::output_native::OriginalMtpNativeHead; -use super::*; +use super::{ + BindingIdentity, Cell, Context, Dense, DeviceBuffer, Error, ModelBinding, MoeWeightCache, MtpKind, MtpRole, Rc, + Result, binding_error, driver_error, +}; use crate::model_binding::qwen4exp_input::{pinned_dense_bytes, rt_dense_name, rt_dense_roles, rt_dense_shape}; #[derive(Clone)] struct RetainedDense<'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/dense_copies_equal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/dense_copies_equal.rs index 49ff3200..761418b1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/dense_copies_equal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/dense_copies_equal.rs @@ -1,8 +1,10 @@ //! Methods of `MoeWeightCache`: `share_rt_mtp_dense`, `share_entry`, `device_copies_equal`, `adopt_rt_buffer` and 2 ... //! Functions: `dense_copies_equal`. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, Dense, Error, ModelBinding, MoeWeightCache, MtpDenseShare, MtpKind, MtpRole, Rc, Result, + RetainedDense, RetainedOriginalMtpWeights, WeightSource, binding_error, driver_error, pinned_dense_bytes, +}; /// Two copies of a dense role may be merged only when kind, shape, length and every byte agree. pub(super) fn dense_copies_equal(a: (MtpKind, usize, usize, &[u8]), b: (MtpKind, usize, usize, &[u8])) -> bool { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/retained_original_mtp_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/retained_original_mtp_weights.rs index eee43417..60b5893e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/retained_original_mtp_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_mtp_weights/retained_original_mtp_weights.rs @@ -1,8 +1,11 @@ //! Methods of `RetainedOriginalMtpWeights`: `from_rt_bank`, `rt_dense`, `rt_extras`, `dense_file_bytes` and 11 more. //! Functions: `rt_kind`. Defines `HeadBinding`. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DeviceBuffer, Error, FULL_FORWARD_ROLES, ModelBinding, MtpHeadSources, MtpKind, MtpRole, + OriginalMtpNativeHead, Rc, Result, RetainedDense, RetainedOriginalMtpWeights, WeightSource, binding_error, + driver_error, rt_dense_name, rt_dense_roles, rt_dense_shape, +}; use leleka_cuda_driver::FullForwardHead; use leleka_cuda_driver::OriginalMtpRetainedFullWeights as FullWeights; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt.rs index 50271530..310c7bcf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt.rs @@ -2,7 +2,11 @@ //! Reuses the one real MMQ/native owners and immutable encoded shared weights; //! routed experts come from the actual registered retained model bank. //! This does not fabricate scalar FFN rows or publish a session checkpoint. -use super::*; +use super::{ + Context, DeviceBuffer, EncodedWeight, Entry, Error, HashMap, MmqRoutingPolicy, MmqWorkspace, ModelBinding, + MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, Rc, Result, + binding_error, driver_error, original_dual_layout, +}; use crate::qwen_forward::prefill_profile::{self as prof, Stage as PStage}; use crate::qwen_forward::{contract::LayerId, dense_weight_cache::DenseWeightCache}; use leleka_cuda_driver::{GdnNativeFormat, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs index 5f9a50cd..66646e50 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weight_cache.rs @@ -1,8 +1,11 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, Error, LayerId, MmqRoutingPolicy, MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, + MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, Rc, ResidentExpertBankSpan, Result, binding_error, + driver_error, +}; /// The prefill layout options of the arena and the validated u32 capacity carved from them. struct ArenaPlan { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weights_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weights_original_prompt.rs index b9b5fe56..5375eaef 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weights_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/moe_weights_original_prompt.rs @@ -3,7 +3,11 @@ #[allow(unused_imports)] use super::prompt_layer_fns::{PromptIo, PromptParts, PromptWeightOwners, SpanScan, run_prompt_layer}; -use super::*; +use super::{ + DenseWeightCache, DeviceBuffer, EncodedWeight, Entry, Error, GdnNativeFormat, HashMap, LayerId, ModelBinding, + MoeWeightCache, MoeWeightDescriptor, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, Rc, Result, + driver_error, native_format, span_cache_enabled, +}; impl<'ctx> MoeWeightCache<'ctx> { /// Genuine device FFN read -> router/shared -> ascending groups of16 -> diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs index 88510138..5d45e196 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_layer_fns.rs @@ -1,7 +1,10 @@ //! One original-prompt MoE layer: expert spans, copy ring and finish (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, DeviceBuffer, Error, GdnNativeFormat, LayerId, ModelBinding, MoeExpertWeights, + MoeMatrixRole, MoeWeightDescriptor, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, PStage, Rc, + ResidentExpertBankSpan, Result, binding_error, driver_error, original_dual_layout, prof, prompt_stream_settings, +}; use crate::model_binding::qwen4exp_input::MoeRoutedSourceScope; use leleka_cuda_driver::{ MappedExpertBank, MmqFormat, MmqWorkspace, OriginalMmqCopySchedule, OriginalMoePromptDevice, OriginalMoePromptLayer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs index 40eca1c6..8ca5f17a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_ring_prefetch.rs @@ -3,8 +3,7 @@ //! miss are copied into its ring's stage slots through this layer's row lease, so the PCIe copies run under this //! layer's combine and the next layer's mixer instead of after the next router. -#[allow(unused_imports)] -use super::*; +use super::{BITS, LayerId, SpanScan}; use crate::qwen_forward::contract::Dimension; use leleka_cuda_driver::{OriginalMmqCopySchedule, OriginalMoePromptLayer, PrefetchSource}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_stream_settings.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_stream_settings.rs index c8626a2e..5fab9bc9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_stream_settings.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_prompt/prompt_stream_settings.rs @@ -1,8 +1,7 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{Error, GdnNativeFormat, MoeWeightDescriptor, PREFILL_STREAM_OVERRIDE, Result, SPAN_CACHE_OVERRIDE}; /// prefill.cpp `stream_all` order (`begin_prompt_stream`): for chunks of at least `STRATA_PREFILL_STREAM_MIN` rows /// (default 4096: it copies every expert of every layer, while the per-layer ring copies only the routed ones, about diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs index 3dfefb3b..f205007e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_original_verify.rs @@ -7,7 +7,7 @@ //! that loader for every layer and then proves all 192 tensors are resident together (a load of a later layer may //! not have evicted an earlier one), and `original_verify_moe` hands them out. Nothing is copied or re-encoded: the //! routed experts are not here (the verifier's expert tier is the pool callback). -use super::*; +use super::{EncodedWeight, Error, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, driver_error}; use crate::qwen_forward::original_serve_verifier::VerifyWeights; use crate::qwen_forward::{ contract::{Dimension, LayerId}, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/learned_main_lru_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/learned_main_lru_profile.rs index ebec66d8..c290e0d0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/learned_main_lru_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/learned_main_lru_profile.rs @@ -4,7 +4,10 @@ #[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::{ + Context, Error, HOST_CAP, MAIN_LIMIT, ModelBinding, MoeWeightCache, PROFILE_SHA, RankedProfile, Result, + cache_profile, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl<'ctx> MoeWeightCache<'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs index 9493d790..026acb27 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs @@ -1,8 +1,11 @@ //! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile`, `new_native_intege... //! Functions: `ranked_keys`. Defines `MapReservation`, `ProfileFill`. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, 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, +}; /// Slot count and metadata ceiling proven when the weight map was reserved. struct MapReservation { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_build.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_build.rs index 28504f64..7a3b772c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_build.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_build.rs @@ -1,6 +1,7 @@ //! The shared-permanent profile build behind the fixed-prefix and learned-main constructors (STRA-338 size: //! 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::*; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_window_spill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_window_spill.rs index 68fe85a5..d93b6f83 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_window_spill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/profile_window_spill.rs @@ -1,8 +1,7 @@ //! Functions: `profile_window_spill`, `profile_window_spill_with_floor`. //! Split out of `cache_profile_fill` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{Error, Result}; // Complete simultaneously live prefill owners; reserve is additive. pub(super) fn profile_window_spill() -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/strata_adaptive_shared_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/strata_adaptive_shared_pool.rs index fe340f66..ef7b0b56 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/strata_adaptive_shared_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_fill/strata_adaptive_shared_pool.rs @@ -3,7 +3,11 @@ #[allow(unused_imports)] use super::profile_build::ProfileFile; -use super::*; +use super::{ + Context, DeviceBuffer, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, + MoeWeightDescriptor, PROFILE_SHA, ProfileLimits, RankedProfile, Rc, RefCell, Result, WORKING_RESERVE, + binding_error, cache_profile, cache_strata_adaptive, cpu_budget, driver_error, profile_window_spill_with_floor, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl<'ctx> MoeWeightCache<'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_sdet.rs index 2aa888ef..35db106d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_profile_sdet.rs @@ -1,5 +1,5 @@ //! Sanitized pure metadata proof, without model/profile files or device owners. -use super::*; +use super::{Digest, Error, HOST_CAP, PrefixPlan, ProfileLimits, RankedProfile, Sha256}; const BASE_BYTES: usize = 24 + 24_576 * 4; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_shared_permanent_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_shared_permanent_sdet.rs index 1125459b..700f2d13 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_shared_permanent_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_shared_permanent_sdet.rs @@ -1,5 +1,8 @@ //! Pure metadata/budget proof; never constructs a ModelBinding or device owner. -use super::*; +use super::{ + Error, HOST_CAP, MoeWeightDescriptor, PrefixPlan, ProfileLimits, RankedProfile, SHARED_MAX_BYTES, + SharedPermanentPool, remaining_shared_main, +}; /// Shape, quantisation kind and byte size of one shared-expert weight role, independent of the layer. struct SharedRoleShape { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive.rs index 38801219..50b04a02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive.rs @@ -1,7 +1,7 @@ //! Literal Strata adaptive policy metadata; never a device or completion certificate. //! Provenance: attested generate.cpp 14cf46dc (serve adapt/apply_pending). use super::cache_profile::{HOST_CAP, PrefixPlan, ProfileLimits, RankedProfile}; -use super::{Error, Result}; +use super::{CachedMoeMatrix, Error, Result, WORKING_RESERVE, binding_error, driver_error}; use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; pub(super) const LAYERS: usize = 48; @@ -52,7 +52,6 @@ pub(super) struct AdaptivePolicy { #[path = "cache_strata_adaptive_sdet.rs"] mod tests; -use super::{CachedMoeMatrix, WORKING_RESERVE, binding_error, driver_error}; use crate::model_binding::qwen4exp_input::{ BindingIdentity, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive_sdet.rs index b081f127..d16d0a25 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/cache_strata_adaptive_sdet.rs @@ -1,6 +1,6 @@ //! Pure source-policy oracle only. No fabricated BindingIdentity, device slot, //! event completion, CPU expert output, or model acceptance certificate. -use super::*; +use super::{AdaptivePolicy, EXPERTS, Error, LAYERS, MoeWeightDescriptor, ProfileLimits, RankedProfile, Swap}; use sha2::{Digest, Sha256}; fn fixture() -> (RankedProfile, [[MoeWeightDescriptor; 3]; LAYERS]) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/chunk_modules.rs b/crates/engine-qwen35-cuda/src/qwen_forward/chunk_module_owners.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/qwen_forward/chunk_modules.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/chunk_module_owners.rs index 23805608..218c5d40 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/chunk_modules.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/chunk_module_owners.rs @@ -1,4 +1,5 @@ -//! Two bounded actor-local module owners; no request or recurrent state. +//! The two CUDA modules of the chunked prefill (the Q6 layer columns and the GR batch), each created on first use +//! and released together. Actor-local; no request or recurrent state. use super::contract::{Error, Result}; use super::qsa_index::driver_error; use leleka_cuda_driver::Context; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs index 1cecb0ae..3e96271f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_original_verify.rs @@ -5,7 +5,10 @@ //! prefill cannot disagree about a weight, and a held assembly keeps them alive without borrowing the cache. //! Native MMVQ projections are `original_verify_projections`; router and shared experts live in the MoE cache //! (`cache_original_verify`). -use super::*; +use super::{ + BoundLayerKind, DenseWeightCache, DeviceRef, Error, GrResident, GrRole, ModelBinding, QsaMatrixKind, QsaMatrixRole, + Rc, Result, driver_error, +}; use leleka_cuda_driver::{ HcHalfBuffers, HcLayerBuffers, HcOutputBuffers, OriginalVerifyGeometry, OriginalVerifyGrBinding, OriginalVerifyQsaBinding, OriginalVerifyQsaLayerWeights, PleBuffers, PleKeyBuffer, 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 1b65cabc..9d96fabd 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 @@ -72,7 +72,7 @@ pub(super) struct PleResident { } type GdnVerificationWorkspace<'ctx> = Rc>>; pub(crate) struct DenseWeightCache<'ctx> { - modules: Option>, + modules: Option>, binding: BindingIdentity, owner: Rc<()>, context: &'ctx Context<'ctx>, 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 a22f67fb..a43267db 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,8 +1,7 @@ //! Functions: `dense_slab_policy`, `startup_step`. //! Split out of `dense_weight_cache` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::SlabPolicy; /// `LELEKA_DENSE_SLAB=0` keeps one allocation per weight (the A/B arm and the rollback); otherwise the dense weights /// are packed into 64 MiB slabs. Both place the same bytes: only buffer addresses move. 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 8d9a666b..cd4089b4 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,8 +1,16 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + ALL_MIRROR_BYTES, BoundLayerKind, Cell, Context, DenseCacheCounters, DenseWeightCache, DeviceBuffer, DeviceRef, + Error, GdnInputLease, GdnInputScratch, GdnMatrixKind, GdnMatrixRole, GdnResident, GdnStateMirror, + GdnVerificationWorkspace, GrBatchInjectWorkspace, GrResident, GrRole, GrScratch, ModelBinding, + OriginalVerifyGdnProjections, OriginalVerifyGdnWeights, OriginalVerifyGeometry, OriginalVerifyNativeMatrix, + OriginalVerifyProjBinding, OriginalVerifyQsaProjections, PleMatrixRole, PleResident, PleWeights, QkScratch, + QsaAttentionScratch, QsaIndexKeyCache, QsaInputLease, QsaInputScratch, QsaMatrixKind, QsaMatrixRole, QsaResident, + QsaSelectedCache, QsaSelectionRequest, RESERVE, Rc, RefCell, RefMut, Result, RouterLease, RouterScratch, + SlabAllocator, SlabPolicy, Workspaces, binding_error, dense_slab_policy, driver_error, startup_step, +}; mod dense_cache_buffers_and_close; mod dense_cache_eager_layer_load; 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 6aa87b3f..0c319e4e 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,8 +1,10 @@ //! Methods of `DenseWeightCache`: `gr_buffers`, `counters`, `chunk_modules`, `close` and 4 more. //! Functions: `close_into`. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseCacheCounters, DenseWeightCache, DeviceBuffer, Error, GrResident, ModelBinding, QkScratch, Rc, + Result, driver_error, +}; impl<'ctx> DenseWeightCache<'ctx> { pub(in super::super::super) fn gr_buffers(&self, entry: &GrResident) -> Result<[Option<&DeviceBuffer<'ctx>>; 4]> { @@ -23,7 +25,7 @@ impl<'ctx> DenseWeightCache<'ctx> { &self, binding: &ModelBinding, context: &Context<'_>, - ) -> Result<&super::super::super::chunk_modules::ChunkModules<'ctx>> { + ) -> Result<&super::super::super::chunk_module_owners::ChunkModules<'ctx>> { self.retained_context(binding, context)?; self.modules.as_ref().ok_or(Error::IdentityMismatch) } 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 d2c04e14..0e608622 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,8 +1,12 @@ //! Methods of `DenseWeightCache`: `new_with_selected`, `unloaded`, `load_eager`, `reserve_layer_tables` and 6 more. //! Functions: `reserve_table`. -#[allow(unused_imports)] -use super::*; +use super::{ + ALL_MIRROR_BYTES, BoundLayerKind, Cell, Context, DenseCacheCounters, DenseWeightCache, Error, GdnInputScratch, + GdnMatrixKind, GdnMatrixRole, GdnResident, GdnStateMirror, GrRole, GrScratch, ModelBinding, QsaIndexKeyCache, + QsaInputScratch, QsaMatrixKind, QsaMatrixRole, QsaResident, QsaSelectedCache, Rc, RefCell, Result, SlabAllocator, + Workspaces, binding_error, dense_slab_policy, driver_error, +}; fn reserve_table(table: &mut Vec, count: usize) -> Result<()> { table.try_reserve_exact(count).map_err(|_| Error::InputAllocation) @@ -21,7 +25,7 @@ impl<'ctx> DenseWeightCache<'ctx> { let slabs = SlabAllocator::new(context, dense_slab_policy()).map_err(driver_error)?; let mut result = Self::unloaded(binding, context, slabs); result.modules = - Some(super::super::super::chunk_modules::ChunkModules::new(context, result.mirror_failed.clone())); + Some(super::super::super::chunk_module_owners::ChunkModules::new(context, result.mirror_failed.clone())); match result.load_eager(binding, selected, n) { Ok(()) => Ok(result), Err(primary) => { 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 3fb8b921..2b451667 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DenseWeightCache, DeviceBuffer, DeviceRef, Error, GdnInputLease, GdnInputScratch, GdnResident, + GdnStateMirror, GrResident, GrRole, ModelBinding, QkScratch, QsaInputLease, QsaInputScratch, QsaResident, + QsaSelectedCache, QsaSelectionRequest, Rc, RefMut, Result, +}; impl<'ctx> DenseWeightCache<'ctx> { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 81e7c176..2a0233d9 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, DeviceRef, Error, GrBatchInjectWorkspace, GrResident, GrRole, GrScratch, ModelBinding, + PleMatrixRole, PleResident, PleWeights, RESERVE, Rc, RefMut, Result, RouterLease, RouterScratch, binding_error, + driver_error, +}; /// The role, row count and byte size a retained PLE matrix must have; any other matrix is refused. struct ExpectedPleMatrix { 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 816d8ed4..3085ba48 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,8 +1,12 @@ //! Methods of `DenseWeightCache`: `ple`, `ple_key`, `ple_value`, `ple_value_tile` and 16 more. //! Functions: `gdn_native_type`, `qsa_native_type`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Context, DenseWeightCache, DeviceBuffer, DeviceRef, Error, GdnMatrixKind, GdnMatrixRole, + GdnResident, ModelBinding, OriginalVerifyGdnProjections, OriginalVerifyGdnWeights, OriginalVerifyGeometry, + OriginalVerifyNativeMatrix, OriginalVerifyProjBinding, OriginalVerifyQsaProjections, PleResident, QsaMatrixKind, + QsaMatrixRole, QsaResident, Rc, Result, binding_error, driver_error, +}; impl<'ctx> DenseWeightCache<'ctx> { pub(in super::super::super) fn ple(&self, binding: &ModelBinding, context: &Context<'_>) -> Result<&PleResident> { 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 b4774df9..cfe3279e 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, DeviceBuffer, Error, GdnVerificationWorkspace, ModelBinding, QkScratch, Rc, RefCell, + Result, RouterScratch, SlabPolicy, driver_error, startup_step, +}; impl<'ctx> DenseWeightCache<'ctx> { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 166ba461..222b2aa4 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, Error, ModelBinding, QkScratch, QsaAttentionScratch, Rc, RefCell, Result, RouterScratch, + driver_error, +}; impl<'ctx> DenseWeightCache<'ctx> { pub(crate) fn new(binding: &ModelBinding, context: &'ctx Context<'ctx>) -> Result { 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 10479cfe..2b65df2f 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,8 +1,10 @@ //! Methods of `PrefillStepProduct`: `mtp_source`. //! Methods of `TargetStepProduct`: `test_prefix_residual`, `mtp_source`, `predicted`, `position` and 1 more. -#[allow(unused_imports)] -use super::*; +use super::{ + Error, ForwardPhase, ModelBinding, Position, PrefillStepProduct, QwenSession, Result, TargetStepOrigin, + TargetStepProduct, TokenId, +}; impl PrefillStepProduct { pub(in super::super) fn mtp_source<'a>( 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 b18b5b57..fee986e2 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 @@ -1,12 +1,14 @@ -//! Groups the submodules `qwen_forward_reset`, `step_core`, `step_entries`. -//! Split out of `executor` to keep its files under the line limit. +//! The methods of `QwenForward` that run a step: the reset, the shared step body and the entry points that call it. +//! Separate from `executor`, which holds the type they work on. -#[allow(unused_imports)] -use super::*; +use super::{ + Error, KarPleCache, ModelBinding, OutputStage, Position, PrefillStepProduct, QwenForward, QwenSession, Result, + Stage, StepCaches, StepCoreResult, StepPurpose, StepRequest, TargetStepProduct, TokenId, +}; #[path = "qwen_forward/qwen_forward_reset.rs"] mod qwen_forward_reset; -#[path = "qwen_forward/step_core.rs"] -mod step_core; +#[path = "qwen_forward/forward_step_body.rs"] +mod forward_step_body; #[path = "qwen_forward/step_entries.rs"] mod step_entries; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_core.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/forward_step_body.rs similarity index 88% rename from crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_core.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/forward_step_body.rs index dad90ea4..9abdea21 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_core.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/forward_step_body.rs @@ -1,10 +1,12 @@ //! The shared body of every forward step: one completed transaction over the input row, the layers and the head. +//! Separate from `step_entries`, the callers (greedy, MTP target, MTP prefill) that pick the step purpose. use super::super::step_layers::{ LayerCtx, capture_streams, finish_step, prepare_step_caches, run_layers, stage_input_row, }; -#[allow(unused_imports)] -use super::*; +use super::{ + Error, OutputStage, QwenForward, QwenSession, Result, Stage, StepCaches, StepCoreResult, StepPurpose, StepRequest, +}; impl QwenForward { /// A forward without its output head can never publish, so it is refused before reading any row or running any 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 2a09389f..e293b4b5 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,8 +1,7 @@ //! Methods of `QwenForward`: `reset`. //! Split out of `qwen_forward` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{QwenForward, QwenSession, Result}; impl QwenForward { pub(crate) fn reset(session: &mut QwenSession<'_>) -> Result<()> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_entries.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_entries.rs index 716c4665..035c0d67 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_entries.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/step_entries.rs @@ -1,7 +1,9 @@ //! The forward-step entry points of QwenForward: greedy, KAR, MTP target and MTP prefill steps. -#[allow(unused_imports)] -use super::*; +use super::{ + Error, KarPleCache, ModelBinding, OutputStage, Position, PrefillStepProduct, QwenForward, QwenSession, Result, + StepCaches, StepPurpose, StepRequest, TargetStepProduct, TokenId, +}; impl QwenForward { pub(crate) fn step( 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 fb3245dc..09a1be14 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,8 +1,10 @@ //! Functions: `read_layer_attention`, `read_layer_one`, `prepare_layer_attention_micro`, `prepare_layer_one_micro` a... //! Defines `LayerEntry`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GrRead, GrStage, InjectedResidual, InputStage, + LayerId, ModelBinding, QwenStepTxn, Result, diagnose, +}; /// The layer-one path consumes and stages the real PLE producer before GR. /// This helper is also the entry for later layers when their FFN provider is diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_residual_capture.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_residual_capture.rs index a2f545da..cafb3b18 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_residual_capture.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_residual_capture.rs @@ -1,7 +1,6 @@ //! The residuals a step hands to the oracle capture (test builds) and to an explicit MTP caller. -#[allow(unused_imports)] -use super::*; +use super::{Error, InjectedResidual, Result}; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::oracle_capture; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_mtp_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_mtp_window.rs index 326993a6..d2e29218 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_mtp_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_mtp_window.rs @@ -1,7 +1,11 @@ //! Closed target verification prerequisite. This is not a serving selector. //! The caller must rewind speculative draft work and genuinely warm the //! current committed source before staging this window. No future origin. -use super::*; +use super::{ + ChunkMoePolicy, DenseWeightCache, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, + PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, QwenSession, Result, Stage, TargetStepProduct, + TokenId, +}; use crate::qwen_forward::{ mtp::{self, MtpChunkStage, MtpSession}, session::chunk::{ChunkRowResidual, VerifiedDraftPublication, VerifiedTargetPrefix}, 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 35ea64e8..837b7f8a 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 @@ -23,7 +23,10 @@ use super::super::{ dense_weight_cache::DenseWeightCache, moe_weight_cache::{MoeWeightCache, RetainedOriginalMtpWeights}, }; -use super::*; +use super::{ + BindingIdentity, BoundLayerKind, Dimension, Error, InputStage, KarPleCache, LayerId, ModelBinding, QwenSession, + Result, Stage, TargetStepOrigin, TokenId, +}; #[path = "original_prompt_embedding.rs"] pub(in crate::qwen_forward) mod embedding; use super::super::input::StagedInput; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/executor_construction_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/executor_construction_operands.rs index 504121a8..728c4e2a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/executor_construction_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/executor_construction_operands.rs @@ -1,5 +1,5 @@ //! The operand groups the construction of `OriginalPromptExecutor` takes. -use super::*; +use super::{Context, PromptWeights, QwenSession}; /// The target model weights, the target session and the device context a prompt executor is built over. pub(in crate::qwen_forward) struct ExecutorTarget<'a, 'ctx> { 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 007fa65c..0184aa1e 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,8 +1,19 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, + DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, ExecutorSizing, ExecutorTarget, + GrNativeProfile, InputStage, KarPleCache, LayerId, ModelBinding, MoeWeightCache, OpenChunk, OriginalDraftKvPending, + OriginalDraftSession, OriginalMtpFullAssembly, OriginalMtpFullOwner, OriginalMtpLoadError, OriginalMtpPrefill, + OriginalMtpRetainedScalarWeights, OriginalMtpScalarPolicy, OriginalPrefillArena, OriginalPromptDevice, + OriginalPromptDraftOutcome, OriginalPromptEmbedding, OriginalPromptExecutor, OriginalPromptPending, + OriginalPromptSample, OriginalPromptTxn, OriginalSessionCheckpoint, PStage, ParkedBlock, ParkedSession, + PleBf16Mode, PromptChunkSource, PromptChunkTarget, PromptDeviceFinal, PromptDeviceNormedRows, PromptDeviceRows, + PromptDeviceSource, PromptInputStage, PromptWeights, QsaLayerDevices, QsaNativePacking, QwenSession, + ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, Result, RetainedOriginalMtpWeights, RowsUpload, RtMtpLoad, + SpanExport, Stage, StagedInput, TokenId, driver_error, prof, staged_input_enabled, +}; #[path = "original_prompt_executor/construction_and_parking.rs"] mod construction_and_parking; 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 6e232caf..919987ca 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,8 +1,14 @@ //! Groups the submodules `executor_construction`, `session_park_and_qsa_owners`. //! Split out of `original_prompt_executor` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Context, DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, + ExecutorSizing, ExecutorTarget, GrNativeProfile, LayerId, ModelBinding, MoeWeightCache, OriginalDraftSession, + OriginalMtpFullAssembly, OriginalMtpFullOwner, OriginalMtpLoadError, OriginalPromptEmbedding, + OriginalPromptExecutor, OriginalSessionCheckpoint, ParkedBlock, ParkedSession, PleBf16Mode, PromptWeights, + QsaNativePacking, QwenSession, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, Result, + RetainedOriginalMtpWeights, RtMtpLoad, SpanExport, driver_error, +}; #[path = "construction_and_parking/executor_construction.rs"] mod executor_construction; 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 2de80d8c..98757cbf 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,8 +1,13 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Context, DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, + ExecutorSizing, ExecutorTarget, GrNativeProfile, LayerId, ModelBinding, MoeWeightCache, OriginalDraftSession, + OriginalMtpFullAssembly, OriginalMtpFullOwner, OriginalMtpLoadError, OriginalPromptEmbedding, + OriginalPromptExecutor, PleBf16Mode, PromptWeights, QsaNativePacking, QwenSession, ResidentQsaLayer, + ResidentQsaOwners, Result, RetainedOriginalMtpWeights, RtMtpLoad, driver_error, +}; use leleka_cuda_driver::{GdnPromptOptions, NativeBatchWorkspace}; impl<'ctx> OriginalPromptExecutor<'ctx> { 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 df444b1f..ce25343b 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,8 +1,11 @@ //! Methods of `OriginalPromptExecutor`: `take_qsa_owners`, `adopt_qsa_owners`, `rebuild_qsa_layers`, `checkpoint_ses... //! Defines `QsaOwners`. -#[allow(unused_imports)] -use super::*; +use super::{ + DenseWeightCache, Error, ModelBinding, OriginalPromptExecutor, OriginalSessionCheckpoint, ParkedBlock, + ParkedSession, PromptWeights, QwenSession, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, Result, + SpanExport, +}; use crate::qwen_forward::session::original_prompt::ParkedPoint; /// The index image and mapped K/V journal of each of the twelve resident QSA layers, by layer slot. 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 fe654b3e..337a2748 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,8 +1,16 @@ //! Groups the submodules `prompt_chunk_forward`, `prompt_executor_close`. //! Split out of `original_prompt_executor` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, + DenseWeightCache, Error, InputStage, KarPleCache, ModelBinding, MoeWeightCache, OpenChunk, OriginalDraftKvPending, + OriginalMtpPrefill, OriginalMtpRetainedScalarWeights, OriginalMtpScalarPolicy, OriginalPrefillArena, + OriginalPromptDevice, OriginalPromptDraftOutcome, OriginalPromptEmbedding, OriginalPromptExecutor, + OriginalPromptPending, OriginalPromptSample, OriginalPromptTxn, PStage, PromptChunkSource, PromptChunkTarget, + PromptDeviceFinal, PromptDeviceNormedRows, PromptDeviceRows, PromptDeviceSource, PromptInputStage, PromptWeights, + QsaLayerDevices, QwenSession, Result, RetainedOriginalMtpWeights, RowsUpload, Stage, StagedInput, TokenId, + driver_error, prof, staged_input_enabled, +}; #[path = "prompt_executor_forward_and_close/prompt_chunk_forward.rs"] mod prompt_chunk_forward; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_draft.rs index f98c7911..689dc743 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_draft.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_draft.rs @@ -1,7 +1,11 @@ //! STRA-338 size: the draft-KV phase of `OriginalPromptExecutor::forward`. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkDraft, Context, Error, MoeWeightCache, OriginalDraftKvPending, OriginalMtpPrefill, + OriginalMtpRetainedScalarWeights, OriginalMtpScalarPolicy, OriginalPromptDraftOutcome, OriginalPromptEmbedding, + OriginalPromptExecutor, OriginalPromptSample, OriginalPromptTxn, PStage, PromptDeviceFinal, PromptDeviceRows, + PromptWeights, Result, RetainedOriginalMtpWeights, Stage, prof, trace_error, trace_step, +}; use crate::qwen_forward::prompt_device_rows::{ DraftKvRequest, FinalPromptSources, ScalarDraftKvRequest, ScalarPromptSources, }; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_final.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_final.rs index 3ed639b2..ec4f8bc2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_final.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_final.rs @@ -1,7 +1,10 @@ //! STRA-338 size: the final row of `OriginalPromptExecutor::forward` (conditioning preview, sample, R trace). -#[allow(unused_imports)] -use super::*; +use super::{ + Carrier, ChunkWork, DenseWeightCache, Error, ModelBinding, OriginalPromptExecutor, OriginalPromptSample, + OriginalPromptTxn, PStage, PromptDeviceFinal, PromptDeviceRows, PromptWeights, Result, driver_error, prof, + trace_error, trace_step, +}; use leleka_cuda_driver::OriginalDeviceResidual; const FNV_OFFSET: u64 = 0xcbf29ce484222325; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_input.rs index 86ffdf8c..52f68fb7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_input.rs @@ -1,7 +1,11 @@ //! STRA-338 size: the input phase of `OriginalPromptExecutor::forward` (staging, row upload, PLE read-ahead). -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkInFlight, Context, DenseWeightCache, Error, InputStage, KarPleCache, ModelBinding, OriginalPrefillArena, + OriginalPromptDevice, OriginalPromptExecutor, OriginalPromptTxn, PStage, PromptDeviceRows, PromptDeviceSource, + PromptInputStage, PromptWeights, Result, RowsUpload, StagedInput, TokenId, driver_error, prof, + staged_input_enabled, +}; use crate::qwen_forward::kar_ple_cache::KarPleStaged; /// What the staging of one chunk's inputs leaves behind: the chunk-wide staged input, the staged PLE rows and the diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_layers.rs index be50cb46..a3040fb8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/forward_stages/forward_layers.rs @@ -1,7 +1,10 @@ //! STRA-338 size: the layer loop of `OriginalPromptExecutor::forward`, one helper per phase of a layer. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Carrier, ChunkWork, DenseWeightCache, Error, InputStage, ModelBinding, MoeWeightCache, + OriginalPromptExecutor, OriginalPromptTxn, PStage, PromptDeviceNormedRows, PromptDeviceRows, PromptWeights, + QsaLayerDevices, Result, prof, +}; use crate::model_binding::qwen4exp_input::BoundLayer; use crate::qwen_forward::gr::GrRole; use crate::qwen_forward::prompt_device_rows::PromptDeviceRead; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_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 2cbc9f37..da66da4e 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,8 +1,16 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, + DenseWeightCache, Error, InputStage, KarPleCache, ModelBinding, MoeWeightCache, OpenChunk, OriginalDraftKvPending, + OriginalMtpPrefill, OriginalMtpRetainedScalarWeights, OriginalMtpScalarPolicy, OriginalPrefillArena, + OriginalPromptDevice, OriginalPromptDraftOutcome, OriginalPromptEmbedding, OriginalPromptExecutor, + OriginalPromptPending, OriginalPromptSample, OriginalPromptTxn, PStage, PromptChunkSource, PromptChunkTarget, + PromptDeviceFinal, PromptDeviceNormedRows, PromptDeviceRows, PromptDeviceSource, PromptInputStage, PromptWeights, + QsaLayerDevices, QwenSession, Result, RetainedOriginalMtpWeights, RowsUpload, Stage, StagedInput, TokenId, + driver_error, prof, staged_input_enabled, +}; use crate::qwen_forward::session::original_prompt::DraftRollback; #[path = "forward_stages/forward_draft.rs"] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_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 69beec37..07311086 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,8 +1,7 @@ //! Methods of `OriginalPromptExecutor`: `close`. //! Split out of `prompt_executor_forward_and_close` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{OriginalPromptExecutor, Result}; impl<'ctx> OriginalPromptExecutor<'ctx> { pub(in crate::qwen_forward) fn close(mut self) -> 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 c169895c..8e36bcd0 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,8 +1,7 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{Error, OriginalPromptExecutor, Result, driver_error}; impl<'ctx> OriginalPromptExecutor<'ctx> { pub(in super::super) fn close_inner(&mut self) -> Result<()> { 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 508412e6..c7e1af8b 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,8 +1,11 @@ //! Methods of `OriginalPromptPending`: `publish`. //! Implements `Drop for OriginalPromptExecutor`, `Drop for OriginalPromptPending` and 2 more. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkCaches, ChunkDraft, Error, NoPromptHooks, OriginalPromptComposer, OriginalPromptExecutor, OriginalPromptHooks, + OriginalPromptPending, PromptChunkSource, PromptChunkTarget, PromptWeights, Result, Stage, TargetStepOrigin, + TokenId, +}; use crate::qwen_forward::session::original_prompt::{DraftRollback, PromptPublication}; impl Drop for OriginalPromptExecutor<'_> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/prompt_chunk_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/prompt_chunk_operands.rs index c076f038..81126e7f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/prompt_chunk_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor_original_prompt/prompt_chunk_operands.rs @@ -1,5 +1,9 @@ //! The operand groups one batched prompt chunk passes between the phases of `OriginalPromptExecutor::forward`. -use super::*; +use super::{ + KarPleCache, MoeWeightCache, OriginalDraftCheckpoint, OriginalDraftSession, OriginalMtpScalarPolicy, + OriginalPrefillArena, OriginalPromptEmbedding, OriginalPromptInput, OriginalPromptTxn, OriginalSessionCheckpoint, + PromptWeights, QwenSession, TokenId, +}; /// The next `count` tokens of the prompt source that one chunk consumes. #[derive(Clone, Copy)] 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 b0c01a68..159ecd34 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,8 +1,6 @@ //! Functions: `staged_input_enabled`. //! Split out of `original_prompt` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; /// `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 { 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 906e7d78..55e145cf 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 @@ -2,8 +2,10 @@ //! Defines `MicroEnv`, `MicroSources`, `MicroBlockSources` and 2 more. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, DenseWeightCache, Error, ForwardPhase, GdnStage, GrStage, LayerId, ModelBinding, MoeExpertStage, + MoeRouteStage, MoeWeightCache, Position, QwenChunkTxn, QwenForward, QwenStepTxn, Result, Stage, TokenId, diagnose, +}; use crate::qwen_forward::gdn::chunk_device::GdnChunkDevice; use crate::qwen_forward::gr::{DetachedGrRead, GrMicroAttentionBank, GrMicroAttentionBlock, MicroBlockRequest}; use crate::qwen_forward::moe_prefill_batch::MoeMicroProducts; 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 0ab53e14..4a3c5283 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,7 +1,9 @@ //! STRA-338 size: the routing of the FFN reads of a micro window. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkFfnRow, Context, DetachedGrRead, Error, ForwardPhase, GrStage, MicroEnv, MoeExpertStage, MoeMicroProducts, + MoeRouteStage, MoeWeightCache, PreparedLayerRow, QwenChunkTxn, QwenStepTxn, Result, Stage, diagnose, +}; use crate::qwen_forward::gr::ResidualReady; use crate::qwen_forward::moe_expert::PreparedMoeRow; use crate::qwen_forward::moe_prefill_batch::{ 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 ae5bc5db..c9af8168 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,7 +1,9 @@ //! STRA-338 size: the native prompt GDN attention blocks of a micro window. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkAttentionRow, Context, DetachedGrRead, Error, GdnChunkDevice, GdnStage, GrMicroAttentionBank, + GrMicroAttentionBlock, GrStage, MicroBlockRequest, MicroEnv, MicroRows, QwenChunkTxn, QwenStepTxn, Result, Stage, +}; use crate::qwen_forward::gdn::PromptLayer; use crate::qwen_forward::gdn::chunk_device::ChunkEdge; use crate::qwen_forward::gdn::chunk_producer::ChunkReady; 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 5ec7318c..e32da09c 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,7 +1,11 @@ //! STRA-338 size: the row-by-row attention blocks of a micro window (device GDN owner or host stages). -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, ChunkAttentionRow, DetachedGrRead, Error, ForwardPhase, GdnChunkDevice, GdnStage, + GrMicroAttentionBank, GrMicroAttentionBlock, GrStage, MicroBlockRequest, MicroEnv, MicroRows, MicroSources, + Position, PreparedLayerRow, ProjectionRow, QwenChunkTxn, QwenForward, QwenStepTxn, Result, Stage, TokenId, + diagnose, +}; use crate::qwen_forward::gdn::chunk_device::ChunkEdge; use crate::qwen_forward::gdn::{DeviceChunkRow, GdnLayerInput}; use crate::qwen_forward::session::chunk::GdnChunkRow; 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 a6ef8368..d043ec7e 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,7 +1,9 @@ //! STRA-338 size: the native prompt QSA attention blocks of a micro window. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkAttentionRow, Context, Error, GrMicroAttentionBank, GrStage, MicroBlockRequest, MicroEnv, MicroRows, + PreparedLayerRow, QwenChunkTxn, Result, Stage, +}; use crate::qwen_forward::gr::ResidualReady; use crate::qwen_forward::prompt_device_rows::PromptWeights; use crate::qwen_forward::qsa_attention::QsaReady; 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 81c16cc4..911129b7 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,8 +1,7 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{BoundLayerKind, DenseWeightCache, Error, LayerId, ModelBinding, QwenChunkTxn, Result}; use crate::model_binding::qwen4exp_input::{GdnMatrixKind, GdnMatrixRole, QsaMatrixKind, QsaMatrixRole}; use crate::qwen_forward::gr::ResidualReady; use crate::qwen_forward::prompt_device_rows::PromptWeights; 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 fda2ed83..2c67420a 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,7 +1,11 @@ //! STRA-338 size: the inputs and the joint target+draft publication shared by the prefill chunk entry points. -#[allow(unused_imports)] -use super::*; +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; 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 3993333a..80b6caba 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +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_native_windowed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor_prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs index e88a4942..cb788161 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + AllocationTrace, ChunkMoePolicy, Error, MoeWeightCache, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, + QwenForward, QwenSession, Result, TargetStepProduct, +}; impl QwenForward { /// Explicit private composition using the owned IntegerIQ3 cache. Each 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 630cbeb9..b9490f66 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,7 +1,9 @@ //! STRA-338 size: the host GDN and QSA attention stages of one prefill row, shared by the FFN-row and micro-FFN paths. -#[allow(unused_imports)] -use super::*; +use super::{ + DenseWeightCache, ForwardPhase, GdnStage, LayerId, ModelBinding, Position, QsaAttentionStage, QsaIndexStage, + QwenForward, QwenStepTxn, Result, TokenId, diagnose, +}; use crate::qwen_forward::gdn::{GdnLayerInput, GdnReady}; use crate::qwen_forward::gr::DetachedGrRead; use crate::qwen_forward::q6_attention_columns::ProjectionRow; 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 ce977016..ad336e50 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,7 +1,10 @@ //! STRA-338 size: the host stages of one prefill row (GDN or QSA attention, GR injection, FFN read, routing). -#[allow(unused_imports)] -use super::*; +use super::{ + AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkMoePolicy, ForwardPhase, GrStage, InjectedResidual, LayerId, + MoeExpertStage, MoeRouteStage, Position, QwenForward, QwenStepTxn, Result, TokenId, diagnose, + read_chunk_attention_ffn, +}; use crate::qwen_forward::contract::TokenLayer; use crate::qwen_forward::gr::{DetachedGrRead, GrRead}; use crate::qwen_forward::moe_expert::PreparedMoeRow; 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 19afb783..996646a8 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,8 +1,7 @@ //! Methods of `TargetStepProduct`: `from_chunk_commit`. Functions: `chunk_diagnostic`. //! Split out of `prefill_chunk` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{Result, TargetStepProduct}; impl TargetStepProduct { // Only the already checked joint chunk publisher supplies this owned 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 9f03f6fb..f31ac909 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,8 +1,13 @@ //! Methods of `CachedGdn`: `project`, `run`, `leading_products`, `recurrence` and 3 more. //! Functions: `step_cached`, `open_chain`, `settle_cached`, `chain_output_role` and 3 more. -#[allow(unused_imports)] -use super::*; +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/gates.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs index da5ce83d..7a215694 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs @@ -1,8 +1,10 @@ //! Methods of `RecurHost`: `validate`, `upload_all`. //! Functions: `gates`, `upload_gate_inputs`, `run_gate_kernels`, `release_owned` and 16 more. -#[allow(unused_imports)] -use super::*; +use super::{ + CandidatePair, Context, DeviceBuffer, Error, InputBindingError, POOL_OVERRIDE, RecurrenceOperands, Result, + STATE_ELEMENTS, Stage, VALUES, driver_error, +}; /// The device copies one `gates` call owns: alpha and beta always, dt and a only when no resident copy is lent. struct GateUploads<'a> { 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 64125c6d..1d760b45 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,8 +1,7 @@ //! Methods of `GdnReady`: `identity`, `output`, `validate_origin`, `take_pending`. //! Split out of `gdn` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{BindingIdentity, Error, GdnPending, GdnReady, Result, TokenLayer}; impl GdnReady { pub(in super::super) fn identity(&self) -> TokenLayer { 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 5e16ba82..15a9b678 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs @@ -2,8 +2,12 @@ //! Functions: `project`, `project_leased`, `project_uploaded`, `upload_matrix_block` and 10 more. use super::gates::{release_with_owned, upload_unless_resident}; -#[allow(unused_imports)] -use super::*; +use super::{ + Bf16ProjectionShape, CHANNELS, CandidatePair, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DriverError, + Error, GdnInputLease, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnWeights, HISTORY_ELEMENTS, LeaseClaim, + ModelBinding, ProjectionKind, ProjectionSpec, Q5KProjectionShape, Q6KProjectionShape, Result, allocate, + binding_error, download, driver_error, release, upload, validate_values, zeros, +}; pub(super) fn project( context: &Context<'_>, 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 76124595..5232ac92 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,8 +1,13 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, CandidatePair, Context, DenseWeightCache, DeviceChunkRow, Dimension, Error, GateHostOperands, + GdnLayerInput, GdnMatrixRole, GdnPending, GdnPrior, GdnReady, GdnStage, GdnWeights, GrRole, LayerId, ModelBinding, + OutNormScale, ProjectedQkvSource, ProjectionOperands, QwenStepTxn, RecurrenceOperands, ResidualReady, Result, + binding_error, chunk_producer, convolve, gates, normalize_qk, out_norm, preflight_budget, project, recur, + step_cached, validate_values, +}; impl GdnStage { /// Select the native program only from this model's actual eager owner. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/step_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/step_operands.rs index 9c086359..fc93854e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/step_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/step_operands.rs @@ -1,7 +1,9 @@ //! The groups of values a GDN layer step passes between its phases (STRA-338: one parameter group per meaning //! instead of long argument lists). All of them are plain stack values or borrows; none allocates. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Context, DenseWeightCache, GdnInputLease, GdnMatrixKind, GdnPrior, GdnStateMirror, GdnWeights, + LayerId, ModelBinding, QwenStepTxn, ResidualReady, TokenLayer, chunk_device, mirror, +}; use crate::qwen_forward::q6_attention_columns::ProjectionRow; use std::{cell::Cell, rc::Rc}; 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 f0041212..9d675158 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,8 +1,11 @@ //! Methods of `QkScratch`: `test_slot_bytes`, `new`, `validate`, `take` and 2 more. Methods of `Role`: `count`. //! Functions: `allocate_qk_slot`, `normalize_retained_qk`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, CHANNELS, Cell, Context, DeviceBuffer, Error, HISTORY_ELEMENTS, MirrorAuthority, Product, + QK_BYTES, QK_RESERVE, QkScratch, Rc, RecurrenceBorrow, RecurrenceParts, RefCell, Result, Role, + ScalarRecurrenceBorrow, TokenLayer, VALUES, allocate, download, driver_error, +}; pub(super) fn allocate_qk_slot<'ctx>(context: &'ctx Context<'ctx>) -> Result> { let required = QK_BYTES.checked_add(QK_RESERVE).ok_or(Error::Overflow)?; 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 74c72e31..71dd9b10 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, DeviceOperand, DeviceProduct, Error, GdnLayerInput, + GdnMatrixKind, GdnMatrixLayout, GdnRowQueue, HISTORY_ELEMENTS, Product, QkReturn, QkScratch, QkvInput, QueueInputs, + QueuedRow, Rc, ReadoutClaim, RecurrenceBorrow, RefCell, Result, Role, ScalarRecurrenceBorrow, TokenLayer, VALUES, + allocate, dispatch_projection, download, driver_error, normalize_retained_qk, validate_values, +}; #[path = "chain/chain_construction_and_buffers.rs"] mod chain_construction_and_buffers; 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 67ea5185..c745c2dc 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Cell, Chain, Context, DeviceBuffer, DeviceOperand, DeviceProduct, Error, GdnMatrixKind, + GdnMatrixLayout, Product, QkReturn, QkScratch, Rc, RefCell, Result, Role, TokenLayer, VALUES, allocate, + dispatch_projection, download, driver_error, validate_values, +}; impl<'ctx> Chain<'ctx> { pub(in super::super::super) fn new( 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 70d3cb7c..315b56b0 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,8 +1,11 @@ //! Methods of `Chain`: `upload_values`, `note`, `note_err`, `free` and 10 more. //! Split out of `chain` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + CHANNELS, Chain, DeviceBuffer, Error, GdnMatrixKind, GdnMatrixLayout, HISTORY_ELEMENTS, Product, QkReturn, + QkScratch, Rc, ReadoutClaim, Result, Role, VALUES, allocate, dispatch_projection, download, driver_error, + normalize_retained_qk, validate_values, +}; impl<'ctx> Chain<'ctx> { pub(in super::super) fn upload_values(&mut self, role: Role, values: &[f32]) -> Result { 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 182cdeac..b728b448 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,8 +1,7 @@ //! Methods of `Chain`: `import_chunk_readout`, `out_norm`, `drain`, `finish`. //! Split out of `chain` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{Chain, DeviceBuffer, Error, Product, Rc, Result, Role, VALUES, download, driver_error}; impl<'ctx> Chain<'ctx> { pub(in super::super::super) fn import_chunk_readout( 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 f58f7126..f769eedc 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,8 +1,10 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + Chain, DeviceBuffer, DeviceOperand, Error, GdnLayerInput, GdnRowQueue, Product, QkvInput, QueueInputs, QueuedRow, + Rc, RecurrenceBorrow, Result, Role, ScalarRecurrenceBorrow, driver_error, validate_values, +}; use leleka_cuda_driver::{GdnConvBuffers, GdnOutNormBuffers, GdnRecurrenceBuffers, GdnRowCompletion, GdnRowPrefix}; fn check_distinct_slots(slots: &[usize; 4]) -> Result<()> { 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 c8796370..4f0b8715 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,8 +1,7 @@ //! Implements `Drop for Chain`. //! Split out of `chain` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::Chain; impl Drop for Chain<'_> { fn drop(&mut self) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chain_fused.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chain_fused.rs index 30cd9215..4b999038 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chain_fused.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chain_fused.rs @@ -3,7 +3,10 @@ //! default `fused_gdn_conv_l2` + `fused_gdn_ab` + `fused_gdn_step_norm`; every stage output has a complete finite //! scan; nothing is published unless the whole drain was clean (the pending `y` operand becomes a `DeviceProduct` //! only then, exactly like `run_row_queue`). -use super::*; +use super::{ + Chain, DeviceBuffer, DeviceOperand, DeviceProduct, Error, Product, Result, Role, allocate, download, driver_error, + validate_values, +}; use leleka_cuda_driver::{GdnFusedCompletion, GdnFusedPrefix, GdnFusedStage, GdnFusedT1}; /// Every operand of one fused row. The host-validated QKV product is the unchanged scalar-chain product; Z stays on 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 2f97e217..6b0e3d57 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, Context, DenseWeightCache, DeviceBuffer, Error, + GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkStart, GdnRowQueue, HISTORY_ELEMENTS, ModelBinding, Rc, Result, + STATE_ELEMENTS, driver_error, micro_rows, mirror_reuse_enabled, preflight_budget, upload, validate_values, +}; impl<'ctx> GdnChunkDevice<'ctx> { pub(in crate::qwen_forward) fn new( 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 75cd9a18..c5299ddb 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + DenseWeightCache, Error, GdnChunkDevice, GdnChunkSeal, GdnPrior, ModelBinding, Result, STATE_ELEMENTS, download, + download_unchecked, driver_error, pool_enabled, +}; impl<'ctx> GdnChunkDevice<'ctx> { pub(in crate::qwen_forward) fn finish( 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 365f5b27..8fe6391c 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,8 +1,10 @@ //! Methods of `ChunkEdge`: `into_parts`, `into_row`. Methods of `ChunkReadout`: `into_parts`, `same_owner`. //! Implements `Drop for ChunkReadout`. Functions: `mirror_reuse_enabled`, `micro_rows`. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, ChunkEdge, ChunkReadout, Context, DeviceBuffer, Error, GdnChunkMicro, GdnChunkRow, Rc, Result, VALUES, + driver_error, validate_values, +}; pub(super) fn mirror_reuse_enabled() -> bool { crate::settings::process().kv.prefill_gdn_mirror 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 d132602b..ff2ccf6b 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,8 +1,7 @@ //! Methods of `GdnChunkDevice`: `bind_native_fused`, `native_fused_operands`, `complete_native_fused_step`. //! Implements `Drop for GdnChunkDevice`. -#[allow(unused_imports)] -use super::*; +use super::{DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, Rc, Result}; impl Drop for GdnChunkDevice<'_> { fn drop(&mut self) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_fused.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_fused.rs index 7a7e2305..b0e19f73 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_fused.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_fused.rs @@ -3,7 +3,11 @@ use super::super::session::chunk::GdnChunkRow; use super::chain::FusedInputs; use super::chunk_producer::{ChunkReady, RowEnv, check_gdn_layer, check_input_origin, settle_row}; -use super::*; +use super::{ + CandidatePair, Context, DenseWeightCache, DeviceBuffer, DeviceChunkRow, Error, GdnLayerInput, GdnMatrixKind, + GdnMatrixRole, GdnStage, GrRole, LayerId, ModelBinding, ProjectedQkvSource, QwenStepTxn, ResidualReady, Result, + Stage, chain, chunk_device, driver_error, preflight_budget, validate_values, +}; use leleka_cuda_driver::GdnFusedT1; use std::{cell::RefCell, rc::Rc}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_numeric_gpu/operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_numeric_gpu/operands.rs index 8ebe6aec..63023748 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_numeric_gpu/operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_numeric_gpu/operands.rs @@ -1,8 +1,18 @@ //! Methods of `Operands`: `recurrence`. //! Functions: `operands`, `convolution_input`, `convolution_weights`, `difference` and 3 more. -#[allow(unused_imports)] -use super::*; +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, +}; impl Operands { // The five recurrence operands of this row, with the value operand taken from the convolution output. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer.rs index a4bc0905..b9545398 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer.rs @@ -2,7 +2,12 @@ use super::super::dense_weight_cache::GdnResident; use super::super::q6_attention_columns::RetainedRow; use super::super::session::chunk::GdnChunkRow; -use super::*; +use super::{ + BindingIdentity, BoundLayerKind, CandidatePair, Context, DenseWeightCache, DeviceBuffer, DeviceChunkRow, Dimension, + Error, GdnInputLease, GdnLayerInput, GdnMatrixRole, GdnStage, GdnWeights, GrRole, LayerId, LeaseClaim, + LeasedProjection, ModelBinding, ProjectedQkvSource, QwenStepTxn, ResidualReady, Result, TokenLayer, chain, + chunk_device, preflight_budget, project_chain_input, validate_values, +}; use leleka_cuda_driver::GdnRowQueue; use std::{cell::Cell, rc::Rc}; pub(in crate::qwen_forward) struct ChunkReady { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/queued_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/queued_row.rs index b95e5cd5..a13b3845 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/queued_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/queued_row.rs @@ -1,5 +1,8 @@ //! The closed one-drain queued chunk row of the GDN producer. -use super::*; +use super::{ + CandidatePair, ChunkReady, DenseWeightCache, DeviceChunkRow, GdnLayerInput, GdnMatrixRole, GdnRowQueue, + ProjectedQkvSource, QwenStepTxn, Result, RetainedRow, RowEnv, chain, chunk_device, settle_row, validate_values, +}; // Same row contract as `step_chain`; the twelve intermediate host readbacks and // the separate launch/guard fences collapse into ONE queue drain. Alpha, raw diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/scalar_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/scalar_row.rs index f413f889..057175eb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/scalar_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_chunk_producer/scalar_row.rs @@ -1,5 +1,8 @@ //! The scalar (decomposed) chunk row of the GDN producer: one chain, host readbacks between the stages. -use super::*; +use super::{ + CandidatePair, ChunkReady, DenseWeightCache, DeviceChunkRow, GdnChunkRow, GdnLayerInput, GdnMatrixRole, + ProjectedQkvSource, QwenStepTxn, Result, RowEnv, chain, chunk_device, settle_row, validate_values, +}; pub(super) fn step_chain<'ctx>( layer_input: GdnLayerInput<'_>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_fused_t1_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_fused_t1_step.rs index 6e9fc6be..dfde5840 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_fused_t1_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_fused_t1_step.rs @@ -11,7 +11,11 @@ //! clean complete drain). Nothing about the prompt/chunk path changes. use super::chain::{FusedInputs, Role}; use super::chunk_producer::RowEnv; -use super::*; +use super::{ + BoundLayerKind, DenseWeightCache, DeviceBuffer, Dimension, Error, GdnLayerInput, GdnMatrixKind, GdnMatrixRole, + GdnPrior, GdnReady, GdnStage, GrRole, LayerId, MirrorStep, ModelBinding, ProjectedQkvSource, QwenStepTxn, + ResidualReady, Result, Stage, chain, preflight_budget, validate_values, +}; use leleka_cuda_driver::GdnFusedT1; impl GdnStage { 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 86d432f0..c6a999bf 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + ALPHA_BETA, Bf16Profile, Buffers, CHANNELS, Context, DeviceBuffer, Error, HISTORY_ELEMENTS, MIXED, Result, + VALUE_HEADS, VALUES, driver_error, +}; impl<'ctx> Buffers<'ctx> { pub(super) fn allocated_bytes(&self) -> usize { 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 c0179af6..321b6ac5 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,8 +1,11 @@ //! Methods of `GdnBatchResources`: `new`, `new_for_prompt`, `new_capacity`, `admit_capacity` and 8 more. //! Implements `Drop for GdnBatchResources`. -#[allow(unused_imports)] -use super::*; +use super::{ + ALPHA_BETA, BATCH_RESERVE, BATCH_SCRATCH_BYTES, Bf16Profile, Buffers, CHANNELS, Context, DeviceBuffer, + EAGER_TOKENS, Error, GDN_BATCH_MAX_TOKENS, GdnBatchResources, GdnMatrixKind, GdnNativeFormat, GdnPrefillBatch, + HISTORY_ELEMENTS, MIXED, Result, Stage, VALUE_HEADS, VALUES, driver_error, +}; impl<'ctx> GdnBatchResources<'ctx> { pub(in crate::qwen_forward) fn new(context: &'ctx Context<'ctx>, profile: Bf16Profile) -> Result { 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 a070706b..ecd8e9e8 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 @@ -6,7 +6,7 @@ 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, }; -use super::*; +use super::{ChunkReady, GdnBatchResources, GdnChunkDevice, GdnChunkMicro, GdnStage, GemmRef, PromptLayer, Result}; impl GdnStage { /// The batched Strata-prefill GDN step over one genuine current causal 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 5b52751f..44b04be4 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,7 +1,11 @@ //! Phases of `GdnStage::step_chunk_batch` (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + BoundLayerKind, Buffers, CHANNELS, ChunkReady, Context, DenseWeightCache, DeviceBuffer, Dimension, Error, + GDN_BATCH_EPSILON, GdnBatchResources, GdnChunkDevice, GdnChunkMicro, GdnMatrixKind, GdnMatrixRole, GdnNativeFormat, + GemmRef, LayerId, MIXED, ModelBinding, Result, Stage, TokenLayer, VALUE_HEADS, VALUES, download, driver_error, + f32_bytes, native_format, validate_values, +}; use crate::qwen_forward::dense_weight_cache::GdnResident; use leleka_cuda_driver::GdnBatchPrefix; use std::cell::Cell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_prompt_device.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_prompt_device.rs index a34b146e..828f8b41 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_prompt_device.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_prompt_device.rs @@ -3,7 +3,10 @@ use super::super::dense_weight_cache::GdnResident; use super::super::session::chunk::GdnChunkRow; use super::chunk_device::{ChunkEdge, GdnChunkDevice}; -use super::*; +use super::{ + BoundLayerKind, Context, DenseWeightCache, DeviceBuffer, Dimension, DriverError, Error, GdnMatrixKind, + GdnMatrixRole, GdnStage, GdnWeights, LayerId, ModelBinding, Result, Stage, driver_error, +}; use leleka_cuda_driver::{ GDN_BATCH_EPSILON, GdnNativeFormat, NativeBatchWorkspace, OriginalDeviceBlock, OriginalDeviceGrRead, OriginalGdnPromptDevice, OriginalGdnPromptWeights, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror/mirror_readout.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror/mirror_readout.rs index a61eec38..dee8dede 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror/mirror_readout.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror/mirror_readout.rs @@ -1,8 +1,7 @@ //! Methods of `MirrorReadout`: `test_values`, `into_parts`, `same_owner`, `into_host`. //! Implements `Drop for MirrorReadout`. -#[allow(unused_imports)] -use super::*; +use super::{DeviceBuffer, Error, MirrorReadout, Rc, ReadoutClaim, Result, VALUES, driver_error, validate_values}; impl<'ctx> MirrorReadout<'ctx> { #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror_fused.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror_fused.rs index fbf3be92..4fcf936d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror_fused.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn_state_mirror_fused.rs @@ -1,7 +1,10 @@ //! Resident-mirror support for the in-place fused T1 recurrence (STRA-169). Child of the mirror module: it needs the //! private resident buffer, key and candidate constructor, and adds no new authority. The canonical immutable host //! prior stays canonical; the candidate it returns is exactly the `MirrorNext` the unchanged `publish` consumes. -use super::*; +use super::{ + DeviceBuffer, Error, GdnPrior, GdnStateMirror, MIRROR_BYTES, MirrorNext, Result, STATE_ELEMENTS, allocate, + driver_error, validate_values, +}; impl<'ctx> GdnStateMirror<'ctx> { /// Allocate the candidate state buffer, seed it from the prior, run `run` (the fused program, which updates the 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 c90e18a5..703623de 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,8 +1,12 @@ //! Groups the submodules `verified_row_compute_and_lease`, `workspace`, `workspace_replay`. //! Split out of `verification` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveLease, BindingIdentity, COUNTS, Cell, Context, DEVICE_BYTES, DeviceBuffer, Error, GdnChunkRow, GdnChunkStart, + GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, LayerId, LayerStorage, PoolRow, RESERVE, Rc, RefCell, ReplaySeal, + Result, SLOTS, STATE_ELEMENTS, Stage, TargetStepOrigin, TokenLayer, VALUES, VerifiedRow, VerifiedRowBuffers, Weak, + Workspace, allocate, chain, download, driver_error, validate_values, +}; #[path = "compute_row/verified_row_compute_and_lease.rs"] mod verified_row_compute_and_lease; 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 b2453b9b..11aafebf 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,8 +1,10 @@ //! Methods of `ActiveLease`: `validate`, `refuse`. Methods of `VerifiedRow`: `history`, `validate`. //! Functions: `compute_row`. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveLease, BindingIdentity, Context, Error, GdnStateFiniteGuard, HISTORY_ELEMENTS, LayerId, Rc, Result, + TargetStepOrigin, TokenLayer, VALUES, VerifiedRow, VerifiedRowBuffers, download, driver_error, validate_values, +}; pub(in super::super::super) fn compute_row( context: &Context<'_>, 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 3b5f5d91..d682c95d 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveLease, BindingIdentity, COUNTS, Cell, Context, DEVICE_BYTES, DeviceBuffer, Error, GdnChunkRow, GdnChunkStart, + GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, LayerId, LayerStorage, PoolRow, RESERVE, Rc, RefCell, Result, + SLOTS, STATE_ELEMENTS, TargetStepOrigin, VALUES, VerifiedRow, Weak, Workspace, allocate, driver_error, + validate_values, +}; impl<'ctx> Workspace<'ctx> { pub(in crate::qwen_forward) fn new( 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 bf3ecb19..ec6c2233 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,8 +1,11 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + ActiveLease, COUNTS, DeviceBuffer, Error, GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, PoolRow, Rc, ReplaySeal, + Result, STATE_ELEMENTS, Stage, VALUES, VerifiedRow, VerifiedRowBuffers, Weak, Workspace, chain, compute_row, + download, driver_error, +}; impl<'ctx> Workspace<'ctx> { pub(in crate::qwen_forward) fn replay( 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 7526b288..069d4962 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,8 +1,7 @@ //! Methods of `Workspace`: `bind_native_fused`. //! Split out of `verification` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ActiveLease, Error, Rc, RefCell, Result, Workspace, driver_error}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl<'ctx> Workspace<'ctx> { 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 04b4fff7..3221a3c5 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 @@ -3,7 +3,12 @@ #[allow(unused_imports)] use super::super::dense_weight_cache::GrResident; -use super::*; +use super::{ + Context, DenseWeightCache, DeviceBuffer, Dimension, Error, GrPhase, GrRead, GrRole, GrScratch, GrStage, GrWeights, + InjectedResidual, LayerId, ModelBinding, PleReady, QwenStepTxn, READ_DEVICE_BYTES, ReadCandidate, ResidualReady, + Result, TokenLayer, admit_budget, binding_error, diagnose, download_f32, driver_error, inject_cached_cuda, + read_cached_cuda, read_cuda, upload_f32, validate_layer, validate_streams, validate_values, +}; /// What one GR read consumes: the residual role being read, whose token/layer it belongs to and its streams. pub(super) struct GrReadSource<'streams> { 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 1bc8ae74..4a3a8c63 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GrPhase, GrScratch, ReadCandidate, RefCell, Result, diagnose, + download_f32, driver_error, validate_values, +}; pub(super) fn read_cached_cuda( context: &Context<'_>, 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 167e5ada..ef86c7e1 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,8 +1,10 @@ //! Methods of `OwnedReadWeights`: `upload`, `select`, `release`. //! Methods of `ReadWork`: `allocate`, `norm_down_silu`, `up_gates`, `release`. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DeviceBuffer, Error, GrPhase, GrWeights, ReadCandidate, Result, diagnose, diagnose_extrema, download_f32, + driver_error, upload_bf16, upload_f32, +}; pub(super) fn read_cuda( context: &Context<'_>, 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 470e7651..f19790c5 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,8 +1,7 @@ //! Methods of `ResidualReady`: `oracle_inject`, `validate_origin`, `identity`, `streams` and 1 more. //! Methods of `InjectedResidual`: `from_candidates`, `validate_origin`, `identity`, `streams`. -#[allow(unused_imports)] -use super::*; +use super::{BindingIdentity, Error, GrRole, InjectedResidual, ResidualReady, Result, TokenLayer, validate_streams}; impl ResidualReady { #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr_attention_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr_attention_chunk.rs index b7e2c532..3b8c63b5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr_attention_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr_attention_chunk.rs @@ -1,5 +1,9 @@ //! Actual immutable GR producer retained across attention projection columns. -use super::*; +use super::{ + Cell, Context, DeviceBuffer, Error, GrRead, GrRole, GrStage, InjectedResidual, ModelBinding, QwenStepTxn, Rc, + ResidualReady, Result, TokenLayer, admit_budget, download_f32, driver_error, upload_cached_f32, validate_streams, + validate_values, +}; pub(in crate::qwen_forward) struct DetachedGrRead { ready: ResidualReady, injected: Cell, 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 433988eb..b4b3ef8d 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 @@ -1,5 +1,10 @@ //! Closed prepared producer for the actual chunk FFN injection. -use super::*; +use super::{ + BindingIdentity, Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Dimension, DriverError, Error, + GrRead, GrRole, GrStage, InjectedResidual, LayerId, ModelBinding, PleReady, QwenStepTxn, Rc, ResidualReady, Result, + TokenLayer, admit_budget, download_f32, driver_error, upload_f32, validate_layer, validate_streams, + validate_values, +}; #[path = "gr_batch_chunk/gr_batch_operands.rs"] mod gr_batch_operands; pub(in crate::qwen_forward) use gr_batch_operands::{GrBatchScope, MicroBlockRequest}; 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 8801efd0..1c872fae 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,7 +1,9 @@ //! Phases of `GrStage::inject_batch` (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DenseWeightCache, DeviceBuffer, Error, GrBatchRow, GrBatchScope, GrRole, InjectedResidual, LayerId, + ModelBinding, Result, admit_budget, download_f32, driver_error, upload_f32, validate_streams, validate_values, +}; /// The packed streams, attention blocks and inject scalars of the validated consecutive rows. pub(super) struct BatchOperands { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr_batch_chunk/gr_batch_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr_batch_chunk/gr_batch_operands.rs index 36af237e..89110c8e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr_batch_chunk/gr_batch_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr_batch_chunk/gr_batch_operands.rs @@ -1,5 +1,5 @@ //! The operand groups of the GR batch and micro-window operations. -use super::*; +use super::{Context, DenseWeightCache, DetachedGrRead, ModelBinding, TokenLayer}; /// The model binding, the dense weight cache and the device context one GR batch operation is valid in; they /// always travel together. 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 b6f4945a..bcc85bf3 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 @@ -3,7 +3,12 @@ #[allow(unused_imports)] use super::super::super::dense_weight_cache::GrResident; -use super::*; +use super::{ + Cell, Context, DenseWeightCache, DetachedGrRead, DeviceBuffer, Dimension, Error, GrBatchScope, GrMicroAttention, + GrMicroAttentionBank, GrMicroAttentionBlock, GrMicroDevice, GrMicroInput, GrRole, GrStage, InjectedResidual, + LayerId, MicroBlockRequest, ModelBinding, PleReady, QwenStepTxn, Rc, ResidualReady, Result, TokenLayer, + micro_driver_error, save_micro_values, validate_layer, validate_values, +}; impl GrStage { pub(super) fn mint_micro_input( 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 a7cc5585..55f4351c 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 @@ -5,7 +5,10 @@ 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}; -use super::*; +use super::{ + Context, DenseWeightCache, DetachedGrRead, Error, GrBatchRow, GrBatchScope, GrRead, GrRole, GrStage, + InjectedResidual, ModelBinding, QwenStepTxn, ResidualReady, Result, TokenLayer, validate_streams, validate_values, +}; impl GrStage { pub(in crate::qwen_forward) fn prepare_detached_batch_injection( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr_retained_handoff/checks.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr_retained_handoff/checks.rs index 218731c2..8926b7cb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr_retained_handoff/checks.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr_retained_handoff/checks.rs @@ -1,7 +1,11 @@ //! Admission checks and the scratch lease of the retained attention -> FFN handoff (moved out of the parent file by //! STRA-338). -use super::*; +use super::{ + Cell, Context, DenseWeightCache, DetachedGrRead, Error, GrPhase, GrRole, GrScratch, InjectedResidual, ModelBinding, + QwenStepTxn, READ_DEVICE_BYTES, Rc, ReadCandidate, RefMut, ResidualReady, Result, TokenLayer, admit_budget, + diagnose, read_cached_cuda, validate_layer, validate_streams, validate_values, +}; pub(super) fn check_retained_origin( binding: &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 2de47d9e..399c35f7 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, Dimension, Error, GrRole, InjectedResidual, InputReady, InputStage, LayerId, + ModelBinding, PLE_HC, PLE_HISTORY, PleCandidate, PleMicroBatchReady, PleMicroInput, PlePending, PlePrior, PleReady, + PleResident, PleWeights, QwenStepTxn, Rc, Result, TokenLayer, binding_error, ple_budget, ple_cuda, + ple_driver_error, ple_transport, ple_values, +}; impl InputStage { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 52738791..7febeb4f 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,8 +1,10 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, DeviceBuffer, DriverError, Error, GrRole, InputReady, InputStage, ModelBinding, + PLE_HISTORY, PlePrior, PleState, QwenStepTxn, Rc, Result, Stage, ple_upload, ple_values, +}; pub(super) fn ple_upload_f32<'ctx>(context: &'ctx Context<'_>, values: &[f32]) -> Result> { let mut bytes = Vec::new(); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mod.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mod.rs index e954e26d..1f8ca8b6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mod.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mod.rs @@ -40,7 +40,7 @@ pub(crate) mod mtp_gr; pub(crate) mod q6_attention_columns; -mod chunk_modules; +mod chunk_module_owners; #[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(crate) mod layer0_mmq_observation; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu.rs index 79d87d64..ae61e48f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu.rs @@ -1,6 +1,10 @@ //! New retained Gate/Up lifecycle proof through actual projection/SwiGLU/Down. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use super::*; +use super::{ + Context, DenseFormat, DeviceBuffer, DriverError, Error, FF, MatrixDims, MoeMatrixKind, N, ProjectionKind, + ProjectionSpec, Result, RoutedFormat, download_f32, driver_error, finish_cached_mlp, launch_projection, + project_retained_gate_up, upload_bytes, upload_f32, +}; use leleka_cuda_driver::Driver; use std::cell::Cell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/encoded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/encoded.rs index 30a9a28a..2177729d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/encoded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/encoded.rs @@ -1,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DenseFormat, DeviceBuffer, DriverError, FF, MatrixDims, MoeMatrixKind, N, ProjectionKind, + ProjectionSpec, Result, RoutedFormat, download_f32, driver_error, finish_cached_mlp, launch_projection, + project_retained_gate_up, upload_bytes, upload_f32, +}; // Elements per block and bytes per block of a fixture format. fn block_geometry(kind: MoeMatrixKind) -> (usize, usize) { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs index 4ca35c3a..82e41d0d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs @@ -1,8 +1,11 @@ //! Methods of `DomainFixture`: `build`, `release`. //! Functions: `hidden_extrema`, `former_fixture_domain_refusal`, `nonfinite_hidden_refused`, `late_nan_projection_re... -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, DriverError, Error, FF, MatrixDims, MoeMatrixKind, N, compare_mlp, down_projection, + download_f32, encoded, finish_cached_mlp, launch_projection, project_retained_gate_up, raw, upload_bytes, + upload_f32, +}; struct DomainFixture<'ctx> { x: DeviceBuffer<'ctx>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down/retained_scalar.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down/retained_scalar.rs index 17e2405e..8d62a8f5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down/retained_scalar.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down/retained_scalar.rs @@ -1,8 +1,10 @@ //! Methods of `RetainedScalar`: `close`. Methods of `TransportBuffer`: `buffer`, `buffer_mut`, `close`, `release`. //! Implements `Drop for TransportBuffer`. -#[allow(unused_imports)] -use super::*; +use super::{ + DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, Result, RetainedDown, RetainedScalar, + ScaledDown, TransportBuffer, download_f32, driver_error, validate_values, +}; impl RetainedScalar<'_> { pub(in super::super) fn close(self) -> Result<()> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu.rs index 3d017d7b..043645a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu.rs @@ -1,7 +1,10 @@ //! New genuine Down/closed scalar/packed DOUBLE combine transport proof. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{upload_bytes, upload_f32}; -use super::*; +use super::{ + Cell, Context, DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, Result, RetainedDown, + RetainedScalar, ScaledDown, download_f32, driver_error, +}; use leleka_cuda_driver::{DenseFormat, Driver, ProjectionKind, ProjectionSpec}; #[test] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/down_reuse_refusal_rig.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/down_reuse_refusal_rig.rs index c6befe73..e62afd84 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/down_reuse_refusal_rig.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/down_reuse_refusal_rig.rs @@ -2,8 +2,10 @@ #[allow(unused_imports)] use super::pair::{Env, le_bytes}; -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, RetainedScalar, ScaledDown, + down_weights, project, refused, retained, scalar_weights, upload_bytes, upload_f32, +}; /// Scopes, inputs and the half-packed owner shared by the refusal phases. pub(super) struct Rig<'c> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/exact.rs index 610fcd73..4477606e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/exact.rs @@ -1,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DenseFormat, DeviceBuffer, DownScope, DownSelection, Error, N, ProjectionKind, ProjectionSpec, + Result, RetainedDown, download_f32, driver_error, upload_bytes, upload_f32, +}; pub(super) fn exact(a: &[f32], b: &[f32]) { assert_eq!(a.len(), b.len()); diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/pair.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/pair.rs index e056513e..3df0b0e4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/pair.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_down_reuse_gpu/pair.rs @@ -1,7 +1,9 @@ //! The two finite pair cases of the retained Down proof (one body per phase, STRA-338). -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, RetainedScalar, ScaledDown, + download_f32, exact, original_down, refused, retained, scalar_weights, upload_bytes, upload_f32, +}; /// Shared state of the proof: one context, the shared failure bit, the refusal counter and the routing weights. pub(super) struct Env<'c> { 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 5b55e826..e6236395 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 @@ -3,8 +3,12 @@ #[allow(unused_imports)] use super::moe_down::{RetainedScalar, ScaledDown}; -#[allow(unused_imports)] -use super::*; +use super::{ + ActualDown, ActualSlotPacket, BoundExpert, Cell, Context, DeviceBuffer, DownOrigin, DownProvenance, DownScope, + Error, ExpertActivation, K, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeWeightCache, N, PackedDown, Rc, + Result, RetainedDown, RoutedExperts, RoutedGateUpQ8, StepCuda, TokenLayer, TransportBuffer, binding_error, + cached_mlp_down, download_f32, driver_error, expert_mlp, upload_bytes, upload_f32, validate_values, +}; /// Shared scalar gate of the shared expert: the scalar buffer plus the uncached path's owned weight upload. fn shared_scalar_buffers<'ctx>( 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 59b2447a..3a2962a0 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 @@ -2,8 +2,10 @@ //! Split out of `moe_expert` to keep its files under the line limit. use super::expert_matrix_projection::{gate_up_dims, gate_up_prepared_format}; -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, Context, DeviceBuffer, ExpertActivation, ExpertMatrix, FF, MoeMatrixRole, MoeWeightCache, Result, + download_f32, driver_error, launch_cached_prepared, launch_cached_projection, project_matrix, upload_f32, +}; pub(super) fn expert_mlp( context: &Context<'_>, 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 99b2a563..8fd3e1c9 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,8 +1,13 @@ //! Methods of `ExpertReady`: `identity`, `output`, `validate_origin`, `from_completed`. //! Methods of `StepCuda`: `dispatch`, `dispatch_prepared`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, BoundExpert, Context, DeviceBuffer, Error, ExpertActivation, ExpertReady, GrRole, K, + KarExpertSource, KarSourceError, LayerId, ModelBinding, MoeExpertSelection, MoeExpertStage, MoeExpertWeights, + MoeWeightCache, N, QwenStepTxn, ResidualReady, Result, RoutedExperts, RoutedGateUpQ8, Stage, TokenLayer, + admit_budget, binding_error, driver_error, execute_cuda_cached, expert_mlp, finish_with_parts, upload_f32, + validate_values, +}; impl ExpertReady { pub(in super::super) fn identity(&self) -> TokenLayer { 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 eb5073d2..f2ffd2ae 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 @@ -2,8 +2,12 @@ //! Split out of `moe_expert` to keep its files under the line limit. use super::expert_matrix_projection::{MatrixDims, gate_up_dims, gate_up_prepared_format}; -#[allow(unused_imports)] -use super::*; +use super::{ + ActualDown, BoundExpert, CachedMoeMatrix, Context, DeclaredMatrix, DownOrigin, DownScope, DownSelection, Error, + ExpertActivation, ExpertMatrix, FF, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, + MoeWeightCache, N, Rc, Result, RetainedDown, TransportBuffer, binding_error, download_f32, driver_error, + launch_cached_prepared, launch_cached_projection, +}; fn check_origin(origin: &DownOrigin, binding: &ModelBinding, weights: &MoeExpertWeights) -> Result<()> { if !origin.binding.matches(&binding.identity()) 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 dcffa8a3..06f1e390 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,8 +1,7 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{Context, DeviceBuffer, DriverError, Error, InputBindingError, Result, Stage}; pub(super) fn validate_values(values: &[f32], expected: usize) -> Result<()> { if values.len() != expected { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive.rs index 3e1d26e9..faf97a51 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive.rs @@ -1,6 +1,10 @@ //! Separate whole-expert resident GPU / owned native CPU miss producer. //! Only genuine completed rows reach the original ascending-slot combine. -use super::*; +use super::{ + ActualDown, ChunkFfnRow, CompletedCpuRow, Context, DownOrigin, DownScope, DownSelection, Error, ExpertGroup, K, + ModelBinding, MoeExpertSelection, MoeMatrixRole, MoeWeightCache, N, Pair, QwenChunkTxn, Rc, Result, RoutedGateUpQ8, + Stage, binding_error, project_group, +}; #[path = "moe_group_adaptive/adaptive_wave.rs"] mod adaptive_wave; use crate::model_binding::qwen4exp_input::{MoeRoutedSourceScope, MoeWeightDescriptor}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive/adaptive_wave.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive/adaptive_wave.rs index 5d7f634f..0949206d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive/adaptive_wave.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive/adaptive_wave.rs @@ -1,7 +1,9 @@ //! The adaptive wave: resident GPU groups beside owned CPU miss batches (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + ActualDown, ChunkFfnRow, Context, DownOrigin, DownScope, Error, ExpertGroup, K, ModelBinding, MoeWeightCache, Pair, + QwenChunkTxn, Rc, Result, RoutedGateUpQ8, Stage, miss_batch_end, prepare_cpu_jobs, project_group, +}; use crate::qwen_forward::cpu_expert_miss::{CpuMissRows, CpuMissWorkspace, runtime_error}; /// The shared inputs of one adaptive wave: resident groups on the GPU, misses on the owned CPU pool. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets.rs index 80faab85..efa20dfd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets.rs @@ -1,6 +1,10 @@ //! Selected adaptive resident queue / owned native CPU misses into real packets. //! No coverage is published before completed transport and current-row checks. -use super::*; +use super::{ + ActualSlotPacket, ChunkFfnRow, CompletedCpuRow, Context, DeviceBuffer, DownOrigin, DownScope, DownSelection, Error, + ModelBinding, MoeExpertSelection, MoeWeightCache, N, PacketGroupMembers, Pair, QwenChunkTxn, Rc, Result, + RoutedGateUpQ8, Stage, binding_error, driver_error, resident_queue, validate_packet_pairs, +}; use crate::qwen_forward::cpu_expert_miss::runtime_error; #[path = "moe_group_adaptive_packets/adaptive_packet_projection.rs"] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/adaptive_packet_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/adaptive_packet_projection.rs index 62897b4f..f91c557d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/adaptive_packet_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/adaptive_packet_projection.rs @@ -3,8 +3,7 @@ use super::super::direct_packets_fns::PacketRun; use super::super::packet_run_project_group_direct::DirectRun; -#[allow(unused_imports)] -use super::*; +use super::{Error, MoeWeightCache, Result, project_inner}; /// Project every expert group of one batch into its slot packets, then drain the ephemeral routed owner whatever the /// outcome. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/gpu_wave_staging.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/gpu_wave_staging.rs index c53833fd..e42b4b60 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/gpu_wave_staging.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/gpu_wave_staging.rs @@ -1,8 +1,7 @@ //! The staging step of the GPU miss queue of one adaptive packet wave. use super::packet_wave::{GpuWave, PacketWave}; -#[allow(unused_imports)] -use super::*; +use super::{Error, MoeWeightCache, Result, Stage, binding_error}; impl PacketWave<'_, '_> { /// Stage the next GPU misses into the free ephemeral slots of the queue. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_plan.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_plan.rs index 9ad2a264..40a94fd1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_plan.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_plan.rs @@ -2,8 +2,10 @@ use super::super::direct_packets_fns::PacketRun; use super::packet_wave::PacketWave; -#[allow(unused_imports)] -use super::*; +use super::{ + ActualSlotPacket, ChunkFfnRow, Error, ModelBinding, MoeExpertSelection, MoeWeightCache, PacketGroupMembers, Pair, + QwenChunkTxn, Result, binding_error, validate_packet_pairs, +}; /// The expert groups of one wave split into resident GPU groups, CPU miss batches and the GPU miss queue. pub(super) struct PacketPlan<'g> { pub(super) residents: Vec<&'g [Pair]>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave.rs index 33a50388..cdcacae6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave.rs @@ -2,8 +2,11 @@ use super::super::adaptive::{miss_batch_end, prepare_cpu_jobs, source_keys}; use super::super::packet_run_project_group_direct::DirectRun; -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkFfnRow, CompletedCpuRow, Context, DeviceBuffer, DownOrigin, DownScope, DownSelection, Error, ModelBinding, + MoeWeightCache, N, Pair, QwenChunkTxn, Rc, Result, RoutedGateUpQ8, Stage, binding_error, driver_error, + resident_queue, runtime_error, +}; use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; use crate::qwen_forward::cpu_expert_miss::{CpuMissRows, CpuMissWorkspace}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave_projection.rs index bb1e2a4e..f51e597e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_adaptive_packets/packet_wave_projection.rs @@ -5,8 +5,7 @@ use super::super::direct_packets_fns::PacketRun; use super::super::packet_run_project_group_direct::DirectRun; use super::packet_plan::PacketPlan; use super::packet_wave::{GpuWave, PacketWave}; -#[allow(unused_imports)] -use super::*; +use super::{ChunkFfnRow, Context, Error, ModelBinding, MoeWeightCache, Result}; /// Classify the groups, stage the GPU misses, run the CPU miss batches and finish the GPU queue. pub(super) fn project_inner<'ctx>( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/bound_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/bound_rows.rs index ac79b601..d540abb7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/bound_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/bound_rows.rs @@ -2,8 +2,14 @@ use super::direct_packets_fns::PacketRun; use super::finish_shared_with::RowTail; -#[allow(unused_imports)] -use super::*; +use super::{ + ActualDown, ChunkFfnRow, Context, DownOrigin, DownScope, Error, ExpertGroup, ExpertReady, K, ModelBinding, + MoeExpertSelection, MoeWeightCache, PackedDown, Pair, QwenChunkTxn, Rc, Result, RoutedGateUpQ8, Stage, StepCuda, + 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_group_chunk/direct_packets_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/direct_packets_fns.rs index 7555923d..e28173f3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/direct_packets_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/direct_packets_fns.rs @@ -3,7 +3,13 @@ use super::finish_shared_with::RowTail; use super::ordered_down_refusal::close_packets; use super::packet_run_project_group_direct::DirectRun; -use super::*; +use super::{ + ActualSlotPacket, ChunkFfnRow, Context, DownOrigin, DownScope, Error, ExpertReady, ModelBinding, MoeWeightCache, + 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_group_chunk/execute_bound.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/execute_bound.rs index e726cc28..698fb918 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/execute_bound.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/execute_bound.rs @@ -2,8 +2,11 @@ //! Split out of `grouped` to keep its files under the line limit. use super::bound_rows::{BoundRows, DirectPacketInputs}; -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, ChunkFfnLayer, ChunkFfnRow, Context, DEVICE_PEAK, DownScope, Error, ExpertReady, FF, K, ModelBinding, + MoeExpertSelection, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, N, Rc, Result, RoutedGateUpQ8, Stage, + TransportBuffer, admit_budget, binding_error, driver_error, use_direct_packets, +}; pub(super) fn execute_bound<'ctx>( context: &Context<'_>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/finish_shared_with.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/finish_shared_with.rs index 125fad39..d1e0bb83 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/finish_shared_with.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/finish_shared_with.rs @@ -1,8 +1,10 @@ //! Methods of `SharedOwners`: `scale_shared`, `combine_with`, `close_all`. //! Functions: `finish_shared_with`, `uses_adaptive`. Defines `RowTail`, `SharedOwners`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, Context, DeviceBuffer, DownOrigin, DownProvenance, DownScope, Error, ExpertActivation, K, + ModelBinding, MoeExpertSelection, MoeWeightCache, PreparedMoeRow, Rc, Result, cached_mlp_down, +}; /// What the shared-expert tail of one row reads besides the weight cache: the row, its activation, the Down scope and /// the row's origin. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/ordered_down_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/ordered_down_refusal.rs index 615f57cc..b4fe4bbc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/ordered_down_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/ordered_down_refusal.rs @@ -3,7 +3,13 @@ use super::finish_shared_with::RowTail; use super::packet_run_project_group_direct::{DownProjection, RefusalReplay}; -use super::*; +use super::{ + ActualSlotPacket, ChunkFfnRow, Context, DeviceBuffer, DownOrigin, DownScope, DownSelection, Error, FF, K, + 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_group_chunk/packet_run_project_group_direct.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/packet_run_project_group_direct.rs index 0f24ce3c..ba0e14ad 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/packet_run_project_group_direct.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/packet_run_project_group_direct.rs @@ -4,7 +4,14 @@ use super::direct_packets_fns::PacketRun; #[allow(unused_imports)] use super::project_group_shared_fns::*; -use super::*; +use super::{ + ActualSlotPacket, CachedMoeMatrix, ChunkFfnRow, Context, DeviceBuffer, DownColumns, DownOrigin, DownScope, + DownSelection, Error, FF, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, + 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_group_chunk/prepared_moe_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/prepared_moe_row.rs index 69d0045e..448ef6b3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/prepared_moe_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/prepared_moe_row.rs @@ -2,8 +2,11 @@ //! Methods of `MoeExpertStage`: `prepare_chunk_row`, `prepare_chunk_row_detached`, `execute_chunk`, `execute_chunk_n... use super::bound_rows::DirectPacketInputs; -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, ChunkFfnRow, Context, DetachedGrRead, Error, ExpertReady, GrRole, GrStage, K, LayerId, + ModelBinding, MoeExpertStage, MoeWeightCache, N, Pair, PreparedMoeRow, QwenChunkTxn, QwenStepTxn, Result, + RoutedExperts, binding_error, execute_bound, prompt_finish, use_direct_packets, validate_values, +}; /// The FFN rows of one chunk layer together with the binding they were sealed against. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group.rs index 27a60b66..ec7e21fb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group.rs @@ -7,7 +7,12 @@ 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, }; -use super::*; +use super::{ + ActualDown, CachedMoeMatrix, ChunkFfnRow, Context, DeviceBuffer, DownColumns, DownOrigin, DownScope, DownSelection, + Error, FF, K, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, MoeWeightCache, + Pair, Rc, Result, RetainedDown, RoutedFormat, RoutedGateUpQ8, Stage, TransportBuffer, download_f32, driver_error, + dual_routed_format, ordered_down_refusal, use_direct_packets, uses_adaptive, +}; /// One expert's row/slot pairs against the chunk rows, the Down scope and the Down origin of every row. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_shared_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_shared_fns.rs index 9f8ceff9..c5921b7b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_shared_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_shared_fns.rs @@ -1,7 +1,10 @@ //! Helpers shared by the resident, direct and source Down groups (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + ActualSlotPacket, CachedMoeMatrix, ChunkFfnRow, Context, DeviceBuffer, DownColumns, DownScope, DriverError, Error, + FF, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, MoeMatrixRole, Pair, Result, RoutedFormat, + RoutedGateUpQ8, Stage, TransportBuffer, binding_error, driver_error, dual_routed_format, +}; /// All three native matrix descriptors must match across the group's pairs. pub(super) fn check_group_descriptors( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_consumers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_consumers.rs index 0433341e..c201cdc5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_consumers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_consumers.rs @@ -10,8 +10,13 @@ use super::project_group_shared_fns::{ GateUpColumns, close_group_buffers, down_kind_format, down_outcome, gate_up_format, hidden_buffer, launch_down_in_workspace, packet_targets, prepared_refs, swiglu_into_hidden, }; -#[allow(unused_imports)] -use super::*; +use super::{ + CachedMoeMatrix, DeviceBuffer, DownColumns, DownSelection, Error, FF, MoeMatrixRole, MoeWeightCache, + 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_group_chunk/project_group_source_fenced.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_fenced.rs index 984d3ac1..04722779 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_fenced.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_chunk/project_group_source_fenced.rs @@ -5,8 +5,10 @@ use super::direct_packets_fns::PacketRun; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::packet_run_project_group_direct::{DirectGroup, DirectRun}; -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkFfnRow, Error, MoeExpertSelection, MoeExpertWeights, MoeWeightCache, PacketGroupMembers, Pair, Result, + binding_error, project_group_source_consumers, validate_packet_pairs, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] fn source_members<'a>(rows: &'a [ChunkFfnRow], pairs: &[Pair]) -> Result> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_resident_queue.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_resident_queue.rs index d721ce35..a7a8f56d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_resident_queue.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_group_resident_queue.rs @@ -3,7 +3,12 @@ use super::adaptive_packets::PacketWave; use super::packet_run_project_group_direct::{DirectGroup, DirectRun, DownProjection, RefusalReplay}; use super::project_group_shared_fns::{down_format, gate_up_format, packet_targets}; use super::project_group_source_consumers::{SourceTail, check_source_members}; -use super::*; +use super::{ + CachedMoeMatrix, DeviceBuffer, DownSelection, Error, FF, MoeExpertSelection, MoeExpertWeights, MoeMatrixKind, + MoeMatrixRole, MoeWeightCache, PacketGroupMembers, Pair, Rc, Result, RoutedFormat, RoutedGateUpQ8, Stage, + binding_error, download_f32, driver_error, ordered_down_refusal, use_direct_packets, uses_adaptive, + validate_packet_pairs, +}; use crate::model_binding::qwen4exp_input::MoeRoutedSourceScope; use crate::qwen_forward::moe_weight_cache::{RoutedResidentOwner, RoutedSourceHealth, TripletLoanRequest}; use leleka_cuda_driver::{RoutedResidentOutputs, RoutedResidentQueue, RoutedResidentRefusal, RoutedResidentWeights}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive.rs index 75e2ab26..e5464cd5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive.rs @@ -1,6 +1,9 @@ //! Original prompt MMQ consumers of actual adaptive or completed staging slots. //! Cache policy and staging ownership stay outside the MMQ numerical products. -use super::*; +use super::{ + Cell, ChunkFfnRow, Context, DeviceBuffer, Error, K, LayerId, ModelBinding, MoeExpertSelection, MoeExpertWeights, + MoeMatrixRole, MoeWeightCache, Pair, QwenChunkTxn, Result, SlotPacks, Stage, binding_error, mmq_error, +}; use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; use crate::qwen_forward::moe_weight_cache::original_dual_layout; use leleka_cuda_driver::{MmqWorkspace, OriginalMmqLayer}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/expert_gather.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/expert_gather.rs index 6a92559a..99ee650f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/expert_gather.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/expert_gather.rs @@ -1,8 +1,11 @@ //! Gather of one expert's matrices into the admitted bank (STRA-338 size: extract-method only). use super::layer_walk::{ExpertGroup, Walk, WalkOwners}; -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, ChunkFfnRow, DeviceBuffer, Error, LayerId, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, + MoeWeightDescriptor, OriginalMmqLayer, Pair, QwenChunkTxn, Result, Stage, binding_error, mmq_error, + original_dual_layout, +}; impl<'ctx> Walk<'_, '_, 'ctx> { /// Gather one expert's three matrices into the admitted bank, from the adaptive owner or its staged slot. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/layer_walk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/layer_walk.rs index e29fbb8b..cc91aede 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/layer_walk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_adaptive/layer_walk.rs @@ -1,7 +1,10 @@ //! The adaptive prompt layer walk over staged and resident experts (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkFfnRow, Context, DeviceBuffer, Error, LayerId, ModelBinding, MoeExpertSelection, MoeMatrixRole, + MoeWeightCache, OriginalMmqLayer, Pair, QwenChunkTxn, Result, SlotPacks, Stage, binding_error, mmq_error, + original_dual_layout, +}; /// Fixed metadata, independent of route frequency: which experts are resident and which miss. pub(super) struct Classified { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk.rs index 229af430..1ed21f13 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk.rs @@ -1,7 +1,12 @@ //! Explicit experimental adaptive MMQ chunk producer. Native T1 stays native. //! Real sealed rows, one source/Q8 layer batch, real group leases, one slotpack. use super::resident_slotpack::{SealedLayer, SlotPacks}; -use super::*; +use super::{ + BoundExpert, Cell, ChunkFfnLayer, ChunkFfnRow, Context, DEVICE_PEAK, DeviceBuffer, DownScope, DriverError, Error, + ExpertReady, K, LayerId, MmqChunkRequest, ModelBinding, MoeExpertSelection, MoeExpertStage, MoeExpertWeights, + MoeMatrixKind, MoeMatrixRole, MoeWeightCache, N, Pair, QwenChunkTxn, Rc, Result, Stage, TransportBuffer, + binding_error, driver_error, grouped_pairs, +}; use leleka_cuda_driver::MmqWorkspace; #[path = "moe_mmq_chunk/admission_fns.rs"] mod admission_fns; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/admission_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/admission_fns.rs index 6631e7ba..30008f40 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/admission_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/admission_fns.rs @@ -1,7 +1,9 @@ //! Support and descriptor admission of one MMQ chunk (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkFfnRow, Error, K, LayerId, ModelBinding, MoeExpertSelection, MoeMatrixKind, MoeMatrixRole, QwenChunkTxn, + Result, binding_error, +}; use crate::model_binding::qwen4exp_input::MoeWeightDescriptor; /// Whether every routed slot of every row has an MMQ-capable Gate/Up/Down kind. `supported` is the starting verdict. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/resident_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/resident_layer.rs index 7a37a299..4ce4ac08 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/resident_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_chunk/resident_layer.rs @@ -1,7 +1,10 @@ //! The resident MMQ chunk execution (STRA-338 size: extract-method only). -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, Cell, ChunkFfnRow, Context, DEVICE_PEAK, DeviceBuffer, DownScope, Error, ExpertReady, K, LayerId, + MmqWorkspace, ModelBinding, MoeExpertSelection, MoeMatrixRole, MoeWeightCache, N, Pair, QwenChunkTxn, Rc, Result, + SealedLayer, SlotPacks, Stage, TransportBuffer, binding_error, grouped_pairs, mmq_error, +}; use leleka_cuda_driver::MmqChunkActivation; /// The sealed rows of one resident MMQ layer batch. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_slotpack.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_slotpack.rs index 216a8dce..83688bf1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_slotpack.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_mmq_slotpack.rs @@ -1,7 +1,11 @@ //! Closed real chunk route -> finite producer copy -> original ordered combine. //! No constructors are exported outside the private resident FFN stage. use super::super::moe_down::ResidentPackedDown; -use super::*; +use super::{ + ChunkFfnRow, Context, DeviceBuffer, DownOrigin, DownScope, Error, ExpertReady, K, LayerId, ModelBinding, + MoeWeightCache, Pair, QwenChunkTxn, Rc, Result, RowTail, Stage, finish_shared_queued, finish_shared_with, + use_shared_tail, +}; pub(super) struct GroupOrigin { owner: Rc<()>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prompt_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prompt_finish.rs index 93a9c37a..51645224 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prompt_finish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prompt_finish.rs @@ -4,7 +4,10 @@ use super::super::super::moe_prefill_batch::{ CombineInput, CombineWindow, MoeMicroProducts, MoePrefillStage, PrefillLoans, }; use super::super::moe_down::ResidentPackedDown; -use super::*; +use super::{ + ChunkFfnRow, Context, DeviceBuffer, DownScope, Error, ExpertReady, K, LayerId, ModelBinding, MoeWeightCache, N, + QwenChunkTxn, Result, Stage, TokenLayer, TransportBuffer, download_f32, driver_error, +}; pub(in crate::qwen_forward) struct NativePromptFinish<'loan, 'ctx, 'dense> { pub(in crate::qwen_forward) products: &'loan mut MoeMicroProducts<'ctx>, 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 d2aeb334..07e81d07 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,8 +1,11 @@ //! Functions: `activation_bytes`, `upload_router_matrix`, `finish_logits`, `project_logits` and 9 more. //! Defines `RouterInput`. -#[allow(unused_imports)] -use super::*; +use super::{ + Bf16ProjectionShape, BindingIdentity, COLUMNS, Context, DenseWeightCache, Dimension, EXPERTS, Error, ExpertId, + FiniteF32, InputBindingError, LayerId, ModelBinding, MoeRouteWeights, QwenStepTxn, Result, RoutedExperts, + RouterLogits, SELECTED, Stage, TILE_ROWS, TokenId, TokenLayer, map_driver_error, +}; use leleka_cuda_driver::DeviceBuffer; fn activation_bytes(activation: &[f32]) -> [u8; COLUMNS * 4] { 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 1c6949c1..3d1b0543 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,8 +1,12 @@ //! Methods of `RouterLogits`: `from_preceding`, `fixture`. //! Methods of `RoutedExperts`: `new`, `identity`, `experts`, `weights` and 2 more. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, COLUMNS, Context, DenseWeightCache, EXPERTS, Error, ExpertId, FiniteF32, GrRole, LayerId, + ModelBinding, MoeRouteStage, MoeRouteWeights, PROJECTION_BYTES, Position, QwenStepTxn, ResidualReady, Result, + RoutedExperts, RouterInput, RouterLogits, SELECTED, TokenId, TokenLayer, binding_error, project_logits, route_with, + run_cuda, validate_logits, validate_request, +}; impl RouterLogits { /// Called only by the preceding router-logit producer after it has computed 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 e7093f6e..275f36da 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,8 +1,11 @@ //! Methods of `MoeWeightCache`: `routed_output_owner`, `uses_mapped_expert_source`, `ephemeral_routed_owner`, `route... //! Functions: `triplet_keys`, `adaptive_raw_triplet`. -#[allow(unused_imports)] -use super::*; +use super::{ + CachedMoeMatrix, Context, DeviceBuffer, Error, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, + MoeWeightCache, MoeWeightDescriptor, Rc, RefCell, Result, RoutedResidentOwner, RoutedSourceHealth, binding_error, + cache_ephemeral_routed, cache_routed_outputs, cache_strata_adaptive, +}; /// The Gate/Up/Down descriptors of one group member, in role order. fn triplet_keys( 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 1e80d504..c2212ca6 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,8 +1,16 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, CachedMoeMatrix, Cell, Context, Dense, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, + FixedMtpWeights, HashMap, LruIndex, MTP_DENSE_LIMIT, MTP_INPUT_WORKSPACE_BYTES, MTP_PACK_EXPERT_BANK_BYTES, + MmqChunkAdmission, MmqChunkRequest, MmqFormat, MmqRoutingPolicy, MmqWeights, MmqWorkspace, ModelBinding, + MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, MtpExpertPicks, + MtpInputWorkspaceOwner, MtpKind, MtpKvClaim, MtpKvResident, MtpRole, MtpStepSite, PendingMtpKv, PreparedUpdates, + Rc, RefCell, Result, RoutedFiniteOwner, RoutedSourceHealth, RoutedWorkspaceOwner, SharedTailRow, + SharedWeightsRequest, SourceMatrix, WORKING_RESERVE, WeightCacheCounters, binding_error, driver_error, dual_layout, + integer_iq3_triplet, oldest_weight, original_dual_layout, original_mmq_triplet, room_fits, +}; #[path = "moe_weight_cache_methods/moe_cache_close_owners.rs"] mod moe_cache_close_owners; 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 bc6a0b85..2dafb974 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,8 +1,7 @@ //! Methods of `MoeWeightCache`: `close_original_owners`, `close_original_owners`, `close_shared_owners`, `close_work... //! Functions: `close_shared`. -#[allow(unused_imports)] -use super::*; +use super::{Error, MoeWeightCache, Rc, Result}; /// A shared owner closes only when this cache holds its last reference; any other holder counts as a failed close. fn close_shared(owner: Rc, close: impl FnOnce(T) -> bool) -> bool { 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 7828b03a..e2733f83 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 @@ -3,8 +3,10 @@ use super::super::super::shared_expert_workspace::{SharedTailInputs, SharedTailKeys, WorkspaceOwner}; use super::moe_cache_lru_updates::shared_keys::{raw_shared_buffers, shared_descriptors}; -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, Error, FixedMtpWeights, MmqWorkspace, ModelBinding, MoeWeightCache, MtpExpertPicks, + MtpKvClaim, MtpRole, MtpStepSite, PendingMtpKv, Rc, Result, SharedTailRow, room_fits, +}; use crate::qwen_forward::mtp_experts::fixed_workspace::{ExpertInputs, FrameAnchor, WorkspaceClaim}; impl<'ctx> MoeWeightCache<'ctx> { 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 2f31b170..7b850ed3 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DeviceBuffer, EncodedWeight, Entry, Error, HashMap, LruIndex, ModelBinding, MoeExpertSelection, + MoeExpertWeights, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, PreparedUpdates, Result, + SharedWeightsRequest, binding_error, oldest_weight, +}; #[path = "moe_cache_lru_updates/shared_keys.rs"] pub(super) mod shared_keys; 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 58b8dc53..4fc406e1 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,8 +1,10 @@ //! The four shared-expert descriptors, their fill and their raw buffers: common to the native shared-weights loan and //! the target shared tail. -#[allow(unused_imports)] -use super::*; +use super::{ + DeviceBuffer, EncodedWeight, Entry, Error, HashMap, ModelBinding, MoeExpertSelection, MoeExpertWeights, + MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, Result, binding_error, +}; const SHARED_ROLES: [MoeMatrixRole; 3] = [MoeMatrixRole::Gate, MoeMatrixRole::Up, MoeMatrixRole::Down]; 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 c66edb54..af6fc8c2 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + CachedMoeMatrix, DeviceRef, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, ModelBinding, MoeMatrixRole, + MoeWeightCache, MoeWeightDescriptor, PreparedUpdates, Result, RoutedSourceHealth, SourceMatrix, binding_error, + driver_error, +}; #[path = "moe_cache_main_entry_routed_source/fill_fns.rs"] pub(super) mod fill_fns; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs index 11bae258..6ce985b5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source/fill_fns.rs @@ -1,8 +1,10 @@ //! The one fill path of the main weight cache: lookup, miss admission, weight construction and publication. The three //! public entries differ only in how room is made and how a dual weight is built from the bytes. -#[allow(unused_imports)] -use super::*; +use super::{ + CachedMoeMatrix, DeviceRef, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, MoeWeightCache, + MoeWeightDescriptor, PreparedUpdates, Result, driver_error, +}; /// How a miss makes room: plain eviction, or eviction that never takes a descriptor the caller still lends. #[derive(Clone, Copy)] 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 c9ea1914..3db41975 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + CachedMoeMatrix, Context, DeviceBuffer, Error, MTP_INPUT_WORKSPACE_BYTES, ModelBinding, MoeExpertSelection, + MoeExpertWeights, MoeMatrixRole, MoeWeightCache, MtpInputWorkspaceOwner, MtpKind, MtpRole, Rc, Result, + WeightCacheCounters, binding_error, +}; impl<'ctx> MoeWeightCache<'ctx> { pub(in super::super::super) fn matrix( 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 0bffb767..ec011233 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,8 +1,11 @@ //! Methods of `MoeWeightCache`: `note_test_mmq_dispatch`, `mmq_context`, `weight_layout`, `has_original_prompt_mmq` ... //! Functions: `admit_triplets`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, Context, Error, MmqChunkAdmission, MmqChunkRequest, MmqFormat, MmqRoutingPolicy, MmqWeights, + MmqWorkspace, ModelBinding, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, Rc, Result, binding_error, + driver_error, dual_layout, integer_iq3_triplet, original_dual_layout, original_mmq_triplet, +}; /// Every triplet of the window passes the policy's kind admission; the first refused one declines the whole chunk. fn admit_triplets(triplets: &[[MoeWeightDescriptor; 3]], rows: usize, original_prompt: bool) -> Result { 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 1ec88c96..de242680 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,8 +1,11 @@ //! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile_mtp_input_spill_floo... //! Functions: `dense_f32_words`. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, Dense, Error, HashMap, MTP_DENSE_LIMIT, MTP_PACK_EXPERT_BANK_BYTES, MmqRoutingPolicy, ModelBinding, + MoeWeightCache, MtpKind, MtpKvResident, MtpRole, Rc, RefCell, Result, WeightCacheCounters, binding_error, + driver_error, room_fits, +}; /// The unfilled cache of one binding/context: every owner empty, every counter zero. The field list is a data literal /// of the cache struct, kept out of the constructor's body. 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 220f9ffd..a9898858 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, Error, LruIndex, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Rc, RefCell, Result, + RoutedFiniteOwner, RoutedWorkspaceOwner, +}; impl<'ctx> MoeWeightCache<'ctx> { /// Explicit candidate-only target tail. The fixed owner is admitted while 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 f3174a3c..ca172969 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,8 +1,11 @@ //! Methods of `MoeWeightCache`: `with_integer_mmq_triplet`, `triplet_fill`, `triplet_owners`, `triplet_admit` and 16... //! Functions: `read_triplet`. Defines `TripletAccounting`, `TripletPlan`. -#[allow(unused_imports)] -use super::*; +use super::{ + BoundExpert, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, ModelBinding, MoeExpertSelection, + MoeExpertWeights, MoeMatrixRole, MoeWeightCache, MoeWeightDescriptor, Result, WORKING_RESERVE, binding_error, + driver_error, integer_iq3_triplet, original_mmq_triplet, room_fits, +}; const TRIPLET_ROLES: [MoeMatrixRole; 3] = [MoeMatrixRole::Gate, MoeMatrixRole::Up, MoeMatrixRole::Down]; 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 cc278679..2518e367 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 @@ -2,8 +2,10 @@ //! Split out of `moe_weight_cache_methods` to keep its files under the line limit. use super::moe_cache_main_entry_routed_source::fill_fns::Room; -#[allow(unused_imports)] -use super::*; +use super::{ + CachedMoeMatrix, Context, DeviceBuffer, Error, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, + WORKING_RESERVE, driver_error, room_fits, +}; impl<'ctx> MoeWeightCache<'ctx> { fn owners_failed(&self) -> bool { 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 387176bf..80a421cf 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,8 +1,7 @@ //! Methods of `RoutedSourceHealth`: `validate`. //! Methods of `MoeWeightCache`: `note_permanent_lookup`, `note_permanent_hit`, `note_permanent_fill`, `note_permanen... -#[allow(unused_imports)] -use super::*; +use super::{Context, Error, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, RoutedSourceHealth}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl 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 ba6800a6..ff50ccfb 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Cell, Context, Error, MTP_INPUT_WORKSPACE_BYTES, MtpInputWorkspace, MtpInputWorkspaceOwner, + RefCell, Result, RoutedGroupWorkspace, RoutedResidentOwner, RoutedWorkspaceOwner, driver_error, +}; impl<'ctx> RoutedWorkspaceOwner<'ctx> { #[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/validate_ranked_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs index 9002e713..0b123d07 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,8 +1,10 @@ //! Methods of `EncodedWeight`: `close`. //! Methods of `RoutedFiniteOwner`: `new`, `matches_context`, `is_failed`, `check_stage` and 1 more. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, EncodedWeight, Error, MAIN_LIMIT, MmqFormat, MoeWeightDescriptor, RefCell, Result, + RoutedFiniteOwner, RoutedFiniteStage, WORKING_RESERVE, cache_profile, driver_error, +}; /// Pure, bounded profile admission before Driver load; no device capability. #[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/window_pins.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/window_pins.rs index c2494e94..641d4d0b 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,7 +7,15 @@ //! `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::*; +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, +}; /// 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/mtp_frame.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs index c94e2d16..2e987f06 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,8 +1,12 @@ //! Methods of `MtpFrame`: `within_bounds`, `validate`, `token`, `position` and 1 more. //! Methods of `MtpInput`: `from_previous`, `frame`, `streams`, `from_target` and 5 more. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DeviceBuffer, Dimension, Error, KnownNext, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, MtpKind, + MtpRole, MtpSession, MtpStepProduct, Position, PrefillStepProduct, QwenSession, Rc, Result, Stage, + TargetStepProduct, TokenId, allocate, binding_error, download, driver_error, f32_weights, norm, preflight, project, + release, reserve, upload, validate_values, +}; impl MtpFrame { fn within_bounds(&self) -> Result { 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 cd1e2f04..6c915119 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,8 +1,10 @@ //! Functions: `project_gated`, `project_attention_out_numeric`. //! Split out of `mtp` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseFormat, DeviceBuffer, Error, ProjectionKind, ProjectionSpec, Result, allocate, download, + driver_error, preflight, +}; const ROWS: usize = 2560; const COLUMNS: usize = 6144; 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 c341cd3d..e71200c7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs @@ -1,8 +1,12 @@ //! Methods of `MtpFinalMixed`: `from_native_mixer`, `frame`, `values`. //! Functions: `step`, `warm_step`, `warm_chunk_row`, `run_blocks` and 12 more. Defines `MtpBlocks`. -#[allow(unused_imports)] -use super::*; +use super::{ + Bf16ProjectionShape, Cell, Context, DenseFormat, DeviceBuffer, Error, ModelBinding, MoeWeightCache, MtpChunkStage, + MtpFinalMixed, MtpFrame, MtpInput, MtpKind, MtpRole, MtpSession, MtpStepProduct, ProjectionKind, ProjectionSpec, + QwenSession, Rc, Result, Stage, StepSessions, allocate, download, driver_error, project_attention_out_numeric, + release, upload, validate_values, +}; pub(in super::super) fn step( binding: &ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention_reuse_gpu.rs index 5fb74648..b1e681d5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention_reuse_gpu.rs @@ -1,6 +1,11 @@ //! 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::*; +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, +}; use leleka_cuda_driver::{DenseFormat, Driver, ProjectionKind, ProjectionSpec}; fn exact(left: &[f32], right: &[f32]) { 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 0cba07f7..723120dc 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,8 +1,9 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{Error, MoeWeightCache, MtpWindowError, Result}; +#[cfg(all(test, target_arch = "x86_64"))] +use super::batch_gpu; // 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 6db17283..d275798c 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,10 +1,10 @@ -//! Groups the submodules `batched_support`, `batched_window`, `draft_warm_and_window` and 1 more. -//! Split out of `mtp_decode` to keep its files under the line limit. +//! 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::*; -mod batched_support; +mod batched_window_plan; mod batched_window; mod draft_warm_and_window; mod scalar_window; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window.rs index 9ecf510a..86f1f904 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window.rs @@ -7,7 +7,7 @@ use super::{ window_stage_error, }; -use super::batched_support::*; +use super::batched_window_plan::*; use crate::qwen_forward::mtp::RetainedFirstSeed; impl MtpDecoder { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_support.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs similarity index 92% rename from crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_support.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs index 2ec3a737..98b16cc6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_support.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_decoder/batched_window_plan.rs @@ -1,7 +1,12 @@ -//! Plan, context and state of one batched MTP window (STRA-338 size: extract-method only). +//! 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. -#[allow(unused_imports)] -use super::*; +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_expert_transport_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu.rs index cb631d51..4440e004 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu.rs @@ -1,7 +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}; -use super::*; +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_expert_transport_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/exact.rs index 4c85019d..020194da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/exact.rs @@ -1,8 +1,13 @@ //! Methods of `Env`: `compare_observed`. Functions: `exact`, `bytes`, `fill_blob_part`, `bank_fixture` and 12 more. //! Defines `SharedStage`. -#[allow(unused_imports)] -use super::*; +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_expert_transport_gpu/owner_guards.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/owner_guards.rs index e06464f4..781050cf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/owner_guards.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/owner_guards.rs @@ -1,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, Env, Error, IDS, Packed, ROUTE, Role, RoutedExpert, Transport, refusal, routed, + shared, shared_project, +}; type Count<'a> = &'a Cell; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/phases.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/phases.rs index 56379165..e3ba0046 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/phases.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_transport_gpu/phases.rs @@ -1,7 +1,9 @@ //! The phases of the retained MTP expert transport proof (one body per phase, STRA-338). -#[allow(unused_imports)] -use super::*; +use super::{ + BLOB_BYTES, Cell, Context, DEVICE_PEAK, DeviceBuffer, Error, ExpertWeights, Fixture, IDS, K, N, ROUTE, Rc, Result, + SelectedRoute, bytes, compose, original, refusal, unchanged, +}; /// One context, the shared failure bit, the refusal counter and the resident charge every phase works against. pub(super) struct Env<'c> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_workspace/fixed_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_workspace/fixed_workspace_gpu.rs index a7bb8924..1fcbda9f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_workspace/fixed_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_expert_workspace/fixed_workspace_gpu.rs @@ -1,7 +1,15 @@ //! GPU proof of the fixed-ABI draft MoE workspace (moved out of mtp_expert_workspace.rs; test builds only). use super::super::mtp_expert_transport::{ExpertWeights, FixedReference, SelectedRoute, fixed_reference}; -use super::*; +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, +}; +#[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; 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 7fe81e49..ed66185b 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 @@ -2,8 +2,11 @@ //! Functions: `admit_input`, `route_mixed`, `compose_bound`, `moe_driver_error` and 1 more. use super::mtp_expert_transport::SelectedRoute; -#[allow(unused_imports)] -use super::*; +use super::{ + Bound, Cell, Context, DEVICE_PEAK, DeviceBuffer, Error, ExpertWeights, FF, K, ModelBinding, MoeWeightCache, + MtpBlock, MtpExpertStage, MtpFrame, MtpKind, MtpMlpReady, MtpRole, N, QwenSession, Rc, Result, Stage, + binding_error, driver_error, mtp_expert_transport, preflight, project, route, validate_values, +}; impl MtpBlock { pub(in super::super) fn frame(&self) -> &MtpFrame { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_final_transport_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_final_transport_gpu.rs index 4828fdca..1a2ae78e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_final_transport_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_final_transport_gpu.rs @@ -1,6 +1,11 @@ //! Independent original re-upload chain versus invocation-local final transport. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] -use super::*; +use super::{ + Bf16ProjectionShape, Candidate, Cell, Context, DeviceBuffer, Error, FINAL_PEAK, Finite, Inputs, Rc, Result, Role, + Transport, at, compose, download, driver_error, +}; +#[cfg(test)] +use super::{Observations, compose_observed}; use crate::qwen_forward::qsa_index::{upload, upload_bytes}; use leleka_cuda_driver::{Device, Driver}; 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 c3f2b2aa..fa00280e 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,8 +1,12 @@ //! Methods of `MtpAttentionRead`: `frame`, `streams`, `mixed`, `inject`. //! Methods of `MtpMlpReady`: `frame`, `streams`, `mixed`, `inject`. -#[allow(unused_imports)] -use super::*; +use super::{ + Candidate, Context, Error, FUSED_PEAK, H, ModelBinding, MoeWeightCache, MtpAttentionRead, MtpAttentionReady, + MtpDraftFinal, MtpFinalMixed, MtpFrame, MtpInput, MtpKind, MtpMlpReady, MtpRole, N, QwenSession, Read, Result, + STREAMS, Stage, allocate, binding_error, download, preflight, release, reserve, shared_driver_error, upload, + validate_values, +}; pub(super) fn driver_error(error: leleka_cuda_driver::Error) -> Error { if crate::driver_errors_traced() { 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 057ac3c7..cc458628 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,8 +1,11 @@ //! Functions: `admit_final_inputs`, `finalize`, `finalize_checked`, `final_matrix` and 7 more. //! Defines `FinalStageInputs`. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, Error, FINAL_PEAK, H, ModelBinding, MoeWeightCache, MtpBlock, MtpDraftFinal, MtpFinalMixed, MtpKind, + MtpMlpReady, MtpRole, N, QwenSession, Rc, Result, STREAMS, admit_role, allocate, download, driver_error, + f32_weights, mtp_final_transport, preflight, project, release, upload, validate_values, +}; /// Frame, finiteness and dense-shape admission shared by the retained and the legacy final chain. fn admit_final_inputs( 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 1eae641c..cb8ca8f2 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,8 +1,9 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Cell, CellPair, DenseKv, Error, HALF_ROW, HalfWindow, MtpFrame, Rc, Result, WINDOW, Weak, reserve, +}; impl DenseKv { pub(super) fn empty(binding: BindingIdentity, owner: Rc>) -> Self { 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 fac213ee..7a891d2f 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, DenseKv, Dimension, Error, ModelBinding, MtpCheckpoint, MtpFrame, MtpSession, Position, Rc, Result, + RetainedFirstSeed, TargetStepOrigin, TokenId, WINDOW, first_seed_retained_charge, +}; impl MtpSession { pub(in crate::qwen_forward) fn new(binding: &ModelBinding) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/stage.rs index fdd0de90..21c9d22c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/stage.rs @@ -1,5 +1,8 @@ //! Chronological row scan that stages one warming chunk of a `MtpKvPrefill` into a `ReadyMtpKvPrefill`. -use super::*; +use super::{ + CellPair, ChunkDraftPublication, DenseKv, Error, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, MtpKvPrefill, + MtpSession, QwenChunkTxn, Rc, ReadyMtpKvPrefill, Result, Stage, TokenId, VecDeque, WINDOW, Weak, mtp, +}; use crate::qwen_forward::session::chunk::ChunkRowResidual; /// The mutable coverage a chunk scan accumulates before it is certified. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/validate.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/validate.rs index 2c73ffcf..d28c00d7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/validate.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_state_warming/validate.rs @@ -1,5 +1,5 @@ //! Window and final-candidate checks of a staged `ReadyMtpKvPrefill`, split out of its publication certificate. -use super::*; +use super::{Error, MtpFrame, MtpSession, QwenChunkTxn, Rc, ReadyMtpKvPrefill, Result, WINDOW, mtp}; use crate::qwen_forward::session::chunk::ChunkRowResidual; impl ReadyMtpKvPrefill<'_, '_> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs index 8ab33434..0e428814 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup.rs @@ -227,21 +227,21 @@ pub(crate) fn open<'ctx>( let reserve = options.reserve_mib.checked_mul(1 << 20).ok_or(Error::Overflow)?; let free = usable_room(context.memory_info().map_err(driver)?.0, context.budget_bytes(), context.allocated_bytes()); let sizing = (free, reserve, pending_mtp_bind_bytes); - let slots = open_parts::initial_slots(&options, &geometry, sizing, profile)?; - let plan = open_parts::size_plan(context, &options, profile, (geometry, slots, reserve))?; + let slots = slot_sizing_and_open_retry::initial_slots(&options, &geometry, sizing, profile)?; + let plan = slot_sizing_and_open_retry::size_plan(context, &options, profile, (geometry, slots, reserve))?; if plan.slots == 0 { return Ok(None); } - let retry = open_parts::Retry { + let retry = slot_sizing_and_open_retry::Retry { auto: options.slots < 0, per_layer: options.per_layer, reserve, max_blob: geometry.max_blob, }; - open_parts::open_with_retry(context, &retry, plan) + slot_sizing_and_open_retry::open_with_retry(context, &retry, plan) } -mod open_parts; +mod slot_sizing_and_open_retry; #[cfg(test)] mod budget_room_tests { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/open_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing_and_open_retry.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/open_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing_and_open_retry.rs index d9ce6afd..45fb292c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/open_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_cache_startup/slot_sizing_and_open_retry.rs @@ -1,5 +1,5 @@ -//! Steps of `original_cache_startup::open`, moved out of it by STRA-338 (size): the slot count, the sizes of the slots, -//! and the open-and-squeeze retry, in the order `open` ran them. +//! How `original_cache_startup::open` decides the number and size of the expert cache slots, and the open-and-squeeze +//! retry that shrinks the plan after a refusal. Separate from `open` so the sizing rules read on their own. use super::{ Context, Error, Geometry, OriginalCacheOptions, OriginalExpertCache, OriginalRankedExperts, Plan, Result, align, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/draft_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/draft_operands.rs index 4d9fdd31..de6e7abe 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/draft_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/draft_operands.rs @@ -1,5 +1,5 @@ //! The operand groups the assembly of the full MTP draft owner takes. -use super::*; +use super::{Context, ModelBinding, OriginalMtpRequest, OriginalNativeOutput, OriginalPromptEmbedding, QwenSession}; use std::path::Path; /// The target model and session an MTP draft is attached to, with the device context both live on. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_prefill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_prefill.rs index 02e8e97e..3c03637d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_prefill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_prefill.rs @@ -3,7 +3,11 @@ //! prompt token; preceding next-IDs come from the same pending input owners. //! The final prompt seed and sampled ID belong to the separate Verifier path. use super::super::moe_weight_cache::MoeWeightCache; -use super::*; +use super::{ + BindingIdentity, DenseWeightCache, Dimension, Error, GrRole, ModelBinding, OriginalPromptPhase, OriginalPromptTxn, + PromptDeviceFinal, PromptDeviceRows, PromptWeights, Rc, Result, ScalarDraftKvRequest, ScalarPromptSources, + SourceInput, TokenId, micro_driver_error, +}; use crate::model_binding::qwen4exp_input::{MtpKind, MtpRole}; use leleka_cuda_driver::{ CompletedDraftKv, DraftKvOutcome, DraftKvPolicy, DraftKvSources, MtpInt8Snapshot, MtpOriginalInt8, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_scalar_prefill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_scalar_prefill.rs index 5ccbd48c..5e994fa8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_scalar_prefill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_scalar_prefill.rs @@ -1,6 +1,10 @@ //! Private child of genuine original_mtp_prefill runtime adapter. Same Final //! phase, shifted actual IDs and current ring receipt, literal scalar producer. -use super::*; +use super::{ + Error, FinalPromptPhase, GrRole, ModelBinding, MtpKind, MtpRole, OriginalPromptDraftOutcome, OriginalPromptPhase, + OriginalPromptTxn, PromptDeviceFinal, PromptDeviceRows, PromptWeights, Rc, Result, ScalarDraftKvRequest, + ScalarPromptSources, check_vocabulary, micro_driver_error, +}; use crate::qwen_forward::moe_weight_cache::RetainedOriginalMtpWeights; use leleka_cuda_driver::{OriginalMtpActor, OriginalMtpRetainedScalarWeights, PrefillRows, RecordRun}; impl<'source, 'arena, 'loan, 'ctx> PromptDeviceRows<'source, 'arena, 'loan, 'ctx> { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_prompt_embedding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_prompt_embedding.rs index 2aa45254..04b6c153 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_prompt_embedding.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_prompt_embedding.rs @@ -1,6 +1,6 @@ //! Genuine native token table owner loaded before the expert cache budget is //! planned. It is tied to one admitted model and the actual CUDA context. -use super::*; +use super::{BindingIdentity, Error, ModelBinding, Result, driver_error}; use leleka_cuda_driver::{Context, DeviceBuffer, OriginalMtpEmbedding}; pub(in crate::qwen_forward) struct OriginalPromptEmbedding<'ctx> { binding: BindingIdentity, 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 466ee814..e4d1fb4b 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 original_serve_engine_original_spec_engine; +mod spec_engine_for_serve_engine; mod serve_engine_draft_commit; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/original_serve_engine_original_spec_engine.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/spec_engine_for_serve_engine.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/original_serve_engine_original_spec_engine.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/spec_engine_for_serve_engine.rs index 80d3aebc..1da3d9fe 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/original_serve_engine_original_spec_engine.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/spec_engine_for_serve_engine.rs @@ -1,5 +1,5 @@ -//! Implements `OriginalSpecEngine for OriginalServeEngine`. -//! Split out of `draft_completion` to keep its files under the line limit. +//! Implements `OriginalSpecEngine` for `OriginalServeEngine`: the engine side of a speculative round, as the +//! speculative controller sees it. Separate from `draft_completion`, which holds the draft logic it calls. use super::{Error, OriginalServeEngine, OriginalServePort, OriginalSpecEngine, Rc, Result, ServedWindow}; 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 c96ee985..70e0382d 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 @@ -15,7 +15,7 @@ struct RoundTally { stop: Option, } -mod original_serve_engine_original_first_draft; +mod first_draft_engine_for_serve_engine; mod original_serve_settings; #[allow(unused_imports)] pub(crate) use original_serve_settings::{ServeCallbacks, SpeculativeRequest, serve_request}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_engine_original_first_draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/first_draft_engine_for_serve_engine.rs similarity index 93% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_engine_original_first_draft.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/first_draft_engine_for_serve_engine.rs index 42f26fd1..e6d95c71 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_engine_original_first_draft.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/first_draft_engine_for_serve_engine.rs @@ -1,5 +1,5 @@ -//! Implements `OriginalFirstDraftEngine for OriginalServeEngine`. -//! Split out of `round_tally` to keep its files under the line limit. +//! Implements `OriginalFirstDraftEngine` for `OriginalServeEngine`: the first-draft stage of a round (seed, pick and +//! stage). Separate from `round_tally`, which counts the rounds. use super::{ DraftLimits, DraftPick, DraftStage, Error, FirstDraftSeed, FirstStage, OriginalFirstDraftEngine, 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 9b7ce884..6b4f4948 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 @@ -124,6 +124,6 @@ use request_sampling::operator_line; #[allow(unused_imports)] use request_sampling::serial_publish; mod ple_on_chain; -mod window_parts; -use window_parts::{report_window, run_pool_group}; +mod run_window_steps; +use run_window_steps::{report_window, run_pool_group}; mod original_serve_host_native_serve_host; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/window_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/run_window_steps.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/window_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/run_window_steps.rs index 12dddeb4..c7e24b9f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/window_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/run_window_steps.rs @@ -1,6 +1,5 @@ -//! Steps of `NativeServeHost::run_window` for the Original host, moved out of it by STRA-338 (size): each helper does -//! one step -//! of the window in the order `run_window` ran it. +//! The steps of `NativeServeHost::run_window` for the Original host: pool group, sampling and verification, window +//! report and PLE rows, in the order a window runs them. Separate so `run_window` stays a short sequence of steps. use super::super::original_serve_pool::window_trace; use super::super::output_native::{HeadSamplerChoice, SamplingWindow}; 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 bcb2d1f2..70bd383e 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 @@ -210,8 +210,8 @@ use prefetch_off_file_exists::prefetch_off_file_exists; use prefetch_off_file_exists::same_spans; #[allow(unused_imports)] pub(in crate::qwen_forward) use prefetch_off_file_exists::scatter; -mod direct_parts; -use direct_parts::{GroupWork, borrow_experts, compute_into_sink, group_formats, plan_expert_ids, prefetch_group}; +mod direct_group_steps; +use direct_group_steps::{GroupWork, borrow_experts, compute_into_sink, group_formats, plan_expert_ids, prefetch_group}; mod cpu_expert_pool; mod pool_layer_trace; use pool_layer_trace::GroupTraceInfo; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_group_steps.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_group_steps.rs index 9e8f3fbb..470f5dd8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_group_steps.rs @@ -1,6 +1,5 @@ -//! Steps of `CpuExpertPool::run_direct`, moved out of it by STRA-338 (size): each helper does one step of the group in -//! the -//! order `run_direct` ran it. +//! The steps of `CpuExpertPool::run_direct`: plan the expert ids, prefetch, borrow the experts, compute the chunks into +//! the sink. Separate from the pool so that one group's life from plan to sink reads in one place. use super::{ BorrowedExpert, BorrowedGroup, DirectCpuPool, DirectTier, DownFormat, Error, ExpertJob, GateUpFormat, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs index 2b70a723..40ec4ac9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_prefix/tests/deferred_decode_tail.rs @@ -1,6 +1,9 @@ //! `PrefixConfig::defer_decode_tail` (`LELEKA_PREFIX_PARK_ASYNC`): the checkpoint at the end of the decode is taken //! after the response, from the same device state, and is the checkpoint the immediate path takes. -use super::*; +use super::{ + Block, ChunkOutcome, Fake, PrefixConfig, PrefixServe, State, TailMode, begin_request, cfg, doc, read_chunks, + session, tail_serve, +}; fn deferring() -> PrefixServe { PrefixServe::new(PrefixConfig { tail: TailMode::Reply, defer_decode_tail: true, ..cfg() }, 1024, 1 << 30, "test") 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 93321ffc..b493031c 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 @@ -307,7 +307,7 @@ mod swap_tie_order; pub(in crate::qwen_forward) use swap_tie_order::TieOrder; mod strata_pcie_auto; use strata_pcie_auto::StrataPcieAuto; -mod strata_pcie_auto_glue; +mod pcie_auto_on_window_pool; #[cfg(test)] mod strata_pcie_auto_tests; mod span_cache_and_pcie_lag; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/strata_pcie_auto_glue.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/pcie_auto_on_window_pool.rs similarity index 100% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/strata_pcie_auto_glue.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/pcie_auto_on_window_pool.rs 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 b0bb7b5a..7eb4931e 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,8 +1,13 @@ //! Methods of `GpuExpertPool`: `admit_group`, `note_usage`, `split_group`, `current_pcie_num` and 7 more. //! Implements `OriginalServePool for GpuExpertPool`. -#[allow(unused_imports)] -use super::*; +use super::{ + CpuExpertPool, EXPERTS, Error, GpuExpertPool, GroupSplit, LAYERS, MappedExpertBank, ModelBinding, MoeWeightCache, + OriginalGpuStream, OriginalServePool, OriginalVerifyCpuRows, OriginalVerifyCpuSink, OriginalVerifyPcieSource, + PcieAuto, PcieLag, PcieSplitPolicy, Rc, ResidentExpertBankSpan, Result, RoutedGroup, SpanCache, StrataPcieAuto, + Swap, SwapSources, TOP_K, TieOrder, adapt_tuning, choose_swaps_by, driver_error, span_cache_enabled, + split_group_pcie, +}; /// The source spans of `experts` of `layer`, in order: from the cache when seen before, else through the CPU /// tier's admission (or the binding's own scan on the legacy path) and remembered. 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 8cfcfa68..ad95b9d4 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 @@ -1,5 +1,5 @@ -//! Groups the submodules `decode_parts`, `decode_teardown`, `executor_opening` and 8 more. -//! Split out of `original_serve_stack` to keep its files under the line limit. +//! The methods of `OriginalServeStack`, grouped by phase: open, prefill, decode, the serve step, teardown and metrics. +//! Separate from `original_serve_stack`, which holds the type and its fields. use super::{ AssembleFailure, AssembleInputs, Began, ChunkOutcome, Clock, Context, CpuExpertPool, DecodeGraphKey, @@ -22,8 +22,8 @@ use super::{ serve_request, tier_for, vram_note, }; -mod decode_parts; -use decode_parts::{ +mod decode_phase_steps; +use decode_phase_steps::{ QsaOwnerHome, QsaOwners, RefillOwners, TierResources, assemble_decode, decode_pcie_mode, gpu_expert_pool, narrow_window_policy, resolve_assembled, return_owners, settle_deferred_refill, }; @@ -31,13 +31,13 @@ mod decode_teardown; use decode_teardown::{Ending, retire_kept, teardown_decode}; mod executor_opening; use executor_opening::ExecutorOpening; -mod open_parts; -use open_parts::{ +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, }; -mod serve_parts; -use serve_parts::{ServeEnv, serve_over_host}; +mod serve_request_step; +use serve_request_step::{ServeEnv, serve_over_host}; mod original_serve_stack_decode_phase; mod original_serve_stack_memory_classes; mod original_serve_stack_metrics_close; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_phase_steps.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_phase_steps.rs index 26bb672f..538565b0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_phase_steps.rs @@ -1,6 +1,5 @@ -//! Phases of `OriginalServeStack::decode_phase`, moved out of it by STRA-338 (size): each helper takes the stack -//! fields it -//! touches, so the destructured borrows of `decode_phase` stay as they were and the order of operations is unchanged. +//! The steps of `OriginalServeStack::decode_phase`: owner hand-over, PCIe mode, tier resources and refill queueing. +//! Each takes only the stack fields it touches, so the destructured borrows of `decode_phase` stay as they were. use super::{ AssembleFailure, AssembleInputs, CpuExpertPool, DecodeResources, DenseWeightCache, Error, ExpertBlobSizes, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs index d5cf3295..633fbe6a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/decode_teardown.rs @@ -1,7 +1,7 @@ //! The end of a decode phase: close the assembly and take the QSA owners back, or - with `LELEKA_DECODE_GRAPH_REUSE` //! and a request that ended cleanly - park it, lend the owners home and keep it for the next request (ledger row Q7). -use super::decode_parts::{QsaOwnerHome, QsaOwners, adopt_disassembled, release_mtp}; +use super::decode_phase_steps::{QsaOwnerHome, QsaOwners, adopt_disassembled, release_mtp}; use super::{ Context, DecodeGraphKey, DecodeResources, Ended, Error, GraphReuse, ModelBinding, MoeWeightCache, OriginalPromptExecutor, ServeFailure, disassemble, failure, operator_line, profile, vram_note, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_phase_steps.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_phase_steps.rs index 40c642cb..3a2a3bf0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/open_phase_steps.rs @@ -1,7 +1,7 @@ -//! 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`: 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. #[allow(unused_imports)] use super::*; use crate::qwen_forward::session::original_prompt::draft::OriginalDraftSession; 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 55bc57b4..69a49aa6 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 @@ -3,7 +3,11 @@ #[allow(unused_imports)] use super::open_phases::{Buffers, Core, TierParts}; -use super::*; +use super::{ + Context, Error, ExpertBlobSizes, GraphReuse, ModelBinding, OriginalServeStack, OriginalVerifyExpertFormats, + Policies, PrefillLayoutOptions, RopeConstants, ServeFailure, StackConfig, at, expert_formats, failure, + mtp_full_policy, mtp_scalar_policy, prefill_layout_options, serve_policies, +}; use crate::qwen_forward::original_serve_stack::stack_groups::{RequestState, ServePolicy, TierState}; /// What `open` derives from the binding and the config before it allocates anything. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_request_step.rs similarity index 96% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_request_step.rs index 437a3bfa..a2c331b3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/serve_request_step.rs @@ -1,4 +1,5 @@ -//! The serve step of `OriginalServeStack::decode_phase`, moved out of `decode_parts` by STRA-338 (size). +//! The step of `OriginalServeStack::decode_phase` that serves one request over the host: run the engine, note the +//! end of the request and settle the served state. Separate from `decode_phase_steps`, which prepares its inputs. use super::{ Clock, Error, NativeServePort, OriginalServeEngine, OriginalServeHost, OriginalServeSettings, 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 b9a0f374..01bc1ede 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,8 +1,11 @@ //! Methods of `PromptChunk`: `run`. Methods of `OriginalServeStack`: `prefix_resume`, `prefix_begin`. //! Implements `ResumeDevice for OriginalServeStack`. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkCaches, ChunkDraft, Context, DBG_T0, Error, OriginalPrefillArena, OriginalServeStack, PrefixServe, + PromptChunk, PromptChunkSource, PromptChunkTarget, PromptWeights, RequestOwners, Result, ResumeDevice, + ServeFailure, ServeRequest, SpecError, StackBlock, StackPoint, StackState, prefix, profile, +}; impl<'ctx> PromptChunk<'_, 'ctx> { pub(super) fn run( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs index ad32eb80..38f25e9a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier.rs @@ -348,9 +348,9 @@ fn place_owners<'ctx>( Some(owners) } -mod assemble_parts; +mod assembly_steps; mod held; -use assemble_parts::{Prepared, RecordEnv, capture_verifier, split_owners}; +use assembly_steps::{Prepared, RecordEnv, capture_verifier, split_owners}; pub(in crate::qwen_forward) use held::RearmSeed; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assemble_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assembly_steps.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assemble_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assembly_steps.rs index 253adce1..75188992 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assemble_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/assembly_steps.rs @@ -1,5 +1,5 @@ -//! Steps of `assemble`, moved out of it by STRA-338 (size): each helper does one step of the assembly in the order -//! `assemble` ran it, with the same profile spans and the same failure ownership. +//! The steps of `assemble` for the Original verifier: split the owners, build the aggregates and the window records. +//! Each step keeps the profile spans and the failure ownership of the whole assembly. use super::{ AssembleFailure, AssembleInputs, Context, Error, ExpertBlobSizes, ModelBinding, OriginalNativeOutput, 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 d3b339d5..47e20a9b 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 @@ -149,8 +149,8 @@ pub(crate) struct CommittedRound { #[cfg(test)] mod tests; -mod finish_parts; -use finish_parts::{RoundFacts, combine_round}; +mod finish_round_steps; +use finish_round_steps::{RoundFacts, combine_round}; mod trace_enabled; #[allow(unused_imports)] pub(crate) use trace_enabled::stats_enabled; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/finish_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/finish_round_steps.rs similarity index 97% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/finish_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/finish_round_steps.rs index 02a92ce5..1885f338 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/finish_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/finish_round_steps.rs @@ -1,6 +1,5 @@ -//! Phases of `OriginalSpecController::finish_round`, moved out of it by STRA-338 (size): each helper does one step of -//! the -//! round's end in the order `finish_round` did it. +//! What `OriginalSpecController::finish_round` does after a committed round: combine the round facts, trace the +//! adaptive or fixed choice, and prepare the next draft batch. Separate so `finish_round` reads as these steps. use super::{ AdaptivePolicy, Choice, CommittedRound, DraftBatch, DraftPlan, DraftPreparation, DraftSampling, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods.rs index cced210a..c4708a05 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `commit_parts`, `verify_parts`, `original_spec_controller_start_request` and 1 more. -//! Split out of `original_spec_controller` to keep its files under the line limit. +//! The methods of `OriginalSpecController` by step of a round: start a request, verify a window, commit it. +//! Separate from `original_spec_controller`, which holds the type and the end of the round. use super::{ AdaptivePolicy, Choice, CommittedRound, DraftBatch, DraftPolicy, Error, MAX_T, NanGuard, Offer, Origin, @@ -7,8 +7,8 @@ use super::{ SpecStats, SuffixDrafter, WindowFailure, }; -mod commit_parts; -mod verify_parts; -use verify_parts::{Round, window_inputs}; +mod commit_round_steps; +mod verify_round_steps; +use verify_round_steps::{Round, window_inputs}; mod original_spec_controller_start_request; mod original_spec_controller_verify_commit; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_round_steps.rs similarity index 94% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_round_steps.rs index 555124b8..f779f1d7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/commit_round_steps.rs @@ -1,7 +1,7 @@ -//! The commit half of `OriginalSpecController::verify_commit`, moved out of it by STRA-338 (size): the round's verified -//! window is accepted, its prefix committed and the receipt handed back, in the order `verify_commit` did it. +//! The commit half of `OriginalSpecController::verify_commit`: accept the verified window, commit its prefix and hand +//! the receipt back. The verify half, which comes first, is `verify_round_steps`. -use super::verify_parts::{Round, WindowPlan}; +use super::verify_round_steps::{Round, WindowPlan}; use super::{CommittedRound, Error, MAX_T, OriginalSpecController, OriginalSpecEngine, Rc, SpecError, SpecResult}; /// The verified window of a round with the plan it ran under and the number of the round it completes. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_parts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_round_steps.rs similarity index 98% rename from crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_parts.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_round_steps.rs index 555c02c1..a6ee5a86 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_parts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/verify_round_steps.rs @@ -1,6 +1,5 @@ -//! Phases of `OriginalSpecController::verify_commit`, moved out of it by STRA-338 (size): each helper does one step of -//! the -//! round in the order `verify_commit` did it, with the same checks, restores and log lines. +//! The verify half of `OriginalSpecController::verify_commit`: plan the window (adaptive or suffix), admit its outputs +//! and run it, with the same checks, restores and log lines. The commit half is `commit_round_steps`. use super::{ AdaptivePolicy, Choice, DraftPolicy, Error, MAX_T, NanGuard, Offer, Origin, OriginalSpecController, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/golden.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/golden.rs index ea7481db..0310962d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/golden.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/golden.rs @@ -8,7 +8,7 @@ //! golden` and review the diff. use super::super::super::original_spec_adaptive::AdaptiveConfig; -use super::*; +use super::{Fake, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, drive, next, prompt}; use std::path::PathBuf; fn golden_path(name: &str) -> PathBuf { 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 e40fef9c..7d2d242e 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,8 +1,10 @@ //! Methods of `OriginalPromptSample`: `greedy`, `conditioning`, `validate`, `matches_final` and 3 more. //! Methods of `FiniteLogits`: `validate_for`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Error, FiniteLogits, LogitValues, ModelBinding, OriginalPromptSample, Position, Result, TokenId, + VOCABULARY, greedy, selected_token, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] impl OriginalPromptSample { 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 4232dff4..78a90181 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Context, Dimension, EMBEDDING, Error, FiniteLogits, GrStage, HEAD_GREEDY_WORKSPACE_BYTES, + InjectedResidual, LayerId, LogitValues, LogitsRow, ModelBinding, OUTPUT_STAGE_BUDGET, OUTPUT_WEIGHT_BYTES, + OutputStage, Position, QwenStepTxn, ResidualAtLayer, Result, Stage, TokenId, binding_error, combine, driver_error, + greedy, validate_weight_owner, +}; impl<'context, 'driver> OutputStage<'context, 'driver> { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 3c6a362d..ea80ea78 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + ACTIVATION_BYTES, BindingIdentity, Context, DeviceBuffer, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, + HEAD_GREEDY_WORKSPACE_BYTES, HeadGreedySelection, LOGIT_BYTES, LogitValues, LogitsRow, OUTPUT_STAGE_BUDGET, + OUTPUT_WEIGHT_BYTES, OutputStage, Position, Q6KProjectionShape, Result, TokenId, VOCABULARY, combine, + decode_logits, driver_error, encode_activation, selected_token, +}; impl<'context, 'driver> OutputStage<'context, 'driver> { pub(in super::super) fn sampler_wants(&self, position: Position) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output_native_history.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output_native_history.rs index ff1e520f..f4b5bba1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output_native_history.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output_native_history.rs @@ -1,7 +1,7 @@ //! Original generate.cpp4291/5529 penalty storage. One model-lifetime device //! allocation and one T*h upload per penalized window; disabled penalties lend //! no buffer. Token history is input data, never numerical/commit authority. -use super::*; +use super::{BindingIdentity, Context, Error, ModelBinding, NativeHeadSampling, Result, driver}; use crate::qwen_forward::session::{QwenSession, TargetStepOrigin}; use crate::qwen_forward::token_memo::PrefixMemo; use leleka_cuda_driver::{DeviceBuffer, SamplerParams, SamplerPath}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu.rs index a0c132c0..b2d4c9e5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu.rs @@ -1,7 +1,12 @@ //! Whole Value and retained PLE versus the unchanged forty-tile baseline. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{ple_upload, ple_upload_f32}; -use super::*; +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, +}; +#[cfg(test)] +use super::{Observations, compose_observed}; use leleka_cuda_driver::{Driver, PleClosedWeights}; struct Matrices<'ctx> { key: DeviceBuffer<'ctx>, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu/bf16.rs b/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu/bf16.rs index 684c5895..6228f678 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu/bf16.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/ple_key_retained_gpu/bf16.rs @@ -1,8 +1,13 @@ //! Methods of `Matrices`: `new`, `aux`, `unchanged`, `close`. //! Methods of `Chain`: `key_value`, `norms`, `gate`, `gated` and 2 more. -#[allow(unused_imports)] -use super::*; +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, +}; +#[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/ple_transport.rs b/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport.rs index f5c4dd4d..0bd432c8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport.rs @@ -58,12 +58,12 @@ use role::admit; use role::at; #[allow(unused_imports)] pub(super) use role::compose; -#[path = "ple_transport/compose_inner.rs"] -mod compose_inner; +#[path = "ple_transport/ple_inner_composition.rs"] +mod ple_inner_composition; #[allow(unused_imports)] -use compose_inner::compose_inner; +use ple_inner_composition::compose_inner; #[cfg(test)] #[allow(unused_imports)] -use compose_inner::compose_observed; +use ple_inner_composition::compose_observed; #[allow(unused_imports)] -pub(super) use compose_inner::compose_queued; +pub(super) use ple_inner_composition::compose_queued; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport/compose_inner.rs b/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport/ple_inner_composition.rs similarity index 95% rename from crates/engine-qwen35-cuda/src/qwen_forward/ple_transport/compose_inner.rs rename to crates/engine-qwen35-cuda/src/qwen_forward/ple_transport/ple_inner_composition.rs index b1b53abd..faae1d76 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport/compose_inner.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/ple_transport/ple_inner_composition.rs @@ -1,8 +1,12 @@ -//! Functions: `compose_inner`, `finish_streams`, `project_key_value`, `gate_of` and 7 more. Defines `ConvOperands`. -//! Split out of `ple_transport` to keep its files under the line limit. +//! 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. -#[allow(unused_imports)] -use super::*; +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/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 5a18b1bc..511314a3 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 @@ -5,8 +5,12 @@ use super::super::super::gdn::PromptSource; use super::produce_original_gdn::{ DeviceBlockResult, GdnLayer, Lap, PromptLayerSite, QsaLayerDevices, inject_span, produce_block, }; -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, Dimension, Error, GrRole, LayerId, ModelBinding, OriginalDeviceGrRead, + OriginalPromptDevice, OriginalPromptPhase, OriginalPromptTxn, PromptDeviceNormedRows, PromptDeviceRead, + PromptDeviceRows, PromptWeights, QwenStepTxn, Result, TokenLayer, micro_driver_error, produce_original_gdn, + produce_original_qsa, run_transfer, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::moe_weight_cache::PromptWeightOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_weights.rs index c7805f59..43a88a91 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_weights.rs @@ -1,5 +1,5 @@ //! The two model-wide owners every prompt row phase is validated against. -use super::*; +use super::{DenseWeightCache, ModelBinding}; /// The model binding and the dense weight cache a prompt phase validates its rows against and reads its weights /// from; they always travel together, so a phase takes this one value instead of two parameters. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/rows_upload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/rows_upload.rs index 4dafefcd..23ada5d6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/rows_upload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/rows_upload.rs @@ -1,5 +1,5 @@ //! What device initialization of the prompt rows uploads from. -use super::*; +use super::OriginalPromptRows; /// The arena lease the rows of a chunk live in and the optional chunk-wide staged input (embedding rows and PLE /// updates) they are initialized from; `None` means the per-token host rows are uploaded instead. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/scalar_draft_kv_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/scalar_draft_kv_operands.rs index 6a0e67ab..981f2605 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/scalar_draft_kv_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/scalar_draft_kv_operands.rs @@ -1,5 +1,5 @@ //! The operands of the scalar draft-KV recording, the fallback of the batched producer. -use super::*; +use super::{DenseWeightCache, ModelBinding, OriginalPromptTxn, PromptDeviceFinal, TokenId}; use crate::qwen_forward::moe_weight_cache::RetainedOriginalMtpWeights; use leleka_cuda_driver::ScalarDraftKvSources; 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 836ac057..d4180e19 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,8 +1,11 @@ //! Methods of `RowFactory`: `row`. //! Functions: `check_inputs`, `check_row`, `check_successor`, `gdn_matrix_of` and 8 more. Defines `RowFactory`. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, ColumnKey, ColumnTarget, Context, DenseWeightCache, DeviceBuffer, Error, GdnMatrixKind, GdnMatrixRole, + GrRole, LayerId, ModelBinding, ProjectionRow, Provider, Q6Job, QsaMatrixKind, QwenChunkTxn, Rc, ResidualReady, + Result, RetainedColumns, Role, Stage, TargetStepOrigin, numeric, numeric_retained, validate_values, +}; /// The rows of one projection: everything but the source and the values. struct RowFactory<'b, 'ctx> { 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 418ee618..ca1ff099 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,8 +1,7 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{Cell, Context, DeviceBuffer, Error, Result, download, driver_error}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use leleka_cuda_driver::q6_layer_preview::{Batch, Prepared}; @@ -129,7 +128,7 @@ impl<'ctx> Q6Job<'_, 'ctx> { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(super) fn numeric<'ctx>( job: Q6Job<'_, 'ctx>, - modules: &super::super::chunk_modules::ChunkModules<'ctx>, + modules: &super::super::chunk_module_owners::ChunkModules<'ctx>, ) -> Result> { let failed = modules.failure_flag(); if failed.get() { @@ -148,7 +147,7 @@ pub(super) fn numeric<'ctx>( #[cfg(not(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64")))] pub(super) fn numeric<'ctx>( job: Q6Job<'_, 'ctx>, - modules: &super::super::chunk_modules::ChunkModules<'ctx>, + modules: &super::super::chunk_module_owners::ChunkModules<'ctx>, ) -> Result> { let _ = (job, modules); Err(Error::Unsupported(Stage::Executor)) @@ -161,7 +160,7 @@ pub(super) fn numeric<'ctx>( #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] pub(super) fn numeric_retained<'ctx>( job: Q6Job<'_, 'ctx>, - modules: &super::super::chunk_modules::ChunkModules<'ctx>, + modules: &super::super::chunk_module_owners::ChunkModules<'ctx>, ) -> Result> { let failed = modules.failure_flag(); if failed.get() { @@ -180,7 +179,7 @@ pub(super) fn numeric_retained<'ctx>( #[cfg(not(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64")))] pub(super) fn numeric_retained<'ctx>( job: Q6Job<'_, 'ctx>, - modules: &super::super::chunk_modules::ChunkModules<'ctx>, + modules: &super::super::chunk_module_owners::ChunkModules<'ctx>, ) -> Result> { let _ = (job, modules); Err(Error::Unsupported(Stage::Executor)) 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 76d8436a..e9f83e52 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,8 +1,11 @@ //! Methods of `AttendBuffers`: `upload`, `launch`. //! Functions: `decode_selected_cached`, `attend_selected`, `settle_retained`, `attend_retained` and 8 more. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DenseWeightCache, DeviceBuffer, Error, ModelBinding, Q, QsaAttendBuffers, QsaAttended, QsaGated, + QsaPrepared, QsaReady, QsaSelectedCache, Rc, Result, Stage, allocate, download, driver_error, project_cached_out, + validate_values, +}; pub(super) fn decode_selected_cached( binding: &ModelBinding, 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 b20eb631..2c4681be 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 @@ -7,8 +7,10 @@ use super::super::qsa_index::QsaPending; use super::super::qsa_prompt_index::LayerResidual; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::qsa_prompt_index::PromptChunkOwners; -#[allow(unused_imports)] -use super::*; +use super::{ + Context, DenseWeightCache, Error, LayerId, ModelBinding, NativeAttended, NativePromptAttentionBatch, Q, QsaReady, + QwenStepTxn, Rc, Result, TokenLayer, attention_driver_error, validate_values, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use crate::qwen_forward::prompt_device_rows::PromptWeights; 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 bf8a55af..654ad129 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 @@ -9,8 +9,12 @@ use super::super::{ qsa_native_resources::NativeQsaResources, qsa_prompt_index::PromptIndexDevices, }; -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, Q, QsaAttentionStage, + QsaGated, QsaMatrixRole, QsaPrepared, QsaReady, QwenStepTxn, Result, SelectedKvBytes, TokenLayer, admit_budget, + allocate, attend_retained, attention_driver_error, decode_selected_cached, download, gate_retained, project, + project_cached_out, release, upload, upload_bytes, validate_values, +}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use leleka_cuda_driver::NativeBatchWorkspace; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention_reuse_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention_reuse_gpu.rs index d9d8ecc7..5545ae82 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention_reuse_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention_reuse_gpu.rs @@ -1,6 +1,11 @@ //! 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::*; +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, +}; 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/qsa_index_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs index f7b8fdd2..666be817 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,8 +1,14 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +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/qsa_index/qsa_pending.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs index da6fc5ca..44765953 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Directory, Error, KV, KvPage, LayerId, PAGE, PackedKv, Position, QsaPending, QsaPrepared, + QsaPrior, QsaWeights, Rc, Result, Stage, State, TokenLayer, context, validate_half, validate_values, +}; impl QsaPending { pub(super) fn new(prior: &QsaPrior, identity: TokenLayer, k: &[u8], v: &[u8], index: &[f32]) -> Result { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index_resident/max_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index_resident/max_rows.rs index bcda3540..8970e88c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index_resident/max_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index_resident/max_rows.rs @@ -1,8 +1,13 @@ //! Methods of `QsaIndexKeyCache`: `layer_bytes`, `new`, `with_eager`, `admit_mirror` and 9 more. //! Functions: `max_rows`, `update`, `append_rows`, `capacity` and 2 more. -#[allow(unused_imports)] -use super::*; +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_native_state.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_native_state.rs index f70552be..28f9a951 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_native_state.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_native_state.rs @@ -1,6 +1,9 @@ //! Canonical mode17 state is the real completed INT8 owner, never decoded FP16. //! Chronological candidates are published by the existing genuine session journal. -use super::*; +use super::{ + BindingIdentity, Directory, Error, LayerId, QsaOwner, QsaPending, QsaPrior, Rc, Result, State, TokenLayer, context, + driver_error, validate_values, +}; use leleka_cuda_driver::{QsaKvSnapshot, QsaPromptIndexPrefix, QsaPromptKv}; impl QsaPrior { pub(in crate::qwen_forward) fn empty_native( diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_operands.rs index cbec5325..2f329800 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_operands.rs @@ -1,5 +1,5 @@ //! The operand groups of the native QSA prompt projections. -use super::*; +use super::{LayerId, NativeBatchWorkspace, QsaNativeBatchWorkspace, ResidualReady}; /// One attention-layer input row: the layer and the ready residual it was produced for. #[derive(Clone, Copy)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_completed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_completed.rs index 45b1cb5c..4c61cc80 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_completed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_completed.rs @@ -3,7 +3,11 @@ #[allow(unused_imports)] use super::resident_qsa_layer::mint; -use super::*; +use super::{ + Context, DenseWeightCache, Error, InputReady, LayerId, ModelBinding, NativeBatchWorkspace, + OriginalQsaResidentPromptDevice, QsaResident, QwenSession, QwenStepTxn, Rc, ResidentQsaCompleted, ResidentQsaRow, + ResidentQsaSeal, Result, TokenLayer, device_error, +}; /// The owners a resident QSA prefix seal validates against and commits through: model binding, dense weight cache, /// original session, prompt producer and native batch workspace. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs index 5b276dac..21cb35c3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_resident_device/resident_qsa_span_export_and_seal.rs @@ -3,7 +3,13 @@ #[allow(unused_imports)] use super::resident_qsa_layer::rehome; -use super::*; +use super::{ + Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, NativeBatchWorkspace, OriginalDeviceBlock, + OriginalQsaMappedJournal, OriginalQsaResidentAppendTarget, OriginalQsaResidentIndex, ParkedLayerSpan, ParkedPrefix, + QsaMatrixRole, QsaNativeKind, QsaNativeWeight, QsaResident, QwenSession, Rc, ResidentCompleteDevices, + ResidentQsaCompleted, ResidentQsaLayer, ResidentQsaOwners, ResidentQsaPrior, ResidentQsaPublication, + ResidentQsaRow, ResidentQsaSeal, ResidentQsaSelection, Result, SpanExport, TokenLayer, device_error, native, +}; impl<'ctx> ResidentQsaLayer<'ctx> { /// Bytes of the cells `first..first + tokens` of this layer as a prefix-cache span (host K/V pages and pooled index 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 0fd04cae..e45c55e4 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,6 +1,10 @@ //! 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::*; +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, +}; use leleka_cuda_driver::Driver; use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind}; 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 99a6e0bc..31ae8110 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Cell, Context, DeviceBuffer, EXTENTS, Error, MATRIX_BYTES, ROUTER_BYTES, Rc, Report, Result, RouterBuffers, + activation, candidate, close_all, finish, healthy, map_driver_error, matrix_bytes, original, original_project, + original_route, snapshot, +}; pub(super) fn valid_reset( workspace: &mut RouterBuffers<'_>, 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 b395d36b..5078e109 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,8 +1,10 @@ //! Methods of `QwenSession`: `note_mtp_failure`, `finish_mtp_device`, `new`, `for_binding` and 11 more. //! Functions: `layers_of_kind`. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, BoundLayerKind, Context, Error, GdnOwner, ModelBinding, PleOwner, Position, QsaOwner, QwenSession, + QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TokenId, +}; /// Which of the bound layers (by position) are of `kind`. fn layers_of_kind(binding: &ModelBinding, kind: BoundLayerKind) -> [bool; N] { 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 3d390aae..0a12d9c6 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, Context, Dimension, Error, GdnPending, GdnPrior, InputReady, LayerId, PlePending, PlePrior, + Position, QsaIndexPrior, QwenStepTxn, Rc, Result, STATE_CAPACITY, Stage, TargetStepOrigin, TokenId, TokenLayer, +}; impl<'driver> QwenStepTxn<'_, 'driver> { pub(in super::super::super) fn token(&self) -> TokenId { 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 99a929cd..fd95e9c2 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,8 +1,10 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + Dimension, Error, FiniteLogits, GdnPending, GdnPrior, GrRole, InjectedResidual, LayerId, PlePending, PlePrior, + QsaIndexPrior, QsaPending, QwenSession, QwenStepTxn, Result, STATE_CAPACITY, Stage, TokenId, TokenLayer, greedy, +}; impl<'driver> QwenStepTxn<'_, 'driver> { pub(in super::super::super) fn qsa_prior(&mut self, layer: LayerId) -> Result { 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 7fde145b..79bd2f2b 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,8 +1,11 @@ //! Methods of `GdnChunkStart`: `prior`, `count`, `binding`, `validate_binding` and 2 more. //! Methods of `GdnChunkRow`: `ordinal`, `identity`, `readout_key`, `matches_readout` and 1 more. -#[allow(unused_imports)] -use super::*; +use super::{ + BindingIdentity, ChunkAttentionRow, ChunkCommit, ChunkFfnRow, Error, GdnChunkAnchor, GdnChunkMicro, GdnChunkRow, + GdnChunkSeal, GdnChunkStart, GdnPrior, GrRole, LayerId, Position, Rc, Result, TargetStepOrigin, TokenId, + TokenLayer, host_charge_bounded, +}; impl GdnChunkStart { pub(in crate::qwen_forward) fn prior(&self) -> &GdnPrior { 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 e357e295..e2532473 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,8 +1,11 @@ //! 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`. -#[allow(unused_imports)] -use super::*; +use super::{ + AttentionProgress, BatchProgress, ChunkRowResidual, Dimension, Error, MicroProgress, ModelBinding, Position, + PromptInit, QwenChunkTxn, QwenSession, Rc, Result, Row, Stage, TargetStepOrigin, TokenId, host_charge, + host_charge_bounded, +}; /// How a prompt chunk is admitted: the host bytes left for it and whether it takes the private windowed path. #[derive(Clone, Copy)] 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 71564bb9..9d5b6a47 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 @@ -3,8 +3,10 @@ #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::{gr::DetachedGrRead, moe_expert::PreparedMoeRow}; -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkFfnRow, Error, FfnInjectionRow, GdnChunkRow, GrRole, LayerId, ModelBinding, Position, PreparedLayerRow, + QwenChunkTxn, QwenStepTxn, Rc, Result, Stage, TokenLayer, +}; impl<'session, 'driver> QwenChunkTxn<'session, 'driver> { #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] 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 e039763a..9c54ed57 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 @@ -3,8 +3,10 @@ #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::{gdn::chunk_device::ChunkEdge, gr::DetachedGrRead}; -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkAttentionRow, Context, Error, GdnChunkMicro, GdnChunkRow, GdnChunkStart, GrRole, LayerId, PreparedLayerRow, + QwenChunkTxn, QwenStepTxn, Rc, Result, Stage, TokenLayer, +}; impl<'session, 'driver> QwenChunkTxn<'session, 'driver> { /// The device attention edge is genuine, but independent FFN GR reads may 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 ecaa7ccb..faa83151 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 @@ -3,8 +3,9 @@ #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::gr::{DetachedGrRead, GrMicroInput}; -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkAttentionRow, Error, GrRole, InputReady, LayerId, PlePrior, QwenChunkTxn, QwenStepTxn, Result, Stage, +}; impl<'session, 'driver> QwenChunkTxn<'session, 'driver> { pub(in crate::qwen_forward) fn input( 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 cb5e4e29..e7c676cc 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,8 +1,11 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkRowResidual, Error, GdnChunkAnchor, GdnChunkJournal, GdnChunkSeal, GdnChunkStart, GdnPrior, LayerId, + ModelBinding, Position, QsaIndexPrior, QwenChunkTxn, QwenSession, Rc, Result, Row, STATE_CAPACITY, Stage, + TargetStepOrigin, TokenId, +}; impl<'session, 'driver> QwenChunkTxn<'session, 'driver> { /// The attention phase of this layer is open at the first row and the retained QSA prior is the one asked for. 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 deecfb0c..14df878a 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,8 +1,7 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ActiveMicroWindow, AttentionSource, LayerId, Rc}; /// The layer whose batched rows are staged, the rows' identity tokens and how many are completed. #[derive(Default)] 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 bd75d580..65a80f00 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,8 +1,12 @@ //! 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. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkCommit, ChunkRowResidual, Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, GrRole, HOST_LIMIT, + InjectedResidual, LayerId, ModelBinding, Position, PrefixState, QwenChunkTxn, QwenSession, QwenStepTxn, Rc, Result, + Row, STATE_CAPACITY, Stage, TargetStepProduct, TokenId, TokenLayer, VerificationJournal, VerifiedDraftPublication, + VerifiedTargetPrefix, greedy_prefix, host_charge_bounded, verification_extra_charge, +}; #[path = "qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs"] mod qwen_chunk_txn_begin_verification; 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 1d25b932..e23ed76b 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,8 +1,11 @@ //! Methods of `QwenChunkTxn`: `validate_verification_source`, `preflight_mtp_verification`, `begin_mtp_verification`... //! Functions: `verification_total_charge`. Defines `ReplayInputs`. -#[allow(unused_imports)] -use super::*; +use super::{ + Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, HOST_LIMIT, LayerId, ModelBinding, Position, + PrefixState, QwenChunkTxn, QwenSession, Rc, Result, Row, STATE_CAPACITY, Stage, TargetStepProduct, TokenId, + TokenLayer, VerificationJournal, VerifiedTargetPrefix, host_charge_bounded, verification_extra_charge, +}; /// The device lease and the verification workspace a replay runs on. type ReplayInputs<'ctx> = ( 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 0a06570f..5bcdf675 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,8 +1,10 @@ //! Methods of `QwenChunkTxn`: `record_gdn_prior`, `record_qsa_prior`, `record_verification_prior`, `validate_state_g... //! Functions: `journal_state`, `journal_state_mut`. -#[allow(unused_imports)] -use super::*; +use super::{ + ChunkRowResidual, Dimension, Error, GrRole, InjectedResidual, LayerId, Position, PrefixState, QwenChunkTxn, + QwenStepTxn, Rc, Result, Row, STATE_CAPACITY, Stage, TokenId, TokenLayer, VerificationJournal, +}; impl<'session, 'driver> QwenChunkTxn<'session, 'driver> { /// Journal the consumed GDN prior of `index` once; it must validate at the row end. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_draft/window_origins.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_draft/window_origins.rs index 5243b930..ad3d159e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_draft/window_origins.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_draft/window_origins.rs @@ -1,5 +1,5 @@ //! The two target origins a verified-window draft transition is checked against. -use super::*; +use super::TargetStepOrigin; /// The target origin before a verified window and the origin it moves to: the committed one, or for a draft launched /// while the commit is still enqueued the prospective one. The independent MTP ring is anchored at `before`. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/prompt_txn_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/prompt_txn_owners.rs index 2dc9a6f0..07d23fa4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/prompt_txn_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session_original_prompt/prompt_txn_owners.rs @@ -1,7 +1,6 @@ //! The owners and inputs a prompt transaction is published, aborted or imported with, grouped by meaning. use super::draft::{OriginalDraftCheckpoint, OriginalDraftSession}; -use super::*; /// The draft session of a prompt transaction and the checkpoint a failed prompt restores it to. pub(in crate::qwen_forward) struct DraftRollback<'a, 'driver> { diff --git a/crates/experimental-ref/src/cvec.rs b/crates/experimental-ref/src/cvec.rs index c407c84d..0e8ccce5 100644 --- a/crates/experimental-ref/src/cvec.rs +++ b/crates/experimental-ref/src/cvec.rs @@ -108,9 +108,9 @@ pub struct CvecTables { #[cfg(test)] mod tests; -mod cvec_error_display_error; +mod cvec_reading_and_errors; #[allow(unused_imports)] -pub use cvec_error_display_error::*; +pub use cvec_reading_and_errors::*; mod load_control_vectors; #[allow(unused_imports)] pub use load_control_vectors::*; diff --git a/crates/experimental-ref/src/cvec/cvec_error_display_error.rs b/crates/experimental-ref/src/cvec/cvec_reading_and_errors.rs similarity index 97% rename from crates/experimental-ref/src/cvec/cvec_error_display_error.rs rename to crates/experimental-ref/src/cvec/cvec_reading_and_errors.rs index f034f3b0..a8d8029b 100644 --- a/crates/experimental-ref/src/cvec/cvec_error_display_error.rs +++ b/crates/experimental-ref/src/cvec/cvec_reading_and_errors.rs @@ -1,5 +1,5 @@ -//! Methods of `GgufTensor`: `elements`. Methods of `Cursor`: `need`, `take`, `u32`, `u64` and 1 more. -//! Implements `Display for CvecError`, `Error for CvecError` and 1 more. +//! The reading side of control vectors: `Cursor` over the file bytes, `GgufTensor::elements` and the `Display` and +//! `Error` impls of `CvecError`. Separate from `cvec`, which applies the vectors. use super::{Cursor, CvecError, CvecMode, CvecOptions, CvecTables, GgufFile, GgufTensor, Meta}; diff --git a/crates/gateway-domain/src/chat_completions/content.rs b/crates/gateway-domain/src/chat_completions/content.rs index 54c6270e..ebb3d5e4 100644 --- a/crates/gateway-domain/src/chat_completions/content.rs +++ b/crates/gateway-domain/src/chat_completions/content.rs @@ -1,6 +1,6 @@ //! Message content and picture parts of a chat request. -use super::*; +use super::{Content, Invalid, Value, json}; pub(crate) fn invalid(param: &'static str, message: &'static str) -> Invalid { (param, message) diff --git a/crates/gateway-domain/src/chat_completions/request.rs b/crates/gateway-domain/src/chat_completions/request.rs index dbeace87..7c80a681 100644 --- a/crates/gateway-domain/src/chat_completions/request.rs +++ b/crates/gateway-domain/src/chat_completions/request.rs @@ -1,6 +1,6 @@ //! `Request::into_responses`: the checks of the supported Chat subset and the native request it becomes. -use super::*; +use super::{Call, Content, Function, Invalid, Message, Request, Tool, Value, content, invalid, json}; impl Request { pub fn into_responses(self) -> Result<(Value, bool, bool), Invalid> { diff --git a/desktop-core/src/cli.rs b/desktop-core/src/cli.rs index 2ff0596f..e8929c00 100644 --- a/desktop-core/src/cli.rs +++ b/desktop-core/src/cli.rs @@ -23,6 +23,12 @@ pub(crate) const HELP: &str = concat!( "replace models." ); +/// The node credential held in the environment variable `name`; the node, its proxy and its worker client all take +/// it this way, so this is the one place the command line reads it. +pub(crate) fn node_credential(name: &str) -> Result> { + Ok(std::env::var(name).map_err(|_| "missing node credential")?) +} + pub(crate) fn read_json( path: &str, ) -> Result> { diff --git a/desktop-core/src/cli/node.rs b/desktop-core/src/cli/node.rs index d13cb63f..034cad2c 100644 --- a/desktop-core/src/cli/node.rs +++ b/desktop-core/src/cli/node.rs @@ -32,7 +32,7 @@ pub(crate) async fn serve(args: &[String]) -> Result<(), Failure> { let (address, token_env, mode) = split_listen_args(args)?; let address = loopback_address(address)?; check_credential_name(token_env)?; - let token = std::env::var(token_env).map_err(|_| "missing node credential")?; + let token = super::node_credential(token_env)?; let mode = parse_mode(mode, &token)?; let stdio_lifetime = mode.stdio_lifetime; let agent = build_agent(token, mode)?; diff --git a/desktop-core/src/cli/proxy.rs b/desktop-core/src/cli/proxy.rs index 5a74c4ac..37d5ad65 100644 --- a/desktop-core/src/cli/proxy.rs +++ b/desktop-core/src/cli/proxy.rs @@ -8,7 +8,7 @@ pub(crate) async fn run( if !listen.ip().is_loopback() { return Err("proxy must bind loopback".into()); } - let token = std::env::var(token_env).map_err(|_| "missing node credential")?; + let token = super::node_credential(token_env)?; let proxy = strata_desktop_core::node_proxy::Proxy::connect(address.parse()?, token).await?; let listener = tokio::net::TcpListener::bind(listen).await?; axum::serve(listener, proxy.router()) diff --git a/desktop-core/src/cli/worker.rs b/desktop-core/src/cli/worker.rs index 91d93f84..95e65470 100644 --- a/desktop-core/src/cli/worker.rs +++ b/desktop-core/src/cli/worker.rs @@ -9,7 +9,7 @@ const USAGE: &str = pub(crate) async fn run(args: &[String]) -> Result<(), Failure> { let (address, env, action, rest) = split_options(args)?; - let token = std::env::var(env).map_err(|_| "missing node credential")?; + let token = super::node_credential(env)?; let mut client = node::connect(address.parse()?).await?; let value = run_worker_action(&mut client, &token, action, rest).await?; println!("{}", serde_json::to_string(&value)?); diff --git a/desktop-core/src/runtime_rpc/generate_rpc.rs b/desktop-core/src/runtime_rpc/generate_rpc.rs index 22534eba..df3bc21f 100644 --- a/desktop-core/src/runtime_rpc/generate_rpc.rs +++ b/desktop-core/src/runtime_rpc/generate_rpc.rs @@ -1,6 +1,10 @@ //! The generation RPC. -use super::*; +use super::{ + AcceptanceGuard, EVENT_QUEUE, GenerationResponse, MESSAGE_LIMIT, ReceiverStream, Request, Response, RuntimeServer, + State, Status, WireStream, api, backend_status, close_admission, fence, loaded_with_handle, lock, mpsc, proto, + proves_nonacceptance, publish, pump, refusal, uuid, +}; /// The request is within the documented ranges; returns the backend sampling controls. fn check_generation(command: &proto::GenerateRequest) -> Result { diff --git a/desktop-core/src/runtime_rpc/model_rpc.rs b/desktop-core/src/runtime_rpc/model_rpc.rs index aef9dbbf..dc07ef7c 100644 --- a/desktop-core/src/runtime_rpc/model_rpc.rs +++ b/desktop-core/src/runtime_rpc/model_rpc.rs @@ -1,6 +1,10 @@ //! The model RPCs: load, unload and reconfigure. -use super::*; +use super::{ + Arc, FRAME_LIMIT, Inner, LifecycleGuard, Request, Response, RuntimeServer, State, Status, api, backend_status, + config_from_proto, descriptor_from_proto, fence, loaded_to_proto, loaded_with_handle, lock, operation_digest, + proto, proves_nonacceptance, publish, refusal, +}; use std::ops::ControlFlow; type LoadResult = Result<(api::LoadedModel, api::BackendCapabilities), Status>; diff --git a/desktop-core/src/runtime_rpc/service.rs b/desktop-core/src/runtime_rpc/service.rs index 86992b6f..b1a4da3b 100644 --- a/desktop-core/src/runtime_rpc/service.rs +++ b/desktop-core/src/runtime_rpc/service.rs @@ -1,6 +1,6 @@ //! The gRPC `Runtime` service: each RPC delegates to its handler in `session_rpc`, `model_rpc` or `generate_rpc`. -use super::*; +use super::{Request, Response, RuntimeServer, Status, WireStream, proto}; #[tonic::async_trait] impl proto::runtime_server::Runtime for RuntimeServer { diff --git a/desktop-core/src/runtime_rpc/session_rpc.rs b/desktop-core/src/runtime_rpc/session_rpc.rs index 643de438..dacbb2bd 100644 --- a/desktop-core/src/runtime_rpc/session_rpc.rs +++ b/desktop-core/src/runtime_rpc/session_rpc.rs @@ -1,6 +1,9 @@ //! The session RPCs: handshake, snapshot, watch, operation lookup and cancel. -use super::*; +use super::{ + Arc, FRAME_LIMIT, Inner, OwnedSemaphorePermit, PROTOCOL_VERSION, Request, Response, RuntimeServer, Status, Stream, + WireStream, api, broadcast, current_snapshot, fence, lock, proto, refusal, uuid, +}; /// The acknowledgement of a cancel: the request is cancelled, or was already finished. fn cancel_ack(command: proto::CancelRequest) -> Response { diff --git a/docs/architecture/output-event.md b/docs/architecture/output-event.md index 5b8e6dfb..e1cf6b99 100644 --- a/docs/architecture/output-event.md +++ b/docs/architecture/output-event.md @@ -42,7 +42,7 @@ wrote that markup. | `responses/create/admit.rs` `check_live_features` | gpt-oss: refuse samplers the worker `GEN` line lacks (a hard-coded field list in `effort.rs`) | `TextCodec::sampling_limit()` returns the set of samplers and the message; `sampler_limit::unsupported_sampler` reads it | | `responses/create/admit.rs` `apply_sampling_defaults` | gpt-oss: drop the samplers it lacks (a second hard-coded list) | `sampler_limit::drop_unsupported_samplers` reads the same set | | `responses/stream/*.rs`, `create/answer.rs` | `tokenizer.decoder()` bytes, then `` and `` scanning in each loop | `TextCodec::live_decoder` / `at_end_decoder`; the loops read `OutputEvent` | -| `responses/intake/parts.rs` `render_prompt` | `match family`: ChatML template with control-token marks, or the Harmony renderer | unchanged (input side, see below) | +| `responses/intake/intake_stages.rs` `render_prompt` | `match family`: ChatML template with control-token marks, or the Harmony renderer | unchanged (input side, see below) | | `responses/intake.rs` `expand_images` | needs the Qwen tokenizer (`qwen()`) for pictures | unchanged (input side) | | `responses/reasoning.rs` `reasoning_plan` | reasoning budget uses the Qwen tokenizer (`qwen()`) | unchanged (Qwen-only feature) | | `serve/engine.rs` | the runtime backend counts with the Qwen tokenizer (`qwen()`) | unchanged (composition) | @@ -201,7 +201,7 @@ Behaviours kept on purpose (they are in the golden): Harmony messages into `` and `` text, and the shared cut and parse read that. Reading the channels directly would change two corners that the golden pins: the `` inside the analysis text above, and the call-without-tools quirk. Both are behaviour changes, so they are left for a step with an owner decision. -* **Prompt rendering is still chosen by `Family`** (`intake/parts.rs`), and the picture expansion, the reasoning budget and the +* **Prompt rendering is still chosen by `Family`** (`intake/intake_stages.rs`), and the picture expansion, the reasoning budget and the runtime backend still ask for the Qwen tokenizer (`qwen()`). They are the input side of the codec; they need a prompt-rendering port, not an output one. * **`GptOssCodec` lives in `strata-control`** because it loads the BPE from a GGUF file; the decoder it hands out is in the domain. diff --git a/docs/architecture/tech-debt.md b/docs/architecture/tech-debt.md index 6be20245..c4b9cb08 100644 --- a/docs/architecture/tech-debt.md +++ b/docs/architecture/tech-debt.md @@ -55,7 +55,7 @@ What the pass did, by `scripts/dev/explicit_imports.py` (with `scripts/dev/rust_ | Crate | "Moved out" headers | `#[allow(unused_imports)] use super::*;` files | What stays a glob | |---|---|---|---| | `cuda-driver` | 471 -> 0 | 564 -> 564 | all: the compile-and-prune loop reached a state it could not close (glob sources the tool cannot trace, `macro_rules!` and item-defining macro calls, 172 files under cfg-gated names, 17 under platform cfg); two attempts with the failing top-level modules excluded were interrupted by the laptop GPU stretch, so the crate got the doc headers only | -| `engine-qwen35-cuda` | 343 -> 0 | 407 -> 236 | 127 platform cfg, 105 under cfg-gated names; `open_parts.rs` stays a glob on purpose (it is at the 400-line limit and the explicit list would put it over) | +| `engine-qwen35-cuda` | 343 -> 0 | 407 -> 236 | 127 platform cfg, 105 under cfg-gated names; `open_phase_steps.rs` (was `open_parts.rs`) stays a glob on purpose (it is at the 400-line limit and the explicit list would put it over) | | `strata-control` | 66 -> 0 | 113 -> 22 | 5 platform cfg, 17 under cfg-gated names (the `responses` and `messages` trees) | | `leleka-model-format` | 54 -> 0 | 77 -> 10 | platform cfg (`bulk_read`, `gguf_resident`, `kar`) | | `leleka-native-cpu-expert` | 58 -> 0 | 62 -> 34 | 10 behind an `extern "C"` glob chain, the rest macro-defined names | @@ -92,6 +92,37 @@ of the `heap` module, counted there now). What the census shows (production code No source ratchet was raised. `leleka-memory`: `dyn-trait` 17 -> 12 (`HostFacts::probe` and its cgroup helpers, `Census::take` and `HostSample::take` are generic over `ProcSource` now), `env-read` 3 -> 2 and `process-global` 10 -> 8 (the trim switch and its cache moved to `leleka-memory-os`, which counts `env-read` 1 and `process-global` 2). +### (c2) Second pass over the engine, gateway and deploy side (owner order 2026-11-14, branch `claude/arch-names-high`) + +**Tools** (`scripts/dev/`, offline aids, Python allowed): `explicit_imports.py` now (1) reads the crate-wide gate `cfg(all(any(target_os = "linux", +target_os = "windows"), target_arch = "x86_64"))` as always true (it made 127 engine files look platform-specific and blocked most of the 105 +"cfg-gated names" files), (2) also expands the bare `use super::*;` that has no `#[allow(unused_imports)]` above it (what `deploy` and part of the +engine carry), and (3) carries the `cfg` of a name declared in the parent onto the import (`#[cfg(feature = "preview-path")] use super::{..};`), so a file +that needs a feature-gated name no longer stays a glob. `rename_module.py` renames a module file to what it holds (`git mv`, the `mod` line, the +`#[path]` string, the path uses in the parent's subtree; `--any-ident` and `--crate-wide` for a name that is imported in lists). `set_header.py` replaces +the generated doc block by the real sentence. `wsl-cargo.sh` limits `CARGO_BUILD_JOBS` (default 4). + +**Names.** Files that said "part of a function" (`*_parts.rs`, `*_inner.rs`, `*_support.rs`, `*_glue.rs`, `shared.rs`, `preview_common.rs`, `stream_parts.rs`, +`chunk_modules.rs`, `*_display_error.rs`, truncated test names) are renamed to the responsibility, with a doc comment that says what the file is and why it is +separate (the generated "split for the size limit" line is gone from them): `tile_parts` -> `prefill_tiles_and_windows`, `reconfigure_parts` -> +`reconfigure_command`, `open_parts` -> `slot_sizing_and_open_retry` / `open_phase_steps`, `decode_parts` -> `decode_phase_steps`, `assemble_parts` -> +`assembly_steps`, `finish_parts` / `commit_parts` / `verify_parts` -> `finish_round_steps` / `commit_round_steps` / `verify_round_steps`, `stream_parts` -> +`kar_shard_plan`, `intake/parts.rs` -> `intake_stages.rs`, `original_serve_engine_original_spec_engine` -> `spec_engine_for_serve_engine`, and the others in +`git log --follow`. Left as they are, on purpose: the `*_sdet.rs` and `tests/*_sdet.rs` names (the established name of the deterministic test targets that +CI and the docs call by name), `qwen4exp_*` (the model family name, shared with `model-format`), the `*_methods` group modules (they say what they group; +their doc comment now says by which phase), `ConversationManager` (a domain type of `engine-core`; renaming it is an API change of its own). + +**Left, with the next step.** + +| What | Why it stays | Next step | +|---|---|---| +| globs in files under a platform cfg (engine 12, `deploy` 12, `strata-control` 6) | the tool compiles on Linux only | a Windows `cargo check` pass for `leleka-deploy` and `strata-control`; for the engine files (`mtp::backing`, `kar_ple`) edit by hand with the cfg on the import | +| `Governor::global()` and `serving_cells()` (engine `process-global` 59) | the S13/S14 injection: a governor handle and the context bound through the engine stack | the S13/S14 step in (d); not a cheap change | +| `Instant::now()` in `strata-control` (22), `desktop-core` (14), `deploy` (28) | the gateway `Clock` port is tokio's `Instant`, the views and the engine use `std::time::Instant`; most sites are deadlines of `tokio::time` | one `Clock` per crate with the instant type of its runtime; half a day per crate with the time-paused tests | +| env reads of `deploy` (41), `desktop-core` (evaluation and seal-exec hooks), the one-line reads of `strata-control` | the CLI and the child environment are the product; the others are test hooks | per-crate `settings` module that is the only reader | +| `path-include` (engine 100, `desktop-core` 2) | not in the owner's list for this pass | `mod x;` through the directory layout with `git mv`, one directory at a time | +| generated doc headers (`Methods of ...`, `Functions: ...`) in about 430 files of these crates | the sentence on why the file is separate needs the author's knowledge | by directory, together with the next feature that touches it | + ### (d) Other open items of this file (unchanged by the pass; the owner's order for them) 1. S13/S14 injection: `settings::process()`, `Governor::global()`, `INSTANCE`/`RECONFIGURING` and the clock into the engine stack (sections S13, S14, S19 below). Blocks most of the `process-global` and `instant-now` numbers of (b). @@ -529,7 +560,7 @@ was kept on purpose. What it did not do: | Left | Why | Removes it | |---|---|---| | `HarmonyDecoder` writes Qwen-style markup that the shared cut and parse read | reading the channels directly changes a `` inside the analysis text and the calls-without-tools quirk; both are pinned by the golden | an owner decision, then one `Bytes` arm that emits events | -| `intake/parts.rs` `render_prompt` still matches `Family`; `qwen()` for pictures, the reasoning budget and the runtime backend | input side of the codec | a prompt-rendering port | +| `intake/intake_stages.rs` `render_prompt` still matches `Family`; `qwen()` for pictures, the reasoning budget and the runtime backend | input side of the codec | a prompt-rendering port | | `GptOssCodec` lives in `strata-control` | it holds the BPE loaded from a GGUF file (`std::fs`), which the pure domain may not read | none needed; the decoder it hands out is in the domain | ## strata-control `responses/` (STRA-338 S6, rest) diff --git a/docs/laptop-profile.md b/docs/laptop-profile.md index dc16593a..007f7dae 100644 --- a/docs/laptop-profile.md +++ b/docs/laptop-profile.md @@ -283,7 +283,7 @@ Basis: the 5090 profile `rtx5090-32g.json` `engine_env` (25 keys), the laptop pr The CPU expert kernel fixes (AVX-512 rows, adaptive page-touch pass) are engine defaults and apply as they are. The three Windows-native open fixes of the 2026-10-25 run are all in the tree: `probe_libraries` (`facts/windows.rs`) finds `%LOCALAPPDATA%\leleka\cublas\bin` for `up --native` as `doctor` does; `plan_windows_mapped` (`resources/sizing.rs`) sets `resident_budget_gib` from the available RAM minus the desktop reserve and the engine's fixed footprint (never the greedy auto value); `reconfigure` refuses up front on a starved host -(`refuse_starved_host`, HTTP 409, nothing changed) and exits the engine (code 70, the supervisor restarts it) when the reopen and the rollback both fail (`reconfigure_parts.rs`). +(`refuse_starved_host`, HTTP 409, nothing changed) and exits the engine (code 70, the supervisor restarts it) when the reopen and the rollback both fail (`reconfigure_command.rs`). ### 2. Fixes (code, no GPU) diff --git a/docs/port-status.md b/docs/port-status.md index 4056ee05..dd9f71a0 100644 --- a/docs/port-status.md +++ b/docs/port-status.md @@ -49,7 +49,7 @@ A `.cu` file may sit at **S** while its Rust host side sits at **L** or **O**; b | Original unit | Rust file(s) | Completeness | Verification | | --- | --- | --- | --- | | `serve/server.py` operational routes (`/props`, `/slots`, `/v1/status`, `/settings`, `/load`, `/unload`, aliases, CORS, idle unload, reload gates, stall watchdog) | `control-plane/src/{app,server_api,worker,config,models_api}.rs`, `crates/serving-policy` | partial: web UI, telemetry (NVML/sysfs) and vision are absent | O: replayed against the real Python handlers (`tests/fixtures/golden/http_surface.json`), `serving-policy` goldens built from Original host code | -| `/v1/chat/completions`, `/v1/messages`, `/v1/responses`, SSE, tools, schema validation | `control-plane/src/{chat,messages,responses,response_tools,tool_output,stream_parts}.rs` | full for the text and function subset; stop sequences and some penalties are rejected | T: mock worker and recorded fixtures; no comparison against the upstream server | +| `/v1/chat/completions`, `/v1/messages`, `/v1/responses`, SSE, tools, schema validation | `control-plane/src/{chat,messages,responses,response_tools,tool_output,kar_shard_plan}.rs` | full for the text and function subset; stop sequences and some penalties are rejected | T: mock worker and recorded fixtures; no comparison against the upstream server | | MCP hub (`serve/mcp.py`) | `control-plane/src/mcp.rs` | stdio and Streamable HTTP | T: `tests/mcp_hub.rs` | | Sampling request keys (`sampling_keys`, `GEN` grammar) | `control-plane/src/{sampling,wire}.rs`, `crates/sampler-ref/src/params.rs` | full | O: golden `GEN` strings lifted from `server.py` by AST | | `serve/structured.py` | `responses.rs`, `response_tools.rs` | full parity (validation only, no grammar decoding) | T | diff --git a/docs/windows.md b/docs/windows.md index 2233e118..12432f96 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -394,7 +394,7 @@ What the start check needs on this laptop: fixed footprint 29.4 GiB (the mapped | --- | --- | --- | | `up --native` said cuBLAS missing while `doctor` found it | done | `facts/windows.rs::probe_libraries` searches `--cublas-dir`, the binary folder, `%LOCALAPPDATA%\leleka\cublasin` (falls back to `%USERPROFILE%\AppData\Local`), `PATH`, System32; `preflight/cuda_libraries.rs` judges `cublas64_12.dll` / `cublasLt64_12.dll` from those facts (test `a_windows_laptop_is_judged_natively_with_dll_names_and_no_systemd_or_memfd`) | | greedy page-locked complement of the mapped bank | done | `resources/sizing.rs::plan_windows_mapped`: `resident_budget_gib = (available - desktop reserve - engine fixed) / GiB`, at most 24; 12 GiB reserve (`dedicated`) or 18 GiB (`workstation`); tests in `resources/tests/windows_presets.rs` | -| `reconfigure` left the engine unusable on a starved host | done | `reconfigure_parts.rs`: `refuse_starved_host` refuses with a message before the old stack is closed; when the reopen and the rollback both fail the engine exits with code 70 two seconds after the reply and the supervisor restarts it (`exit_for_restart`). The exit path itself has no unit test (it ends the process); the refusal text is `starved_host_error` | +| `reconfigure` left the engine unusable on a starved host | done | `reconfigure_command.rs`: `refuse_starved_host` refuses with a message before the old stack is closed; when the reopen and the rollback both fail the engine exits with code 70 two seconds after the reply and the supervisor restarts it (`exit_for_restart`). The exit path itself has no unit test (it ends the process); the refusal text is `starved_host_error` | One more gap found by the same audit and closed here: under WSL2 (route A) the planner did not know the physical cores, so the `workstation` preset asked for **12** CPU expert workers on the 8-core laptop, where native Windows gets 7 (the pool pins to the 7 physical cores left after the host thread and spins the other 5 unpinned, `docs/upstream-port-plan.md` row 2.3). `facts/linux.rs` now reads the diff --git a/scripts/dev/explicit_imports.py b/scripts/dev/explicit_imports.py index 2d343f8f..7cf9718e 100644 --- a/scripts/dev/explicit_imports.py +++ b/scripts/dev/explicit_imports.py @@ -11,6 +11,7 @@ crate takes minutes per round. Offline refactoring aid (STRA-338 debt (c)); not """ import collections import json +import os import pathlib import posixpath import re @@ -20,10 +21,10 @@ import sys import tempfile sys.path.insert(0, str(pathlib.Path(__file__).parent)) -from rust_modtree import IDENT, OPAQUE, Crate, statements, strip_code # noqa: E402 +from rust_modtree import IDENT, MIXED_CFG, OPAQUE, Crate, normalize_cfg, statements, strip_code # noqa: E402 -GLOB_RE = re.compile(r"^#\[allow\(unused_imports\)\]\s*\nuse super::\*;[ \t]*\n", re.M) -USE_SUPER_RE = re.compile(r"(?m)^(?:// used only with some cargo features of this crate\n#\[allow\(unused_imports\)\]\n)?(?:#\[cfg\(test\)\]\n)?use super::(?:\{[^}]*\}|[A-Za-z_]\w*);\n") +GLOB_RE = re.compile(r"^(?:#\[allow\(unused_imports\)\]\s*\n)?use super::\*;[ \t]*\n", re.M) +USE_SUPER_RE = re.compile(r"(?m)^(?:// used only with some cargo features of this crate\n#\[allow\(unused_imports\)\]\n)?(?:#\[cfg\([^\n]*\)\]\n)*use super::(?:\{[^}]*\}|[A-Za-z_]\w*);\n") HEADER_RE = re.compile(r"\A((?://![^\n]*\n)+)") PLATFORM_CFG = re.compile( r"cfg\([^\n]*(windows|macos|miri|target_feature|not\((?:target_|windows|unix|miri)" @@ -268,6 +269,7 @@ class Plan: self.skipped = {} self._macro_cache = {} self.imports = {} # file -> {name: 'normal' | 'test'} + self.cfgs = {} # file -> {name: cfg attribute text the name is declared under in the parent} def candidates(self): return [f for f, t in self.texts.items() if GLOB_RE.search(t) and self.crate.by_file[f].parent is not None] @@ -275,7 +277,7 @@ class Plan: def skip_reason(self, f): mod = self.crate.by_file[f] decl = mod.parent.decl_attrs.get(mod.name, "") - if PLATFORM_CFG.search(decl) or PLATFORM_CFG.search(self.texts[f]): + if PLATFORM_CFG.search(normalize_cfg(decl)) or PLATFORM_CFG.search(normalize_cfg(self.texts[f])): return "platform cfg" if f.name == "tests.rs" or f.name.endswith("_tests.rs"): return "test module" @@ -296,7 +298,7 @@ class Plan: return False def blocked_reason(self, f): - return "cfg-gated names in the parent chain" if f in self.blocked else None + return "names under mixed or platform cfg in the parent chain" if f in self.blocked else None def extra_requirements(self): """{module file: names other files import from it by path (`super::X`, `crate::a::X`, `a::X`)}.""" @@ -354,8 +356,11 @@ class Plan: continue wanted |= {n for n, (may_be_trait, _) in parent_names.items() if may_be_trait} needs[f] = {n for n in wanted if n in parent_names and n not in self._own_names(mod)} - if any(parent_names[n][1] for n in needs[f]): + conditional = {n: parent_names[n][1] for n in needs[f] if parent_names[n][1]} + if any(c == MIXED_CFG or PLATFORM_CFG.search(c) for c in conditional.values()): self.blocked.add(f) + elif conditional: + self.cfgs[f] = conditional needs[f] |= {"@anon:" + p for p in orig.anon_paths(mod.parent, True) if p not in self._own_anon(mod)} return needs @@ -378,6 +383,22 @@ class Plan: done.append(f) return done + @staticmethod + def grouped_use(names, cfgs, cfg_test): + """`use super::{..};` statements for `names`, one per cfg attribute the names are declared under.""" + groups = {} + for name in names: + groups.setdefault(cfgs.get(name, ""), []).append(name) + out = "" + for cfg in sorted(groups): + statement = pack_use_fixed(groups[cfg], cfg_test) + if cfg: + # the cfg attributes of the declaration go first; `#[cfg(test)]` (added by pack_use) stays beside them + out += cfg + chr(10) + statement + else: + out += statement + return out + def render(self, f): text = self.texts[f] imports = self.imports.get(f) @@ -389,12 +410,13 @@ class Plan: anon_test = [n for n in test if n.startswith("@anon:")] normal = [n for n in normal if not n.startswith("@anon:")] test = [n for n in test if not n.startswith("@anon:")] + cfgs = self.cfgs.get(f, {}) block = "".join(f"use {n[6:]} as _;" + chr(10) for n in anon_normal) block += "".join("#[cfg(test)]" + chr(10) + f"use {n[6:]} as _;" + chr(10) for n in anon_test) - block += (pack_use_fixed(normal) if normal else "") + (pack_use_fixed(test, True) if test else "") + block += self.grouped_use(normal, cfgs, False) + self.grouped_use(test, cfgs, True) if residual: note = "// used only with some cargo features of this crate" + chr(10) - block += note + "#[allow(unused_imports)]" + chr(10) + pack_use_fixed(residual) + block += note + "#[allow(unused_imports)]" + chr(10) + self.grouped_use(residual, cfgs, False) if getattr(self, "prune", False): matches = list(USE_SUPER_RE.finditer(text)) for index in reversed(range(len(matches))): @@ -410,7 +432,8 @@ class Plan: def write(self): for f in self.texts: text = self.render(f) - if text != self.texts[f]: + # compare with what is on disk: a file given back its glob must overwrite the explicit list written before + if text != open(f, encoding="utf-8", newline="").read(): with open(f, "w", encoding="utf-8", newline=chr(10)) as handle: handle.write(text) @@ -451,9 +474,15 @@ def main(): names = {} for m in USE_SUPER_RE.finditer(text): text0 = m.group(0) - kind = "residual" if text0.startswith("// used only") else "test" if "#[cfg(test)]" in text0 else "normal" + cfg_lines = [ln for ln in text0.splitlines() if ln.startswith("#[cfg(")] + kind = "residual" if text0.startswith("// used only") else "normal" + cfg = "\n".join(cfg_lines) + if cfg == "#[cfg(test)]": + kind, cfg = ("test" if kind == "normal" else kind), "" for name in re.findall(IDENT, m.group(0).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) @@ -532,7 +561,8 @@ def main(): test_only = plan.is_test_only(f) a_unused = test_only or all(name in fl.get(r, ()) for fl in a_flags) b_unused = all(name in fl.get(r, ()) for fl in b_flags) - if a_unused and b_unused: + test_cfg = re.search(r"\btest\b", plan.cfgs.get(f, {}).get(name, "")) is not None + if (a_unused or imp[name] == "test" or test_cfg) and b_unused: # compiled by the test build only del imp[name] changed = True elif a_unused and not test_only and imp[name] == "normal": diff --git a/scripts/dev/rename_module.py b/scripts/dev/rename_module.py new file mode 100644 index 00000000..c09f9582 --- /dev/null +++ b/scripts/dev/rename_module.py @@ -0,0 +1,105 @@ +"""Rename a Rust module file to what it contains (STRA-338 debt (c), names), keeping history and every path in order. + +Usage: python scripts/dev/rename_module.py CRATE_DIR OLD_FILE NEW_NAME [--apply] + + CRATE_DIR the crate directory (holds src/) + OLD_FILE the module file to rename, as a path (`src/a/b/old_name.rs`) relative to CRATE_DIR or absolute + NEW_NAME the new module name (no `.rs`) + +Without --apply the plan is printed. With --apply the tool + + * `git mv`s the file (and the directory `old_name/` that holds its children, when one exists), + * rewrites the `mod old_name;` declaration of the parent (and the file name of its `#[path = "..."]`), + * replaces the identifier `old_name` by `NEW_NAME` in the parent file and every `.rs` file below the parent's directory (all of the crate + with --crate-wide; every whole-word use of the name with --any-ident) that names it as a path segment + (`old_name::x`, `::old_name`, `use ..{old_name, ..}`, `mod old_name`), and the old file name inside `#[path]` strings. + +It never touches a file outside CRATE_DIR; docs that quote the old name are listed so they can be updated by hand. +Offline refactoring aid, not part of the product. Compile afterwards (`cargo check --workspace --all-targets`). +""" +import os +import pathlib +import re +import subprocess +import sys + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) +from rust_modtree import Crate # noqa: E402 + + +def git(root, *args): + subprocess.run(["git", "-C", str(root), *args], check=True) + + +def main(): + crate_dir = pathlib.Path(sys.argv[1]).resolve() + old_file = pathlib.Path(sys.argv[2]) + old_file = (old_file if old_file.is_absolute() else crate_dir / old_file).resolve() + new_name = sys.argv[3] + apply = "--apply" in sys.argv + old_name = old_file.stem + crate = Crate(crate_dir) + mod = crate.by_file.get(old_file) + if mod is None or mod.parent is None: + sys.exit(f"{old_file} is not a module file of {crate_dir}") + if old_file.name in ("mod.rs", "lib.rs", "main.rs"): + sys.exit("a mod.rs / lib.rs / main.rs file is named by its directory") + new_file = old_file.with_name(new_name + ".rs") + old_dir, new_dir = old_file.with_suffix(""), new_file.with_suffix("") + if new_file.exists(): + sys.exit(f"{new_file} exists") + name = re.escape(old_name) + # only the uses of the name as a module: `old::x`, `mod old`, `super::old;` (not a function, method or field `old`) + ident = re.compile( + rf"(? {new_file.name} (module `{old_name}` of {mod.parent.file.name})") + touched = [] + parent_file = mod.parent.file + scope_dir = parent_file.parent if parent_file.name in ("mod.rs", "lib.rs", "main.rs") else parent_file.with_suffix("") + scope = [parent_file] + (sorted(scope_dir.rglob("*.rs")) if scope_dir.is_dir() else []) + if "--crate-wide" in sys.argv: + scope = sorted(crate_dir.rglob("*.rs")) + for file in dict.fromkeys(scope): + if "target" in file.parts: + continue + text = file.read_text(encoding="utf-8") + if old_name not in text: + continue + new_text = path_name.sub(rf"\g<1>{new_name}\g<2>", text) + new_text = path_dir.sub(rf"\g<1>{new_name}\g<2>", new_text) + new_text = ident.sub(new_name, new_text) + if new_text != text: + touched.append((file, text, new_text)) + for file, text, new_text in touched: + hits = len(ident.findall(text)) + len(path_name.findall(text)) + len(path_dir.findall(text)) + print(f" rewrite {file.relative_to(crate_dir)}: {hits} occurrence(s)") + if not apply: + return + root = subprocess.run( + ["git", "-C", str(crate_dir), "rev-parse", "--show-toplevel"], capture_output=True, text=True, check=True + ).stdout.strip() + git(root, "mv", str(old_file), str(new_file)) + if old_dir.is_dir(): + git(root, "mv", str(old_dir), str(new_dir)) + for file, text, new_text in touched: + if file == old_file: + file = new_file + elif old_dir in file.parents: + file = new_dir / file.relative_to(old_dir) + with open(file, "w", encoding="utf-8", newline="\n") as handle: + handle.write(new_text) + docs = subprocess.run( + ["git", "-C", root, "grep", "-l", "-F", old_name + ".rs", "--", "docs", "scripts", "*.md", "*.json"], + capture_output=True, text=True, + ).stdout.split() + if docs: + print("files that still quote the old file name:", *docs, sep="\n ") + + +if __name__ == "__main__": + main() diff --git a/scripts/dev/rust_modtree.py b/scripts/dev/rust_modtree.py index c3da93b5..f12e3acb 100644 --- a/scripts/dev/rust_modtree.py +++ b/scripts/dev/rust_modtree.py @@ -2,6 +2,7 @@ This is a one-off refactoring aid (STRA-338 debt (c)); it is not part of the product and not committed. """ +import os import pathlib import re @@ -9,8 +10,58 @@ IDENT = r"(?:r#)?[A-Za-z_][A-Za-z0-9_]*" OPAQUE = None # a glob that cannot be resolved inside the crate (external crate, enum variants) -def strip_code(text): - """The text with comments, string and char literals blanked (newlines kept) so structure can be scanned.""" +_OS = r'target_os = "(?:linux|windows)"' +SUPPORTED_GATE = re.compile( + rf'all\(any\({_OS}, {_OS}\), target_(?:arch = "x86_64"|pointer_width = "64")\)|any\({_OS}, {_OS}\)' +) + +# a name declared under different `cfg` attributes (or under one and without): it cannot be imported by one cfg +MIXED_CFG = "" + + +def merge_cfg(old, new): + """The cfg of a name seen with `old` (None: not seen) and again with `new`: equal ones agree, others are mixed.""" + if old is None or old == new: + return new + return MIXED_CFG + + +def cfg_text(raw_text, stripped, start, head): + """The `#[cfg(..)]` attributes (supported-target gate removed) of the statement that starts at `start`, as text + ('' when it has none); `stripped` is `strip_code(raw_text, keep_offsets=True)`, so offsets agree.""" + head_start = stripped.index(head, start) if head else start + found = re.findall(r"#\[cfg\([^\n]*?\)\]", raw_text[start:head_start]) + return normalize_cfg("\n".join(found)).strip() + + +def normalize_cfg(text): + """`text` with the crate-wide gate of the supported targets (Linux or Windows on x86_64, true wherever the crate builds) + replaced by `true`, so that it is not mistaken for a platform difference; `cfg(true)` attributes are dropped.""" + text = SUPPORTED_GATE.sub("true", text) + text = re.sub(r"(?<=all\()true, ", "", text) + text = re.sub(r", true(?=[,)])", "", text) + return re.sub(r"#\[cfg\(true\)\]", "", text) + + +def has_cfg(attrs): + """True when the attribute text carries a `cfg(` that really conditions the item (the supported-target gate does not).""" + return "cfg(" in normalize_cfg(attrs) + + +def _blank(text, i, j): + """Spaces for text[i:j], newlines kept.""" + return "".join(ch if ch == "\n" else " " for ch in text[i:j]) + + +def _quoted(text, i, j): + """The string literal text[i:j] as quotes around spaces (newlines kept): the same length.""" + return '"' + _blank(text, i + 1, j - 1) + '"' if j - i >= 2 else _blank(text, i, j) + + +def strip_code(text, keep_offsets=False): + """The text with comments, string and char literals blanked (newlines kept) so structure can be scanned. + With `keep_offsets` every character keeps its offset (blanked ones become spaces), so a span found in the result + can be cut out of the original text.""" out = [] i, n = 0, len(text) while i < n: @@ -18,7 +69,10 @@ def strip_code(text): two = text[i : i + 2] if two == "//": j = text.find("\n", i) - i = n if j < 0 else j + j = n if j < 0 else j + if keep_offsets: + out.append(" " * (j - i)) + i = j continue if two == "/*": depth, j = 1, i + 2 @@ -29,7 +83,7 @@ def strip_code(text): depth, j = depth - 1, j + 2 else: j += 1 - out.append("\n" * text.count("\n", i, j)) + out.append(_blank(text, i, j) if keep_offsets else "\n" * text.count("\n", i, j)) i = j continue raw = re.match(r'(?:b?r)(#*)"', text[i : i + 12]) if c in "rb" else None @@ -37,7 +91,7 @@ def strip_code(text): end = '"' + raw.group(1) j = text.find(end, i + raw.end()) j = n if j < 0 else j + len(end) - out.append('""' + "\n" * text.count("\n", i, j)) + out.append(_blank(text, i, j) if keep_offsets else '""' + "\n" * text.count("\n", i, j)) i = j continue if c == '"' or (c == "b" and text[i : i + 2] == 'b"'): @@ -45,14 +99,14 @@ def strip_code(text): while j < n and text[j] != '"': j += 2 if text[j] == "\\" else 1 j = min(j + 1, n) - out.append('""' + "\n" * text.count("\n", i, j)) + out.append(_quoted(text, i, j) if keep_offsets else '""' + "\n" * text.count("\n", i, j)) i = j continue if c == "'": if text[i + 1 : i + 2] == "\\": j = text.find("'", i + 2) j = n if j < 0 else j + 1 - out.append("' '") + out.append("'" + " " * (j - i - 2) + "'" if keep_offsets else "' '") i = j continue if text[i + 2 : i + 3] == "'": @@ -200,12 +254,19 @@ class Module: def text(self): return self.file.read_text(encoding="utf-8") + def _mark(self, name, cfg): + """Record that `name` is declared under `cfg` (a second, different cfg makes it mixed).""" + self.conditional[name] = merge_cfg(self.conditional.get(name), cfg) + def parsed(self): """(items {name: is_pub}, uses [(name, is_pub, path)], globs [(path, is_pub)])""" if self._parsed: return self._parsed - items, uses, globs, self.anon, self.conditional = {}, [], [], [], set() - for attrs, head, _, _ in statements(strip_code(self.text)): + items, uses, globs, self.anon, self.conditional = {}, [], [], [], {} + raw_text = self.text + kept = strip_code(raw_text, keep_offsets=True) + for attrs, head, start, _ in statements(kept): + cfg = cfg_text(raw_text, kept, start, head) m = re.match(r"(pub\s*(?:\([^)]*\))?\s+)?use\b(.*?);?\s*$", head, re.S) if m: is_pub = bool(m.group(1)) @@ -218,8 +279,8 @@ class Module: name = path[-2] if name != "_": uses.append((name, is_pub, path)) - if "cfg(" in attrs: - self.conditional.add(name) + if cfg: + self._mark(name, cfg) elif path[0] not in ("super", "self"): self.anon.append(("::".join(path), is_pub)) continue @@ -228,26 +289,26 @@ class Module: rf"(pub(?:\s*\([^)]*\))?\s+)?(?:safe\s+|unsafe\s+)?(fn|static)\s+({IDENT})", head ): items[name.removeprefix("r#")] = (bool(vis), kind) - if "cfg(" in attrs: - self.conditional.add(name.removeprefix("r#")) + if cfg: + self._mark(name.removeprefix("r#"), cfg) continue macro = re.match(rf"({IDENT}(?:::{IDENT})*)\s*!\s*[(\[{{]", head) if macro and macro.group(1) != "macro_rules": # an item-defining macro call: every constant-like name and every named item inside may be a definition for name in re.findall(r"\b([A-Z][A-Z0-9_]{2,})\b", head): items[name] = (True, "macro") - if "cfg(" in attrs: - self.conditional.add(name) + if cfg: + self._mark(name, cfg) for kind, name in re.findall(rf"\b(fn|struct|enum|const|static|trait|type|mod)\s+({IDENT})", head): items[name] = (True, "macro") - if "cfg(" in attrs: - self.conditional.add(name) + if cfg: + self._mark(name, cfg) continue m = ITEM_RE.match(head) if m and m.group(3) != "_": items[m.group(3).removeprefix("r#")] = (bool(m.group(1)), m.group(2)) - if "cfg(" in attrs: - self.conditional.add(m.group(3).removeprefix("r#")) + if cfg: + self._mark(m.group(3).removeprefix("r#"), cfg) self._parsed = (items, uses, globs) return self._parsed @@ -258,9 +319,11 @@ class Crate: self.by_file = {} self.root = None src = self.root_dir / "src" - for name in ("lib.rs", "main.rs"): - if (src / name).exists(): - self.root = self._add((src / name).resolve(), None, "crate") + # ROOT_FILE (relative to the crate directory) names another crate root, such as `src/bin/tool/main.rs` + roots = [os.environ["ROOT_FILE"]] if os.environ.get("ROOT_FILE") else ["src/lib.rs", "src/main.rs"] + for name in roots: + if (self.root_dir / name).exists(): + self.root = self._add((self.root_dir / name).resolve(), None, "crate") break self._ns_cache = {} @@ -322,10 +385,10 @@ class Crate: return False def names(self, mod, full, _stack=()): - """{name: (may_be_a_trait, is_conditional)} visible in `mod` to its descendants (`full`) or to outsiders + """{name: (may_be_a_trait, cfg text)} visible in `mod` to its descendants (`full`) or to outsiders (pub-ish only); OPAQUE when a glob cannot be resolved. A name may be a trait when it is a trait item or an imported CamelCase name: a trait in scope is used by method calls without ever being written. A name is - conditional when its declaration carries a `cfg` attribute.""" + conditional when its declaration carries a `cfg` attribute: the second member is that cfg text ('' when none).""" key = (mod.file, full) if key in self._ns_cache: return self._ns_cache[key] @@ -334,14 +397,15 @@ class Crate: stack = _stack + (key,) items, uses, globs = mod.parsed() cond = mod.conditional - out = {n: (kind == "trait", n in cond) for n, (is_pub, kind) in items.items() if full or is_pub} + out = {n: (kind == "trait", cond.get(n, "")) for n, (is_pub, kind) in items.items() if full or is_pub} for n, is_pub, _ in uses: if full or is_pub: - old = out.get(n, (False, False)) - out[n] = (old[0] or n[:1].isupper(), old[1] or n in cond) + old = out.get(n) + here = (n[:1].isupper(), cond.get(n, "")) + out[n] = here if old is None else (old[0] or here[0], merge_cfg(old[1], here[1])) for n in mod.children: if full: - out.setdefault(n, (False, False)) + out.setdefault(n, (False, "")) result = out for path, is_pub in globs: if not (full or is_pub): @@ -356,8 +420,8 @@ class Crate: break result = dict(result) for n, (may, conditional) in inner.items(): - old = result.get(n, (False, False)) - result[n] = (old[0] or may, old[1] or conditional) + old = result.get(n) + result[n] = (may, conditional) if old is None else (old[0] or may, merge_cfg(old[1], conditional)) self._ns_cache[key] = result return result diff --git a/scripts/dev/set_header.py b/scripts/dev/set_header.py new file mode 100644 index 00000000..c387df49 --- /dev/null +++ b/scripts/dev/set_header.py @@ -0,0 +1,25 @@ +"""Replace the leading `//!` doc block of a Rust file by the given lines (the real "what and why" of a file). + +Usage: python scripts/dev/set_header.py FILE LINE [LINE ...] (each LINE at most 116 columns; `//! ` is added) +Offline refactoring aid (STRA-338 debt (c)), not part of the product. +""" +import pathlib +import sys + + +def set_header(path, lines): + for line in lines: + if len(line) > 116: + sys.exit(f"{path}: header line too long ({len(line)}): {line}") + text = pathlib.Path(path).read_text(encoding="utf-8") + rows = text.split("\n") + end = 0 + while end < len(rows) and rows[end].startswith("//!"): + end += 1 + rows[:end] = ["//! " + line for line in lines] + with open(path, "w", encoding="utf-8", newline="\n") as handle: + handle.write("\n".join(rows)) + + +if __name__ == "__main__": + set_header(sys.argv[1], sys.argv[2:]) diff --git a/scripts/dev/wsl-cargo.sh b/scripts/dev/wsl-cargo.sh index 18e1aead..ba3fe6f9 100644 --- a/scripts/dev/wsl-cargo.sh +++ b/scripts/dev/wsl-cargo.sh @@ -4,4 +4,4 @@ log="$1"; shift root="$(cd "$(dirname "$0")/../.." && pwd)" wslroot="/mnt/$(echo "${root}" | sed -E 's#^/([a-zA-Z])/#\L\1/#')" -MSYS_NO_PATHCONV=1 wsl -d Ubuntu -e bash -lc "source ~/.cargo/env; cd '${wslroot}'; export CARGO_INCREMENTAL=0 CARGO_TARGET_DIR=\$PWD/target/wsl; cargo $* > '${wslroot}/${log}' 2>&1; echo \"EXIT \$?\" >> '${wslroot}/${log}'" +MSYS_NO_PATHCONV=1 wsl -d Ubuntu -e bash -lc "source ~/.cargo/env; cd '${wslroot}'; export CARGO_INCREMENTAL=0 CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-4} CARGO_TARGET_DIR=\$PWD/target/wsl; cargo $* > '${wslroot}/${log}' 2>&1; echo \"EXIT \$?\" >> '${wslroot}/${log}'"