engine-qwen35-cuda: explicit imports instead of use super::* in all 193 files (test modules, GPU proofs and platform-cfg files included)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-14 20:35:20 +01:00
co-authored by Claude Sonnet 5.5
parent b66ed637ff
commit c0d34a6648
194 changed files with 1065 additions and 248 deletions
@@ -1,7 +1,11 @@
//! The request clocks of the backend on a manual clock (STRA-338 S14): the terminal publication deadline, the
//! prefill/decode accounting of the measurement recorder and the clock reads of the source verification.
use super::*;
use super::{
BACKPRESSURE_TIMEOUT, Clock, ContractError, Duration, EvaluationMeasurement, FinishReason, GenerationEvent,
GenerationFailure, GenerationSink, GenerationTerminal, NativeBackendConfig, Usage, emit_event, emit_terminal,
measurement, verify_sources_parallel,
};
use leleka_obs::time::ManualClock;
fn completed() -> GenerationTerminal {
@@ -1,5 +1,21 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationExecution,
EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent,
GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive,
InputBindingError, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION,
LoadedModel, MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice,
OriginalServeMode, OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda,
Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender,
SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, close_context, load, thread,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners as LoadedTarget;
use std::env;
pub(super) mod rig;
@@ -1,7 +1,11 @@
//! The loaded real owners the single-load GPU proofs share: the pinned binding over the inherited sealed archive,
//! the device owners built on one bounded Context, a phase run on a fresh target owner, and the teardown whose
//! results are asserted only after every attempt was made. Opening and scheduling stay with each proof.
use super::*;
use super::{
InheritedKarArchive, ModelBinding, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Tokenizer, VerifiedGgufFile,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
use std::{
env,
panic::{AssertUnwindSafe, catch_unwind},
@@ -1,7 +1,15 @@
//! Disposable, real-owner numerical observation. Never an actor publication gate.
//! Forced inputs are public IDs; no expected model tensors or invented state.
use super::combined_changed_boundary_proof::rig::Owners;
use super::*;
use super::{
AtomicBool, EvaluationExecution, FinishReason, Generation, GenerationSink, ModelBinding, MtpContinuation, Mutex,
Shared, SystemClock, Tokenizer, generate_mtp_resume,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, KarPleCache, MoeWeightCache, MtpDecoder, OutputStage, QwenSession, TargetStepProduct,
TokenId,
};
use crate::qwen_forward::mtp::KnownNext;
use crate::qwen_forward::mtp_decode::DraftHeadOwners;
use crate::qwen_forward::{mtp::PrefixDraftSnapshot, session::ResetReplaySnapshot};
@@ -3,7 +3,9 @@
use super::combined_changed_boundary_proof::rig::{
DEVICE_BUDGET, MOE_REFUSAL, Owners, PinnedTokenizer, bind_pinned_with_tokenizer, require_opt_in,
};
use super::*;
use super::{Driver, ModelBinding, PathBuf, Rc, Tokenizer};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenSession};
use std::{
env,
panic::{AssertUnwindSafe, catch_unwind, resume_unwind},
@@ -1,5 +1,11 @@
//! The single-token generation step loop.
use super::*;
use super::{
AtomicBool, BackendError, Clock, DenseWeightCache, Dimension, ErrorCode, EvaluationExecution, FinishReason,
GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationSink, Instant, KarPleCache, ModelBinding,
MoeWeightCache, MtpDecoder, Ordering, OutputStage, Position, QwenForward, QwenSession, Shared, SystemClock,
TargetStepProduct, TokenId, Tokenizer, Usage, Utf8Pending, emit_event, error, exhausted, generate_mtp, invalid,
measurement, native_position, unavailable, unsupported,
};
use crate::qwen_forward::executor::{PrefillChunkInputs, StepCaches, StepRequest};
pub(super) struct Generation<'a, 'context, 'driver, C: Clock = SystemClock> {
@@ -1,6 +1,8 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in};
use super::*;
use super::{Driver, EvaluationExecution, ModelBinding, PathBuf, Rc};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenForward};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use std::{env, panic::resume_unwind};
@@ -5,7 +5,10 @@
//! `FakeDevice` (no GPU). Time is a `ManualClock` that the device moves by the scripted cost of a chunk or a round, so
//! the deadline and the prefill/decode accounting are exact. Normal completion, stop, length, acceptance and timing
//! are here; `ends` holds the cancel, deadline and error exits, `prefix` the cross-session cache.
use super::*;
use super::{
Arc, AtomicBool, ErrorCode, FinishReason, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink,
GenerationStream, GenerationTerminal, Mutex, Ordering, Shared, Tokenizer, Usage, original_serve,
};
use crate::qwen_forward::original_serve_engine::{ServeOutcome, ServeStop};
use crate::qwen_forward::original_serve_request::{ServeDevice, ServeError, ServeRequest};
use crate::qwen_forward::original_serve_stack::lifecycle_fake::{FakeDevice, FakeStack, Script, greedy_continuation};
@@ -1,6 +1,12 @@
//! The owner-side Load: bind the sources, open CUDA, build the caches, then serve generations until Unload.
//! The phases live in `load_*.rs`; this file fixes the order they run in.
use super::*;
use super::{
Announcement, BackendError, Bound, Closed, Command, EvaluationExecution, EvaluationObserver, Identity, LoadedModel,
ModelDescriptor, NativeBackendConfig, OptimizedBackendConfig, Ordering, QwenSession, Rc, Receiver, Reply,
RuntimeConfig, Serving, Shared, SystemClock, admit_load, bind_model, build_loaded, check_not_cancelled,
close_context, close_weights, experimental_modes, launch_original, load_weights, new_conversations,
open_checked_context, open_driver, original_serve, probe_experimental_plan, serve_commands, start_governor,
};
use leleka_cuda_driver::Context;
/// Everything one Load needs from its owner thread.
@@ -1,5 +1,9 @@
//! The CUDA half of a Load: driver, device context, load-time probes and the hand-over to the Original serve stack.
use super::*;
use super::{
Announcement, BackendError, Bound, Driver, Governed, LoadEnv, LoadPhase, ModelBinding, NativeBackendConfig, Rc,
build_loaded, exhausted, experimental_modes, load_failure, original_serve, probe_experimental,
probe_kar_level_decode, unavailable,
};
use leleka_cuda_driver::Context;
pub(super) fn open_driver() -> Result<Driver, BackendError> {
@@ -1,6 +1,9 @@
//! What the phase functions of the Load (STRA-338 S5b) must keep from the code they replaced: the policy flags, the
//! execution gates and the weight-cache log line, each compared with the expressions of the former `serve_load`.
use super::*;
use super::{
Counters, EvaluationExecution, OptimizedBackendConfig, OptimizedOwnerPolicy, PolicyFlags, execution_gate_message,
generation_cache_line,
};
#[cfg(feature = "preview-path")]
use crate::qwen_forward::dense_weight_cache::DenseCacheCounters;
#[cfg(feature = "preview-path")]
@@ -1,5 +1,8 @@
//! The weight caches a native Load builds on the CUDA context: output head, KAR PLE cache, dense and MoE weights.
use super::*;
use super::{
BackendError, Bound, DenseWeightCache, KarPleCache, LoadEnv, LoadPhase, ModelBinding, MoeWeightCache, OutputStage,
PolicyFlags, exhausted, invalid, load_failure, load_forward_failure, load_moe,
};
use leleka_cuda_driver::Context;
type ForwardResult<T> = Result<T, crate::qwen_forward::contract::Error>;
@@ -1,6 +1,21 @@
//! Candidate-only PUBLIC quality proof against one retained actual Native arm.
//! Historical wall time is never used as an A/B measurement.
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, DenseWeightCache, Digest, Dimension, Driver, Duration, ErrorCode,
EvaluationExecution, EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FRAME_LIMIT,
FinishReason, Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream,
GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError, InputConstants, Instant,
KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, KarPleCache,
LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure, ModelBinding, ModelDescriptor, MoeWeightCache,
MtpContinuation, MtpDecoder, MtpWindowError, MtpWindowSpec, Mutex, Ordering, OriginalServeChoice,
OriginalServeMode, OriginalServeOptions, OutputStage, PathBuf, Position, PrefixCacheOptions, PrefixTail, QUEUE,
Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, QwenForward, QwenSession, Rc, Receiver, RecentIds,
ResidentConversations, ResidentPolicy, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, SupportedModelTuple,
SyncSender, SystemClock, TargetStepProduct, TokenId, Tokenizer, Usage, VerifiedGgufFile, WindowWitness,
combined_changed_boundary_proof, emit_terminal, error, generate, generate_mtp_resume, load, measurement, owner,
prepare_prompt, request, session, spawn, thread,
};
use serde_json::{Value, json};
use std::{
env,
@@ -1,7 +1,26 @@
//! Configured five PUBLIC cases on one actual Strata adaptive cache owner.
//! No Native inference replay; original paired quality/timing remains separately required.
use super::super::combined_changed_boundary_proof::rig::close_context_flags;
use super::*;
use super::{
Arc, AssertUnwindSafe, AtomicBool, AtomicU64, BACKEND_API_VERSION, BASELINE_SHA, Backend, BackendCapabilities,
BackendError, BackendIdentity, Baseline, CAP, CacheCounts, Clock, ContractError, DEVICE_BUDGET, DeferredTail,
Digest, Driver, Duration, ErrorCode, EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource,
FinishReason, GenerationEvent, GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal,
InferenceMode, InheritedKarArchive, InputBindingError, Inputs, KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels,
KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure,
ModelBinding, ModelDescriptor, Mutex, OpenOptions, OpenOptionsExt, Ordering, OriginalServeChoice,
OriginalServeMode, OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Proof, Qwen4ExpArtifact,
Qwen35Cuda, Qwen35CudaStart, Rc, Read, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared,
SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, Value, VerifiedGgufFile, WindowWitness, Write,
baseline, catch_unwind, env, error, fivecase_runtime, json, metadata, path, request, resume_unwind, save, sha,
thread, token_ids,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport};
use std::path::Path;
@@ -1,5 +1,8 @@
//! The cleanup documents of the adaptive proof and the assertions made once every teardown attempt was done.
use super::*;
use super::{
AdaptiveClosed, AssertUnwindSafe, Baseline, InheritedKarArchive, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, Path,
Value, bank_copies_json, catch_unwind, fivecase_runtime, json, resume_unwind, save, token_ids,
};
/// The owner wall profile as the artifacts record it.
pub(super) struct OwnerWall {
@@ -1,5 +1,7 @@
//! What the adaptive owners reported before and during their ordered teardown.
use super::*;
use super::{AdaptiveOwners, ModelBinding, Value, bank_report_json, json};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, MoeWeightCache};
/// A completion counter as the artifacts record it, and whether it is positive.
pub(super) struct Count {
@@ -1,6 +1,9 @@
//! Private CPU-only framing on the caller's already admitted tokenizer.
//! No model load, generation, expected outputs or state/capability publication.
use super::*;
use super::{
CAP, GenerationRequest, Inputs, MODEL_DIGEST, OpenOptions, OpenOptionsExt, PathBuf, Read, Tokenizer, Value, env,
json, path, prepare_prompt, public_renderer, request, save, sha,
};
use std::os::unix::fs::{MetadataExt, PermissionsExt};
const BASE_FRAME_SHA: &str = "9512d4883fca31282206c3a03c8d4d3f3085b5c1dfedd998c8957061e01514e4";
@@ -1,6 +1,9 @@
//! Private five fresh public requests on the caller's one admitted model owner.
//! This helper neither loads weights nor supplies an output oracle.
use super::*;
use super::{
Arm, CAP, EvaluationExecution, FinishReason, GenerationRequest, Inputs, KAR_MTP_PROFILE, MODEL_DIGEST, OpenOptions,
OpenOptionsExt, Read, Tokenizer, Value, candidate_windows, env, json, path, prepare_prompt, save, sha, token_ids,
};
use std::os::unix::fs::MetadataExt;
const CASE_COUNT: usize = 5;
const BASE_FRAME_SHA: &str = "9512d4883fca31282206c3a03c8d4d3f3085b5c1dfedd998c8957061e01514e4";
@@ -1,6 +1,13 @@
//! One actual owner generation on a fresh target/draft state: bounded stream consumer, failure artifact and the
//! measurement record of a completed arm.
use super::*;
use super::{
AtomicBool, CacheCounts, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason,
Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream,
GenerationTerminal, ModelBinding, MtpContinuation, Ordering, QUEUE, Rc, Shared, SystemClock, Tokenizer, Usage,
Value, WindowWitness, cache, cache_json, emit_terminal, generate_mtp_resume, json, measurement, path, save, thread,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, Instant, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
const WALL_BOUNDARY: &str = "immediately before generate_mtp_resume through terminal, actual channel EOF and \
consumer join; excludes session teardown and helpers";
@@ -1,5 +1,5 @@
//! The retained completed Native arm and the checks of the MTP window witnesses of a candidate arm.
use super::*;
use super::{Arm, FRAME_LIMIT, Value, WindowWitness, json, sealed_bytes, sha};
pub(super) const BASELINE_SHA: &str = "4d61ee949d37a738500c889f23f07310b6d75c7c8dfe5f50173eceafe1882fbe";
pub(super) struct Baseline {
@@ -1,6 +1,11 @@
//! The one loaded owner of the PUBLIC candidate proofs: admission of the sealed inputs, the load, the ordered
//! teardown and the artifacts of it. The proofs differ only in the `Proof` hooks (`native_down_pair_proofs.rs`).
use super::*;
use super::{
AtomicBool, BASELINE_SHA, Baseline, CAP, DenseWeightCache, GenerationRequest, InheritedKarArchive, Inputs, Instant,
KAR_MTP_PROFILE, KarPleCache, MODEL_DIGEST, ModelBinding, MoeWeightCache, Mutex, OpenOptions, OpenOptionsExt,
OutputStage, PathBuf, Qwen4ExpArtifact, Rc, Read, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile,
baseline, env, json, metadata, path, request, save, sha,
};
use crate::qwen_forward::owner_wall_profile::{self, Sample};
use leleka_model_format::qwen4exp::{ProvisionalExpertSource, ResidentExpertSourceReport};
use std::os::unix::fs::PermissionsExt;
@@ -1,6 +1,10 @@
//! The four PUBLIC candidate proofs: they differ in the caches they load, in what they generate and in what
//! they conclude; the owner, the teardown and the artifacts are shared (`native_down_pair_run.rs`).
use super::*;
use super::{
Arm, BASELINE_SHA, Baseline, CAP, Check, DenseWeightCache, EvaluationExecution, Finish, FinishReason,
KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding, MoeFacts, MoeWeightCache, Owner, Proof, QwenForward, QwenSession, Rc,
RunCtx, Value, cache_json, candidate_windows, fivecase_runtime, json, merged, save, token_ids, with_counters,
};
use crate::qwen_forward::moe_expert::LoadedArms;
use crate::qwen_forward::moe_weight_cache::LearnedMainWitness;
use fivecase_runtime::FiveCaseReport;
@@ -1,6 +1,9 @@
//! Runs a `Proof` on the one loaded owner: generation, ordered teardown, the cleanup artifacts that survive a
//! failed generation, and the assertions that follow every attempted teardown.
use super::*;
use super::{
AssertUnwindSafe, DEVICE_BUDGET, Driver, Finish, Host, InheritedKarArchive, ModelBinding, Owner, OwnerCounters,
Proof, Rc, RunCtx, Teardown, Value, Witnessed, bank_json, catch_unwind, json, merged, resume_unwind, save,
};
use crate::qwen_forward::owner_wall_profile::{self, Sample};
const SCOPE: &str =
@@ -1,6 +1,9 @@
//! Files, environment, request framing and counters shared by the PUBLIC pair proofs.
//! Included by `native_down_candidate_only.rs` and `native_down_public_pair.rs` (each owns its copy of the state).
use super::*;
use super::{
CacheCounts, Digest, GenerationRequest, OpenOptions, OpenOptionsExt, Ordering, PathBuf, Read, Sha256, Tokenizer,
Value, Write, env, json, prepare_prompt, public_renderer,
};
pub(super) const ARTIFACT_CAP: usize = 16 * 1024 * 1024;
pub(super) static ARTIFACT_BYTES: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
@@ -1,5 +1,25 @@
//! One-load private PUBLIC generation pair; actual owner timings, never HTTP timings.
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationExecution,
EvaluationMeasurement, EvaluationObserver, ExperimentalConfig, ExpertSource, FRAME_LIMIT, FinishReason, Generation,
GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream, GenerationTerminal,
InferenceMode, InheritedKarArchive, InputBindingError, KAR_MTP_PROFILE, KarArchiveRef, KarExpertLevels,
KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel, MODEL_DIGEST, MeasurementFailure,
ModelBinding, ModelDescriptor, MtpContinuation, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, QUEUE, Qwen4ExpArtifact, Qwen35Cuda,
Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, Shared, SupportedModelTuple,
SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, emit_terminal, error,
generate_mtp_resume, load, measurement, owner, request, spawn, thread,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId, session,
};
#[cfg(test)]
use super::prepare_prompt;
use serde_json::{Value, json};
use std::{
env,
@@ -1,6 +1,13 @@
//! One actual owner generation of the one-load PUBLIC pair on a fresh target/draft state: bounded stream
//! consumer, failure artifact and the measurement record of a completed arm.
use super::*;
use super::{
AtomicBool, CacheCounts, Duration, EvaluationExecution, EvaluationMeasurement, FRAME_LIMIT, FinishReason,
Generation, GenerationEvent, GenerationFailure, GenerationRequest, GenerationSink, GenerationStream,
GenerationTerminal, ModelBinding, MtpContinuation, QUEUE, Rc, Shared, SystemClock, Tokenizer, Usage, Value,
WindowWitness, cache, cache_json, emit_terminal, generate_mtp_resume, json, measurement, path, save, thread,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage, QwenSession};
pub(super) struct Arm {
pub(super) measurement: EvaluationMeasurement,
@@ -1,5 +1,13 @@
//! The one-load PUBLIC pair: sealed inputs, one owner load, four arms (two warm, two measured) and the artifacts.
use super::*;
use super::{
ARTIFACT_BYTES, ARTIFACT_CAP, Arm, AssertUnwindSafe, AtomicBool, CAP, DEVICE_BUDGET, Driver, Duration,
EvaluationExecution, GenerationRequest, InheritedKarArchive, Inputs, KAR_MTP_PROFILE, MODEL_DIGEST, ModelBinding,
Mutex, Ordering, PathBuf, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, Shared, Tokenizer, Value, VerifiedGgufFile,
catch_unwind, env, json, long_public_preflight, merged, metadata, ns, path, request, reserve_artifacts,
resume_unwind, save, sha,
};
#[cfg(feature = "preview-path")]
use super::{DenseWeightCache, KarPleCache, MoeWeightCache, OutputStage};
use std::os::unix::fs::PermissionsExt;
const NATIVE_POLICY: &str = "native64-same-dual-cache-retained-mtp-kv";
@@ -1,6 +1,8 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, Owners, bind_pinned, require_opt_in};
use super::*;
use super::{Driver, EvaluationExecution, ModelBinding, PathBuf, Rc};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenForward};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use std::{env, panic::resume_unwind};
@@ -1,8 +1,16 @@
//! The steps of the Original owner loop `run`: open and report the stack, admit and serve a generate command,
//! sweep idle sessions and close everything; early exits stay in `run`.
#[allow(unused_imports)]
use super::*;
use super::{
ActiveGuard, Admission, AtomicBool, BackendError, CapturedIds, ClientLink, Clock, Command, DeferredTail, Duration,
ErrorCode, FinishReason, ForwardError, GENERATION_TIMEOUT, GenerationEvent, GenerationFailure, GenerationRequest,
GenerationSink, GenerationTerminal, IdleSweep, Live, LoadPhase, LoadedModel, LoopCtx, ModelBinding, Ordering,
OriginalServeOptions, OriginalServeStack, PREFIX_SUMMARY, PathBuf, PhaseDurations, PrefixTail, QUEUE, Rc, Receiver,
ReopenEnv, Reply, RequestToServe, ServeDevice, ServeError, ServeFailure, ServeRequest, ServeStop, Shared,
StackConfig, SystemClock, TokenVocabulary, Tokenizer, Usage, Utf8Pending, context_fits, emit_terminal, exhausted,
generate, invalid, load_failure, meta_facts, open_error, prepare_prompt, publish_prefix_summary, stack_config,
unavailable,
};
use leleka_backend_api::GenerationStream;
use leleka_cuda_driver::Context;
use std::sync::Arc;
@@ -1,6 +1,6 @@
//! Unit tests of `original_serve`.
use super::*;
use super::{ConfigFacts, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, PathBuf, choose, context_fits};
fn facts() -> ConfigFacts {
ConfigFacts {
@@ -23,7 +23,23 @@
//!
//! Output lines: `MEM-REPORT <tag> <json>` (the governor's full report), `MEM-CENSUS <json>`, `MEM-SOAK ...`, `MEM-SHED
//! ...`, `MEM-RESULT`.
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc,
Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock,
Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, probes, spawn, thread,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId, session,
};
use crate::qwen_forward::original_serve_stack::dbg_el;
use crate::qwen_forward::{
original_serve_request::{ServeError, ServeRequest},
@@ -3,7 +3,7 @@
//! prefix store and the glibc heap, then fits the slope of each series against the request count after the
//! warm-up and prints it with its confidence interval.
use super::traffic::{Tally, TrafficRequest};
use super::*;
use super::{Census, Mem, PathBuf, env, list, number, print_report};
const TSV_HEADER: &str = "t_s\treq\trss\trss_anon\trss_file\trss_shmem\tswap\tavail\tcached\tshmem_sys\t\
active_file\tinactive_file\tvram_used\tvram_acct\tprefix_store\tmalloc_arena\tmalloc_in_use\tmalloc_free\t\
@@ -1,6 +1,10 @@
//! Loads the pinned model under the memory governor, opens the serve stack as production starts it and runs the
//! scenario of `LELEKA_MEM_SCENARIO` on it.
use super::*;
use super::{
CancelAt, Census, Driver, Governor, InheritedKarArchive, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget,
PrefixConfig, Qwen4ExpArtifact, Rc, Rng, SHARD0, SHARD1, ServeError, StackConfig, Tokenizer, VerifiedGgufFile,
census, dbg_el, env, filler, guard, number, print_report, required_path, serve_one, text,
};
/// What the operator asked for.
struct Plan {
@@ -1,5 +1,5 @@
//! Model-free probe of the sealed KAR memfd under the governor's residency guard.
use super::*;
use super::{Governor, InheritedKarArchive, env, guard, number, required_path};
/// One second of the probe: the memfd's swapped bytes, the cost of looking, and the swap counters since the last.
fn probe_second(governor: &Governor, t: u64, last_in: &mut Option<(u64, u64)>) {
@@ -1,7 +1,7 @@
//! The reader scenario: decode speed and the memfd's residency while a competing reader streams a big file
//! through the page cache (what the Original did when it read the KAR file next to the memfd): phase A without the
//! reader, B with it, C after.
use super::*;
use super::{Mem, NO_STOP, PathBuf, number, print_report, text};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
@@ -1,6 +1,6 @@
//! The shed scenario: the prefix cache evicted, requests refused and the budget restored, driven by floors moved
//! next to the memory the host has now, so the real limit is never approached.
use super::*;
use super::{Admission, Level, Mem, RequestShape, number, print_report};
use std::time::Duration;
fn available() -> u64 {
@@ -1,6 +1,6 @@
//! The soak scenario: mixed requests (cancels, refusals, long prompts, prefix-cache churn) judged flat after warm-up.
use super::traffic::{Tally, TrafficRequest};
use super::*;
use super::{Census, Mem, Tolerances, check_flat, list, number, print_report};
/// The knobs of the soak.
struct Soak {
@@ -1,6 +1,6 @@
//! The mixed traffic of the soak and the leak scenarios: sessions that grow by tool turns, big prompts,
//! unshared prompts, cancels and requests the governor must refuse.
use super::*;
use super::{Admission, Mem, RequestShape, ServeError};
/// What the traffic has done so far.
#[derive(Default)]
@@ -33,7 +33,23 @@
//!
//! Run: `cargo test -p leleka-engine-qwen35-cuda -- --ignored --exact
//! backend::original_serve_prefix_smoke::original_serve_prefix_cache_smoke`.
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc,
Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock,
Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, probes, request,
};
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId, session,
};
use crate::qwen_forward::original_serve_stack::dbg_el;
use crate::qwen_forward::{
original_serve_request::{ServeError, ServeRequest},
@@ -1,7 +1,7 @@
//! What the prefix-cache smoke does around the served requests: the per-request accounting, the verification
//! against a full read, the summary, the pool protocol on the live cache and the cancellation checks.
use super::run::Pfx;
use super::*;
use super::{CancelAt, ServeError, Served, env, filler, ids, mem_available_mib, rss_mib, serve_one};
/// What the served requests added up to.
#[derive(Default)]
@@ -1,7 +1,11 @@
//! Loads the pinned model, opens the stack in the mode asked for and serves the scripted workload.
use super::extras::{RequestAt, Tally};
use super::workload::{Plan, Workload};
use super::*;
use super::{
CancelAt, Driver, InheritedKarArchive, ModelBinding, OriginalServeStack, PathBuf, PrefixBudget, PrefixConfig,
Qwen4ExpArtifact, Rc, SHARD0, SHARD1, ServeError, Served, StackConfig, Tokenizer, VerifiedGgufFile, dbg_el, env,
filler, mem_available_mib, number, required_path, rss_mib, serve_one, text, workload,
};
/// The pinned tokenizer and EOS, the KAR archive and the binding with its expert source.
struct Pinned {
@@ -25,7 +25,25 @@
//! While the verifier window producers listed in `UNBOUND_PRODUCERS` are unbound the stack refuses to open
//! with the first missing producer's name; that refusal is the expected result of this smoke until they land.
use super::super::qwen_forward::original_serve_stack::dbg_el;
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact, Qwen35Cuda, Qwen35CudaStart, Rc,
Receiver, RecentIds, RuntimeConfig, SHARD0, SHARD1, Sha256, SupportedModelTuple, SyncSender, SystemClock,
Tokenizer, Usage, VerifiedGgufFile, WindowWitness, config, load, original_prompt, probes,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::original_serve_arms;
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
use crate::qwen_forward::{
original_serve_request::{RequestSampling, ServeError, ServeRequest},
original_serve_stack::{OriginalServeStack, StackConfig},
@@ -1,6 +1,9 @@
//! The conversation cache on the real model: the resume smoke, and the requests, the timing and the chunk
//! comparison the coverage smoke shares.
use super::*;
use super::{
OriginalServeStack, PROMPT, PathBuf, ServeError, StackConfig, Tokenizer, dbg_el, env, env_or, open_pinned,
open_stack, optin, request, with_context,
};
/// What one request of the conversation smokes returned.
pub(super) struct Served {
@@ -1,7 +1,10 @@
//! Coverage of the conversation cache on the real model (documented on
//! `original_serve_conversation_coverage_smoke`): every resumed request is compared token for token with the
//! same request read from the empty prompt; every check prints a `CONV-CHECK name ok|FAIL` line.
use super::*;
use super::{
CancelAfter, OriginalServeStack, PROMPT, PathBuf, PromptRequest, ServeError, Served, StackConfig, Tokenizer,
agent_sampler, dbg_el, env, env_or, ids, open_pinned, open_stack, optin, same_chunks, serve_once, with_context,
};
/// The knobs of the coverage smoke.
struct Knobs {
@@ -1,6 +1,11 @@
//! Long-context smoke of the streamed INT8 KV: one greedy request over a prompt far longer than the resident
//! window (documented on `original_serve_long_context_streamed_kv_smoke`).
use super::*;
use super::{
OriginalServeStack, PathBuf, ServeRequest, StackConfig, Tokenizer, collect, dbg_el, env, env_or, ids, number,
open_pinned, open_stack, request, with_context,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::original_serve_arms;
use std::time::Instant;
const COLORS: [&str; 8] = ["amber", "blue", "crimson", "green", "grey", "ivory", "orange", "violet"];
@@ -1,6 +1,25 @@
//! The main smoke: greedy twice across a reset, a sampled request, a cancellation, the optional parity corpus
//! and a short prompt on the scalar draft-KV path.
use super::*;
use super::{
Arc, AtomicBool, AtomicU64, BACKEND_API_VERSION, Backend, BackendCapabilities, BackendError, BackendIdentity,
CacheCounts, Clock, ContractError, DeferredTail, Digest, Driver, Duration, ErrorCode, EvaluationMeasurement,
EvaluationObserver, ExperimentalConfig, ExpertSource, FinishReason, GenerationEvent, GenerationRequest,
GenerationSink, GenerationStream, GenerationTerminal, InferenceMode, InheritedKarArchive, InputBindingError,
KarArchiveRef, KarExpertLevels, KarExpertSource, KarExpertSourceConfig, LOAD_CONFIG_VERSION, LoadedModel,
MeasurementFailure, ModelBinding, ModelDescriptor, Mutex, Ordering, OriginalServeChoice, OriginalServeMode,
OriginalServeOptions, OriginalServeStack, PROMPT, PathBuf, PrefixCacheOptions, PrefixTail, Qwen4ExpArtifact,
Qwen35Cuda, Qwen35CudaStart, Rc, Receiver, RecentIds, RuntimeConfig, ServeError, ServeRequest, Sha256, StackConfig,
SupportedModelTuple, SyncSender, SystemClock, Tokenizer, Usage, VerifiedGgufFile, WindowWitness, agent_sampler,
collect, dbg_el, env, env_or, ids, open_pinned, open_stack, optin, report_timing, request, with_context,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::original_serve_arms;
#[cfg(feature = "preview-path")]
use super::{
DenseWeightCache, Dimension, InputConstants, Instant, KarPleCache, MoeWeightCache, MtpDecoder, MtpWindowError,
MtpWindowSpec, OutputStage, Position, QwenForward, QwenSession, ResidentConversations, ResidentPolicy,
TargetStepProduct, TokenId,
};
mod corpus;
@@ -1,7 +1,9 @@
//! The parity corpus of the main smoke: every line of `LELEKA_SMOKE_PROMPTS` is tokenized with the verified
//! tokenizer, served greedily for `LELEKA_SMOKE_MAX_NEW` tokens (default 64) and printed as ids so the Original
//! can be run on the same ids.
use super::*;
use super::{ServeError, ServeRequest, Smoke, Tokenizer, agent_sampler, env, env_or, report_timing};
#[cfg(all(test, target_arch = "x86_64"))]
use super::original_serve_arms;
use crate::qwen_forward::{
original_serve_engine::ServeOutcome,
original_serve_request::{RequestSampling, original_stop_tokens},
@@ -1,6 +1,9 @@
//! The pinned model, the Context and the Original serve stack the smokes of `backend_original_serve_smoke.rs`
//! run on, and the helpers they share.
use super::*;
use super::{
Driver, InheritedKarArchive, ModelBinding, OriginalServeStack, Qwen4ExpArtifact, Rc, SHARD0, SHARD1, ServeError,
ServeRequest, StackConfig, Tokenizer, VerifiedGgufFile, dbg_el, env, required_path,
};
use crate::qwen_forward::original_serve_engine::ServeOutcome;
use std::str::FromStr;
@@ -1,7 +1,10 @@
//! The ranked expert profile read through the WeightSource port: the refusals and their order are the ones of the
//! former file read, and the double of the port stands in for the file.
use super::sources::{read_pinned_profile, read_ranked_expert_profile};
use super::*;
use super::{
BackendError, Digest, ErrorCode, RANKED_EXPERT_PROFILE_BYTES, RANKED_EXPERT_PROFILE_SHA, RankedExpertProfileSource,
Sha256,
};
use leleka_model_format::weight_source::MemWeightSource;
fn hex(bytes: &[u8]) -> String {
@@ -1,6 +1,8 @@
//! Private sole new changed-path model gate; actual source identity/load preserved.
use super::combined_changed_boundary_proof::rig::{DEVICE_BUDGET, MOE_REFUSAL, Owners, bind_pinned, require_opt_in};
use super::*;
use super::{Driver, PathBuf, Rc};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenForward};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use std::{env, panic::resume_unwind};
@@ -1,5 +1,9 @@
//! Running one admitted generation: the Generation step context and the choice of the generation loop.
use super::*;
use super::{
Admitted, Exchange, FinishReason, Generation, GenerationFailure, InferenceMode, Job, MtpContinuation, Ordering,
QwenSession, Serving, Usage, clock_seed, generate, generate_mtp_resume, invalid, measurement, request_sampler,
unavailable, unsupported,
};
use std::cell::RefCell;
pub(super) type Sampler = Result<Option<leleka_sampler_ref::SamplerParams>, leleka_sampler_ref::SamplingError>;
@@ -4,7 +4,9 @@
use super::combined_changed_boundary_proof::rig::{
DEVICE_BUDGET, MOE_REFUSAL, Owners, PinnedTokenizer, bind_pinned, bind_pinned_with_tokenizer, require_opt_in,
};
use super::*;
use super::{Driver, ModelBinding, PathBuf, Rc, Tokenizer};
#[cfg(feature = "preview-path")]
use super::{MoeWeightCache, QwenForward, QwenSession};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use std::{
env,
+12 -1
View File
@@ -1,4 +1,15 @@
use super::*;
use super::{
Active, ActiveGuard, Arc, AtomicBool, Backend, BackendError, Command, DeferredTail, Digest, ErrorCode,
EvaluationExecution, FRAME_LIMIT, GenerationRequest, InferenceMode, KAR_LOAD_REPLY_TIMEOUT, KAR_PROFILE,
LOAD_CONFIG_VERSION, LoadedModel, MODE_DIGEST, MODEL_DIGEST, ModelDescriptor, Mutex, OPTIMIZED_EXECUTION,
OUTPUT_LIMIT, Ordering, PROMPT_LIMIT, Proxy, QUEUE, QUEUED_OWNERS_EXECUTION, RANKED_EXPERT_PROFILE_SHA,
REPLY_TIMEOUT, RecentIds, RuntimeConfig, SHARD0, Sha256, Shared, SyncSender, Tokenizer, Utf8Pending,
kar_expert_mode_digest, kar_mode_digest, load_reply_timeout, mpsc, optimized_execution_digest,
pinned_model_descriptor, prepare_prompt, queued_owners_execution_digest, request_sampler, validate_handle,
validate_kar_selection, validate_load, validate_request,
};
#[cfg(feature = "preview-path")]
use super::{Dimension, InputConstants, Position, native_position};
#[test]
fn queued_owner_identity_is_distinct_and_binds_profile_and_actual_bound_mode() {
let old_fields = [
@@ -1,6 +1,6 @@
//! Unit tests of this module (split out of its file; the test ids are unchanged).
use super::*;
use super::{ResidentConversations, ResidentPolicy, ResumeSource};
fn policy(budget_gib: usize, slots: usize) -> ResidentPolicy {
ResidentPolicy { budget_bytes: budget_gib << 30, slots, fixed_bytes: 100 << 20, bytes_per_token: 20_000 }
@@ -1,6 +1,9 @@
//! Unit tests of this module (split out of its file; the test ids are unchanged).
use super::*;
use super::{
ExperimentalConfig, ExperimentalError, KvFormat, Mode, OptIn, PathBuf, Program, ensure_consumed,
load_control_vector_tables, mode_digest, plan, pool_bytes,
};
fn cfg(modes: &[Mode], resident: i64) -> ExperimentalConfig {
let mut opt_in = OptIn::default();
@@ -1,6 +1,9 @@
//! Page-cache release after the load (`drop_file_cache`), moved out of `memory_governor` by STRA-338 (size).
use super::*;
use super::{
BackendError, CacheWish, DeviceSample, Entry, EnvSource, FixedItem, Governor, GovernorConfig, HostFacts, HostProc,
KarForm, Mutex, OpenStage, PlanInput, SamplerGuard, Settings, Space, VramFacts, When,
};
/// Give back the page cache the load created: the shards were read once to verify and to copy the resident bank, and
/// nothing reads those pages again (the bank is a RAM copy). Left in place they are the cache pressure that pushed the
@@ -1,6 +1,6 @@
//! Unit tests of this module (split out of its file; the test ids are unchanged).
use super::*;
use super::{E, NATIVE_EPSILON, TensorSignature, block_range, descriptor, exact_bf16, kind};
#[test]
fn epsilon_is_exact_original_layer_operand() {
assert_eq!(NATIVE_EPSILON.to_bits(), 0x358637bd);
@@ -1,6 +1,6 @@
//! Unit tests of this module (split out of its file; the test ids are unchanged).
use super::*;
use super::{GrRole, InputBindingError, TensorSignature, exact_bf16, role_set, validate_descriptor};
#[test]
fn gr_binding_accepts_only_exact_finite_bf16_containers() {
for bits in [0, 0x80000000, 0x3f800000, 0x00010000, 0x7f7f0000] {
@@ -1,7 +1,11 @@
//! Methods of `OwnedCopy`: `create`, `writer`, `owns_directory`, `owns_file` and 1 more.
//! Implements `Drop for OwnedCopy`. Functions: `inode`, `regular`, `root`, `copy_exact` and 8 more.
use super::*;
use super::{
BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File,
INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix,
MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, read_exact_range, read_expert_rows,
};
use sha2::{Digest, Sha256};
use std::io::Read;
use std::os::unix::fs::{DirBuilderExt, MetadataExt, OpenOptionsExt, PermissionsExt};
@@ -1,7 +1,11 @@
//! The reads of the MTP weights: dense rows, expert rows and the binding identity check.
#[allow(unused_imports)]
use super::*;
use super::{
BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File,
INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix,
MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing, descriptor, read_exact_range,
read_expert_rows, row_range, validate_numeric,
};
impl MtpWeights {
/// Operator-only fixed profile. The copy owns an unnamed read-only inode for
@@ -1,8 +1,11 @@
//! Functions: `read_expert_rows`, `read_expert_row`, `row_range`, `allocate` and 3 more.
//! Split out of `mtp` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
BindingIdentity, DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, EXPERT_BLOB, EXPERT_BYTES, FILE_PINS, File,
INDEX_BYTES, INDEX_LIMIT, InputBindingError, InputResult, MAX_READ, MAX_ROWS, ModelBinding, MtpExpertMatrix,
MtpExpertRef, MtpIndex, MtpKind, MtpRole, MtpRows, MtpWeights, Path, backing,
};
pub(super) fn read_expert_rows(
experts: &File,
@@ -1,6 +1,9 @@
//! Unit tests of this module (split out of its file; the test ids are unchanged).
use super::*;
use super::{
BindingIdentity, DESCRIPTORS, INDEX_LIMIT, InputBindingError, MtpIndex, MtpKind, MtpRole, interleave_q2, row_range,
rt_dense_name, rt_dense_roles, rt_dense_shape, validate_identity, validate_numeric,
};
fn index() -> String {
DESCRIPTORS
.iter()
@@ -1,8 +1,12 @@
//! Methods of `InputConstants`: `test_fixture`. Methods of `BindingIdentity`: `test_identity`.
//! Functions: `validate_ple_descriptor`, `bind_layers`, `bind_layer`.
#[allow(unused_imports)]
use super::*;
use super::{
BoundLayer, BoundLayerKind, GlobalRole, InputBindingError, InputResult, LayerRole, PLE_ROWS, Qwen4ExpArtifact,
TensorRole,
};
#[cfg(test)]
use super::{BindingIdentity, InputConstants, Rc};
pub(super) fn validate_ple_descriptor(artifact: &Qwen4ExpArtifact) -> InputResult<()> {
let ple = artifact
@@ -1,8 +1,11 @@
//! Methods of `InheritedKarArchive`: `open`, `open_sparse`, `open_sparse`, `sparse_extents` and 7 more.
//! Functions: `open_sealed_archive_fd`, `open_read_only_archive`, `check_read_only_archive`, `reopen_read_only_archi...
#[allow(unused_imports)]
use super::*;
use super::{
ARCHIVE_DIGEST, BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError,
KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path,
PathBuf, RefCell, SparseArchive, VerifiedKarPleArtifact, private_copy,
};
use leleka_model_format::weight_source::{BackingKind, FileWeightSource, Verification, WeightIdentity};
#[cfg(test)]
@@ -1,8 +1,12 @@
//! Methods of `KarRowPacket`: `payload`, `partition`. Methods of `KarRowReader`: `read_rows`.
//! Functions: `open_archive_reader`, `load_pinned_inherited_archive`, `log_startup_read`, `load_pinned_inherited_arc...
#[allow(unused_imports)]
use super::*;
use super::{
BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError, KarPleBinding,
KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, KarRowPacket, KarRowReader, LoadPhase, NATIVE_DIGESTS,
PINNED_ARCHIVE_BYTES, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, VerifiedKarPleArtifact,
open_sealed_archive_fd, pinned_profile, reopen_read_only_archive, verify_open_provenance,
};
/// The read handle of the inherited archive: a read-only reopen of the file, or the sealed memfd itself.
#[cfg(target_os = "linux")]
@@ -1,8 +1,12 @@
//! Methods of `InheritedKarArchive`: `expert_capture_observation`.
//! Functions: `pinned_profile`, `pinned_parts`, `pinned_profile_spec`, `load_pinned_archive` and 3 more.
#[allow(unused_imports)]
use super::*;
use super::{
ARCHIVE_DIGEST, BindingIdentity, File, InheritedKarArchive, InputBindingError, InputResult, KarError,
KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PART0_F32_DIGEST,
PART1_F32_DIGEST, PLE_ROWS, PROVENANCE_DIGEST, Path, PathBuf, RefCell, VIRTUAL_F32_DIGEST, VerifiedKarPleArtifact,
error, input_failure, kar_failure, private_copy,
};
/// Candidate expectations from independently verified v4 conversion receipts
/// d51353be and 0d8a4a52. Construction reads no archive and grants no serving
@@ -1,7 +1,11 @@
//! Implements `Write for BrokenSink`.
//! Functions: `diagnostic_cases`, `assert_kar_diagnostic_redacts`, `assert_input_diagnostic_survives_broken_sink`, `...
use super::*;
use super::{
BindingIdentity, File, InputBindingError, InputResult, KarError, KarPlePartProvenance, KarPleProfile,
KarPleProfileSpec, LoadPhase, NATIVE_DIGESTS, PLE_ROWS, Path, PathBuf, RefCell, VerifiedKarPleArtifact, error,
input_diagnostic, kar_diagnostic, pinned_profile, pinned_profile_spec,
};
#[cfg(not(target_os = "windows"))]
struct BrokenSink;
@@ -1,8 +1,10 @@
//! Functions: `checked_reader`, `copy_exact`, `copy_exact_reporting`, `copy_buffer` and 1 more.
//! Split out of `private_copy` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
COPY_BUFFER, File, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions,
OpenOptionsExt, Path, Read, SOURCE_FLAGS, Seek, Write, inode, input_failure, phase_error, report_io,
};
#[cfg(target_os = "macos")]
pub(super) fn checked_reader(own: &OwnedCopy, bytes: u64) -> InputResult<File> {
@@ -1,8 +1,10 @@
//! Methods of `OwnedCopy`: `create`, `created`, `writer`, `detach` and 2 more. Implements `Drop for OwnedCopy`.
//! Functions: `inode`, `diagnostic`, `report_io`, `phase_error` and 8 more.
#[allow(unused_imports)]
use super::*;
use super::{
File, Inode, InputBindingError, InputResult, IoPhase, LoadPhase, Metadata, MetadataExt, OpenOptions,
OpenOptionsExt, Path, Read, SOURCE_FLAGS, Seek, Write, checked_reader, copy_exact, input_failure,
};
pub(super) fn inode(meta: &Metadata) -> Inode {
(meta.dev(), meta.ino())
@@ -1,8 +1,12 @@
//! The lazily created workspaces of the dense weight cache, moved out of it by STRA-338 (size): consecutive owners,
//! declared in the order the cache dropped them, so the drop order is unchanged.
#[allow(unused_imports)]
use super::*;
use super::{
DeviceBuffer, GdnInputScratch, GrBatchInjectWorkspace, GrScratch, QkScratch, QsaAttentionScratch, QsaIndexKeyCache,
QsaInputScratch, QsaSelectedCache, Rc, RefCell, RouterScratch,
};
#[cfg(test)]
use super::Cell;
/// Every scratch owner of the cache that starts empty (`None` or an empty list) and is filled on first use.
#[derive(Default)]
@@ -3,7 +3,14 @@
//! attention, then completes the whole FFN GR bank. Qualification is pending.
#![allow(dead_code)]
use super::super::session::chunk::QwenChunkTxn;
use super::*;
use super::{
BindingIdentity, BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage,
InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage,
MoeWeightCache, OutputStage, Position, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenForward,
QwenSession, QwenStepTxn, Result, Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct,
TokenId, VerificationChunk, VerificationSource, WindowCaches, diagnose, prefill_chunk,
prepare_layer_attention_micro, read_layer_attention, validate_layer_plan,
};
#[derive(Clone, Copy)]
enum ChunkMoePolicy {
Native,
@@ -2,8 +2,10 @@
//! Methods of `Rig`: `snapshot`, `prefill`, `step_final`, `prefill_chunk` and 7 more.
#![cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
#[allow(unused_imports)]
use super::*;
use super::{
DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, Position,
PrefillChunkInputs, QwenForward, QwenSession, Result, Stage, TokenId,
};
use crate::qwen_forward::executor::{PrefillStepProduct, StepCaches, StepRequest, TargetStepProduct};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use crate::qwen_forward::mtp::KnownNext;
@@ -1,5 +1,9 @@
//! Only the explicitly selected new full-model MMQ gate. Old observers unchanged.
use super::*;
use super::{
ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage,
Position, PrefillChunkInputs, QwenForward, QwenSession, Result, Stage, StepCaches, StepRequest, TargetStepProduct,
TokenId,
};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use crate::qwen_forward::mtp::KnownNext;
use crate::qwen_forward::mtp::MtpChunkNumericSnapshot;
@@ -1,6 +1,6 @@
//! Separate native-certified activation model observer. Original failed observer unchanged.
use super::mmq_evaluation::{ChunkExact, ChunkRun, MmqRun, Observation, pos};
use super::*;
use super::{QwenForward, TokenId};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use crate::qwen_forward::mtp_decode::MtpDecoder;
@@ -1,8 +1,17 @@
//! Groups the submodules `joint_chunk`, `prefill_chunk_cached_windowed`, `prefill_chunk_native_windowed` and 1 more.
//! Split out of `prefill_chunk` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error,
ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv,
ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, QsaAttentionStage,
QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result, Stage, StepCaches,
StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, TokenId, VerificationChunk, VerificationSource,
WindowCaches, chunk_diagnostic, diagnose, prefill_chunk, prepare_layer_attention_micro, prepare_micro_ffn_rows,
prepare_q6_layer_columns, qwen_forward, read_chunk_attention_ffn, read_layer_attention, validate_layer_plan,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::{check_chunk_on_loaded, window_numeric};
mod joint_chunk;
#[allow(unused_imports)]
@@ -1,8 +1,18 @@
//! Methods of `ChunkEnv`: `new`, `with_boundary`, `native_prompt`. Methods of `ChunkRun`: `window`.
//! Defines `MicroBank`, `MicroBank`, `NativeMoe` and 6 more.
#[allow(unused_imports)]
use super::*;
use super::{
AllocationTrace, AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension,
Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId,
MicroEnv, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs,
PrefillChunkPlan, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession,
QwenStepTxn, Result, Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TokenId, VerificationChunk,
VerificationSource, WindowCaches, chunk_diagnostic, diagnose, prepare_layer_attention_micro,
prepare_micro_ffn_rows, prepare_q6_layer_columns, qwen_forward, read_chunk_attention_ffn, read_layer_attention,
validate_layer_plan,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::window_numeric;
use leleka_cuda_driver::Context;
mod chunk_layer;
@@ -2,8 +2,12 @@
use super::window_experts::ExpertRun;
use super::window_ffn::WindowOwners;
#[allow(unused_imports)]
use super::*;
use super::{
BoundLayerKind, ChunkEnv, ChunkRun, Context, Dimension, Error, GdnPlan, InjectedResidual, LayerId, MoeWeightCache,
NativeMoe, QwenChunkTxn, QwenForward, Result,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::window_numeric;
use crate::qwen_forward::gdn::chunk_device::GdnChunkDevice;
use crate::qwen_forward::moe_expert::ChunkFfnLayer;
use crate::qwen_forward::session::chunk::{ChunkFfnRow, ChunkMicroWindow};
@@ -1,7 +1,12 @@
//! STRA-338 size: admission, transaction begin, input rows and output head of one prefill chunk.
#[allow(unused_imports)]
use super::*;
use super::{
ChunkEnv, ChunkMoePolicy, ChunkOpening, Context, DenseWeightCache, Error, InjectedResidual, InputStage,
KarPleCache, ModelBinding, MoeWeightCache, OutputStage, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn,
QwenForward, QwenSession, QwenStepTxn, Result, Stage, chunk_diagnostic,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::window_numeric;
/// The MMQ actor context, and the contexts of the recurrence and verification GDN owners when they are in use.
type ChunkContexts<'ctx, 'driver> =
@@ -1,7 +1,13 @@
//! STRA-338 size: the attention reads of one window of a prefill layer.
#[allow(unused_imports)]
use super::*;
use super::{
ChunkEnv, ChunkRun, Error, GrStage, InjectedResidual, InputStage, LayerEntry, LayerId, MicroBank, QwenChunkTxn,
QwenForward, Result, Stage, chunk_diagnostic, prepare_layer_attention_micro, read_layer_attention,
};
#[cfg(all(test, target_arch = "x86_64"))]
use super::window_numeric;
#[cfg(test)]
use super::QwenStepTxn;
use crate::qwen_forward::session::chunk::ChunkAttentionRow;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
use crate::qwen_forward::{
@@ -1,7 +1,9 @@
//! STRA-338 size: the expert execution and the batched FFN injection of one window of a prefill layer.
#[allow(unused_imports)]
use super::*;
use super::{
ChunkEnv, ChunkMoePolicy, ChunkRun, Error, GrStage, InjectedResidual, LayerId, MoeExpertStage, MoeWeightCache,
NativeMoe, QwenChunkTxn, QwenForward, Result, Stage, chunk_diagnostic,
};
use crate::qwen_forward::gr::GrBatchRow;
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
use crate::qwen_forward::moe_expert::NativePromptFinish;
@@ -1,7 +1,11 @@
//! STRA-338 size: the projected columns and the prepared FFN rows of one window of a prefill layer.
#[allow(unused_imports)]
use super::*;
use super::{
AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkRun, Error, ForwardPhase, GdnStage, InjectedResidual, LayerId,
MicroBank, MicroEnv, MoeExpertStage, MoeRouteStage, NativeMoe, Position, QwenChunkTxn, QwenForward, QwenStepTxn,
Result, Stage, TokenId, chunk_diagnostic, diagnose, prepare_micro_ffn_rows, prepare_q6_layer_columns,
read_chunk_attention_ffn,
};
use crate::qwen_forward::gdn::chunk_device::{ChunkEdge, GdnChunkDevice};
use crate::qwen_forward::gdn::{DeviceChunkRow, GdnLayerInput};
use crate::qwen_forward::gr::DetachedGrRead;
@@ -1,8 +1,12 @@
//! Methods of `AttentionHandoff`: `new`.
//! Methods of `QwenForward`: `test_layer0_pair_on_loaded`, `run_layer0_diagnostic`.
#[allow(unused_imports)]
use super::*;
use super::{DenseWeightCache, ForwardPhase, GrStage, ModelBinding, Result, diagnose};
#[cfg(test)]
use super::{
ChunkMoePolicy, Dimension, Error, KarPleCache, MoeWeightCache, OutputStage, PrefillChunkInputs, QwenForward,
QwenSession, Stage, TokenId,
};
use crate::qwen_forward::gr::AttentionBlockOutput;
#[cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
@@ -1,7 +1,14 @@
//! Changed MicroWindow boundary observer. No model loading or serving switch.
//! The returned report owns only counts/booleans; its assertions belong AFTER
//! the caller has closed all actual GPU owners and checked allocated_bytes=0.
use super::*;
use super::{
AttentionHandoff, BindingIdentity, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, GdnStage,
GrRead, GrStage, InjectedResidual, InputStage, KarPleCache, LayerEntry, LayerId, MicroEnv, ModelBinding,
MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage, Position, PrefillChunkInputs, PrefillChunkPlan,
QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenChunkTxn, QwenForward, QwenSession, QwenStepTxn, Result,
Stage, StepCaches, StepPurpose, StepRequest, TargetStepOrigin, TargetStepProduct, TokenId, VerificationChunk,
VerificationSource, WindowCaches, qwen_forward,
};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use crate::qwen_forward::mtp_decode::MtpDecoder;
use std::{cell::Cell, rc::Rc};
@@ -1,7 +1,10 @@
//! The proof phases of the window boundary observer (STRA-338 size: extract-method only).
#[allow(unused_imports)]
use super::*;
use super::{
BoundaryPlan, Cell, ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache,
MtpDecoder, OutputStage, PartialReport, Position, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward,
QwenSession, Rc, Result, Stage, StepCaches, StepRequest, TargetStepProduct, TokenId, owned_journal, tokens,
};
use crate::qwen_forward::mtp::KnownNext;
use crate::qwen_forward::mtp::MtpChunkNumericSnapshot;
use crate::qwen_forward::session::ResetReplaySnapshot;
@@ -1,6 +1,9 @@
//! Cache-reset-replay numerical proof, moved out of `executor.rs` by STRA-338 (size); same module path as before.
use super::*;
use super::{
BoundLayerKind, DenseWeightCache, Dimension, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, Position,
QwenForward, QwenSession, Result, StepCaches, StepRequest, TokenId, validate_layer_plan,
};
use crate::qwen_forward::loaded_target_owners::LoadedTargetOwners;
use crate::qwen_forward::{
dense_weight_cache::DenseCacheCounters, moe_weight_cache::WeightCacheCounters, session::ResetReplaySnapshot,
@@ -1,7 +1,11 @@
//! Phases of `QwenForward::step_core` (STRA-338 size: extract-method only, same order of operations).
#[allow(unused_imports)]
use super::*;
use super::{
BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual,
InputStage, KarPleCache, LayerId, ModelBinding, MoeExpertStage, MoeRouteStage, MoeWeightCache, OutputStage,
Position, QsaAttentionStage, QsaIndexStage, QsaPrepareRequest, QwenStepTxn, Result, TokenId, diagnose,
read_layer_attention, validate_layer_plan,
};
use crate::qwen_forward::gdn::GdnLayerInput;
use crate::qwen_forward::moe_expert::ExpertRowRequest;
use crate::qwen_forward::qsa_attention::QsaReady;
@@ -1,6 +1,9 @@
//! Unit tests of this module (split out of its file; the test ids are unchanged).
use super::*;
use super::{
BoundLayerKind, Dimension, Error, LayerId, OutputStage, Position, QwenForward, QwenSession, QwenStepTxn, Result,
Stage, TokenId, validate_descriptors,
};
#[test]
fn topology_validation_requires_the_exact_contiguous_closed_sequence() {
@@ -5,7 +5,10 @@ use super::super::{
GateHostOperands, GdnOwner, GdnPrior, GdnStateMirror, OutNormScale, RecurrenceOperands, convolve, gates,
normalize_qk, out_norm, recur, release, upload,
};
use super::*;
use super::{
BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, Error, GdnMatrixKind, HISTORY_ELEMENTS, Product, Rc,
Role, TokenLayer, VALUES, allocate, download,
};
use crate::qwen_forward::contract::{Dimension, LayerId, Position, TokenId};
use leleka_cuda_driver::{Bf16ProjectionShape, Driver};
@@ -7,7 +7,11 @@ use super::super::{
GateHostOperands, OutNormScale, RecurrenceOperands, STATE_ELEMENTS, convolve, gates, normalize_qk, out_norm, recur,
release, upload,
};
use super::*;
use super::{
BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, DeviceOperand, Error, GdnMatrixKind, GdnRowQueue,
HISTORY_ELEMENTS, QkScratch, QkvInput, QueueInputs, QueuedRow, Rc, Result, Role, TokenLayer, VALUES, allocate,
download,
};
use crate::qwen_forward::contract::{Dimension, LayerId, Position, TokenId};
use leleka_cuda_driver::{Bf16ProjectionShape, Driver};
@@ -2,7 +2,19 @@
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
use super::super::session::chunk::GdnChunkMicro;
use super::super::session::chunk::{GdnChunkRow, GdnChunkSeal, GdnChunkStart};
use super::*;
use super::{
ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, Context, DenseFormat, DenseWeightCache,
DeviceBuffer, DeviceChunkRow, Dimension, DriverError, Error, GateHostOperands, GdnInputLease, GdnInputScratch,
GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior, GdnStateKey,
GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS, InputBindingError, LayerId, LeaseClaim, LeasedProjection,
MirrorAuthority, MirrorStep, ModelBinding, OutNormScale, ProjectedQkvSource, ProjectionKind, ProjectionOperands,
ProjectionSpec, PromptLayer, PromptProgram, PromptSource, Q5KProjectionShape, Q6KProjectionShape, QkScratch,
QwenStepTxn, ReadoutClaim, RecurrenceOperands, ResidualReady, Result, STATE_ELEMENTS, Stage, TokenLayer, VALUES,
allocate, chain, download, download_unchecked, driver_error, pool_enabled, preflight_budget, release, state,
upload, validate_values, verification,
};
#[cfg(test)]
use super::CHANNELS;
use leleka_cuda_driver::{GdnRowQueue, GdnStateFiniteGuard};
use std::{cell::Cell, rc::Rc};
pub(in crate::qwen_forward) const CHUNK_DEVICE_CHARGE: usize = 2 * STATE_ELEMENTS * 4 + 4;
@@ -1,8 +1,19 @@
//! Groups the submodules `chunk_device_batch_compute`, `chunk_device_construction`, `chunk_device_finish_cleanup`.
//! Split out of `chunk_device` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge,
ChunkReadout, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, Dimension, DriverError, Error,
GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease,
GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior,
GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS,
InputBindingError, LayerId, LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, OutNormScale,
ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource,
Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, Rc, ReadoutClaim, ReadoutDownload,
RecurrenceOperands, ResidualReady, Result, STATE_ELEMENTS, Stage, TokenLayer, VALUES, allocate, chain, download,
download_unchecked, driver_error, micro_rows, mirror_reuse_enabled, pool_enabled, preflight_budget, release, state,
upload, validate_values, verification,
};
mod chunk_device_batch_compute;
mod chunk_device_construction;
@@ -1,8 +1,12 @@
//! Methods of `GdnChunkDevice`: `finish_batch`, `history`, `step_source`, `read_checked` and 13 more.
//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
ChunkEdge, ChunkReadout, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, HISTORY_ELEMENTS, Rc, ReadoutDownload,
Result, VALUES, allocate, download, driver_error, preflight_budget, validate_values,
};
#[cfg(test)]
use super::upload;
impl<'ctx> GdnChunkDevice<'ctx> {
/// Adopt the final state of a batch that drained clean: the separate `next`
@@ -3,7 +3,18 @@
use super::super::super::contract::{Dimension, LayerId};
use super::super::super::session::chunk::TestGdnComponentRows;
use super::super::{RecurrenceOperands, convolve, recur};
use super::*;
use super::{
ALL_MIRROR_BYTES, Bf16ProjectionShape, BindingIdentity, BoundLayerKind, CHANNELS, CHUNK_DEVICE_CHARGE, Cell,
ChunkReadout, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DeviceChunkRow, DriverError, Error,
GateHostOperands, GdnChunkDevice, GdnChunkMicro, GdnChunkRow, GdnChunkSeal, GdnChunkStart, GdnInputLease,
GdnInputScratch, GdnLayerInput, GdnMatrixKind, GdnMatrixLayout, GdnMatrixRole, GdnOwner, GdnPending, GdnPrior,
GdnRowQueue, GdnStateFiniteGuard, GdnStateKey, GdnStateMirror, GdnWeights, GrRole, HISTORY_ELEMENTS,
InputBindingError, LeaseClaim, LeasedProjection, MirrorAuthority, MirrorStep, ModelBinding, OutNormScale,
ProjectedQkvSource, ProjectionKind, ProjectionOperands, ProjectionSpec, PromptLayer, PromptProgram, PromptSource,
Q5KProjectionShape, Q6KProjectionShape, QkScratch, QwenStepTxn, Rc, ReadoutClaim, ResidualReady, Result,
STATE_ELEMENTS, Stage, TokenLayer, allocate, chain, download, driver_error, preflight_budget, release, state,
upload, validate_values,
};
use leleka_cuda_driver::Driver;
const ROWS: usize = 65;
@@ -1,8 +1,10 @@
//! Functions: `batch_adoption`, `adoption_rows`, `adoption_phase`, `batch_operand_guards` and 6 more.
//! Split out of `numeric_gpu` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{
BindingIdentity, Context, Dimension, Error, GdnChunkDevice, GdnChunkRow, GdnPrior, HISTORY_ELEMENTS, LayerId,
Result, STATE_ELEMENTS, TestGdnComponentRows, component_owner, difference, download, driver_error, require,
};
// Batch adoption of the Strata-prefill step. Pure ownership/identity: no kernel
// runs here, the final state is a recognisable pattern written into `next`.
@@ -1,8 +1,12 @@
//! Methods of `Fixture`: `new`, `row_guards`, `run_rows`, `compute_row` and 12 more.
//! Functions: `require_rejected_clean`, `exercise`, `run_gdn_chunk_numeric`. Defines `Fixture`, `ComputedRow`.
#[allow(unused_imports)]
use super::*;
use super::{
BUDGET, BindingIdentity, CHUNK_DEVICE_CHARGE, ChunkReadout, Context, Counts, DeviceBuffer, Dimension, Driver,
Error, GdnChunkDevice, GdnChunkRow, GdnChunkSeal, GdnPrior, GdnStateFiniteGuard, LayerId, Operands, Rc, Reference,
Result, STATE_ELEMENTS, TestGdnComponentRows, component_owner, convolution_input, convolution_weights, convolve,
difference, download, driver_error, operands, reference, require, upload,
};
// The prior, the same-PTX reference and the row sources every stage of the component proof uses.
struct Fixture {
@@ -1,8 +1,11 @@
//! Functions: `driver_error`, `validate_candidates`, `state_index`, `key_head`.
//! Split out of `gdn` to keep its files under the line limit.
#[allow(unused_imports)]
use super::*;
use super::{DriverError, Error, KEY_HEADS, Result, Stage, VALUE_HEADS, WIDTH};
#[cfg(test)]
use super::CandidateFixture;
#[cfg(test)]
use super::{HISTORY_ELEMENTS, STATE_ELEMENTS, TokenLayer, validate_values};
pub(in super::super) fn driver_error(error: DriverError) -> Error {
if crate::driver_errors_traced() {
@@ -1,6 +1,9 @@
//! ONE binding-loaded layer0 transport proof; no synthetic ModelBinding,
//! fabricated session advancement or all48/full-model qualification.
use super::*;
use super::{
Context, DenseWeightCache, Dimension, Error, FOUR_BORROW_BYTES, GdnPrior, GdnStage, HISTORY_ELEMENTS, LayerId,
ModelBinding, QwenStepTxn, ResidualReady, Result, STATE_ELEMENTS, Stage, VALUES, validate_values,
};
use crate::qwen_forward::gdn::GdnLayerInput;
use crate::qwen_forward::{
contract::{Position, TokenId},
@@ -1,6 +1,9 @@
//! New per-layer input lease parity; synthetic component, never ModelBinding.
#![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
use super::*;
use super::{
BindingIdentity, Context, DeviceBuffer, Error, GdnInputLease, GdnInputScratch, GdnMatrixKind, GdnMatrixLayout,
GdnMatrixRole, LeaseClaim, allocate, dispatch_projection, download, input_scratch, project_retained, upload,
};
use input_scratch::INPUT_BYTES;
use leleka_cuda_driver::Driver;
use std::{
@@ -1,7 +1,7 @@
//! New device mirror against the actual uncached recurrence, not a model oracle.
#![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
use super::super::{GdnOwner, HISTORY_ELEMENTS, RecurrenceOperands, recur};
use super::*;
use super::{BindingIdentity, Cell, Context, Error, GdnPrior, GdnStateMirror, MIRROR_BYTES, MirrorNext, Rc, VALUES};
use crate::qwen_forward::contract::{Dimension, LayerId, Position, TokenId, TokenLayer};
use leleka_cuda_driver::Driver;
@@ -13,7 +13,11 @@
use super::super::session::chunk::GdnChunkMicro;
use super::chunk_device::GdnChunkDevice;
use super::chunk_producer::ChunkReady;
use super::*;
use super::{
BoundLayerKind, CHANNELS, Context, DenseWeightCache, DeviceBuffer, Dimension, Error, GdnMatrixKind, GdnMatrixRole,
GdnStage, HISTORY_ELEMENTS, LayerId, ModelBinding, PromptLayer, Result, Stage, TokenLayer, VALUE_HEADS, VALUES,
download, driver_error, validate_values,
};
use leleka_cuda_driver::{GDN_BATCH_EPSILON, GDN_BATCH_MAX_TOKENS, GdnGemm, GdnNativeFormat, GdnPrefillBatch};
const MIXED: usize = 2560;

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