diff --git a/crates/engine-core/src/conversation/cache/conversation_cache.rs b/crates/engine-core/src/conversation/cache/conversation_cache.rs index a5374a9d..6f47f887 100644 --- a/crates/engine-core/src/conversation/cache/conversation_cache.rs +++ b/crates/engine-core/src/conversation/cache/conversation_cache.rs @@ -1,5 +1,6 @@ -//! Methods of `ConversationCache`: `new`, `enabled`, `budget`, `slots` and 15 more. Functions: `deepest_key`. -//! Split out of `cache` to keep its files under the line limit. +//! Behaviour of the parked-conversation cache: byte and slot accounting, the retained K/V reuse buffers, best-prefix +//! lookup, making room by eviction, removal of superseded copies and `put`. +//! Pure CPU policy; the types and the `ParkedConversation` trait it works on are in the parent `cache` module. use super::{ CheckpointKey, ConversationCache, ConversationImageKey, ConversationKv, ConversationKvReuse, Match, diff --git a/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs b/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs index a3491442..9d82b16c 100644 --- a/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs +++ b/crates/engine-core/src/conversation/cache/conversation_checkpoint.rs @@ -1,5 +1,5 @@ -//! Methods of `ConversationCheckpoint`: `bytes`. Methods of `ConversationKv`: `bytes`, `buffers`, `buffers_mut`. -//! Implements `Default for SavedConversation`, `ParkedConversation for SavedConversation`. +//! Byte accounting of a saved checkpoint and of a layer's K/V buffers, the reuse bookkeeping for retained K/V, and +//! the `ParkedConversation` view of a host-memory `SavedConversation` (live and checkpoint keys, steering, size). use super::{ CheckpointKey, ConversationBuffer, ConversationCheckpoint, ConversationImageKey, ConversationKv, diff --git a/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs b/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs index 3971be70..010a0a59 100644 --- a/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs +++ b/crates/engine-core/src/conversation/cache/tests/retained_buffers_count_against_bytes.rs @@ -1,6 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! retained_buffers_count_against_bytes_but_not_slots, a_b_a_recovery_and_slot_eviction, -//! checkpoints_steering_and_boundary_rules, image_identity_is_part_of_the_prefix .... +//! Pins the cache accounting and eviction rules: retained K/V buffers cost bytes but no slot, A-B-A recovery, slot +//! and byte eviction oldest first, checkpoint, steering and boundary matching, image identity as part of the prefix, +//! and superseded copies of one conversation never pushing another out. use super::{A, B, ConversationCache, ConversationImageKey, ConversationKv, cp, exact_kv_layers, image, size_of, with}; diff --git a/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs b/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs index 6c62309e..a9cf235a 100644 --- a/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs +++ b/crates/engine-core/src/conversation/cache/tests/what_is_not_superseded.rs @@ -1,6 +1,5 @@ -//! Tests of `tests` by topic: what_is_not_superseded, -//! disabled_caches_store_nothing, take_out_of_range_is_none_and_prefix_len_is_generic_over_token_types, -//! struct_sizes_match_the_64_bit_original_layout. +//! Pins what the cache must NOT treat as superseded (other conversations sharing only a root, a different steering +//! mode, entries without checkpoints), plus the disabled-cache, out-of-range `take` and struct-layout edge cases. use super::{ A, B, ConversationCache, ConversationCheckpoint, ConversationImageKey, ConversationKv, SavedConversation, cp, diff --git a/crates/engine-core/src/conversation/kv/kv_image_readback.rs b/crates/engine-core/src/conversation/kv/kv_image_readback.rs index 9706651b..4f8886c9 100644 --- a/crates/engine-core/src/conversation/kv/kv_image_readback.rs +++ b/crates/engine-core/src/conversation/kv/kv_image_readback.rs @@ -1,5 +1,5 @@ -//! Functions: `verify_ring`, `kv_verify`. -//! Split out of `kv` to keep its files under the line limit. +//! Read-back check of a restored K/V layer: the saved bytes and the drafter ring's resident pages are compared with +//! the device and the authoritative payload is fingerprinted. Diagnostic only; it never changes model state. use super::{ ConvResult, ConversationKv, KvLayer, KvPool, KvTarget, QsaDesc, StateMemory, Verifier, kv_validate, region, diff --git a/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs b/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs index 95d15b35..bfb979f5 100644 --- a/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs +++ b/crates/engine-core/src/conversation/kv/kv_image_save_restore.rs @@ -1,5 +1,6 @@ -//! Methods of `Verifier`: `compare`, `failure`. -//! Functions: `set_geometry`, `reusable_prefix`, `capture_buffer`, `capture_layer` and 5 more. +//! Capture, validation and restore of one layer's K/V image against device memory. Capture keeps the unchanged prefix +//! of buffers retained from an earlier restore and copies only the rest; restore refills streamed residency. +//! Also the `Verifier` that compares device bytes with the image for the read-back check. use super::{ ConvError, ConvResult, ConversationKv, IDX_BLOCK, KvLayer, KvPool, KvTarget, Layout, ModelGeometry, PAGE_SIZE, diff --git a/crates/engine-core/src/conversation/kv/layout.rs b/crates/engine-core/src/conversation/kv/layout.rs index 0bd3a91a..8b55d9df 100644 --- a/crates/engine-core/src/conversation/kv/layout.rs +++ b/crates/engine-core/src/conversation/kv/layout.rs @@ -1,5 +1,5 @@ -//! Methods of `Layout`: `sizes`. -//! Functions: `kv_q4_bytes_per_head`, `valid_extent`, `geometry_ok`, `check_layout_inputs` and 12 more. +//! Byte layout of one layer's K/V image: the snapshot format code, the extent and geometry checks, and the sizes of +//! keys, values, scales and pooled indexer rows. `kv_bytes` and `kv_capture_bytes` give the sizes a capture needs. use super::{ ConvError, ConvResult, ConversationKv, IDX_BLOCK, KV_HYBRID, KV_ROTATED, KvLayer, KvPool, Layout, ModelGeometry, diff --git a/crates/engine-core/src/conversation/manager/conversation_manager.rs b/crates/engine-core/src/conversation/manager/conversation_manager.rs index e97714f5..49224e07 100644 --- a/crates/engine-core/src/conversation/manager/conversation_manager.rs +++ b/crates/engine-core/src/conversation/manager/conversation_manager.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `conversation_resume_checkpoints`, `conversation_state_events`. -//! Split out of `manager` to keep its files under the line limit. +//! Hub of the `ConversationManager` implementation: the resume and checkpoint half and the state and parking half +//! live in the two child modules and share the imports declared here. use super::{ CheckpointKey, ConvError, ConvResult, ConversationCache, ConversationCheckpoint, ConversationImageKey, diff --git a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs index 8735e1d3..c579b7ac 100644 --- a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs +++ b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_resume_checkpoints.rs @@ -1,5 +1,6 @@ -//! Methods of `ConversationManager`: `pick_resume`, `take_incoming`, `restore_parked`, `align_to_request` and 10 more. -//! Split out of `conversation_manager` to keep its files under the line limit. +//! The request path of `ConversationManager`: choose what a request resumes from (live session, checkpoint or parked +//! conversation), restore and position the device, then keep the checkpoint chain through the prompt and at the end. +//! Mirrors the resume choice and `checkpoint_at` of the Original's `generate.cpp`. use super::{ ConvError, ConvResult, ConversationCheckpoint, ConversationImageKey, ConversationManager, PromptAction, PromptPath, diff --git a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs index 1bfd0e3d..0814efe3 100644 --- a/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs +++ b/crates/engine-core/src/conversation/manager/conversation_manager/conversation_state_events.rs @@ -1,5 +1,5 @@ -//! Methods of `ConversationManager`: `new`, `options`, `live`, `live_ok` and 13 more. -//! Split out of `conversation_manager` to keep its files under the line limit. +//! The state half of `ConversationManager`: construction, read-only views of the live tokens, checkpoints and cache, +//! the event log, invalidation, and the parking of the current session (size estimate, making room, capture, store). use super::{ CheckpointKey, ConvResult, ConversationCache, ConversationCheckpoint, ConversationKvReuse, ConversationManager, diff --git a/crates/engine-core/src/conversation/manager/conversation_options_default.rs b/crates/engine-core/src/conversation/manager/conversation_options_default.rs index af5aceb8..3b648d38 100644 --- a/crates/engine-core/src/conversation/manager/conversation_options_default.rs +++ b/crates/engine-core/src/conversation/manager/conversation_options_default.rs @@ -1,5 +1,5 @@ -//! Implements `Default for ConversationOptions`. Functions: `images_below`, `starts_with`, `is_allocation`. -//! Split out of `manager` to keep its files under the line limit. +//! Default `ConversationOptions` and the prompt-prefix helpers the manager uses: picture positions below a limit, +//! the "saved point is a prefix of the request" test, and the classification of allocation failures. use super::{ConvError, ConversationImageKey, ConversationOptions}; diff --git a/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs b/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs index 7f4f3014..61f47879 100644 --- a/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs +++ b/crates/engine-core/src/conversation/manager_tests/byte_budget_and_slot.rs @@ -1,8 +1,7 @@ -//! Tests of manager_tests by topic (moved out of the test file by STRA-338): -//! the_byte_budget_and_slot_limit_evict_oldest_first, -//! an_incompatible_parked_image_is_discarded_and_the_request_falls_back, -//! a_failed_restore_transfer_is_fatal_to_the_request, -//! switching_steering_invalidates_checkpoints_and_isolates_parked_images .... +//! Pins the manager's budget and failure rules: the byte budget and slot limit evict oldest first, an incompatible +//! parked image is discarded, a failed restore transfer is fatal, steering switches isolate parked images, a +//! cancelled prompt keeps its checkpoints, periodic checkpoints follow the chunk stride, and pictures and the PLE +//! history window are part of the resume identity. use super::{ConversationImageKey, DeviceEngine, ReplayedRequest, TURN, chat, gen_tokens, options, world}; diff --git a/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs b/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs index 75d1bd2b..1460bbfa 100644 --- a/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs +++ b/crates/engine-core/src/conversation/manager_tests/continuing_chat_reuses.rs @@ -1,7 +1,6 @@ -//! Tests of manager_tests by topic (moved out of the test file by STRA-338): -//! a_continuing_chat_reuses_the_live_session_without_a_copy, an_identical_prompt_still_reads_its_last_token, -//! a_rewritten_tail_resumes_from_the_turn_boundary_checkpoint, the_shared_root_is_pinned_while_other_checkpoints_rotate -//! .... +//! Pins which source a request resumes from: a continuing chat reuses the live session without a copy, a rewritten +//! tail resumes from the turn-boundary checkpoint, the shared root stays pinned while other checkpoints rotate, +//! switching conversations parks and restores exactly, and physical-memory admission gates parking. use super::{GIB, ReplayedRequest, Run, TURN, World, chat, gen_tokens, options, world}; diff --git a/crates/engine-core/src/conversation/manager_tests/hash.rs b/crates/engine-core/src/conversation/manager_tests/hash.rs index e2f310ff..96261fce 100644 --- a/crates/engine-core/src/conversation/manager_tests/hash.rs +++ b/crates/engine-core/src/conversation/manager_tests/hash.rs @@ -1,5 +1,5 @@ -//! Methods of `SimDevice`: `per`, `row_bytes`, `write_cell`, `mirror_ring` and 7 more. -//! Implements `StateMemory for SimDevice`. Functions: `hash`, `pat`, `pattern`, `idx`. +//! The simulated device memory of the manager tests: token-prefix hashing and patterns, the `SimDevice` byte regions +//! (running state, K/V pools, indexer rows, drafter ring) and its `StateMemory` implementation. use super::{ IdxKind, KvLayer, KvPool, PAGE, RingBlocks, SLOTS, SimDevice, StateMemory, StateRegion, kv_region, state_sizes, diff --git a/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs b/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs index c9b9902f..257b4a67 100644 --- a/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs +++ b/crates/engine-core/src/conversation/manager_tests/sim_device_session_device.rs @@ -1,5 +1,5 @@ -//! Methods of `ReplayedRequest`: `new`. Methods of `World`: `read_plan`, `request`. -//! Implements `SessionDevice for SimDevice`. +//! The simulated world of the manager tests: `SimDevice` as a `SessionDevice`, the small model geometry, the +//! `World` that replays requests (reading a prompt plan into device state) and the chat and token generators. use super::{ ConversationImageKey, ConversationManager, ConversationOptions, DeviceEngine, Fixture, FixtureGeometry, GIB, diff --git a/crates/engine-core/src/conversation/snapshot_tests/fixture.rs b/crates/engine-core/src/conversation/snapshot_tests/fixture.rs index e7f93bd4..1c6f0bb8 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/fixture.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/fixture.rs @@ -1,5 +1,5 @@ -//! Methods of `Fx`: `new`, `unchanged`, `restore`, `reject` and 13 more. -//! Functions: `fixture_geometry`, `fixture_session`, `fixture_checkpoint`, `fixture_image` and 3 more. +//! The fixture of the snapshot tests: a small model with a first, a last and a drafter layer registered in host +//! memory, a complete saved image, and the checks `Fx` runs on it (sizes, save, restore, rejection before any write). use super::{ ConversationCheckpoint, ConversationImageKey, ConversationKvReuse, ConversationView, HostMemory, IDX_BLOCK, diff --git a/crates/engine-core/src/conversation/snapshot_tests/full_session.rs b/crates/engine-core/src/conversation/snapshot_tests/full_session.rs index 504ec73d..ce4a69ae 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/full_session.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/full_session.rs @@ -1,5 +1,5 @@ -//! Methods of `Session`: `new`, `spare`, `fill`, `save_checkpoint` and 9 more. -//! Functions: `session_geometry`, `put_session_regions`, `session_spec`, `full_session`. Defines `Session`. +//! The whole-session scenario of the snapshot tests: a main and a draft layer with running state and checkpoints in +//! one host memory, saved and restored, with the observations compared against the golden values. use super::{ ConversationCheckpoint, ConversationImageKey, ConversationKv, ConversationKvReuse, Fixture, HYBRID, HostMemory, diff --git a/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs b/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs index fe714149..b412eb3a 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/golden_state.rs @@ -1,5 +1,5 @@ -//! Functions: `golden_state`, `fnv`, `fnv_buf`, `assert_kv` and 2 more. -//! Split out of `snapshot_tests` to keep its files under the line limit. +//! Helpers that compare saved images, K/V layers and checkpoints with the golden JSON the Original's C++ produced: +//! FNV fingerprints of the buffers and the field-by-field assertions. use super::{ConversationCheckpoint, ConversationKv, SavedConversation}; diff --git a/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs b/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs index f7d9e702..3cd00fd8 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/kv_level.rs @@ -1,5 +1,5 @@ -//! Methods of `Level`: `save`, `restore`, `reject_hybrid_streaming`, `reject_bad_extents` and 5 more. -//! Functions: `kv_level`. Defines `Level`. +//! The per-layer K/V scenario of the snapshot tests: for one format and residency mode, save, restore, verify, and +//! reject hybrid-streaming and bad extents, over one fixture layer in host memory. use super::{ ConversationKv, Fixture, HYBRID, HostMemory, KV_INT8, KV_Q4, KV_VALUE_INT8, KvLayer, KvPool, KvTarget, equal, diff --git a/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs b/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs index 15244030..9bbb63c0 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/kv_region.rs @@ -1,5 +1,5 @@ -//! Methods of `Alloc`: `put`. Methods of `Fixture`: `new`, `with_geometry`, `source`, `fill` and 1 more. -//! Functions: `kv_region`, `mk_view`, `equal`, `q4_per_head` and 8 more. Defines `Alloc`, `Dims`. +//! Allocation of the K/V pools of a snapshot-test layer (fp16, INT8, Q4_0 and hybrid formats, device slots and host +//! pools) in host memory, and the region and view helpers the other snapshot tests share. use super::{ ConversationCheckpoint, ConversationImageKey, ConversationKv, ConversationView, Fixture, FixtureGeometry, HYBRID, diff --git a/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs b/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs index 61f985bc..7caef515 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/layer_snapshots_are_byte_exact.rs @@ -1,7 +1,6 @@ -//! Tests of snapshot_tests by topic (moved out of the test file by STRA-338): -//! layer_snapshots_are_byte_exact_across_formats_and_residency_modes, whole_session_snapshots_round_trip_exactly, -//! validation_rejects_before_any_device_write_and_faults_are_fatal, -//! checkpoint_save_restore_round_trips_through_host_memory .... +//! Pins the snapshot contracts: layer and whole-session images are byte exact across formats and residency modes, +//! validation rejects before any device write, checkpoints round-trip through host memory, and geometry, carve sizes, +//! layouts and payload hashes match the Original's golden values. use super::{ ConversationCheckpoint, ConversationKv, Fixture, HYBRID, HostMemory, IDX_BLOCK, IdxKind, KV_F16, KV_INT8, KV_Q4, diff --git a/crates/engine-core/src/conversation/snapshot_tests/pools.rs b/crates/engine-core/src/conversation/snapshot_tests/pools.rs index a1dfcfd3..49f02dc9 100644 --- a/crates/engine-core/src/conversation/snapshot_tests/pools.rs +++ b/crates/engine-core/src/conversation/snapshot_tests/pools.rs @@ -1,5 +1,5 @@ -//! Methods of `Pools`: `new`, `register`, `image`. Functions: `mark_present`. -//! Split out of `snapshot_tests` to keep its files under the line limit. +//! The K/V pool set of a snapshot-test layer: which buffers a format has (fp16, INT8, Q4_0), registering them in host +//! memory and building the matching image. use super::{ ConversationKv, HostMemory, IdxKind, KvLayer, KvPool, ModelGeometry, Pools, QsaDesc, StateRegion, kv_region, diff --git a/crates/engine-core/src/prefix_cache/store/decayed.rs b/crates/engine-core/src/prefix_cache/store/decayed.rs index 3162928a..ac306720 100644 --- a/crates/engine-core/src/prefix_cache/store/decayed.rs +++ b/crates/engine-core/src/prefix_cache/store/decayed.rs @@ -1,5 +1,4 @@ -//! Functions: `decayed`. -//! Split out of `store` to keep its files under the line limit. +//! Half-life decay of a hit mass or prior with age, shared by the store's value estimate. pub(super) fn decayed(value: f64, age: u64, half_life: f64) -> f64 { diff --git a/crates/engine-core/src/prefix_cache/store/policy_params_default.rs b/crates/engine-core/src/prefix_cache/store/policy_params_default.rs index 889d82da..730c7369 100644 --- a/crates/engine-core/src/prefix_cache/store/policy_params_default.rs +++ b/crates/engine-core/src/prefix_cache/store/policy_params_default.rs @@ -1,5 +1,4 @@ -//! Methods of `Candidate`: `key`, `blocks`. Implements `Default for PolicyParams`. -//! Split out of `store` to keep its files under the line limit. +//! The operator-facing default values of `PolicyParams`, and the accessors of an admission `Candidate`. use super::{Candidate, PolicyParams}; diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store.rs b/crates/engine-core/src/prefix_cache/store/prefix_store.rs index e904a804..f36680bf 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `admit`, `prefix_store_consider_commit`, `prefix_store_evict_and_budget` and 2 more. -//! Split out of `store` to keep its files under the line limit. +//! Hub of the `PrefixStore` implementation: admission, the consider and commit path, eviction and budget, the +//! statistics and clock, and node scoring each live in a child module over the shared store types. use super::{ Block, ByteSize, CHAIN_SEED, Candidate, Consider, HashMap, HashSet, KeptTail, Match, Node, NodePayload, diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs index 887dc6e1..7d240b09 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_consider_commit.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixStore`: `consider`, `consider_tail`, `candidate_value`, `commit` and 3 more. -//! Split out of `prefix_store` to keep its files under the line limit. +//! Admission decision and commit of prefix-store nodes: `consider` (is a node worth its bytes), the request-end tail +//! variants, the value estimate of a candidate, and `commit` once the caller has built the payloads. use super::{ByteSize, Candidate, Consider, HashSet, KeptTail, NodePayload, PrefixStore, Reject}; diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_evict_and_budget.rs b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_evict_and_budget.rs index 7f8a74c0..8cd67ed9 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_evict_and_budget.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_evict_and_budget.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixStore`: `enforce_budget`, `abort`, `release_orphans`, `evict` and 6 more. -//! Split out of `prefix_store` to keep its files under the line limit. +//! Removal from the prefix store: enforcing the byte budget, aborting a candidate, evicting a node together with the +//! blocks only it covered, orphan release, clearing, and the invariant check. use super::{ByteSize, Candidate, HashSet, Node, PrefixStore}; #[cfg(any(test, feature = "testing"))] diff --git a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_stats_and_clock.rs b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_stats_and_clock.rs index aad9e3b4..3e1c4add 100644 --- a/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_stats_and_clock.rs +++ b/crates/engine-core/src/prefix_cache/store/prefix_store/prefix_store_stats_and_clock.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixStore`: `new`, `config`, `stats`, `bytes` and 26 more. -//! Split out of `prefix_store` to keep its files under the line limit. +//! Construction, statistics, request clock and expiry of the prefix store, and its lookups: the longest token-exact +//! match, the hash-only prefix match a router uses, the node heads, and the hit and miss records that feed admission. use super::{ ByteSize, CHAIN_SEED, HashMap, HashSet, Match, Node, PrefixStore, Stats, StoreConfig, chain_step, decayed, diff --git a/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs b/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs index 393b5b6f..55aae5b2 100644 --- a/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs +++ b/crates/engine-core/src/prefix_cache/store/tests/hit_by_another_session.rs @@ -1,8 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_hit_by_another_session_makes_a_shared_root_outlive_private_leaves, -//! thinning_a_chain_keeps_the_deepest_node_and_the_blocks_it_needs, -//! the_budget_is_enforced_again_when_the_real_payload_is_bigger_than_the_estimate, -//! commit_refuses_blocks_that_are_not_the_candidates .... +//! Pins the store's sharing and budget behaviour: a hit by another session keeps a shared root alive, chains are +//! thinned, the budget is enforced again when a payload exceeds its estimate, collisions are never matched, the node +//! cap evicts by value, and long agent sessions stay inside the budget with a fast lookup. use super::{ BLOCK, Consider, G, Payload, PolicyParams, PrefixStore, Reject, STATE, StoreConfig, chain, put, store, tokens, diff --git a/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs b/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs index 465352f4..7691e4f5 100644 --- a/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs +++ b/crates/engine-core/src/prefix_cache/store/tests/request_resumes_from.rs @@ -1,7 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_request_resumes_from_the_deepest_node_of_any_session, common_prefixes_are_stored_once, -//! a_node_with_descendants_is_a_branch_point_and_a_frontier_is_not, -//! the_prompt_end_checkpoint_survives_the_decode_end_checkpoint_of_its_request .... +//! Pins resume and eviction semantics of the store: resume from the deepest node of any session, shared prefixes +//! stored once, branch points versus frontiers, request-end tail nodes and their supersession, retention and expiry, +//! and value-ordered eviction under a full budget. use super::{ BLOCK, Consider, G, MINUTE, Payload, PolicyParams, PrefixStore, Reject, STATE, StoreConfig, put, put_tail, diff --git a/crates/engine-core/src/prompt/prompt_options.rs b/crates/engine-core/src/prompt/prompt_options.rs index 1e2351fb..355920cb 100644 --- a/crates/engine-core/src/prompt/prompt_options.rs +++ b/crates/engine-core/src/prompt/prompt_options.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptOptions`: `original_mode17`. -//! Methods of `PromptPlan`: `new_in_context`, `new`, `prompt`, `next_segment` and 1 more. +//! Prompt planning of the Original serve path: the options and capacity choice (auto ladder, cache-slot loan), the +//! validity checks, the `PromptPlan` iterator that cuts a prompt into segments, and `drive`, which runs a plan. use super::{ DriveError, DriveSummary, PlanError, PlanLimits, PromptAction, PromptOptions, PromptPath, PromptPlan, PromptRunner, diff --git a/crates/engine-core/src/spec/adaptive/adaptive_config.rs b/crates/engine-core/src/spec/adaptive/adaptive_config.rs index f1bff54e..56dd11f3 100644 --- a/crates/engine-core/src/spec/adaptive/adaptive_config.rs +++ b/crates/engine-core/src/spec/adaptive/adaptive_config.rs @@ -1,5 +1,5 @@ -//! Methods of `AdaptiveConfig`: `new`, `with_policy`, `set_option`, `set_tuning` and 1 more. -//! Methods of `Cell`: `rate`, `add`. Functions: `p_bucket`, `m_bucket`, `logit`, `sigmoid`. +//! Constants of the adaptive window policy: construction, the `LELEKA_SPEC_POLICY` presets, named options for replay +//! arms, the acceptance `Cell` statistics, and the probability bucketing and logit helpers. use super::{AdaptiveConfig, Cell, FLOOR_CEILING, FLOOR_CEILING_LEGACY, MAX_T, P_BUCKETS, P_EDGES}; diff --git a/crates/engine-core/src/spec/adaptive/adaptive_policy.rs b/crates/engine-core/src/spec/adaptive/adaptive_policy.rs index fc06c6dc..02994f8f 100644 --- a/crates/engine-core/src/spec/adaptive/adaptive_policy.rs +++ b/crates/engine-core/src/spec/adaptive/adaptive_policy.rs @@ -1,5 +1,5 @@ -//! Methods of `AdaptivePolicy`: `new`, `config`, `rounds`, `begin_request` and 7 more. -//! Split out of `adaptive` to keep its files under the line limit. +//! State and calibration of the adaptive window policy: per-request reset, the acceptance rate of an MTP draft or a +//! suffix row, the per-width cost mean and its fit, and the candidate widths offered to the decision. use super::{ AdaptiveConfig, AdaptivePolicy, Cand, Cell, M_BUCKETS, MAX_T, N0_BUCKET, N0_DEPTH, N0_SUFFIX, Offer, Origin, diff --git a/crates/engine-core/src/spec/adaptive/spec_stats.rs b/crates/engine-core/src/spec/adaptive/spec_stats.rs index 61504a89..31c2a8cd 100644 --- a/crates/engine-core/src/spec/adaptive/spec_stats.rs +++ b/crates/engine-core/src/spec/adaptive/spec_stats.rs @@ -1,5 +1,5 @@ -//! Methods of `SpecStats`: `record`, `line`. -//! Split out of `adaptive` to keep its files under the line limit. +//! Per-round statistics of the adaptive policy (width, accepted rows, flags, milliseconds) and the one-line report +//! printed from them. use super::{MAX_T, RoundFlags, SpecStats}; diff --git a/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs b/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs index 29d6cb9e..2bb08d08 100644 --- a/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs +++ b/crates/engine-core/src/spec/adaptive/tests/default_ceiling.rs @@ -1,6 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! the_default_ceiling_is_the_new_one_and_the_legacy_switch_restores_the_old_policy_exactly, -//! the_smooth_floor_moves_continuously_with_the_bar, a_trace_is_reproducible, stats_line_reports_the_histograms. +//! Pins the policy constants: the default draft-floor ceiling is the new one, the legacy switch restores the earlier +//! policy exactly, the smooth floor moves continuously with the bar, traces are reproducible, and the stats line. use super::{ AdaptiveConfig, AdaptivePolicy, CODE_COSTLY, FLOOR_CEILING, P_BUCKETS, P_EDGES, PROSE_CHEAP, Rng, RoundFlags, diff --git a/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs b/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs index 5bce6e24..0307a1c5 100644 --- a/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs +++ b/crates/engine-core/src/spec/adaptive/tests/stationary_regimes_reach_the_best.rs @@ -1,6 +1,6 @@ -//! Tests of `tests` by topic: stationary_regimes_reach_the_best_fixed_width, -//! it_widens_when_rows_are_cheap_and_narrows_when_they_are_not, it_follows_a_change_of_content_and_of_cost, -//! reaction_to_a_switch_takes_tens_of_rounds_not_hundreds .... +//! Pins the adaptive window's learning: stationary regimes reach the best fixed width, it widens when rows are cheap +//! and narrows when not, follows a change of content or cost, explores cheaply, interpolates unmeasured widths, and +//! keeps the draft plan inside its bounds. use super::{ AdaptivePolicy, CODE_CHEAP, CODE_COSTLY, Choice, MAX_T, Offer, Origin, PROSE_CHEAP, PROSE_COSTLY, REPEAT, Rng, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs index 3933e54a..cbf970e6 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/original_serve_mode.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeMode`: `parse`, `as_str`. Methods of `ExpertSource`: `parse`, `as_str`. -//! Implements `Default for OriginalServeOptions`. +//! Parsing and printing of the Original-path choices (`OriginalServeMode`, `ExpertSource`, `PrefixTail`), the +//! published prefix-cache pool summary, and the default and run-time validation of `OriginalServeOptions`. use super::{ BackendError, ConfigFacts, ExpertSource, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs index ae4676f5..6c62bc7e 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/runner/command_loop.rs @@ -1,5 +1,5 @@ -//! The command loop of the Original owner, moved out of `run` by STRA-338 (size): receive, sweep the idle sessions, -//! and answer each command in the order `run` did. +//! The command loop of the Original owner: publish readiness, then receive commands, sweep idle sessions while none +//! arrives, and answer Load (refused), Reconfigure, Unload and Generate until unload or shutdown. use super::{ BackendError, Command, Duration, GenerateEnv, IdleSweep, Live, LoadPhase, LoadedModel, Ordering, diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs b/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs index 7fa58caa..b03cc57b 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of `original_serve`. +//! Pins the Original-path selection and options: modes parse and print symmetrically, `Auto` takes the Original path +//! only when everything is sealed and fed, explicit `Original` never falls back and names what is missing, `Preview` +//! is never overridden, option bounds, the conversation-cache defaults, and the eight-cell slack of the fit test. use super::{ConfigFacts, OriginalServeChoice, OriginalServeMode, OriginalServeOptions, PathBuf, choose, context_fits}; diff --git a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs index 77c86354..d2aa3bb5 100644 --- a/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs +++ b/crates/engine-qwen35-cuda/src/backend/original_serve_replay/required_path.rs @@ -1,5 +1,5 @@ -//! Functions: `required_path`. -//! Split out of `original_serve_replay` to keep its files under the line limit. +//! Reads an operator-owned input path from an environment variable for the replay and the GPU proofs; a missing +//! variable panics with its name, so a proof never runs against a guessed file. use super::{PathBuf, env}; diff --git a/crates/engine-qwen35-cuda/src/backend/tests.rs b/crates/engine-qwen35-cuda/src/backend/tests.rs index 1477b82b..05cf4462 100644 --- a/crates/engine-qwen35-cuda/src/backend/tests.rs +++ b/crates/engine-qwen35-cuda/src/backend/tests.rs @@ -1,3 +1,7 @@ +//! Backend-level tests of the Native path: the queued-owner identity digest, explicit KAR selection and context +//! admission, request caps and sampling plans, incremental UTF-8 publication, cancel with a full control queue, +//! control-token encoding, and a request arriving during the deferred tail. + use super::{ Active, ActiveGuard, Arc, AtomicBool, Backend, BackendError, Command, DeferredTail, Digest, ErrorCode, EvaluationExecution, FRAME_LIMIT, GenerationRequest, InferenceMode, KAR_LOAD_REPLY_TIMEOUT, KAR_PROFILE, diff --git a/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs b/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs index 7bf82d4c..dde09a75 100644 --- a/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs +++ b/crates/engine-qwen35-cuda/src/conversation/resident/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the resident-conversation store: a disabled policy keeps the single continuation, an identical prompt may +//! reuse the live session but not a parked one, A-B-A swaps pick the longest prefix (ties to the newest), slots and +//! bytes bound the parked set oldest first, unusable candidates are dropped, and operator settings parse strictly. use super::{ResidentConversations, ResidentPolicy, ResumeSource}; diff --git a/crates/engine-qwen35-cuda/src/experimental/tests.rs b/crates/engine-qwen35-cuda/src/experimental/tests.rs index 0cfc2d99..eb9c96c2 100644 --- a/crates/engine-qwen35-cuda/src/experimental/tests.rs +++ b/crates/engine-qwen35-cuda/src/experimental/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the experimental-mode admission: the default is off and changes nothing, each mode selects the Original's +//! format and programs, exclusions follow its rules, pool sizes match, the digest binds modes, values and files, +//! an enabled mode is refused until the forward pass consumes it, and control-vector files are validated at load. use super::{ ExperimentalConfig, ExperimentalError, KvFormat, Mode, OptIn, PathBuf, Program, ensure_consumed, diff --git a/crates/engine-qwen35-cuda/src/model_binding/mod.rs b/crates/engine-qwen35-cuda/src/model_binding/mod.rs index c70d0831..896574b4 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/mod.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/mod.rs @@ -1,3 +1,6 @@ +//! Binding of the pinned model files to the engine: the KAR expert source and its levels, the Qwen4Exp input +//! binding (weights read from the verified artifact) and the KAR PLE source. + pub(crate) mod kar_expert_source; pub(crate) mod kar_levels; pub(crate) mod qwen4exp_input; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs index f204b1dd..7e64b905 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/binding_identity_and_input_binding_error.rs @@ -1,5 +1,6 @@ -//! Methods of `BindingIdentity` and `BoundLayer`, and the `Display` and `Error` impls of `InputBindingError`: what a -//! binding says about itself and how its failures read. +//! The small identity and constants types of the input binding: `Display` text of `InputBindingError`, the identity +//! that ties a weights handle to its binding, the index and kind of a bound layer, and the `InputConstants` read from +//! the artifact (PLE head offsets and vocabularies, EOS, context length) with their validation. use super::{ BindingIdentity, BoundLayer, BoundLayerKind, InputBindingError, InputConstants, InputResult, PLE_ROWS, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs index 152e1f18..5588f4c6 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gdn/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the GDN weight binding: the epsilon is the Original's exact layer operand, the projection kinds and +//! containers are the closed set, and shapes and row bounds are checked before any read. use super::{E, NATIVE_EPSILON, TensorSignature, block_range, descriptor, exact_bf16, kind}; #[test] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs index 7b1c8b58..c19514cf 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/gr/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the GR weight binding: only exact finite BF16 containers are accepted, role shapes are frozen, and the final +//! layer has no injection. use super::{GrRole, InputBindingError, TensorSignature, exact_bf16, role_set, validate_descriptor}; #[test] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs index 01bcc7d2..08b6a223 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/model_binding.rs @@ -1,5 +1,5 @@ -//! Methods of `ModelBinding`: `bind`, `from_artifact`, `from_artifact_with_kar_ple`, `with_kar_expert_source` and 22... -//! Functions: `bind_expert_counts`. +//! The `ModelBinding` over a verified Qwen4Exp artifact: its constructors (plain, with KAR PLE, KAR expert source or +//! MTP pack), layer and expert counts, the embedding and PLE row reads, and expert-count validation. use super::{ BindingError, BindingIdentity, BoundLayer, EMBEDDING_VALUES, GlobalRole, InputBindingError, InputConstants, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs index 5c7492c0..cc206e1d 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `model_binding_moe_descriptors`, `moe_expert_block_reads`. -//! Split out of `moe_expert` to keep its files under the line limit. +//! Hub of the `ModelBinding` MoE accessors: expert matrix admission and preload descriptors (one child) and the +//! block reads of selected expert rows from the artifact (the other). use super::{ E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs index 6a2bfac8..3df9d6cc 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/model_binding/model_binding_moe_descriptors.rs @@ -1,5 +1,5 @@ -//! Methods of `ModelBinding`: `moe_expert_weights`, `moe_preload_descriptor`, `check_preload_key`, `moe_preload_bloc... -//! Functions: `moe_matrix`, `check_gate_scalar`, `preload_key`, `preload_matrix_role` and 1 more. +//! Admission of one layer's routed and shared MoE matrices against the expected kind, shape and extent, and the +//! preload descriptors and blocks of routed experts that the MoE weight cache reads to preload pinned experts. use super::super::routed_source_descriptor::validate_rows_finite; use super::super::routed_source_descriptor::{check_matrix_tensor, check_moe_metadata, selected_expert}; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs index d6b5e839..536c5ddc 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_expert_weights.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeExpertWeights`: `matches`, `matrix`, `shape`, `kind`. -//! Methods of `MoeExpertBlock`: `kind`, `columns`, `rows`, `bytes` and 1 more. +//! Accessors of the admitted `MoeExpertWeights` and `MoeExpertBlock`, and the decoding of raw tensor kinds into +//! `MoeMatrixKind` for routed and shared matrices, with the selection and row-range checks. use super::{ BindingIdentity, E, EXPERTS, FF, InputResult, Matrix, MoeExpertBlock, MoeExpertSelection, MoeExpertWeights, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_routed_source_scope.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_routed_source_scope.rs index 9f6078db..0ac270dd 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_routed_source_scope.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/moe_routed_source_scope.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeRoutedSourceScope`: `retarget`, `check_first_member`, `check_members`. -//! Methods of `ModelBinding`: `with_moe_routed_group_source`, `moe_shared_preload_descriptors`, `moe_shared_preload_... +//! The routed-source group scope (`MoeRoutedSourceScope`): retargeting it to a new set of experts with member checks, +//! and the shared-expert preload descriptors and blocks streamed from the artifact. use super::routed_source_descriptor::check_moe_metadata; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs index 0465a865..1175c012 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/moe_expert/routed_source_descriptor.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeRoutedSourceScope`: `validate_binding`, `descriptor`, `block`, `bank_span` and 2 more. -//! Methods of `ModelBinding`: `with_moe_routed_source`, `check_members_select`, `open_routed_source`. +//! Source descriptors and reads of routed experts: model-metadata and finite-weight admission, and the scope's +//! descriptor, block, bank-span and mapped-span reads over the retained artifact owners. use super::{ BindingIdentity, E, EXPERTS, FF, InputResult, LayerRole, Matrix, ModelBinding, MoeExpertBlock, MoeExpertSelection, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs index 7111885e..eaadea4a 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/dense_bytes_types.rs @@ -1,5 +1,5 @@ -//! Defines `MtpIndex`, `MtpRows`, `MtpWeights`. -//! DENSE_BYTES, EXPERT_BYTES, EXPERT_BLOB, INDEX_BYTES, MAX_ROWS, MAX_READ .... +//! The pinned MTP pack: byte sizes, read limits and file digests of `dense.txt`, `dense.bin` and `experts.bin`, and +//! the `MtpWeights`, `MtpRows` and `MtpIndex` owners that hold its files and rows. use super::{BindingIdentity, File, MtpKind}; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs index 1e6b5260..3debfba7 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/descriptors_types.rs @@ -1,5 +1,5 @@ -//! Items of the parent module. -//! Split out of `mtp` to keep its files under the line limit. +//! The table of the 31 MTP tensors: for each role its name, source file, shape, source SHA-256 and, where it is +//! packed into `dense.bin`, the kind and byte placement. use super::{Dense, Descriptor, MtpKind, MtpRole}; diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs index 1271f2e4..66e8346e 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/mtp_kind_types.rs @@ -1,5 +1,5 @@ -//! Defines `MtpKind`, `MtpExpertMatrix`, `MtpExpertRef` and 3 more. -//! MtpKind, MtpExpertMatrix, MtpRole, Descriptor, Dense. +//! The vocabulary of the MTP pack: storage kinds, expert matrices, the roles of its tensors, and the `Descriptor` +//! and `Dense` records that describe one tensor. #[derive(Clone, Copy, Debug, Eq, PartialEq)] diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs index 45917a99..718a3883 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/pack_identity.rs @@ -1,5 +1,5 @@ -//! Methods of `IndexScan`: `accept`, `fits`, `complete`. Methods of `MtpIndex`: `inspect`. -//! Functions: `pack_identity`, `descriptor`, `pinned_dense_bytes`, `rt_dense_roles` and 6 more. +//! Identity and index of the MTP pack: the digests that name it, the descriptor lookup, the RT-directory contract +//! (consumed roles, names, kinds, shapes) and the strict parser that turns `dense.txt` into a validated `MtpIndex`. use super::{ DENSE_BYTES, DESCRIPTORS, Dense, Descriptor, FILE_PINS, INDEX_LIMIT, InputBindingError, InputResult, MtpIndex, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs index 0eecf459..0dffcfcd 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/mtp/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the MTP pack binding: exact receipts and runtime index, the RT contract's roles and shapes, malformed +//! descriptors never becoming an index, bounded rows and lossless Q2 planes keeping signed zeros, non-finite weights +//! refused, and an identity that cannot be recreated from metadata. use super::{ BindingIdentity, DESCRIPTORS, INDEX_LIMIT, InputBindingError, MtpIndex, MtpKind, MtpRole, interleave_q2, row_range, diff --git a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs index fde7c92c..63e755c1 100644 --- a/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs +++ b/crates/engine-qwen35-cuda/src/model_binding/qwen4exp_input/validate_ple_descriptor.rs @@ -1,5 +1,5 @@ -//! Methods of `InputConstants`: `test_fixture`. Methods of `BindingIdentity`: `test_identity`. -//! Functions: `validate_ple_descriptor`, `bind_layers`, `bind_layer`. +//! Bind-time admission of a Qwen4Exp artifact: the per-layer token-embedding (PLE) descriptor and the ordered list of +//! bound layers with their kinds. Also the test fixtures for `InputConstants` and `BindingIdentity`. use super::{ BoundLayer, BoundLayerKind, GlobalRole, InputBindingError, InputResult, LayerRole, PLE_ROWS, Qwen4ExpArtifact, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs index a43267db..59a8c5fc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_slab_policy.rs @@ -1,5 +1,5 @@ -//! Functions: `dense_slab_policy`, `startup_step`. -//! Split out of `dense_weight_cache` to keep its files under the line limit. +//! Startup policy of the dense weight cache: whether dense weights are packed into 64 MiB slabs or get one allocation +//! each, and the step-named refusal message of the prompt-capacity startup. Both layouts place the same bytes. use super::SlabPolicy; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs index cd4089b4..32e39404 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `dense_cache_buffers_and_close`, `dense_cache_eager_layer_load`, `dense_cache_gdn_qsa_works... -//! Split out of `dense_weight_cache` to keep its files under the line limit. +//! The `impl DenseWeightCache` blocks by responsibility: constructors, eager layer load, matrix registration, PLE and +//! verifier weight views, prompt and GDN scratch, GDN/QSA workspaces, buffers and close. Shared imports live here. use super::{ ALL_MIRROR_BYTES, BoundLayerKind, Cell, Context, DenseCacheCounters, DenseWeightCache, DeviceBuffer, DeviceRef, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_buffers_and_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_buffers_and_close.rs index 0c319e4e..15a08ad4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_buffers_and_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_buffers_and_close.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `gr_buffers`, `counters`, `chunk_modules`, `close` and 4 more. -//! Functions: `close_into`. +//! Buffer access and teardown of the dense weight cache: GR buffers, counters, chunk modules and the consuming close, +//! which releases scratch, modules, batch workspaces, buffers and slabs and keeps the first error. use super::{ Context, DenseCacheCounters, DenseWeightCache, DeviceBuffer, Error, GrResident, ModelBinding, QkScratch, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_eager_layer_load.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_eager_layer_load.rs index 0e608622..66d39b1c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_eager_layer_load.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_eager_layer_load.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `new_with_selected`, `unloaded`, `load_eager`, `reserve_layer_tables` and 6 more. -//! Functions: `reserve_table`. +//! Eager load of the dense weights at construction: reserves the layer tables, loads the router, GDN and QSA layers +//! of a binding into the slab allocator and adds the scratch owners. use super::{ ALL_MIRROR_BYTES, BoundLayerKind, Cell, Context, DenseCacheCounters, DenseWeightCache, Error, GdnInputScratch, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs index 2b451667..76f5fbbe 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_gdn_qsa_workspaces.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseWeightCache`: `gdn_batch_resources`, `qsa_native_workspace`, `test_record_gr_batch_completed`, `... -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! Lookups of the dense cache that the decode and prompt paths borrow from: GDN batch resources, QSA workspace, +//! GDN and QSA scratch loans, and the per-layer GDN, QSA, GR and router entries with buffer handles for a held +//! verify assembly. use super::{ Cell, Context, DenseWeightCache, DeviceBuffer, DeviceRef, Error, GdnInputLease, GdnInputScratch, GdnResident, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs index 2a0233d9..1ef9605a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_matrix_registration.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `add`, `add_f32`, `add_bf16`, `add_gr` and 13 more. Defines `ExpectedPleMatrix`. -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! Registration of dense matrices (raw, F32, BF16, GR roles, the retained PLE matrices) into the cache with byte and +//! finite checks, plus binding validation and the router, GR, PLE and native batch scratch loans. use super::{ Context, DenseWeightCache, DeviceRef, Error, GrBatchInjectWorkspace, GrResident, GrRole, GrScratch, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs index 3085ba48..809b4d4a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_ple_and_verify_weights.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseWeightCache`: `ple`, `ple_key`, `ple_value`, `ple_value_tile` and 16 more. -//! Functions: `gdn_native_type`, `qsa_native_type`. +//! Read-only views of the loaded dense weights: PLE key, value and norm slots, GDN and QSA matrix and norm slots, and +//! the ordered operands of the Original verifier window (GDN weights, QSA gammas, native MMVQ projections). They are +//! the cache's own allocations, so no host conversion happens at this boundary. use super::{ BoundLayerKind, Context, DenseWeightCache, DeviceBuffer, DeviceRef, Error, GdnMatrixKind, GdnMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs index cfe3279e..ab31a03d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_cache_prompt_and_gdn_scratch.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseWeightCache`: `new_original_prompt_capacity`, `load_prompt_owners`, `load_prompt_workspaces`, `l... -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! The prompt-capacity constructor of the dense weight cache (prompt owners, workspaces and scratch sized for the +//! chunk capacity) and the pools that serve it: idle GDN finite guards, pooled GDN state buffers and the GDN +//! verification workspace. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GdnVerificationWorkspace, ModelBinding, QkScratch, Rc, RefCell, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_weight_cache_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_weight_cache_constructors.rs index 222b2aa4..1c3900dc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_weight_cache_constructors.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/dense_weight_cache_methods/dense_weight_cache_constructors.rs @@ -1,5 +1,5 @@ -//! Methods of `DenseWeightCache`: `new`, `new_qsa_selected`, `new_qsa_selected_router`, `new_qsa_selected_router_gr_... -//! Split out of `dense_weight_cache_methods` to keep its files under the line limit. +//! The named constructors of the dense weight cache, from the plain cache up to the selected router, GR batch, QK, +//! attention and MTP journal variants, and the attachment of the prompt owners, queues and native QSA resources. use super::{ Context, DenseWeightCache, Error, ModelBinding, QkScratch, QsaAttentionScratch, Rc, RefCell, Result, RouterScratch, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs index e6ac1bf0..4fe9d212 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/dense_weight_cache/workspaces.rs @@ -1,5 +1,6 @@ -//! The lazily created workspaces of the dense weight cache, moved out of it by STRA-338 (size): consecutive owners, -//! declared in the order the cache dropped them, so the drop order is unchanged. +//! The lazily created workspaces of the dense weight cache (GDN, QSA, GR and router scratch, idle guards and pooled +//! GDN state buffers), all empty at construction and filled on first use. The fields are declared in the order the +//! cache drops them, so the drop order is unchanged. use super::{ DeviceBuffer, GdnInputScratch, GrBatchInjectWorkspace, GrScratch, QkScratch, QsaAttentionScratch, QsaIndexKeyCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs index e4965950..bef1d479 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor.rs @@ -1,5 +1,6 @@ -//! Groups the submodules `construction_and_parking`, `prompt_executor_forward_and_close`, `prompt_executor_retire_ow... -//! Split out of `original_prompt` to keep its files under the line limit. +//! Impl family of `OriginalPromptExecutor`, the owner of every device resource of the layer-major Original prefill +//! (prompt rows, GDN, QSA, MTP). The children share this import list: construction and parking, chunk forward, +//! retirement. use super::{ BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs index d1693815..29946253 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `executor_construction`, `session_park_and_qsa_owners`. -//! Split out of `original_prompt_executor` to keep its files under the line limit. +//! Construction of an `OriginalPromptExecutor` and the parking of its session state. Builds the device owners and the +//! twelve resident QSA layers; parks, imports and restores the session for the prefix cache. use super::{ BoundLayerKind, Context, DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs index 98757cbf..35ec4a20 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/executor_construction.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptExecutor`: `new`, `new_with_mtp_weights`, `check_construction`, `empty` and 17 more. -//! Split out of `construction_and_parking` to keep its files under the line limit. +//! Builds an `OriginalPromptExecutor`: the prompt, GDN, QSA and MTP device owners and the twelve resident QSA layers. +//! Also the drafter hooks the serve host calls on it (RT bank selection, prompt length, draft limit, idle, KV +//! restore). use super::{ BoundLayerKind, Context, DenseWeightCache, Dimension, DraftAttachmentTables, DraftAttachmentTarget, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs index ce25343b..f386fa5f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/construction_and_parking/session_park_and_qsa_owners.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptExecutor`: `take_qsa_owners`, `adopt_qsa_owners`, `rebuild_qsa_layers`, `checkpoint_ses... -//! Defines `QsaOwners`. +//! Session handoff of the executor: the resident QSA owners lent to the native verifier for a decode phase and taken +//! back, and the checkpoint, park, import and restore of the session point (prefix cache, request reset). use super::{ DenseWeightCache, Error, ModelBinding, OriginalPromptExecutor, OriginalSessionCheckpoint, ParkedBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close.rs index 82e5aa82..533cdaf0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `prompt_chunk_forward`, `prompt_executor_close`. -//! Split out of `original_prompt_executor` to keep its files under the line limit. +//! Running and closing a prompt chunk on the executor: the forward pass over the arena and the consuming `close`. use super::{ BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs index 9fcf0cff..5065a867 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptExecutor`: `forward`, `arena_holds_window`, `admit_window`, `finish_forward` and 4 more. -//! Functions: `trace_step`, `arena_serves_chunk`, `trace_error`. Defines `ForwardDone`, `StagedRows`. +//! `OriginalPromptExecutor::forward`: one batched prompt chunk, from input staging through every layer to the final +//! row, its sample and the draft KV. An error rolls the transaction and the draft back; success leaves a pending +//! target to publish. use super::{ BoundLayerKind, Carrier, ChunkCaches, ChunkDraft, ChunkInFlight, ChunkRollback, ChunkWork, Context, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs index 689dc743..8f588029 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_draft.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the draft-KV phase of `OriginalPromptExecutor::forward`. +//! The draft-KV phase of `OriginalPromptExecutor::forward`. use super::{ ChunkDraft, Context, Error, MoeWeightCache, OriginalDraftKvPending, OriginalMtpPrefill, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs index ec4f8bc2..4e5a75af 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_final.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the final row of `OriginalPromptExecutor::forward` (conditioning preview, sample, R trace). +//! The final row of `OriginalPromptExecutor::forward` (conditioning preview, sample, R trace). use super::{ Carrier, ChunkWork, DenseWeightCache, Error, ModelBinding, OriginalPromptExecutor, OriginalPromptSample, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs index 52f68fb7..d1dfe7d2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_input.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the input phase of `OriginalPromptExecutor::forward` (staging, row upload, PLE read-ahead). +//! The input phase of `OriginalPromptExecutor::forward` (staging, row upload, PLE read-ahead). use super::{ ChunkInFlight, Context, DenseWeightCache, Error, InputStage, KarPleCache, ModelBinding, OriginalPrefillArena, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs index a3040fb8..7558d188 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_chunk_forward/forward_layers.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the layer loop of `OriginalPromptExecutor::forward`, one helper per phase of a layer. +//! The layer loop of `OriginalPromptExecutor::forward`, one helper per phase of a layer. use super::{ BoundLayerKind, Carrier, ChunkWork, DenseWeightCache, Error, InputStage, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_executor_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_executor_close.rs index 07311086..7cc06990 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_executor_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_forward_and_close/prompt_executor_close.rs @@ -1,5 +1,4 @@ -//! Methods of `OriginalPromptExecutor`: `close`. -//! Split out of `prompt_executor_forward_and_close` to keep its files under the line limit. +//! Consuming `close` of the executor; the retirement of the owners itself is `close_inner`. use super::{OriginalPromptExecutor, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs index 8e36bcd0..9a7e17bd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor/prompt_executor_retire_owners.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptExecutor`: `close_inner`, `retire_device_owners`, `retire_mtp_and_layers`. -//! Split out of `original_prompt_executor` to keep its files under the line limit. +//! Retirement of the executor's device owners: prompt, GDN, QSA, transport, attention, MTP and the resident layers. +//! Every owner is closed even after a failure; the first error is kept and the executor is marked failed. use super::{Error, OriginalPromptExecutor, Result, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs index c7e1af8b..5397dbbd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/original_prompt_executor_drop.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptPending`: `publish`. -//! Implements `Drop for OriginalPromptExecutor`, `Drop for OriginalPromptPending` and 2 more. +//! Publication and rollback of a prompt chunk: `OriginalPromptPending::publish`, and the drops that close the +//! executor or abort an unpublished transaction. Also the `PromptRunner` that drives the chunks of a prompt plan, and +//! `driver_error`. use super::{ ChunkCaches, ChunkDraft, Error, NoPromptHooks, OriginalPromptComposer, OriginalPromptExecutor, OriginalPromptHooks, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs index 159ecd34..172eb120 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/original_prompt/staged_input_enabled.rs @@ -1,5 +1,4 @@ -//! Functions: `staged_input_enabled`. -//! Split out of `original_prompt` to keep its files under the line limit. +//! The `prefill_staged_input` switch: staged chunk input, or the per-token host path of the KAR inputs (the A/B arm). /// `LELEKA_PREFILL_STAGED_INPUT=0` keeps the per-token host path of the KAR inputs (the A/B arm). diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs index cc2806e2..be5921b4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/check_chunk_on_loaded.rs @@ -1,5 +1,6 @@ -//! Methods of `Ids`: `new`, `position`. -//! Methods of `Rig`: `snapshot`, `prefill`, `step_final`, `prefill_chunk` and 7 more. +//! GPU test phase on the loaded target: a genuine four-row prefill chunk must reproduce the scalar known-next path +//! exactly (logits, greedy token, residual, state, draft), and a cancelled chunk must leave the committed target and +//! draft untouched. #![cfg(all(test, any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs index ee6dceaf..3c357e07 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows.rs @@ -1,5 +1,5 @@ -//! Methods of `MicroRows`: `reserve`, `push`, `collect`, `inject`. Functions: `prepare_micro_ffn_rows`. -//! Defines `MicroEnv`, `MicroSources`, `MicroBlockSources` and 2 more. +//! FFN preparation of a micro window of a prefill layer: the attention blocks of the window, one whole retained-GR +//! FFN read over them, then the per-row proofs. The block kinds and the FFN routing are the child modules. #![cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs index 4a3c5283..3a26d009 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/ffn_rows.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the routing of the FFN reads of a micro window. +//! The routing of the FFN reads of a micro window. use super::{ ChunkFfnRow, Context, DetachedGrRead, Error, ForwardPhase, GrStage, MicroEnv, MoeExpertStage, MoeMicroProducts, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs index c9af8168..b2d405a1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/gdn_native.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the native prompt GDN attention blocks of a micro window. +//! The native prompt GDN attention blocks of a micro window. use super::{ ChunkAttentionRow, Context, DetachedGrRead, Error, GdnChunkDevice, GdnStage, GrMicroAttentionBank, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs index e32da09c..302994ae 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/plain_rows.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the row-by-row attention blocks of a micro window (device GDN owner or host stages). +//! The row-by-row attention blocks of a micro window (device GDN owner or host stages). use super::{ BoundLayerKind, ChunkAttentionRow, DetachedGrRead, Error, ForwardPhase, GdnChunkDevice, GdnStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs index d043ec7e..20f61a2f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_micro_ffn_rows/qsa_native.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the native prompt QSA attention blocks of a micro window. +//! The native prompt QSA attention blocks of a micro window. use super::{ ChunkAttentionRow, Context, Error, GrMicroAttentionBank, GrStage, MicroBlockRequest, MicroEnv, MicroRows, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs index 911129b7..32fcda05 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/prepare_q6_layer_columns.rs @@ -1,5 +1,5 @@ -//! Functions: `prepare_q6_layer_columns`, `q6_inputs`, `q6_roles`, `q6_project` and 1 more. -//! Split out of `prefill_chunk` to keep its files under the line limit. +//! Q6K projection of the attention rows of a layer: the validated residual input of each row goes through the layer's +//! Q6K matrices (GDN or QSA roles), giving the projected columns per row for the retained GR bank. use super::{BoundLayerKind, DenseWeightCache, Error, LayerId, ModelBinding, QwenChunkTxn, Result}; use crate::model_binding::qwen4exp_input::{GdnMatrixKind, GdnMatrixRole, QsaMatrixKind, QsaMatrixRole}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs index 0642643c..f251b02e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `joint_chunk`, `prefill_chunk_cached_windowed`, `prefill_chunk_native_windowed` and 1 more. -//! Split out of `prefill_chunk` to keep its files under the line limit. +//! Chunk entry points of `QwenForward`: the joint target+draft prefill chunk in its cached, MMQ and native windowed +//! forms, and the planned layer loop they share. use super::{ AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs index c431cae6..501f8aff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/joint_chunk.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the inputs and the joint target+draft publication shared by the prefill chunk entry points. +//! The inputs and the joint target+draft publication shared by the prefill chunk entry points. use super::{ ChunkMoePolicy, DenseWeightCache, Error, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, QwenForward, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs index 80b6caba..090a2c7a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_cached_windowed.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenForward`: `test_chunk_on_loaded`, `prefill_chunk_mmq_joint`, `prefill_chunk_cached_joint`, `prepa... -//! Split out of `qwen_forward` to keep its files under the line limit. +//! Entry points of `QwenForward` for the cached prefill chunk: MMQ joint, cached joint and the private outer256 +//! windowed experiments (plain and retained-GR transport). Normal serving stays on outer64 with the host transport. use super::{ ChunkMoePolicy, MoeWeightCache, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, QwenForward, QwenSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs index cb788161..ced380a7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_native_windowed.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenForward`: `prefill_chunk_native_integer_iq3_windowed256_retained_gr_joint`, `prepare_prefill_chun... -//! Split out of `qwen_forward` to keep its files under the line limit. +//! Entry point of `QwenForward` for the native IntegerIQ3 prefill chunk: outer256 layers run in windows of at most 64 +//! rows over the retained-GR transport; the draft is warmed and published with the target only after all 48 layers +//! completed. use super::{ AllocationTrace, ChunkMoePolicy, Error, MoeWeightCache, PrefillChunkInputs, PrefillChunkPlan, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs index 858c0c53..474fa71a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned.rs @@ -1,5 +1,6 @@ -//! Methods of `ChunkEnv`: `new`, `with_boundary`, `native_prompt`. Methods of `ChunkRun`: `window`. -//! Defines `MicroBank`, `MicroBank`, `NativeMoe` and 6 more. +//! The planned prefill chunk: admission, the `ChunkEnv` every phase reads, the `ChunkRun` of the rows a run covers +//! and the layer loop that ends in the output head. The phases are the child modules (setup, layer, window attention, +//! FFN, experts). use super::{ AttentionHandoff, BoundLayerKind, ChunkMoePolicy, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs index ce89ceca..fef33659 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_layer.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: one layer of the prefill chunk, its GDN device owner and its windows. +//! One layer of the prefill chunk, its GDN device owner and its windows. use super::window_experts::ExpertRun; use super::window_ffn::WindowOwners; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs index 496b946d..0d720bb1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/chunk_setup.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: admission, transaction begin, input rows and output head of one prefill chunk. +//! Admission, transaction begin, input rows and output head of one prefill chunk. use super::{ ChunkEnv, ChunkMoePolicy, ChunkOpening, Context, DenseWeightCache, Error, InjectedResidual, InputStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs index b9490f66..5215db16 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/host_attention.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the host GDN and QSA attention stages of one prefill row, shared by the FFN-row and micro-FFN paths. +//! The host GDN and QSA attention stages of one prefill row, shared by the FFN-row and micro-FFN paths. use super::{ DenseWeightCache, ForwardPhase, GdnStage, LayerId, ModelBinding, Position, QsaAttentionStage, QsaIndexStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs index 65062021..2fb5da02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_attention.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the attention reads of one window of a prefill layer. +//! The attention reads of one window of a prefill layer. use super::{ ChunkEnv, ChunkRun, Error, GrStage, InjectedResidual, InputStage, LayerEntry, LayerId, MicroBank, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs index 82248e3f..5709e1e9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_experts.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the expert execution and the batched FFN injection of one window of a prefill layer. +//! The expert execution and the batched FFN injection of one window of a prefill layer. use super::{ ChunkEnv, ChunkMoePolicy, ChunkRun, Error, GrStage, InjectedResidual, LayerId, MoeExpertStage, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs index 7606f215..0d9ef893 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the projected columns and the prepared FFN rows of one window of a prefill layer. +//! The projected columns and the prepared FFN rows of one window of a prefill layer. use super::{ AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkRun, Error, ForwardPhase, GdnStage, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs index e920ac5d..d08b94b2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/qwen_forward/prefill_chunk_planned/window_ffn_flow.rs @@ -1,4 +1,4 @@ -//! STRA-338 size: the host stages of one prefill row (GDN or QSA attention, GR injection, FFN read, routing). +//! The host stages of one prefill row (GDN or QSA attention, GR injection, FFN read, routing). use super::{ AttentionHandoff, BoundLayerKind, ChunkEnv, ChunkMoePolicy, ForwardPhase, GrStage, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs index ea40d3bf..006ebbdb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/read_chunk_attention_ffn.rs @@ -1,5 +1,6 @@ -//! Methods of `AttentionHandoff`: `new`. -//! Methods of `QwenForward`: `test_layer0_pair_on_loaded`, `run_layer0_diagnostic`. +//! The FFN read of a chunk attention row: the detached attention residual and the block output (`AttentionHandoff`) +//! go to the retained GR bank. Also the layer-0 pair diagnostic, whose four-row chunk must refuse with the executor +//! error. use super::{DenseWeightCache, ForwardPhase, GrStage, ModelBinding, Result, diagnose}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs index 996646a8..9698f1db 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/target_step_product.rs @@ -1,5 +1,5 @@ -//! Methods of `TargetStepProduct`: `from_chunk_commit`. Functions: `chunk_diagnostic`. -//! Split out of `prefill_chunk` to keep its files under the line limit. +//! `TargetStepProduct` of a committed prefill chunk (only the checked joint publisher supplies its final source) and +//! the `chunk_diagnostic` tracer, which prints the stage, layer and rows of a failure in test builds only. use super::{Result, TargetStepProduct}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs index dc9ae9c8..7ac9ec4c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_chunk/window_numeric/proof.rs @@ -1,4 +1,5 @@ -//! The proof phases of the window boundary observer (STRA-338 size: extract-method only). +//! The phases of the window boundary observer: the unchanged Native4 baseline measured first, the windowed candidate +//! under the retained-GR policy compared with it, and the cancellation phase. use super::{ BoundaryPlan, Cell, ChunkMoePolicy, DenseWeightCache, Dimension, Error, KarPleCache, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs index 2b65df2f..9448b57c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/prefill_step_product.rs @@ -1,5 +1,6 @@ -//! Methods of `PrefillStepProduct`: `mtp_source`. -//! Methods of `TargetStepProduct`: `test_prefix_residual`, `mtp_source`, `predicted`, `position` and 1 more. +//! `mtp_source` of a finished step: the validated product (token, position, ten residual streams, origin) an MTP +//! draft starts from, for a known-next prefill step and for a full target step. A stale origin or a non-finite stream +//! is refused. use super::{ Error, ForwardPhase, ModelBinding, Position, PrefillStepProduct, QwenSession, Result, TargetStepOrigin, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs index e293b4b5..a5548050 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/qwen_forward/qwen_forward_reset.rs @@ -1,5 +1,4 @@ -//! Methods of `QwenForward`: `reset`. -//! Split out of `qwen_forward` to keep its files under the line limit. +//! `QwenForward::reset`: returns the session to the empty prompt. use super::{QwenForward, QwenSession, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs index 09a1be14..1be83f22 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/read_layer_attention.rs @@ -1,5 +1,6 @@ -//! Functions: `read_layer_attention`, `read_layer_one`, `prepare_layer_attention_micro`, `prepare_layer_one_micro` a... -//! Defines `LayerEntry`. +//! The GR attention read of one layer of a step: layer 0 applies, layer 1 consumes the PLE producer first, later +//! layers read from the previous residual. Also the micro-window variants and the layer-plan and descriptor +//! validation. use super::{ BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GrRead, GrStage, InjectedResidual, InputStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs index f5111017..f3bc82c3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/reset_replay_sdet.rs @@ -1,4 +1,6 @@ -//! Cache-reset-replay numerical proof, moved out of `executor.rs` by STRA-338 (size); same module path as before. +//! GPU test: cached forward and legacy replay agree numerically across an actual reset of the same session (not two +//! fresh requests), with the cache counters unchanged and only equality and bounded counts reported, never tensor +//! words. use super::{ BoundLayerKind, DenseWeightCache, Dimension, KarPleCache, ModelBinding, MoeWeightCache, OutputStage, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs index 7a5576a4..8947e066 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/step_layers.rs @@ -1,4 +1,5 @@ -//! Phases of `QwenForward::step_core` (STRA-338 size: extract-method only, same order of operations). +//! The layer phases of `QwenForward::step_core`: cache preparation, the input row, the layer loop (attention half +//! with GDN or QSA, FFN half with routing and experts) and the step finish. The order of the stages is the contract. use super::{ BoundLayerKind, DenseWeightCache, Dimension, Error, ForwardPhase, GdnStage, GrRead, GrStage, InjectedResidual, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs index 33c2ff59..04ea33bd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/executor/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the layer-plan topology check (the exact contiguous closed sequence) and, on a GPU, that a missing output +//! refuses before the layers without committing state and that two tokens finish all layers and commit. use super::{ BoundLayerKind, Dimension, Error, LayerId, OutputStage, Position, QwenForward, QwenSession, QwenStepTxn, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs index f31ac909..a0548099 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/cached_step.rs @@ -1,5 +1,6 @@ -//! Methods of `CachedGdn`: `project`, `run`, `leading_products`, `recurrence` and 3 more. -//! Functions: `step_cached`, `open_chain`, `settle_cached`, `chain_output_role` and 3 more. +//! One native GDN token step with the dense-weight cache: projections, convolution, q/k norm, gates, recurrence. +//! Runs on a step-local `Chain`, then publishes the next recurrent state through the mirror only if the whole step +//! succeeded; on failure the computed candidate is discarded and the chain is cleaned up. use super::{ CandidatePair, Context, DEVICE_PEAK, DenseWeightCache, DeviceBuffer, Error, GdnInputLease, GdnLayerInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs index 9d675158..008bb41f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/allocate_qk_slot.rs @@ -1,5 +1,6 @@ -//! Methods of `QkScratch`: `test_slot_bytes`, `new`, `validate`, `take` and 2 more. Methods of `Role`: `count`. -//! Functions: `allocate_qk_slot`, `normalize_retained_qk`. +//! The retained whole-QK scratch slot of the GDN chain and the q/k normalisation that writes into it. +//! One slot is lent to a chain at a time and must come back as the same allocation; a failed return forbids every +//! later take. Also gives each chain `Role` its element count and the products and borrows their accessors. use super::{ BindingIdentity, CHANNELS, Cell, Context, DeviceBuffer, Error, HISTORY_ELEMENTS, MirrorAuthority, Product, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs index d7f84f03..3b13793e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `chain_construction_and_buffers`, `chain_projection_convolution`, `chain_readout_and_finish... -//! Split out of `chain` to keep its files under the line limit. +//! The step-local `Chain` of GDN stage products, split by phase: construction and buffers, scalar projection and +//! convolution stages, readout and finish, and the one-drain row queue. All phases share the chain's private slots. use super::{ BindingIdentity, CHANNELS, Cell, Chain, Context, DeviceBuffer, DeviceOperand, DeviceProduct, Error, GdnLayerInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_construction_and_buffers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_construction_and_buffers.rs index c745c2dc..7bc99b28 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_construction_and_buffers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_construction_and_buffers.rs @@ -1,5 +1,5 @@ -//! Methods of `Chain`: `new`, `validate`, `set_verification_pool`, `return_fixed` and 15 more. -//! Split out of `chain` to keep its files under the line limit. +//! Construction of a step-local `Chain` and its slot bookkeeping: pending operands, products, buffer lookup. +//! Every lookup refuses a stale epoch, a wrong role or a foreign chain, so a capability cannot outlive its drain. use super::{ BindingIdentity, Cell, Chain, Context, DeviceBuffer, DeviceOperand, DeviceProduct, Error, GdnMatrixKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs index 315b56b0..f313d5bc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_projection_convolution.rs @@ -1,5 +1,5 @@ -//! Methods of `Chain`: `upload_values`, `note`, `note_err`, `free` and 10 more. -//! Split out of `chain` to keep its files under the line limit. +//! The scalar (host-readback) stages of the GDN chain: upload, projection, convolution, q/k normalisation, gates. +//! Each producer runs its own kernel and its own finite readback; callers never hand in a separate numeric proof. use super::{ CHANNELS, Chain, DeviceBuffer, Error, GdnMatrixKind, GdnMatrixLayout, HISTORY_ELEMENTS, Product, QkReturn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_readout_and_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_readout_and_finish.rs index b728b448..b7ffaa02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_readout_and_finish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_readout_and_finish.rs @@ -1,5 +1,5 @@ -//! Methods of `Chain`: `import_chunk_readout`, `out_norm`, `drain`, `finish`. -//! Split out of `chain` to keep its files under the line limit. +//! The tail of the GDN chain: import of a chunk readout, the output norm, and the drain that ends the chain. +//! `drain` bumps the epoch (invalidating every product), returns pooled slots and frees the rest. use super::{Chain, DeviceBuffer, Error, Product, Rc, Result, Role, VALUES, download, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs index f769eedc..52d07aa7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain/chain_row_queue.rs @@ -1,5 +1,6 @@ -//! Methods of `Chain`: `run_row_queue`, `reserve_row_slots`, `drain_row_queue`, `row_input_buffers` and 12 more. -//! Functions: `check_distinct_slots`. Defines `RowSlots`, `RowInputBuffers`, `RowOutputBuffers`. +//! The queued row of the GDN chain: conv, q/k norm, beta sigmoid, gates, recurrence and out-norm in ONE driver drain. +//! The scalar chain's intermediate host readbacks and fences are gone; every stage output is still scanned for finite +//! values and nothing is published unless the whole drain was clean. Also lends recurrence inputs to the caller. use super::{ Chain, DeviceBuffer, DeviceOperand, Error, GdnLayerInput, GdnRowQueue, Product, QkvInput, QueueInputs, QueuedRow, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs index 4f0b8715..ae72fb6e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chain/chain_drop.rs @@ -1,5 +1,4 @@ -//! Implements `Drop for Chain`. -//! Split out of `chain` to keep its files under the line limit. +//! Drop of a `Chain`: drains it, so slots go back to their pools or are freed even when a step bails out early. use super::Chain; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods.rs index abb0f45f..6ad48c03 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `chunk_device_batch_compute`, `chunk_device_construction`, `chunk_device_finish_cleanup`. -//! Split out of `chunk_device` to keep its files under the line limit. +//! The `GdnChunkDevice` methods by phase: construction and admission, per-row and batch compute, finish and cleanup. use super::{ BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, ChunkReadout, Context, DenseWeightCache, DeviceBuffer, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_batch_compute.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_batch_compute.rs index 460d22fb..5eca8118 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_batch_compute.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_batch_compute.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnChunkDevice`: `finish_batch`, `history`, `step_source`, `read_checked` and 13 more. -//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. +//! Per-row and per-batch recurrence compute of a `GdnChunkDevice`: upload or borrow the inputs, run the step, +//! read the readout back and mint the row edges. The earliest full-state refusal precedes the readout and any user. +//! Also adopts the final state of a batch that drained clean. use super::{ ChunkEdge, ChunkReadout, DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, HISTORY_ELEMENTS, Rc, ReadoutDownload, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_construction.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_construction.rs index 6b0e3d57..04241e1e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_construction.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_construction.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnChunkDevice`: `new`, `empty`, `copy_history`, `take_prior_owners` and 16 more. -//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. +//! Construction and admission of a `GdnChunkDevice`: prior-state upload, verification pool, optional row queue. +//! Validates that rows, batches and micro-windows are exactly the next rows of the chunk from the cursor. +//! Nothing is mutated until a clean drain completes the step. use super::{ BindingIdentity, CHUNK_DEVICE_CHARGE, Cell, ChunkEdge, Context, DenseWeightCache, DeviceBuffer, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs index c5299ddb..3c2efd22 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/gdn_chunk_device_methods/chunk_device_finish_cleanup.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnChunkDevice`: `finish`, `sealed_prior`, `return_scratch_and_guard`, `adopt_final_state` and 5 more. -//! Split out of `gdn_chunk_device_methods` to keep its files under the line limit. +//! End of life of a `GdnChunkDevice`: seal the chunk, return scratch and guards, adopt the final state, clean up. +//! Covers the ordinary chunk and the MTP verification variant. Cleanup keeps the first failure, frees the rest. use super::{ DenseWeightCache, Error, GdnChunkDevice, GdnChunkSeal, GdnPrior, ModelBinding, Result, STATE_ELEMENTS, download, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs index 8fe6391c..f820325e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/mirror_reuse_enabled.rs @@ -1,5 +1,5 @@ -//! Methods of `ChunkEdge`: `into_parts`, `into_row`. Methods of `ChunkReadout`: `into_parts`, `same_owner`. -//! Implements `Drop for ChunkReadout`. Functions: `mirror_reuse_enabled`, `micro_rows`. +//! Edge and readout handles of a GDN chunk row, and the `prefill_gdn_mirror` switch for reusing the resident mirror. +//! A `ChunkReadout` frees its device buffer on drop; it can be consumed only by the chain that owns its scope. use super::{ Cell, ChunkEdge, ChunkReadout, Context, DeviceBuffer, Error, GdnChunkMicro, GdnChunkRow, Rc, Result, VALUES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs index ff2ccf6b..da0a7e89 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/native_fused_step.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnChunkDevice`: `bind_native_fused`, `native_fused_operands`, `complete_native_fused_step`. -//! Implements `Drop for GdnChunkDevice`. +//! The in-place fused T1 recurrence of a verification `GdnChunkDevice`: bind the closed fused program to its +//! workspace, hand out the step operands, complete the step. Also the Drop that cleans up the chunk's device owners. use super::{DeviceBuffer, Error, GdnChunkDevice, GdnChunkRow, Rc, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs index 87950278..7d727ccb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/batch_adoption.rs @@ -1,5 +1,6 @@ -//! Functions: `batch_adoption`, `adoption_rows`, `adoption_phase`, `batch_operand_guards` and 6 more. -//! Split out of `numeric_gpu` to keep its files under the line limit. +//! GPU-test proof of batch adoption on a `GdnChunkDevice`: only the next consecutive rows form a batch, a refused +//! batch mutates nothing, an accepted one advances the cursor and swaps the final state into place once. +//! Pure ownership and identity: no kernel runs, the final state is a recognisable pattern. use super::{ BindingIdentity, Context, Dimension, Error, GdnChunkDevice, GdnChunkRow, GdnPrior, HISTORY_ELEMENTS, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs index 81e5f18f..36f1d02d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/exercise.rs @@ -1,5 +1,6 @@ -//! Methods of `Fixture`: `new`, `row_guards`, `run_rows`, `compute_row` and 12 more. -//! Functions: `require_rejected_clean`, `exercise`, `run_gdn_chunk_numeric`. Defines `Fixture`, `ComputedRow`. +//! GPU-test driver of the chunk-device recurrence proof: 65 rows, the seal, finite guards and abort/replay. +//! Compares every readout and interior state against a same-PTX reference and checks that wrong rows, rival seals and +//! non-finite sources are refused without moving the owner. use super::{ BUDGET, BindingIdentity, CHUNK_DEVICE_CHARGE, ChunkReadout, Context, Counts, DeviceBuffer, Dimension, Driver, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs index e67ac3d2..65f4b9a9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/chunk_device/numeric_gpu/operands.rs @@ -1,5 +1,5 @@ -//! Methods of `Operands`: `recurrence`. -//! Functions: `operands`, `convolution_input`, `convolution_weights`, `difference` and 3 more. +//! Deterministic row inputs, convolution data and the reference recurrence of the chunk-device GPU proof, plus the +//! component owner that holds real buffers without a model binding. use super::{ CHUNK_DEVICE_CHARGE, Cell, Context, Error, GdnChunkDevice, GdnChunkStart, GdnPrior, Operands, ROWS, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs index aa103a5f..c0082b22 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/driver_error.rs @@ -1,5 +1,5 @@ -//! Functions: `driver_error`, `validate_candidates`, `state_index`, `key_head`. -//! Split out of `gdn` to keep its files under the line limit. +//! Maps CUDA driver errors to the GDN `Error` and holds the GDN state addressing checks (`state_index`, `key_head`). +//! The state address is the exact native layout, never a head-major reinterpretation. use super::{DriverError, Error, KEY_HEADS, Result, Stage, VALUE_HEADS, WIDTH}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs index 7a215694..e9cb7f87 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gates.rs @@ -1,5 +1,6 @@ -//! Methods of `RecurHost`: `validate`, `upload_all`. -//! Functions: `gates`, `upload_gate_inputs`, `run_gate_kernels`, `release_owned` and 16 more. +//! Kernel runners of the scalar GDN stages: gates, the recurrence step and the output norm, with their device +//! upload, download and release helpers. Every output is read back and checked finite before use. +//! Also the `prefill_gdn_pool` switch that pools the 3.1 MB state buffers across layers and chunks. use super::{ CandidatePair, Context, DeviceBuffer, Error, InputBindingError, POOL_OVERRIDE, RecurrenceOperands, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs index 1d760b45..9d05ad2e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/gdn_ready.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnReady`: `identity`, `output`, `validate_origin`, `take_pending`. -//! Split out of `gdn` to keep its files under the line limit. +//! Accessors of `GdnReady`, the finished output of one GDN layer step: its identity, origin check and the pending +//! recurrent candidate, which can be taken once (the session is the only publisher). use super::{BindingIdentity, Error, GdnPending, GdnReady, Result, TokenLayer}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs index cda577a1..1dbca0e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `state_mirror_compute_and_admit`, `state_mirror_publish_and_close`. -//! Split out of `mirror` to keep its files under the line limit. +//! The `GdnStateMirror` methods by phase: construction, admission and compute, then publish, adopt and close. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GdnPending, GdnPrior, GdnStateKey, GdnStateMirror, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs index 9af89767..8184ad6a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_compute_and_admit.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnStateMirror`: `new`, `allocate_mirror`, `compute`, `compute_retained` and 13 more. -//! Split out of `gdn_state_mirror_methods` to keep its files under the line limit. +//! Admission and compute half of `GdnStateMirror`: allocate the resident state buffer at load, check that a prior is +//! exactly the state the mirror holds, upload it on a miss, run the step and mint the candidate. +//! Nothing here changes the mirror's identity; only `publish` does. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GdnPrior, GdnStateMirror, MIRROR_BYTES, MirrorNext, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_publish_and_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_publish_and_close.rs index afc3ac2a..76d06f34 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_publish_and_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/gdn_state_mirror_methods/state_mirror_publish_and_close.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnStateMirror`: `compute_borrowed`, `step_products`, `publish`, `admit_publish` and 5 more. -//! Split out of `gdn_state_mirror_methods` to keep its files under the line limit. +//! Publish half of `GdnStateMirror`: replace the resident buffer by an admitted candidate, hand the resident image to +//! a chunk, adopt a sealed chunk's state, and close. A hit key is never published before replacement cleanup is done. use super::{ Context, DeviceBuffer, Error, GdnPending, GdnPrior, GdnStateKey, GdnStateMirror, MIRROR_BYTES, MirrorAuthority, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs index dee8dede..e5a9f756 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/mirror_readout.rs @@ -1,5 +1,5 @@ -//! Methods of `MirrorReadout`: `test_values`, `into_parts`, `same_owner`, `into_host`. -//! Implements `Drop for MirrorReadout`. +//! The readout of one mirror step: the device buffer and the finite host values read back from it. +//! Only the recurrence producer can pair the buffer with its readback; dropping it frees the device buffer. use super::{DeviceBuffer, Error, MirrorReadout, Rc, ReadoutClaim, Result, VALUES, driver_error, validate_values}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs index fd54ab2f..d7725965 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/mirror/upload_checked.rs @@ -1,5 +1,4 @@ -//! Functions: `upload_checked`. -//! Split out of `mirror` to keep its files under the line limit. +//! Uploads host f32 values into a fresh device buffer, freeing it and latching the failed flag if the copy fails. use super::{Cell, Context, DeviceBuffer, Error, Result, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs index c6a999bf..e3c88b02 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/buffers.rs @@ -1,5 +1,6 @@ -//! Methods of `Buffers`: `allocated_bytes`, `new`, `pool_sizes`, `from_pool` and 1 more. Methods of `Images`: `take`. -//! Functions: `next_buffer`, `release_pool`. Defines `PoolIter`, `Images`, `Projections` and 1 more. +//! The per-call device buffers of one batched GDN prefill step: BF16/FP16 activation images, projection outputs and +//! rolling histories, sized for `tokens` rows. Allocated as one pool and released together, so a failed allocation +//! leaves nothing behind. use super::{ ALPHA_BETA, Bf16Profile, Buffers, CHANNELS, Context, DeviceBuffer, Error, HISTORY_ELEMENTS, MIXED, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs index 321b6ac5..39abc3f5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_batch_resources.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnBatchResources`: `new`, `new_for_prompt`, `new_capacity`, `admit_capacity` and 8 more. -//! Implements `Drop for GdnBatchResources`. +//! The persistent owner of the batched GDN prefill program: closed driver program, dequantization scratch and the +//! per-call buffers, charged once per context before the routed prefix plan is admitted. +//! Buffers grow to a prompt's token count; closing releases scratch, program and buffers (also on Drop). use super::{ ALPHA_BETA, BATCH_RESERVE, BATCH_SCRATCH_BYTES, Bf16Profile, Buffers, CHANNELS, Context, DeviceBuffer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs index 7b8ba09e..18c0c3cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/gdn_stage.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnStage`: `step_chunk_batch`. -//! Split out of `prefill_batch` to keep its files under the line limit. +//! Entry point `GdnStage::step_chunk_batch`: the batched Strata-prefill GDN step over one causal micro-window. +//! Rows and cursor come only from the validated micro; every row edge is minted after the whole batch drained finite. use super::step_batch::{ check_gdn_window, gather_gdn_rows, gdn_operands, latch_cuda_failure, prepare_or_refuse, run_gdn_program, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs index 44b04be4..ca08d80e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/prefill_batch/step_batch.rs @@ -1,4 +1,7 @@ -//! Phases of `GdnStage::step_chunk_batch` (STRA-338 size: extract-method only). +//! The phases of `GdnStage::step_chunk_batch`: check the window, gather its genuine rows, resolve the layer's +//! resident matrices, run the closed batch program and settle. Edges are minted only after the whole batch drained +//! finite and the chunk device adopted the final state; a refusal marks the chunk device and, on CUDA failure, the +//! transport. use super::{ BoundLayerKind, Buffers, CHANNELS, ChunkReady, Context, DenseWeightCache, DeviceBuffer, Dimension, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs index 15a9b678..353a7fdb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/projection.rs @@ -1,5 +1,6 @@ -//! Methods of `ProjectionOperands`: `without_cache`. -//! Functions: `project`, `project_leased`, `project_uploaded`, `upload_matrix_block` and 10 more. +//! Scalar projection stages of the GDN layer: QKV, alpha, beta, Z and Out matrix products, the convolution and the +//! q/k normalisation, each with a host readback checked finite. Uses the resident dense-weight cache and the input +//! lease when present, otherwise uploads the matrix block for this call only. use super::gates::{release_with_owned, upload_unless_resident}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs index 5232ac92..b65e495a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/stage_steps.rs @@ -1,5 +1,5 @@ -//! Methods of `GdnStage`: `step_chunk_selected`, `step`, `step_projected`, `step_impl` and 4 more. -//! Split out of `gdn` to keep its files under the line limit. +//! The `GdnStage` step entry points of one token: pick the fused native owner, the cached chain or the uncached path. +//! Validates binding, layer, input origin and prior before any device work, then returns a `GdnReady` candidate. use super::{ BoundLayerKind, CandidatePair, Context, DenseWeightCache, DeviceChunkRow, Dimension, Error, GateHostOperands, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs index 8e5c7a15..42d9a2e4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `verified_row_compute_and_lease`, `workspace`, `workspace_replay`. -//! Split out of `verification` to keep its files under the line limit. +//! Row compute of MTP verification, split by owner: the verified row, the `Workspace` it runs in, and accepted-prefix +//! replay on that workspace. use super::{ ActiveLease, BindingIdentity, COUNTS, Cell, Context, DEVICE_BYTES, DeviceBuffer, Error, GdnChunkRow, GdnChunkStart, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row_compute_and_lease.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row_compute_and_lease.rs index 11aafebf..e3c0f751 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row_compute_and_lease.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/verified_row_compute_and_lease.rs @@ -1,5 +1,5 @@ -//! Methods of `ActiveLease`: `validate`, `refuse`. Methods of `VerifiedRow`: `history`, `validate`. -//! Functions: `compute_row`. +//! One verified GDN row of MTP verification: the recurrence compute over the workspace buffers, plus the checks +//! of the active lease and of a saved `VerifiedRow`. A refused lease invalidates every row minted under it. use super::{ ActiveLease, BindingIdentity, Context, Error, GdnStateFiniteGuard, HISTORY_ELEMENTS, LayerId, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs index d682c95d..08b66fd4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace.rs @@ -1,5 +1,5 @@ -//! Methods of `Workspace`: `new`, `empty`, `reserve_slot_tables`, `allocate_owners` and 15 more. -//! Split out of `compute_row` to keep its files under the line limit. +//! The verification `Workspace`: fixed device owners (three state buffers, readout, finite guard, per-row operands) +//! for one verify round. Admits a lease, lends layers and rows out, takes them back and records verified rows. use super::{ ActiveLease, BindingIdentity, COUNTS, Cell, Context, DEVICE_BYTES, DeviceBuffer, Error, GdnChunkRow, GdnChunkStart, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs index ec6c2233..1b221d19 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/compute_row/workspace_replay.rs @@ -1,5 +1,6 @@ -//! Methods of `Workspace`: `replay`, `replayed_prior`, `replay_row`, `settle_replay` and 9 more. -//! Methods of `ReplaySeal`: `validate_prior`. Implements `Drop for Workspace`, `Drop for PoolRow`. +//! Replay of the accepted prefix on the verification workspace: after a verify round, re-run only the accepted rows +//! from the untouched device prior and return the resulting `GdnPrior`. Checks cancellation between rows. +//! Also cleanup and Drop of the workspace and of pooled rows. use super::{ ActiveLease, COUNTS, DeviceBuffer, Error, GdnPrior, GdnStateFiniteGuard, HISTORY_ELEMENTS, PoolRow, Rc, ReplaySeal, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs index 069d4962..7319fc3d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gdn/verification/workspace.rs @@ -1,5 +1,4 @@ -//! Methods of `Workspace`: `bind_native_fused`. -//! Split out of `verification` to keep its files under the line limit. +//! Binds the closed fused T1 program to the verification `Workspace`, so fused rows reuse its owners and lease. use super::{ActiveLease, Error, Rc, RefCell, Result, Workspace, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs index 1c872fae..7111bb61 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/batch_inject.rs @@ -1,4 +1,6 @@ -//! Phases of `GrStage::inject_batch` (STRA-338 size: extract-method only). +//! The phases of `GrStage::inject_batch`: gather the consecutive rows, run the queued T1/T2/T3 workspace path or the +//! generic device path, and publish one `InjectedResidual` per row. The exclusive scratch lease ends before any host +//! finite validation or publication of a row capability. use super::{ Cell, Context, DenseWeightCache, DeviceBuffer, Error, GrBatchRow, GrBatchScope, GrRole, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs index 7f0837fc..1f51bc17 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_micro_input.rs @@ -1,5 +1,5 @@ -//! Methods of `GrMicroInput`: `validate_origin`, `identity`. Methods of `GrMicroAttention`: `into_parts`. -//! Implements `Drop for GrMicroAttentionBank`. Functions: `save_micro_values`, `micro_driver_error`. +//! Micro-window side of GR: accessors of the immutable current-row input, the attention bank that owns the micro +//! device (legacy or native), and its close/Drop. Maps driver errors for the micro path and saves finite row values. use super::{ BindingIdentity, DetachedGrRead, DeviceBuffer, DriverError, Error, GrBatchScope, GrMicroAttention, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs index cf618a93..fffc2e0c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `GrStage`: `mint_micro_input`, `prepare_micro_initial`, `prepare_micro_after_ple`, `prepare_micro_afte... -//! Methods of `GrBatchScope`: `detach_rows`, `refuse_device`, `seal`. +//! GR over one micro-window of rows: mint micro inputs (initial, after PLE, after FFN) and read the attention blocks +//! of every row in one device call. Checks that all rows are the next positions of one layer and that the bank, +//! binding and transaction agree; refusal closes the micro device. use super::super::super::dense_weight_cache::GrResident; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs index 5c7830db..652a910b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/batch_chunk/gr_stage_prepare_injection.rs @@ -1,5 +1,5 @@ -//! Methods of `GrStage`: `prepare_detached_batch_injection`, `prepare_batch_injection`, `inject_batch`. -//! Functions: `check_batch_read`. +//! Batch injection of GR: prepare the FFN-side detached reads of a chunk and inject each block output back into its +//! residual streams. Every read is checked against the transaction (binding, origin, position, finite witnesses). use super::batch_inject::{device_inject, gather_batch}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs index 50c757a2..ccaf73df 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/diagnose.rs @@ -1,5 +1,5 @@ -//! Methods of `GrScratch`: `new`, `new_identity`, `allocate_owned`, `buffer` and 5 more. -//! Methods of `GrRead`: `ready`, `finish`. Implements `Drop for GrScratch`. +//! GR scratch and failure diagnostics: the eagerly charged actor-owned scratch slot (11 device owners) that every GR +//! read overwrites, its lease/finish, and the labelled aggregate diagnostics that reveal no tensor data. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GR_INJECT_BYTES, GR_OUTPUT_BYTES, GR_OWNED_DEVICE_BYTES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs index 6996c3e0..ed066814 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/download_f32.rs @@ -1,5 +1,5 @@ -//! Methods of `GrStage`: `validate_detached_ffn`, `validate_ffn_ready`. -//! Functions: `download_f32`, `driver_error`, `binding_error`, `validate_values` and 2 more. +//! Host-side helpers shared by the GR stages: finite device readback, driver and binding error mapping, and the +//! shape checks of values, layers and streams. Also validates a detached FFN read against the current transaction. use super::{ DetachedGrRead, DeviceBuffer, Dimension, DriverError, Error, GrRole, GrStage, InputBindingError, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs index 6675062c..dbd0ec3b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/gr_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `GrStage`: `apply`, `read_ffn`, `read_attention`, `read_attention_after_ple` and 6 more. -//! Functions: `copy_streams`, `resolve_gr_weights`, `read_candidate`, `check_injection_origin` and 2 more. +//! Single-row entry points of the GR stage: `apply` for layer 0, the attention and FFN reads, the final mix and the +//! injection of a block output into the residual streams. Each entry validates origin, layer and transaction before +//! touching the device; the result is a read capability or an `InjectedResidual`. use super::super::dense_weight_cache::GrResident; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs index 5b327d43..9ef07ee5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu.rs @@ -1,5 +1,4 @@ -//! Functions: `run_proof`, `compare_outputs`, `release_owners`, `original_first_fixed_outputs_repeat_overwrite_abort... -//! Defines `Tally`. +//! GPU test that the fixed GR output workspace is overwritten on every repeat read, survives an abort and is cleaned. use super::{ BindingIdentity, Cell, Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GR_OUTPUT_DEVICE_BYTES, GrScratch, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs index f9a28ce3..3e02ac1a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/check_handoff.rs @@ -1,5 +1,5 @@ -//! Functions: `check_handoff`, `handoff_reference`, `residual_differences`, `ffn_differences`. -//! Split out of `output_workspace_gpu` to keep its files under the line limit. +//! GPU-test check of the attention to FFN handoff: the swapped producer feeds the FFN read without a host residual +//! upload, and residual and FFN outputs are compared against fresh-allocation references. use super::{ BindingIdentity, Context, DeviceBuffer, Error, GR_OUTPUT_DEVICE_BYTES, GrScratch, ReadCandidate, Result, block, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs index c4772494..58ef0927 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/output_workspace_gpu/fresh_read.rs @@ -1,5 +1,5 @@ -//! Functions: `fresh_read`, `release_reverse`, `fresh_read_launch`, `queue_fresh_read` and 5 more. -//! Split out of `output_workspace_gpu` to keep its files under the line limit. +//! GPU-test reference of the output workspace proof: fresh-allocation GR read and inject with the original +//! allocation boundary, plus the pattern inputs and the NaN poison that proves every retained byte is overwritten. use super::{Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GrScratch, Result, download_f32, driver_error, upload_f32}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs index 4a3a8c63..a8916ba0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cached_cuda.rs @@ -1,5 +1,5 @@ -//! Functions: `read_cached_cuda`, `borrow_read_outputs`, `borrow_read_inject`, `cached_read_body` and 12 more. -//! Split out of `gr` to keep its files under the line limit. +//! The cached GR read and inject on the actor-owned scratch: queued read kernels, the finite mask naming the first +//! failing stage, and the upload/copy/budget helpers. No result is cached: every active byte is rewritten per call. use super::{ Cell, Context, DeviceBuffer, Error, GR_OUTPUT_BYTES, GrPhase, GrScratch, ReadCandidate, RefCell, Result, diagnose, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs index ef86c7e1..8720b631 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/read_cuda.rs @@ -1,5 +1,5 @@ -//! Methods of `OwnedReadWeights`: `upload`, `select`, `release`. -//! Methods of `ReadWork`: `allocate`, `norm_down_silu`, `up_gates`, `release`. +//! The uncached GR read: upload the weights (unless resident), run norm, down projection, SiLU, up gates and the +//! inject coefficients on a fresh workspace, read them back and release everything before publishing. use super::{ Context, DeviceBuffer, Error, GrPhase, GrWeights, ReadCandidate, Result, diagnose, diagnose_extrema, download_f32, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs index f19790c5..e1c01364 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/residual_ready.rs @@ -1,5 +1,5 @@ -//! Methods of `ResidualReady`: `oracle_inject`, `validate_origin`, `identity`, `streams` and 1 more. -//! Methods of `InjectedResidual`: `from_candidates`, `validate_origin`, `identity`, `streams`. +//! Accessors of the GR capabilities: `ResidualReady` (a read result with mixed values and streams) and +//! `InjectedResidual` (streams after injection). Each can be checked for binding and role origin. use super::{BindingIdentity, Error, GrRole, InjectedResidual, ResidualReady, Result, TokenLayer, validate_streams}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs index 6375eba7..bdbed92a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/gr/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of `gr`. +//! Pins GR refusals: shape and numeric failures leave inputs unchanged, a late NaN publishes no streams, norm and +//! post-op overflow are detected, not masked, and an injected capability from another model or stage is refused. use super::{ BindingIdentity, Dimension, Error, GrRole, InjectedResidual, LayerId, TokenLayer, validate_layer, validate_streams, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs index 71314d89..f69e9d6f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input.rs @@ -1,3 +1,7 @@ +//! The input stage of a model step: the types of what a token step consumes (InputReady with its residual streams and +//! PLE rows, the chunk-wide StagedInput) and of the PLE history it advances (owner, prior, pending, ready). +//! The behaviour lives in the submodules; this file holds the data and the constants of the PLE layout. + #![allow(dead_code)] use super::contract::{Dimension, Error, Position, Result, Stage, TokenId}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs index 53c5d647..7fae45e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/gather_rows.rs @@ -1,5 +1,6 @@ -//! Methods of `InputReady`: `test_fixture`. Methods of `PleOwner`: `new`, `matches`. -//! Functions: `gather_rows`, `binding_error`. +//! The PLE history state of a session: PlePrior (the nine-slot history before a step), PlePending and PleReady (a +//! step in flight), plus the head-major gather of the sixteen PLE rows of one token. +//! Kept apart from input_stage so the history types can be checked and advanced without the input stage's callers. use super::{ BindingIdentity, Dimension, EMBEDDING_VALUES, Error, GrRole, InjectedResidual, InputBindingError, InputError, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs index cfe43abb..1eb2ece0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/hash.rs @@ -1,3 +1,6 @@ +//! The sixteen PLE row indices of a token: a wrapping multiplicative hash of the token and its two predecessors +//! (with the EOS rule), identical per head to the Original, and bounded to the token and row domains. + use super::super::contract::{Error, Result}; use crate::model_binding::qwen4exp_input::{InputConstants, PLE_ROWS, VOCABULARY}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs index 6949a8df..ed3d11f1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `InputStage`: `consume`, `consume_kar`, `consume_kar_deferred`, `ple_rows_ahead` and 3 more. -//! Functions: `admit_kar_input`, `stage_new_embedding`, `window_ple_row`, `gather_window_rows` and 3 more. +//! InputStage: turns a token and position into the step's input, its embedding broadcast to the four residual streams +//! and its sixteen PLE rows, for decode (`consume`) and for KAR-backed prefill (`consume_kar`, `..._deferred`). +//! The deferred form only records rows for the chunk-wide device gather; it never materialises per-row host values. use super::{ Context, Dimension, EMBEDDING_VALUES, Error, InputBindingError, InputError, InputReady, InputStage, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs index 399c35f7..0211fed1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/input_stage_ple_micro.rs @@ -1,5 +1,6 @@ -//! Methods of `InputStage`: `prepare_ple_micro_input`, `apply_ple_micro_cached`, `apply_ple`, `apply_ple_cached`. -//! Functions: `check_micro_origin`, `check_micro_source`, `copy_ple_values`, `check_micro_admission` and 12 more. +//! The PLE step of InputStage: validates the genuine layer-one residual and the PLE prior, composes the key, value, +//! gate and history update on the device, and returns the new streams and history as one candidate or none. +//! No session history escapes on a numerical or transport refusal; the micro-window form covers a whole window. use super::{ Context, DenseWeightCache, Dimension, Error, GrRole, InjectedResidual, InputReady, InputStage, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs index da7d7a26..34b1a794 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_cuda.rs @@ -1,5 +1,6 @@ -//! Methods of `PleUploads`: `upload`. Methods of `OwnedPleAux`: `upload`, `select`, `release`. -//! Functions: `ple_cuda`, `project_key_value`, `ple_project`, `project_resident_key` and 6 more. +//! The CUDA composition of one PLE row from separate uploads: key and value projection of the embedding, then gate, +//! norms and convolution over the residual streams and the nine-slot history, with resident or uploaded weights. +//! Owns every device buffer of the step and releases them before a candidate can leave. use super::{ Bf16ProjectionShape, Context, DenseWeightCache, DeviceBuffer, Error, ModelBinding, PLE_DEVICE_PEAK, PLE_HC, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs index bc48ddeb..57ab95cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/ple_key_retained_gpu/bf16.rs @@ -1,5 +1,5 @@ -//! Methods of `Matrices`: `new`, `aux`, `unchanged`, `close`. -//! Methods of `Chain`: `key_value`, `norms`, `gate`, `gated` and 2 more. +//! Test support for the retained-PLE proof: synthetic BF16 PLE matrices and the legacy chain (one key projection and +//! forty ephemeral value tiles) that the whole-matrix retained path must reproduce bit for bit. use super::{ Bf16ProjectionShape, Context, DeviceBuffer, Finite, Matrices, Role, Transport, at, ple_download, ple_driver_error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs index 0d49a691..034f8eb2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_transport/role.rs @@ -1,5 +1,6 @@ -//! Methods of `Role`: `count`. Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 8 more. -//! Implements `Drop for Transport`. Functions: `at`, `compose`, `admit`. +//! Impls of the PLE transport: the device buffers of one invocation, the certificates (`Finite`) a full readback +//! mints for each role (key, value, norms, gate, conv, history, streams), and the entry points `compose` and `admit`. +//! Any CUDA failure latches the invocation as failed, so nothing it produced can be published. use super::{ Cell, Context, DeviceBuffer, Error, Finite, PLE_HC, PLE_HISTORY, PleCandidate, PleRows, Rc, Result, Role, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs index 7febeb4f..3546598c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/ple_upload_f32.rs @@ -1,5 +1,5 @@ -//! Methods of `InputStage`: `prepare_original_prompt_history`, `finish_original_prompt_history`, `prepare_prompt_dev... -//! Functions: `ple_upload_f32`, `ple_upload_u16`, `ple_download`, `ple_driver_error`. +//! Host-device transfer helpers of the PLE path (f32 and u16 uploads, readback, driver error mapping) and the +//! preparation of the prompt PLE history on the device: seeding it from the prior, closing it after a prefill chunk. use super::{ Context, DenseWeightCache, DeviceBuffer, DriverError, Error, GrRole, InputReady, InputStage, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs b/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs index 664e8e89..b42eca24 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/input/residual_streams.rs @@ -1,5 +1,5 @@ -//! Methods of `ResidualStreams`: `broadcast`, `values`. -//! Methods of `InputReady`: `binding_identity`, `token`, `position`, `streams` and 3 more. Implements `From for Error`. +//! Accessors of the input step: `ResidualStreams` (one embedding broadcast to the four residual streams, checked for +//! shape and finiteness) and the read-only view of `InputReady` (binding, token, position, streams, PLE rows). use super::{ BindingIdentity, EMBEDDING_VALUES, Error, InputError, InputReady, Position, ResidualStreams, Result, StagedInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs index 1fa25287..322a8841 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/kar_ple_cache_methods.rs @@ -1,5 +1,6 @@ -//! Methods of `KarPleCache`: `new`, `admit_budget`, `allocate_scratch`, `admit_binding` and 15 more. -//! Functions: `check_stage_rows`, `encode_staged`, `verify_ahead_packets`, `serialize_books` and 4 more. +//! The lifecycle of `KarPleCache`: admission of the budget and binding, the staging scratch, staging a chunk of PLE +//! rows (hits, misses, packets from the read-ahead or the archive), commit after the device accepted the scatter, +//! and the direct 16-row gather with scatter, decode and finite readback. The cache map changes only in `commit`. use super::{ AHEAD_KEEP, AHEAD_THREADS, Ahead, Arc, CACHE_BYTES, Context, DeviceBuffer, Error, GatherPlan, KarPleBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs index 8fad61f9..df0bc762 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/lru_tests.rs @@ -1,5 +1,6 @@ -//! Methods of `Rng`: `next`, `row`. Methods of `Scan`: `new`, `victim`, `plan`, `gather`. -//! Functions: `token`, `gather_equals_the_full_scan_on_random_sequences`, `chunks_and_gathers_interleaved_keep_every... +//! Pins the resident-row LRU of the KAR PLE cache: gather planning equals a full-scan reference on random +//! sequences, chunks and gathers interleaved keep every row in its own slot, and eviction examines a handful of +//! queue items, not the whole cache. use super::{Lookup, Residents, SLOTS, assign_slots, lookup_rows, plan_gather, publish_gather}; use std::collections::HashMap; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs index 7dc91ff8..b8df218f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/publish_gather.rs @@ -1,5 +1,5 @@ -//! Methods of `Ahead`: `collect`. Functions: `publish_gather`, `ahead_enabled`. -//! Split out of `kar_ple_cache` to keep its files under the line limit. +//! Publication of a gather the device accepted (evict victims, map new rows, age the sixteen rows in order), the +//! `LELEKA_PLE_AHEAD` switch for read-ahead of the next chunk's packets, and collection of a finished read-ahead. use super::{Ahead, PlannedMiss, Residents}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs index 9b8ab142..ff609710 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/row_parity_probe.rs @@ -1,5 +1,6 @@ -//! Functions: `fnv`, `probe_binding`, `probe_rows`, `dump_decoded_rows_for_original_comparison` and 2 more. -//! Split out of `kar_ple_cache` to keep its files under the line limit. +//! Ignored probes against the real KAR archive and a GPU: dump the decoded PLE rows as FNV hashes for comparison +//! with the Original, and check that the batch read equals the sixteen-row reads. They admit a plain file path +//! through the same verification as production. use super::{BindingIdentity, KarPleBinding, KarPleCache, PLE_ROWS}; use crate::model_binding::qwen4exp_kar_ple::pinned_profile; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs index 94838bc2..5344a1ca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/scratch_bytes.rs @@ -1,5 +1,6 @@ -//! Methods of `Residents`: `len`, `get`, `contains_key`, `try_reserve` and 7 more. -//! Methods of `KarPleStaged`: `updates`, `slots`. Implements `Hasher for RowHasher`. +//! The row bookkeeping of the KAR PLE cache: `Residents`, the map of cached rows with a recency queue that finds +//! the oldest rows without scanning, the hasher for dense row numbers, and the pure slot planning for a chunk +//! (`lookup_rows`, `assign_slots`) and a gather (`plan_gather`). Nothing here touches the device. use super::{ Entry, Error, GatherPlan, Hasher, KarPleStaged, Lookup, MAX_MISSES, PlannedMiss, Residents, Result, RowHasher, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs index 3d6dca7d..6dd06703 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/kar_ple_cache/slot_tests.rs @@ -1,5 +1,6 @@ -//! Functions: `apply`, `the_scatter_staging_buffers_match_the_update_records`, `chunk`, `consistent` and 9 more. -//! Defines `Given`. +//! Pins the slot assignment of the KAR PLE cache: fresh rows get distinct free slots, hits keep their slots and +//! refresh age, a full cache evicts the oldest untouched rows, rows match by id not position, and a chunk that needs +//! more slots than the untouched rows hold is refused. Also the scatter staging sizes. use super::{Error, Lookup, MAX_MISSES, Residents, UPDATE_RECORD_BYTES, assign_slots, lookup_rows, scratch_bytes}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs index 575f6e91..51f578a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/cached_expert_run.rs @@ -1,5 +1,6 @@ -//! Methods of `ActualSlotPacket`: `validate`. Methods of `ActualDown`: `take`. -//! Functions: `shared_scalar_buffers`, `release_shared_inputs`, `scaled_shared`, `finish_with_parts` and 1 more. +//! Cached-weights execution of one expert row: routed Down packets, the scalar-gated shared expert and the combine. +//! Owns the partial buffers of a run and closes every one of them whatever failed, so a failure never leaks device +//! memory. Also holds the origin checks that tie a Down packet to the binding and layer that minted it. use super::moe_down::{RetainedScalar, ScaledDown}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs index 4e89fa25..86e3e2a4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_matrix_projection.rs @@ -1,5 +1,7 @@ -//! Functions: `matrix_dims`, `gate_up_dims`, `prepared_routed_format`, `gate_up_prepared_format` and 15 more. -//! Defines `MatrixDims`, `ExpertMatrix`, `ExpertActivation` and 2 more. +//! Projection of one expert matrix (Gate, Up or Down): shape and format admission, launch plan per matrix kind, +//! readback. The declared dimensions come from the binding; each matrix kind maps to exactly one launch (dense, +//! routed prepared Q8 or cached MMQ), and a kind without a plan is refused. The uncached diagnostic path uploads the +//! raw matrix here. use super::{ BoundExpert, CachedMoeMatrix, Context, DEVICE_PEAK, DenseFormat, DeviceBuffer, Error, FF, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs index 3a2962a0..c3ed9aaa 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_mlp_values.rs @@ -1,5 +1,7 @@ -//! Functions: `expert_mlp`, `cached_expert_mlp`, `uncached_hidden`, `project_cached_gate_up` and 3 more. -//! Split out of `moe_expert` to keep its files under the line limit. +//! One expert MLP (Gate and Up, SwiGLU, Down) returning host values, on the uncached diagnostic path or on cached +//! weights. The uncached path keeps its original download and re-upload chain; the cached path keeps Gate/Up on the +//! device. Release of every owned buffer is attempted after the last use and a cleanup failure withholds a finished +//! candidate. use super::expert_matrix_projection::{gate_up_dims, gate_up_prepared_format}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs index 8fd3e1c9..96ed8a92 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/expert_step.rs @@ -1,5 +1,7 @@ -//! Methods of `ExpertReady`: `identity`, `output`, `validate_origin`, `from_completed`. -//! Methods of `StepCuda`: `dispatch`, `dispatch_prepared`. +//! Entry of one MoE expert step: validates the FFN row, uploads the activation and dispatches the routed experts and +//! the shared expert (weight cache, KAR archive or uncached diagnostic) into an `ExpertReady` row. All descriptors +//! and expert ids are admitted before any CUDA work; the activation and the prepared owner are released whatever the +//! dispatch result, and the dispatch error wins over cleanup errors. use super::{ BindingIdentity, BoundExpert, Context, DeviceBuffer, Error, ExpertActivation, ExpertReady, GrRole, K, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs index f91c557d..8da4a37c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/adaptive_packet_projection.rs @@ -1,5 +1,6 @@ -//! Functions: `project_adaptive_packets`. -//! Split out of `adaptive_packets` to keep its files under the line limit. +//! Entry that projects every expert group of one chunk batch into its slot packets on the adaptive path. +//! It owns the ephemeral routed owner for the call and drains it whatever the outcome, so no pending expert transfer +//! outlives the batch, including after a prepare, copy or cancel error. use super::super::direct_packets_fns::PacketRun; use super::super::packet_run_project_group_direct::DirectRun; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs index f51e597e..af8a880e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/adaptive_packets/packet_wave_projection.rs @@ -1,5 +1,6 @@ -//! Functions: `project_inner`, `observe_adaptive`, `ephemeral_slot_count`. -//! Split out of `adaptive_packets` to keep its files under the line limit. +//! Driver of one adaptive packet wave: observe the rows for the adaptive policy, classify the expert groups, stage +//! the GPU misses, run the CPU miss batches, then finish the GPU queue. Also checks that the ephemeral routed owner +//! has a supported slot count (legacy 2, or mapped 8 or 16). use super::super::direct_packets_fns::PacketRun; use super::super::packet_run_project_group_direct::DirectRun; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs index bf231305..107d86f7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/arm.rs @@ -1,5 +1,6 @@ -//! Functions: `arm`, `probe_payload`, `preflight_copy`, `corrupted_bytes` and 1 more. -//! Split out of `direct_gpu` to keep its files under the line limit. +//! Setup of one proof arm of the direct-Down transport probe: real layer-0 chunk rows, the probe payload and the +//! corrupted-byte and refused-scope cases the all-copy preflight uses. Completed layer-0 FFN products stay private; +//! no injection, head or target publication is made, and a cancelled chunk is dropped, not repaired. use super::{ Cell, ChunkFfnLayer, DEVICE_PEAK, DownScope, Error, FF, K, LoadedArms, MoeExpertStage, N, Observation, ObservedArm, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs index 8d458a04..f006eead 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/loaded_arms.rs @@ -1,5 +1,6 @@ -//! Methods of `LoadedArms`: `arm`, `matches_snapshot`, `precheck`, `reference_and_candidate` and 2 more. -//! Methods of `QwenForward`: `test_direct_down_on_loaded`. +//! The arms of the loaded direct-Down proof on a real binding and session: reference, candidate, cancelled and +//! recovery runs of the same three-row chunk. Pins that a cancelled arm is refused after the copy and leaves the +//! session snapshot untouched, and that the recovery arm after a reset reproduces the reference outputs. use super::{ CANCELLED_ON_COPY, DirectDownReport, DirectRun, Error, K, LoadedArms, N, ObservedArm, QwenForward, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs index 3d9b7147..5a98259d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/policy.rs @@ -1,5 +1,7 @@ -//! Methods of `Observation`: `begin`, `take`. Methods of `DirectDownReport`: `assert_after_teardown`. -//! Implements `Drop for Observation`. Functions: `policy`, `copy_completed`, `observe_packet`, `compare` and 7 more. +//! Observation hooks and the report of the direct-Down proof: whether an arm uses the old split-and-pack or the +//! direct copy, recording of the copied packets, and their comparison. Also builds the chunk inputs of an arm. The +//! report is asserted only after the caller closed every cache, session and Context; it is not a full-target commit +//! proof. use super::{ CANCELLED_ON_COPY, COPIED, ChunkAttentionRow, ChunkFfnRow, DenseWeightCache, DetachedGrRead, DeviceBuffer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs index 1c468146..70070e82 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/direct_gpu/probe.rs @@ -1,5 +1,6 @@ -//! Methods of `Probe`: `run`, `fill_sentinels`, `split_and_pack_old`, `copy_direct` and 7 more. -//! Functions: `transport_probe`, `output_differences`, `same_outputs`. +//! Byte-level transport probe: the old split-and-pack of a grouped Down result against the direct whole-group copy. +//! Both packets start from sentinels so untouched slots are compared too. Also pins the refusals: an invalid slot or +//! column in the all-copy preflight mutates nothing, an alien scope is refused, and a non-finite source is refused. use super::{ Cell, Context, DownScope, DownSelection, DriverError, Error, ExpertReady, K, N, Probe, Rc, Result, SLOTS, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs index 698fb918..048f1718 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/execute_bound.rs @@ -1,5 +1,7 @@ -//! Functions: `execute_bound`, `open_bound`, `finish_bound`, `is_extended_group` and 8 more. -//! Split out of `grouped` to keep its files under the line limit. +//! Entry of one chunk layer on the bound (cached-weight) path: admit and reserve device room, upload the row +//! activations, prepare their Q8 owners, run the rows, then close every owner. Decides whether the rows run as sorted +//! expert groups and opens the step-local Down scope; any failure marks the transport failed and the primary error +//! wins over cleanup errors. use super::bound_rows::{BoundRows, DirectPacketInputs}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs index d1e0bb83..07936fb1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/finish_shared_with.rs @@ -1,5 +1,6 @@ -//! Methods of `SharedOwners`: `scale_shared`, `combine_with`, `close_all`. -//! Functions: `finish_shared_with`, `uses_adaptive`. Defines `RowTail`, `SharedOwners`. +//! Shared-expert tail of one chunk row: scalar-gate scaling of the shared expert and the weighted combine with the +//! routed Down packet, finished by a caller-supplied combine. Holds the partial owners of the row and closes every +//! one in a fixed order whatever failed; also tells whether the adaptive path serves the row. use super::{ BoundExpert, Context, DeviceBuffer, DownOrigin, DownProvenance, DownScope, Error, ExpertActivation, K, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs index b4fe4bbc..7550d988 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/ordered_down_refusal.rs @@ -1,5 +1,7 @@ -//! Functions: `ordered_down_refusal`, `replay_selection`, `use_direct_packets`, `validate_packet_pairs` and 5 more. -//! Defines `PacketGroupMembers`. +//! Refusal and finish rules shared by the direct packet groups: replay of a numerical Q8 refusal in original row +//! order, packet and pair validation against the row origins, and the shared-expert finish. A later column's +//! quantizer refusal must not overtake an earlier column's Down NonFinite, so the refusal is replayed ascending; +//! every packet is closed whatever the first failure was. use super::finish_shared_with::RowTail; use super::packet_run_project_group_direct::{DownProjection, RefusalReplay}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs index bf5454de..d23a38fb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/packet_run_project_group_direct.rs @@ -1,5 +1,7 @@ -//! Methods of `PacketRun`: `project_group_direct`. -//! Methods of `DirectGroup`: `check_descriptors`, `run`, `project_gate_up`, `project_gate_up_role` and 6 more. +//! Plain device path (no source fence) that projects one expert group into its row slot packets: Gate and Up, SwiGLU, +//! grouped Down, then copy of the Down columns into each row's packet. Defines the group and run descriptors the +//! direct and source paths share. Origins of all rows are validated before any packet is mutably loaned, and every +//! group buffer is closed whatever the outcome. use super::direct_packets_fns::PacketRun; use super::project_group_shared_fns::*; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs index 448ef6b3..60dd5406 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/prepared_moe_row.rs @@ -1,5 +1,7 @@ -//! Methods of `PreparedMoeRow`: `validate`, `into_read`. -//! Methods of `MoeExpertStage`: `prepare_chunk_row`, `prepare_chunk_row_detached`, `execute_chunk`, `execute_chunk_n... +//! Per-row entry of the chunk MoE stage: prepares a row from its detached GR read and route, and executes the rows of +//! a chunk layer on the ordinary or the native-prompt path. The chunk transaction validates each row and its micro- +//! batch size (1 to 64 rows) before experts run; the direct packet path is used when the cache allows it. Also holds +//! the row-to-expert inverse grouping. use super::bound_rows::DirectPacketInputs; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs index 215642b1..dc1f54ed 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group.rs @@ -1,5 +1,7 @@ -//! Methods of `ResidentGroup`: `run`, `project_gate_up`, `project_gate_up_role`, `finish_gate_up` and 7 more. -//! Methods of `DownArgs`: `refusal_values`. Functions: `project_group`. +//! Resident (or adaptive workspace) path that projects one expert group: Gate and Up, SwiGLU, then grouped Down +//! stored into the Down cells of the group's rows. Each Gate/Up role keeps the original finite stage boundary; a +//! numerical refusal of a later column is replayed in row order so it cannot overtake an earlier column's NonFinite. +//! Destination cells must still be empty. use super::packet_run_project_group_direct::{DownProjection, GroupBuffers, RefusalReplay}; use super::project_group_shared_fns::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs index c201cdc5..d9a78724 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_consumers.rs @@ -1,5 +1,6 @@ -//! Methods of `DirectGroup`: `run_source`, `source_gate_up`, `source_up`, `source_gate_up_role` and 5 more. -//! Functions: `project_group_source_consumers`, `check_source_members`. +//! Source-backed direct group: Gate, Up, SwiGLU and Down of one expert read through the opened routed source scope. +//! The scope ends after the last private consumer and before any packet coverage or group acceptance; a failure +//! discards every copied private packet. Also checks that the source members match the group descriptors. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::packet_run_project_group_direct::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs index 04722779..c824cfa1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/grouped/project_group_source_fenced.rs @@ -1,5 +1,6 @@ -//! Methods of `PacketRun`: `direct_group`, `project_group_fenced`. Functions: `source_members`. -//! Split out of `grouped` to keep its files under the line limit. +//! Fenced entry of the source-backed direct group: opens the source scope around the consumers of one expert group. +//! The mandatory source finish is attempted even after a failure and runtime primary errors are preserved; the cache +//! is rechecked after the matrix and source loans ended. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::direct_packets_fns::PacketRun; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs index 2177729d..6772340d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/encoded.rs @@ -1,5 +1,6 @@ -//! Functions: `block_geometry`, `fill_block`, `encoded`, `exact` and 9 more. -//! Split out of `moe_activation_reuse_gpu` to keep its files under the line limit. +//! Deterministic encoded expert-matrix fixtures and the reference MLP of the retained Gate/Up proof (GPU tests only). +//! Builds quantized blocks for each matrix kind with bounded values, runs the same Down kernel and a download and re- +//! upload reference chain, and checks the outputs are bit-exact and the uploaded matrices unchanged. use super::{ Cell, Context, DenseFormat, DeviceBuffer, DriverError, FF, MatrixDims, MoeMatrixKind, N, ProjectionKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs index 82e41d0d..0580e4cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_activation_reuse_gpu/former_fixture_domain_refusal.rs @@ -1,5 +1,6 @@ -//! Methods of `DomainFixture`: `build`, `release`. -//! Functions: `hidden_extrema`, `former_fixture_domain_refusal`, `nonfinite_hidden_refused`, `late_nan_projection_re... +//! Refusal cases of the retained Gate/Up proof: the fixture of a former domain failure, non-finite hidden values, a +//! late NaN written by a real projection, a Down shape mismatch, and saturation. Each case must be refused by genuine +//! native admission before the retained projection owner is published. use super::{ Cell, Context, DeviceBuffer, DriverError, Error, FF, MatrixDims, MoeMatrixKind, N, compare_mlp, down_projection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs index 706731a6..99d20c2a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/down_scope.rs @@ -1,5 +1,6 @@ -//! Methods of `DownScope`: `new`, `with_routed_finite`, `with_routed_workspace`, `with_workspace` and 15 more. -//! Functions: `check_grouped_selections`, `completed_row_source`. Defines `GroupedColumn`, `GroupedHandoff`. +//! The step-local scope every Down output of one expert step is minted under: its epoch, failure flag and workspaces. +//! A CUDA failure recorded in the scope poisons it, so no later consumer can use a Down output of a failed step. Also +//! splits a grouped Down allocation into per-slot Down owners once its producer readback is finite. use super::{ Cell, CompletedCpuRow, Context, DeviceBuffer, DownScope, DownSelection, Error, K, N, Rc, Result, RetainedDown, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs index 4477606e..c7155b96 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/moe_down_reuse_gpu/exact.rs @@ -1,5 +1,5 @@ -//! Functions: `exact`, `down_weights`, `scalar_weights`, `project` and 3 more. -//! Split out of `moe_down_reuse_gpu` to keep its files under the line limit. +//! Fixtures and exact-comparison helpers of the retained Down proof: seeded Down and scalar weight bytes, the +//! original Down projection, retained Down outputs, and a check that an expected refusal is counted. use super::{ Cell, Context, DenseFormat, DeviceBuffer, DownScope, DownSelection, Error, N, ProjectionKind, ProjectionSpec, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs index 1eed90dc..f1d194c3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/resident_packed_down.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentPackedDown`: `new`, `validate`, `complete`, `with_completed` and 7 more. -//! Split out of `moe_down` to keep its files under the line limit. +//! Destination of the K routed Down outputs of one resident chunk row, filled by one closed producer copy. +//! Coverage is published only after the copy and the origin and cancellation postchecks succeeded; partial coverage +//! is never visible, and the window can be lent out only once every slot is covered. use super::{DeviceBuffer, DownScope, Error, K, N, Rc, ResidentPackedDown, Result, ScaledDown}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs index 8d62a8f5..24f49ab6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/moe_down/retained_scalar.rs @@ -1,5 +1,6 @@ -//! Methods of `RetainedScalar`: `close`. Methods of `TransportBuffer`: `buffer`, `buffer_mut`, `close`, `release`. -//! Implements `Drop for TransportBuffer`. +//! Ownership and lifetime of the retained Down device buffers: scalar, scaled shared and the packed routed Down. +//! `TransportBuffer` fails closed (a failed scope refuses every access) and releases its device memory on drop; the +//! packed owner fills K slots in order and lends only a complete, in-scope packet to the combine. use super::{ DeviceBuffer, DownScope, DownSelection, Error, K, N, PackedDown, Rc, Result, RetainedDown, RetainedScalar, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs index f2ffd2ae..f49b9fc8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/scoped_expert_mlp.rs @@ -1,5 +1,6 @@ -//! Functions: `check_origin`, `swiglu_hidden`, `project_down`, `close_down_parts` and 4 more. Defines `DownProvenance`. -//! Split out of `moe_expert` to keep its files under the line limit. +//! Expert MLP on cached weights whose Down output is minted inside a step-local `DownScope` (Gate, Up, SwiGLU, Down). +//! Gate, Up and hidden stay on the device as scope-owned buffers; the Down result is recorded under the scope's +//! origin and every owner is closed after use, the primary failure winning over cleanup failures. use super::expert_matrix_projection::{MatrixDims, gate_up_dims, gate_up_prepared_format}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs index dfb7a46c..7ccaf69b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the expert-row collection and finite checks: completed tiles keep all rows, a late failure withholds the +//! candidate, and a non-finite last expert output is refused while a signed zero is retained. use super::{DEVICE_PEAK, Error, FF, N, admit_budget}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs index 06f1e390..87826447 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_expert/validate_values.rs @@ -1,5 +1,5 @@ -//! Functions: `validate_values`, `upload_bytes`, `upload_f32`, `download_f32` and 2 more. -//! Split out of `moe_expert` to keep its files under the line limit. +//! Shared helpers of the expert stage: finite and length checks of host values, f32 upload and download of device +//! buffers, and the mapping of binding and driver errors onto the stage error. use super::{Context, DeviceBuffer, DriverError, Error, InputBindingError, Result, Stage}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs index 95a83f12..a6cde714 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/device_bytes.rs @@ -1,5 +1,6 @@ -//! Methods of `Buffers`: `new`, `from_pool`, `into_outputs`, `release`. -//! Functions: `device_bytes`, `release_pool`, `buffer_sizes`, `allocate_pool` and 4 more. +//! Device buffers of one batched prefill MoE step: the per-call sizes in allocation order and the `Buffers` that +//! own them. Sizes depend on the window row count, the router profile and whether the combine runs. The pool is +//! released as a whole, and outputs are handed out only after the internal owners are released. use super::{ Buffers, Context, DeviceBuffer, EXPERTS, Error, FF, MIXED, MoeBf16Profile, Result, SELECTED, driver_error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs index ddcc799c..dc266b01 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_resources.rs @@ -1,5 +1,6 @@ -//! Methods of `MoePrefillResources`: `new`, `validate_context`, `allocated_bytes`, `close` and 1 more. -//! Methods of `RouteRow`: `validate_origin`. Implements `Drop for MoePrefillResources`, `Drop for MoeMicroProducts`. +//! Persistent resources of the batched prefill MoE router and shared expert, and the products it hands to the caller. +//! Owns the allocation charge, context check and close of both; validates that every route row and window come from +//! the genuine FFN reads of the layer under the same binding, and that route ids and weights are valid. use super::{ BindingIdentity, Context, DeviceBuffer, EXPERTS, Error, GdnNativeFormat, GrRole, LayerId, MOE_BATCH_SCRATCH_BYTES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs index c8048bcc..be8d3520 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/moe_prefill_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `MoePrefillStage`: `transient_bytes`, `route_shared_micro`, `combine_micro`. -//! Split out of `moe_prefill_batch` to keep its files under the line limit. +//! Entry points of the batched prefill MoE stage over one micro-window: the router and shared expert, and the later +//! separate combine. The combine consumes only the products' own device outputs, so it re-routes nothing and +//! recomputes no shared expert; it is single-use per window and fenced against the actual chunk rows and binding. use super::{ Buffers, CombineInput, CombineOperands, CombineWindow, Error, MIXED, MicroInputs, MoeBf16Profile, MoeMicroProducts, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs index c042c301..93d935c9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_prefill_batch/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the prefill MoE contract: a route row needs distinct in-range ids and finite, ordered unit weights, the +//! shared formats are the six native kinds, device byte counts follow the prompt-path buffer set, and f32 staging is +//! little-endian. use super::{ EXPERTS, Error, FF, GdnNativeFormat, MIXED, MoeBf16Profile, MoeWeightDescriptor, SELECTED, device_bytes, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs index 07e81d07..e93d098d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/project_logits.rs @@ -1,5 +1,7 @@ -//! Functions: `activation_bytes`, `upload_router_matrix`, `finish_logits`, `project_logits` and 9 more. -//! Defines `RouterInput`. +//! Router projection and route validation: the 512 router logits of one mixed residual, then the raw top-10 turned +//! into `RoutedExperts` only through the same checks, for a per-row and for a batch route. Validates request shape, +//! binding and finite logits; the router matrix is uploaded here only on the uncached diagnostic path, and every +//! owner is released explicitly. use super::{ Bf16ProjectionShape, BindingIdentity, COLUMNS, Context, DenseWeightCache, Dimension, EXPERTS, Error, ExpertId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs index 3d1b0543..da22f8de 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/router_logits.rs @@ -1,5 +1,6 @@ -//! Methods of `RouterLogits`: `from_preceding`, `fixture`. -//! Methods of `RoutedExperts`: `new`, `identity`, `experts`, `weights` and 2 more. +//! Producer-owned router products and the route entry points of `MoeRouteStage`. +//! `RouterLogits` and `RoutedExperts` can be made only by the router producer for one token, layer and binding; the +//! stage routes from the typed FFN read, through the retained router scratch or the closed CUDA operation. use super::{ BindingIdentity, COLUMNS, Context, DenseWeightCache, EXPERTS, Error, ExpertId, FiniteF32, GrRole, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs index 15b5376d..58efaaf4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/run_cuda.rs @@ -1,5 +1,6 @@ -//! Functions: `logits_to_bytes`, `decode_route`, `release_route_buffers`, `run_cuda` and 1 more. -//! Split out of `moe_route` to keep its files under the line limit. +//! The fixed CUDA route operation: the 512 logits go to the device and the top-10 expert ids and weights come back. +//! Explicit releases are part of success: a cleanup failure withholds the host result. Also maps driver errors to the +//! closed runtime error categories. use super::{Context, DriverError, EXPERTS, Error, IDS_BYTES, LOGITS_BYTES, Result, SELECTED, Stage, WEIGHTS_BYTES}; use leleka_cuda_driver::DeviceBuffer; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs index a6ecbfca..efc2f346 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_route/tests.rs @@ -1,3 +1,7 @@ +//! Pins the router contract against an independent reference: typed results keep tie order and weights, wrong +//! binding, token or layer identity and bad topology or logits are refused before dispatch, malformed or non-finite +//! routes are never published, driver failures return no partial route, and rank weights never grow. + use super::{ BindingIdentity, DriverError, EXPERTS, Error, ExpertId, LOGITS_BYTES, LayerId, Result, RoutedExperts, RouterLogits, SELECTED, Stage, TokenId, TokenLayer, map_driver_error, route_with, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs index 04563ab5..df50fec3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_mapped_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `MappedStageShape`: `slots`. -//! Methods of `EphemeralRoutedOwner`: `new_mapped`, `slot_count`, `uses_mapped`, `mapped_eligible`. +//! The mapped variant of the ephemeral routed owner: 8 or 16 whole-triplet slots filled by a device copy straight +//! from the retained expert bank pages, with no host payload read. Owns the slot state machine (idle, pending, +//! completed, in use), its byte accounting and drain/release. The owner delegates here whenever `mapped` is set. use super::{ Buffers, Context, DeviceBuffer, EphemeralRoutedOwner, Error, HOST_LIMIT, MappedExpertCopyScratch, MappedSlot, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs index 867b84b8..a0fb07d2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `ephemeral_owner_allocation`, `ephemeral_owner_loans_and_drain`, `ephemeral_owner_stage_tra... -//! Split out of `cache_ephemeral_routed` to keep its files under the line limit. +//! The non-mapped half of `EphemeralRoutedOwner`, split by phase: allocation and key checks, staging and transfer, +//! loans and drain. Each phase file is an `impl` block of the one owner; the slot state machine stays in the parent. use super::{ Buffers, CLOSED_MAXIMUM, Cell, Context, DeviceBuffer, EphemeralRoutedOwner, Error, HOST_LIMIT, MappedStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs index 2956ac23..7780ae2f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_allocation.rs @@ -1,5 +1,6 @@ -//! Methods of `EphemeralRoutedOwner`: `new`, `validate_maximum`, `allocate_idle`, `room` and 9 more. -//! Functions: `key_identity_ok`, `key_shape_ok`. +//! Construction and admission of the ephemeral routed owner: the two idle whole-triplet slots, the room check against +//! the context budget and free device memory, and the key checks that tie a staged triplet to its binding and layer. +//! Every allocation is made up front so a later stage can never fail on device memory. use super::{ CLOSED_MAXIMUM, Context, DeviceBuffer, EphemeralRoutedOwner, Error, MappedStage, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_loans_and_drain.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_loans_and_drain.rs index 2a1aa7f6..433addf0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_loans_and_drain.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_loans_and_drain.rs @@ -1,5 +1,6 @@ -//! Methods of `EphemeralRoutedOwner`: `loan_completed`, `borrow_triplet`, `with_triplet_inner`, `settle_inner_loan` ... -//! Split out of `ephemeral_routed_owner` to keep its files under the line limit. +//! Loan, drain and release of the ephemeral routed owner: a completed triplet is lent once to a synchronous callback +//! and returns to idle. Drain waits for every pending copy and keeps the buffers; release closes everything and +//! poisons the owner on any failure so a half-released slot is never reused. use super::{ Buffers, DeviceBuffer, EphemeralRoutedOwner, Error, MappedStage, MoeRoutedSourceScope, MoeWeightDescriptor, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs index 1f4e1d17..d6ef3ad2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/ephemeral_routed_owner/ephemeral_owner_stage_transfer.rs @@ -1,5 +1,6 @@ -//! Methods of `EphemeralRoutedOwner`: `stage_inner`, `fixed_preparation`, `admit_stage`, `install_idle_buffers` and ... -//! Functions: `check_block_matches`. Defines `DetachedPayloads`. +//! Staging side of the ephemeral routed owner: admit a triplet against the host and device limits, read its three +//! blocks from the routed source, detach the host payloads and enqueue one owned copy into an idle slot. Also polls +//! and waits for that copy and installs the finished buffers, so a slot is Completed only once all roles landed. use super::{ Buffers, Cell, DeviceBuffer, EphemeralRoutedOwner, Error, HOST_LIMIT, ModelBinding, MoeExpertBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs index df7531ee..f1f95c1d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_ephemeral_routed/healthy_cancel.rs @@ -1,5 +1,6 @@ -//! Functions: `healthy_cancel`, `observe_cancel`, `combine`, `close_buffers` and 2 more. -//! Split out of `cache_ephemeral_routed` to keep its files under the line limit. +//! Cancellation and cleanup helpers shared by the ephemeral routed owner and its mapped stage: the rule that only an +//! observed executor cancel on a healthy owner keeps the owner alive, and the buffer and slot release functions that +//! keep the first error while still closing every buffer. use super::{Buffers, Cell, Error, Result, Slot, Stage, driver_error}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs index 864d8cd7..7e4f92f3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index.rs @@ -1,5 +1,6 @@ -//! Methods of `LruIndex`: `new`, `with_capacity`, `metadata_bytes`, `len` and 15 more. -//! Split out of `cache_lru_index` to keep its files under the line limit. +//! The bounded min-heap behind the per-matrix expert LRU: ages by descriptor slot, atomic batch update (prepare then +//! commit), removal, and the oldest-key search that skips the protected keys of the current round. It is the only +//! eviction order of the MoE cache, so the slot count and the heap/position coherence are checked here. use super::{ ABSENT, Error, HOST_LIMIT, LruIndex, MAX_KEYS, MAX_PROTECTED, MoeWeightDescriptor, Node, PER_LAYER, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs index b5df35b6..ef9d74d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/lru_index_seeding.rs @@ -1,5 +1,6 @@ -//! Methods of `LruIndex`: `seed_existing`, `is_pristine`, `load_seed`, `seed_insert` and 5 more. -//! Split out of `cache_lru_index` to keep its files under the line limit. +//! Seeding of an empty `LruIndex` from entries that already exist on the device: used by constructors that fill the +//! cache before it is published. A refused seed restores the empty state, and `matches_existing` lets a test prove +//! the index equals the actual owners. use super::{ABSENT, Error, LruIndex, MAX_KEYS, MoeWeightDescriptor, Node, Result, slot}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs index 1aeb438a..28d35f04 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/slot.rs @@ -1,5 +1,5 @@ -//! Functions: `slot`. -//! Split out of `cache_lru_index` to keep its files under the line limit. +//! Maps an expert or shared-weight descriptor (layer, expert, role) to its fixed slot in the LRU position table, +//! and refuses any coordinate outside the 48-layer, 512-expert domain. use super::{Error, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs index 790c7145..b6a82219 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_lru_index/tests.rs @@ -1,4 +1,6 @@ -//! Pure metadata proof. Literal descriptors convey no model, weight or device authority. +//! Pins the bounded LRU index against a scan oracle: oldest-first order with protected keys, atomic batch refusals, +//! descriptor collisions, a full index and long deterministic churn. Literal descriptors carry no model or device +//! authority, so these tests run without a GPU. use super::{LruIndex, MAX_KEYS, MoeWeightDescriptor, PER_LAYER, slot}; #[cfg(any(test))] use super::HOST_LIMIT; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs index 66646e50..29bfd194 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weight_cache.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_original_prompt_arena`, `retained_bank_mapping`, `arena_workspace`, `attach_are... -//! Functions: `arena_driver_error`, `shared_descriptors`, `shared_bytes`. Defines `ArenaPlan`, `ExpertBankMapping`. +//! Bring-up of the original prefill arena on `MoeWeightCache`: carves the arena from the prefill options, maps the +//! retained expert bank, builds the MMQ workspace with its expert group arena, and attaches the copy schedule and +//! prompt device. Also the prompt-routing capture, the end of a prompt expert stream and the per-expert span lookups. use super::{ Context, Error, LayerId, MmqRoutingPolicy, MmqWorkspace, ModelBinding, MoeExpertSelection, MoeExpertWeights, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs index 2986fa32..b3538863 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/moe_weights_original_prompt.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `original_prompt_moe`, `original_prompt_parts`, `original_prompt_precheck`. -//! Functions: `raw_weight`, `shared_formats`, `shared_weights`. +//! Entry point of one original-prompt MoE layer on the cache: borrows the disjoint owners the layer drives (shared +//! weights, copy ring, span state), prechecks binding and dense cache, and loads the router and shared weights raw. +//! The layer body itself is in `prompt_layer_fns`. use super::prompt_layer_fns::{PromptIo, PromptParts, PromptWeightOwners, SpanScan, run_prompt_layer}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs index 5fab9bc9..3499405a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_original_prompt/prompt_stream_settings.rs @@ -1,5 +1,6 @@ -//! Functions: `prompt_stream_settings`, `native_format`, `span_cache_enabled`, `set_span_cache_override`. -//! Split out of `cache_original_prompt` to keep its files under the line limit. +//! Settings of the prompt expert stream and span cache: whether a prefill chunk copies every expert of every layer +//! through an issuer thread or uses the per-layer copy ring, and the per-arm overrides the replay harness sets. +//! Also maps a descriptor's raw kind to its native format. use super::{Error, GdnNativeFormat, MoeWeightDescriptor, PREFILL_STREAM_OVERRIDE, Result, SPAN_CACHE_OVERRIDE}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_sdet.rs index 7c9752e1..686e5d21 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/learned_main_sdet.rs @@ -1,4 +1,5 @@ -//! Pure current-age bootstrap policy proof; no binding/device/weight certificate. +//! Pins the learned-main bootstrap: a seeded LRU index equals the scan over the actual ages, refused seeds restore +//! the empty owner, and `learned_main_slot_bound` equals the expanded multiset count. Pure policy, no device. use super::super::cache_lru_index::LruIndex; use super::{MoeWeightDescriptor, learned_main_slot_bound}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs index 54861722..8ed42848 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/ranked_profile.rs @@ -1,5 +1,6 @@ -//! Methods of `RankedProfile`: `parse`, `check_header`, `parse_pair`, `ordered_pairs` and 1 more. -//! Methods of `PlanBudget`: `capacity`, `new`. Defines `PlanBudget`. +//! Parser of the ranked expert profile (the `STRP` file: header, SHA check, ordered layer/expert pairs and the +//! optional rank table) and the prefix planner: `PlanBudget` turns the device limits into the largest whole-triplet +//! prefix of the ranking that can stay pinned. Pure metadata; it reads no weights and touches no device. use super::{ Digest, EXPERTS, Error, HOST_CAP, LAYERS, PAIRS, PrefixPlan, ProfileLimits, RankedProfile, Result, Sha256, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs index 37bd6688..c7567864 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile/shared_permanent_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `SharedPermanentPool`: `new`, `contains`, `quartet`, `descriptor_count` and 7 more. -//! Functions: `remaining_shared_main`, `learned_main_slot_bound`. +//! The permanent pool of shared-expert quartets (gate, up, down, scalar) of all 48 layers, pinned for the model +//! lifetime, with per-role hit, fill and eviction counters. Also the two sizing rules that leave the rest of the main +//! tier to the learned LRU: what remains after the shared bytes and the upper bound of routed slots. No device state. use super::{Error, LAYERS, MoeWeightDescriptor, Result, RoleTraffic, SHARED_MAX_BYTES, SharedPermanentPool}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs index 8181c72a..e93190f0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/learned_main_lru_profile.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_profile_shared_permanent_learned_main_lru`, `learned_main_totals`, `check_learn... -//! Split out of `cache_profile_fill` to keep its files under the line limit. +//! Constructor of the MoE cache whose routed main tier is a learned LRU over the shared permanent pool: the preload +//! bytes are kept, routed residency is then learned from traffic. Also the witness and totals that check the actual +//! main entries against the byte limit and the slot bound. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::profile_build::{ProfileFile, ProfileKind, ProfileRequest}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs index e6164ae8..cf672050 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `pinned_triplet_preload`, `profile_ranked_fill_and_pool`. -//! Split out of `cache_profile_fill` to keep its files under the line limit. +//! The `MoeWeightCache` constructors of the profile fill: the ranked fill with its pinned pool and the pinned triplet +//! preload. use super::{ Context, DeviceRef, EncodedWeight, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs index 76872ac1..46ddd439 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/pinned_triplet_preload.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `preload_pinned_triplet`, `admit_pinned_triplet`, `pinned_layouts`, `check_pinned_ro... -//! Defines `PinnedLayouts`, `PinnedSource`, `PinnedAdmission`. +//! Preload of one pinned routed expert triplet of the ranked profile: admit it against room and spill reserve, read +//! its three raw blocks from the binding, upload them (dual or mixed layout) and commit them as pinned main entries +//! with the traffic counters. Also the profile witness that reads those counters back for tests. use super::{ DeviceRef, EncodedWeight, Entry, Error, MAIN_LIMIT, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs index 026acb27..ddcfac42 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/moe_weight_cache/profile_ranked_fill_and_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile`, `new_native_intege... -//! Functions: `ranked_keys`. Defines `MapReservation`, `ProfileFill`. +//! Constructors of the MoE cache for the ranked profile with the retained MTP KV and shared tail: derive the prefix +//! plan from the first-expert descriptors of every layer, reserve the one weight map under the metadata ceiling, +//! install the pinned pool and preload the ranked prefix. An MTP input or spill floor widens the window reserve. use super::{ Context, Entry, Error, HOST_CAP, HashMap, MAIN_LIMIT, ModelBinding, MoeMatrixRole, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs index d93b6f83..eec7ee48 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/profile_window_spill.rs @@ -1,5 +1,6 @@ -//! Functions: `profile_window_spill`, `profile_window_spill_with_floor`. -//! Split out of `cache_profile_fill` to keep its files under the line limit. +//! The device bytes the prefill MoE micro-window keeps live next to the pinned pool (the live prefill owners and the +//! GDN chunk charge), optionally raised by a reusable spill floor. The profile planners reserve this much beyond the +//! pinned prefix. use super::{Error, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs index ce98641a..627bff67 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/shared_quartet_preload.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile_mtp_input_spill_floo... -//! Defines `QuartetRoom`. +//! Preload of the shared-expert quartets (gate, up, down, scalar) into the main tier of a profile with a shared +//! permanent pool: admission against room and spill, upload, then publication with no fallible step after the first +//! insert. Also the shared-pool witness that reconciles the traffic counters with actual residency. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs index 0a850b46..15a6d3b3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_profile_fill/strata_adaptive_shared_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `new_native_strata_adaptive_shared_permanent`, `new_native_strata_adaptive_shared_pe... -//! Functions: `adaptive_template`. Defines `AdaptivePlan`, `SharedKeys`. +//! Constructors of the MoE cache for the Strata adaptive policy (copy transport or mapped transport): size the shared +//! permanent pool and the adaptive plan from the descriptor template, admit the whole allocation bound before the +//! first shared upload, then adopt the adaptive owner. A failed build closes the cache. use super::profile_build::ProfileFile; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs index e1b01cd6..338e706a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/adaptive_cache.rs @@ -1,5 +1,6 @@ -//! Methods of `AdaptiveCache`: `preload`, `unpublished`, `validate`, `revalidate_keys` and 19 more. -//! Defines `StagedPairs`, `Staged`, `UploadReserve` and 1 more. +//! The adaptive expert cache of the Strata policy: the device slots that hold whole expert triplets and the transfer +//! queue of the current round. It observes every routed row, serves hits, stages the due swaps after each verified +//! window, polls the copies and publishes a swap only after its transfer completed. use super::{ ADAPT_EVERY, ADAPT_SWAPS, AdaptiveCache, AdaptivePolicy, AdaptiveSizing, AdaptiveWitness, CachedMoeMatrix, Context, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs index 30892856..c4b37459 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/reserve.rs @@ -1,5 +1,6 @@ -//! Methods of `AdaptivePolicy`: `new`, `template_charges`, `initial_slots_for`, `measure_metadata` and 13 more. -//! Functions: `reserve`, `cell`, `blob_key_identity_ok`, `blob_key_shape_ok` and 2 more. Defines `InitialSlots`. +//! `AdaptivePolicy`, the pure frequency policy of the Strata adaptive cache: usage counters, the resident map and the +//! initial slots of the ranked prefix, then swap selection per verified window (candidates used twice or more +//! against the coldest residents). Holds metadata only; the adapter owns the buffers and confirms every transfer. use super::{ ADAPT_EVERY, ADAPT_SWAPS, AdaptivePolicy, CELLS, EXPERTS, Error, HOST_CAP, LAYERS, MoeWeightDescriptor, PrefixPlan, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs index d16d0a25..3719e80e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/tests.rs @@ -1,5 +1,5 @@ -//! Pure source-policy oracle only. No fabricated BindingIdentity, device slot, -//! event completion, CPU expert output, or model acceptance certificate. +//! Pins the adaptive policy to its Strata original: frequency threshold, same-layer slots, pending transition, +//! decay and refusals of bad observations. A pure oracle; no binding identity, device slot or completion is faked. use super::{AdaptivePolicy, EXPERTS, Error, LAYERS, MoeWeightDescriptor, ProfileLimits, RankedProfile, Swap}; use sha2::{Digest, Sha256}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs index bcbb6a6a..0c647e11 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/cache_strata_adaptive/transfer_metadata_bound.rs @@ -1,5 +1,4 @@ -//! Functions: `transfer_metadata_bound`. -//! Split out of `cache_strata_adaptive` to keep its files under the line limit. +//! The host metadata bound of one adaptive round: the swap count times the size of a transfer record. use super::{ADAPT_SWAPS, Transfer}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs index 275f36da..95b7d66c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_cache_routed_owners.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `routed_output_owner`, `uses_mapped_expert_source`, `ephemeral_routed_owner`, `route... -//! Functions: `triplet_keys`, `adaptive_raw_triplet`. +//! The routed-expert owners of the MoE cache and the loans through them: output owner, ephemeral owner, resident +//! queue, CPU miss owner, and the Strata adaptive row observation, window completion and polling. The callbacks lend +//! whole triplet buffers read-only; no fill, poll or mutable cache access happens while a loan is held. use super::{ CachedMoeMatrix, Context, DeviceBuffer, Error, ModelBinding, MoeExpertSelection, MoeExpertWeights, MoeMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs index 85532e76..d9364c9a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `moe_cache_close_owners`, `moe_cache_compose_shared_and_mtp`, `moe_cache_lru_updates` and 7... -//! Split out of `moe_weight_cache` to keep its files under the line limit. +//! The `impl MoeWeightCache` blocks by responsibility: constructors, lookup, triplet and chunk admission, LRU +//! updates, shared and MTP composition, routed source fills, validation and teardown. Shared imports live here. use super::{ BoundExpert, CachedMoeMatrix, Cell, Context, Dense, DeviceBuffer, DeviceRef, EncodedWeight, Entry, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_close_owners.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_close_owners.rs index 2dafb974..29ab6b1b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_close_owners.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_close_owners.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `close_original_owners`, `close_original_owners`, `close_shared_owners`, `close_work... -//! Functions: `close_shared`. +//! Consuming teardown of the MoE cache: closes the Original owners, shared owners, workspaces and every encoded +//! weight in a fixed order, keeps the first error and counts an owner still held elsewhere as a failed close. use super::{Error, MoeWeightCache, Rc, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs index e2733f83..0a7d53cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_compose_shared_and_mtp.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `compose_target_shared_tail`, `compose_shared`, `compose_fixed_mtp_experts`, `admit_... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Composition of the closed device producers over cache-owned weights: target shared tail, the fixed MTP experts, +//! the MTP KV ring (prepare and attend) and MMQ assembly. Descriptors are admitted before any fill and every weight +//! stays borrowed until the producer's completion readback has consumed the result. use super::super::super::shared_expert_workspace::{SharedTailInputs, SharedTailKeys, WorkspaceOwner}; use super::moe_cache_lru_updates::shared_keys::{raw_shared_buffers, shared_descriptors}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates.rs index 2115c4ce..a0995b38 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `prepare_lru_updates`, `spill_updates`, `pinned_updates_allowed`, `commit_lru_update... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! LRU bookkeeping of the main tier (prepare, commit, eviction key, removal) and the lending of whole shared weights: +//! the native prefill resources and `with_native_shared_weights`. Shared weights are filled without evicting one +//! another and stay protected while lent. use super::{ Context, DeviceBuffer, EncodedWeight, Entry, Error, HashMap, LruIndex, ModelBinding, MoeExpertSelection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs index 4fc406e1..452f782d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_lru_updates/shared_keys.rs @@ -1,5 +1,5 @@ -//! The four shared-expert descriptors, their fill and their raw buffers: common to the native shared-weights loan and -//! the target shared tail. +//! The four shared-expert descriptors of a layer, their fill and their raw buffers: common to the native +//! shared-weights loan and the target shared tail. use super::{ DeviceBuffer, EncodedWeight, Entry, Error, HashMap, ModelBinding, MoeExpertSelection, MoeExpertWeights, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs index 2e5dcda7..22bfbc74 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_main_entry_routed_source.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `main_entry`, `main_entry_owned_gate_up`, `with_matrix_routed_source`, `source_healt... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Main-tier lookup and fill for routed expert matrices: the entries that hit or fill the cache, the loan of a cache +//! matrix to a closed routed-source consumer, and the adaptive slot matrix, which can never fill or evict. use super::{ CachedMoeMatrix, DeviceRef, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, ModelBinding, MoeMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs index 3db41975..e1beb533 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_matrix_and_mtp_lookup.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `matrix`, `shared_scalar`, `admit_mtp_input_workspace`, `mtp_input_workspace_support... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Read-side lookups of the MoE cache: a routed or shared matrix, the shared scalar, the MTP bank, matrix and F32 +//! rows, and the MTP input workspace admission and completion count. Lookups never fill or evict. use super::{ CachedMoeMatrix, Context, DeviceBuffer, Error, MTP_INPUT_WORKSPACE_BYTES, ModelBinding, MoeExpertSelection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_chunk_admission.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_chunk_admission.rs index ec011233..22bd5258 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_chunk_admission.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_chunk_admission.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `note_test_mmq_dispatch`, `mmq_context`, `weight_layout`, `has_original_prompt_mmq` ... -//! Functions: `admit_triplets`. +//! MMQ chunk admission and workspace access of the MoE cache: checks every triplet of a chunk against the kind +//! admission policy before quantization, cache fill or a gate/up kernel runs, and lends the MMQ workspace and the +//! three whole weights of a triplet. A refused triplet declines the whole chunk. use super::{ BoundExpert, Context, Error, MmqChunkAdmission, MmqChunkRequest, MmqFormat, MmqRoutingPolicy, MmqWeights, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs index de242680..038742ff 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_mmq_constructors.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail_profile_mtp_input_spill_floo... -//! Functions: `dense_f32_words`. +//! The base constructors of the MoE cache: the empty cache of one binding and context, the pinned MTP pack upload +//! (with or without its expert bank), and the MMQ, native MMQ and integer IQ3 variants with the retained MTP KV. use super::{ Cell, Context, Dense, Error, HashMap, MTP_DENSE_LIMIT, MTP_PACK_EXPERT_BANK_BYTES, MmqRoutingPolicy, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs index a9898858..32081b79 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_shared_tail_constructors.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `new_native_integer_iq3_mmq_retained_mtp_kv_shared_tail`, `new_native_integer_iq3_mm... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Constructors that add the target shared tail and the bounded LRU index to the MoE cache, plus the small +//! accessors the profile and adaptive builders use (pinned test, spill length, main reservation, request note). use super::{ Context, Error, LruIndex, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Rc, RefCell, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs index ca172969..7aaaadea 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_triplet_plan_upload.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `with_integer_mmq_triplet`, `triplet_fill`, `triplet_owners`, `triplet_admit` and 16... -//! Functions: `read_triplet`. Defines `TripletAccounting`, `TripletPlan`. +//! Triplet access to the MMQ weights: plans a gate/up/down request, fills only what is missing under room and slot +//! admission, uploads whole triplets and publishes them after driver completion with no fallible step after the +//! first insert. A full hit allocates and uploads nothing. use super::{ BoundExpert, EncodedWeight, Entry, Error, MmqFormat, MmqWeights, ModelBinding, MoeExpertSelection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs index 2518e367..71d4f5dd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/moe_weight_cache_methods/moe_cache_validate_prepare_step.rs @@ -1,5 +1,5 @@ -//! Methods of `MoeWeightCache`: `owners_failed`, `validate_original_owners`, `validate_original_owners`, `validate` ... -//! Split out of `moe_weight_cache_methods` to keep its files under the line limit. +//! Validation and per-step preparation of the MoE cache: binding, context and owner health checks, the transient MMQ +//! reserve, the room routine that evicts for a request while protecting lent entries, and plain device upload. use super::moe_cache_main_entry_routed_source::fill_fns::Room; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs index 761418b1..d795fedb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/dense_copies_equal.rs @@ -1,5 +1,6 @@ -//! Methods of `MoeWeightCache`: `share_rt_mtp_dense`, `share_entry`, `device_copies_equal`, `adopt_rt_buffer` and 2 ... -//! Functions: `dense_copies_equal`. +//! Merges the two device copies of the MTP dense roles on the RT-directory path: when both are read back and prove +//! byte-equal, the cache adopts the RT bank allocation and frees its own, so the model holds one copy. Also builds +//! the retained original MTP weights from the cache. use super::{ Cell, Context, Dense, Error, ModelBinding, MoeWeightCache, MtpDenseShare, MtpKind, MtpRole, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs index 60b5893e..15cd8597 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/original_mtp_weights/retained_original_mtp_weights.rs @@ -1,5 +1,6 @@ -//! Methods of `RetainedOriginalMtpWeights`: `from_rt_bank`, `rt_dense`, `rt_extras`, `dense_file_bytes` and 11 more. -//! Functions: `rt_kind`. Defines `HeadBinding`. +//! The model-lifetime MTP weights taken from the loaded RT bank: dense roles, extras and the expert bank, shared +//! by reference and checked against the role contract. Serves the scalar prefill graph weights and the full MTP +//! forward role order, choosing between the native head and the gathered draft-vocabulary head. use super::{ Context, DeviceBuffer, Error, FULL_FORWARD_ROLES, ModelBinding, MtpHeadSources, MtpKind, MtpRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs index 80a421cf..5b60dbfa 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_source_health.rs @@ -1,5 +1,5 @@ -//! Methods of `RoutedSourceHealth`: `validate`. -//! Methods of `MoeWeightCache`: `note_permanent_lookup`, `note_permanent_hit`, `note_permanent_fill`, `note_permanen... +//! Health check of the routed source (failed flag, poisoned context, binding identity) and the cache hooks that count +//! lookups, hits, fills and evictions of permanent-pool entries in the active pool (pinned or adaptive shared). use super::{Context, Error, ModelBinding, MoeWeightCache, MoeWeightDescriptor, Result, RoutedSourceHealth}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs index ff50ccfb..3d476cd2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/routed_workspace_owner.rs @@ -1,5 +1,6 @@ -//! Methods of `RoutedWorkspaceOwner`: `new`, `matches_context`, `is_failed`, `with_workspace` and 1 more. -//! Methods of `RoutedResidentOwner`: `new`, `matches_context`, `is_failed`, `with_queue` and 1 more. +//! The small device owners the routed expert path leases from the MoE cache: the routed group workspace, the resident +//! queue and the MTP input workspace. Each is created once per context, lent to one synchronous callback at a time, +//! marked failed on any execution error and released on close or drop. use super::{ BindingIdentity, Cell, Context, Error, MTP_INPUT_WORKSPACE_BYTES, MtpInputWorkspace, MtpInputWorkspaceOwner, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs index 0b123d07..3609cb77 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/moe_weight_cache/validate_ranked_profile.rs @@ -1,5 +1,6 @@ -//! Methods of `EncodedWeight`: `close`. -//! Methods of `RoutedFiniteOwner`: `new`, `matches_context`, `is_failed`, `check_stage` and 1 more. +//! Admission rules of the MoE cache: bounded validation of a ranked profile before the driver loads, the room +//! predicate, which descriptors get the padded dual MMQ layout (and the Original prompt formats), triplet shape +//! checks, and `RoutedFiniteOwner`, the guard that proves a routed stage output is finite. use super::{ Cell, Context, DeviceBuffer, EncodedWeight, Error, MAIN_LIMIT, MmqFormat, MoeWeightDescriptor, RefCell, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs index 2e987f06..82321638 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/mtp_frame.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpFrame`: `within_bounds`, `validate`, `token`, `position` and 1 more. -//! Methods of `MtpInput`: `from_previous`, `frame`, `streams`, `from_target` and 5 more. +//! The frame of one draft token and the input of a draft step: `MtpFrame` (which target position, token and depth a +//! draft branch stands on) and `MtpInput`, the pre-FC norms and the two Q8_0 matrices that turn the source residual +//! and the next-token embedding into the draft step input. Frames are valid only for the current target session and +//! epoch, so a reset or rewind invalidates every older one. No CPU forward arithmetic happens here. use super::{ Context, DeviceBuffer, Dimension, Error, KnownNext, ModelBinding, MoeWeightCache, MtpFrame, MtpInput, MtpKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs index 6c915119..53e5b7c6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/project_attention_out_numeric.rs @@ -1,5 +1,6 @@ -//! Functions: `project_gated`, `project_attention_out_numeric`. -//! Split out of `mtp` to keep its files under the line limit. +//! Output projection of the draft attention: the 6144 gated attention values to 2560 through the Q8_0 matrix. +//! It reads the retained gated device buffer directly, reserving the same output and quantizer room as the original +//! upload-based path. use super::{ Context, DenseFormat, DeviceBuffer, Error, ProjectionKind, ProjectionSpec, Result, allocate, download, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs index 6358a365..5c5a9210 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/checked_chunk_end.rs @@ -1,5 +1,7 @@ -//! Methods of `ValidatedWarmEnd`: `from_txn`. -//! Methods of `MtpSession`: `stage_chunk`, `stage_chunk_bound`, `stage_chunk_with_end`, `admit_chunk_start` and 2 more. +//! Staging of a draft chunk branch over an actual bounded target chunk: `MtpSession::stage_chunk` forks a private +//! candidate, and `MtpChunkStage` validates its anchor and lineage and publishes it once. The live draft stays +//! borrowed until the joint target and draft publication, so a failed chunk leaves it unchanged; also checks the +//! chunk end position against its limit. use super::{ Error, ModelBinding, MtpChunkStage, MtpSession, Position, QwenChunkTxn, QwenSession, Rc, Result, TargetStepOrigin, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs index 238c23cf..09ccd802 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/chunk/mtp_session.rs @@ -1,5 +1,5 @@ -//! Methods of `MtpSession`: `test_chunk_snapshot`, `test_chunk_eq`. -//! Split out of `chunk` to keep its files under the line limit. +//! Test-only numeric snapshot of a chunk-candidate draft session and its comparison, used to prove that a refused or +//! cancelled chunk left the draft bit-identical. #[cfg(all(test, target_arch = "x86_64"))] use super::MtpChunkNumericSnapshot; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs index cb8ca8f2..d00ef22e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/dense_kv.rs @@ -1,5 +1,6 @@ -//! Methods of `DenseKv`: `empty`, `append`, `ring_validate`, `ring_same` and 6 more. Functions: `validate_half`. -//! Split out of `state` to keep its files under the line limit. +//! Immutable dense draft K/V (`DenseKv`): append one cell for a frame, validate and compare the ring mirror, and read +//! the half-precision window of a frame. Cells are shared and never mutated; an append returns a new value, and every +//! cell is checked finite before it is admitted. use super::{ BindingIdentity, Cell, CellPair, DenseKv, Error, HALF_ROW, HalfWindow, MtpFrame, Rc, Result, WINDOW, Weak, reserve, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs index 7a891d2f..e7590f70 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/mtp_session.rs @@ -1,5 +1,6 @@ -//! Methods of `MtpSession`: `new`, `frame`, `prior`, `validate_frame` and 17 more. Functions: `seed_frame_foreign`. -//! Split out of `state` to keep its files under the line limit. +//! The draft session `MtpSession`: committed draft K/V, residual and position, and the frames and checkpoints derived +//! from them. Commit publishes only a fully produced pending K/V and residual; restore accepts only checkpoints of +//! this live lineage, including the closed first-seed restore that replaces a repeated warm. use super::{ Cell, DenseKv, Dimension, Error, ModelBinding, MtpCheckpoint, MtpFrame, MtpSession, Position, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs index 2ebf9e07..74f6aae7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/prefix_draft_snapshot.rs @@ -1,5 +1,6 @@ -//! Methods of `PrefixDraftSnapshot`: `has_prefix`, `numeric_eq`, `retained_bytes`. -//! Methods of `MtpSession`: `test_prefix_snapshot`, `admit_snapshot_owner`, `admit_snapshot_frame`. +//! Test-only snapshot of the draft state after a target prefix, with its numeric comparison and retained size, and +//! the admission checks of its owner and frame. Also keeps the live-checkpoint count honest: dropping an +//! `MtpCheckpoint` releases its slot against the cap. use super::{CellPair, Error, HALF_ROW, MtpCheckpoint, MtpFrame, Rc, Result}; #[cfg(all(test, target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs index 510c1d5e..a8ad2fe1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/state/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the draft state rules: first-seed restore keeps the real snapshot and rolls back to the original, a coupled +//! refusal never re-mints or mutates, ring operations need the exact parent epoch and branch, and a new pending +//! token, epoch or residual is refused atomically. Metadata and lineage only, not a CUDA or numerical proof. use super::{ BindingIdentity, Cell, CellPair, DenseKv, Dimension, Error, HALF_ROW, MtpCheckpoint, MtpFrame, MtpSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs index e71200c7..bfa66aa2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp/step.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpFinalMixed`: `from_native_mixer`, `frame`, `values`. -//! Functions: `step`, `warm_step`, `warm_chunk_row`, `run_blocks` and 12 more. Defines `MtpBlocks`. +//! One MTP draft step: attention read, draft attention, MLP read, experts, final mix, optional greedy head, then +//! commit of the draft state; also the norm and projection helpers the draft stages share. The known-next warm path +//! and the chunk-row path run it without a head; a chunk row commits only a private draft. Block products live until +//! the step is committed and synchronized; a teardown ambiguity stays sticky. use super::{ Bf16ProjectionShape, Cell, Context, DenseFormat, DeviceBuffer, Error, ModelBinding, MoeWeightCache, MtpChunkStage, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs index 8e7ede5c..7312adca 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_stage.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpAttentionReady`: `frame`, `output`, `streams`, `inject` and 2 more. -//! Methods of `MtpAttentionStage`: `run`. Implements `Drop for RetainedAttended`, `Drop for RetainedGated`. +//! The MTP draft attention stage: runs one dense draft attention row over the read of the source row and returns +//! `MtpAttentionReady`, which carries a pending K/V cell and never commits a draft position. Admits every pinned +//! descriptor before CUDA work, produces the K/V cell and Q and gate of the row, and owns the retained attended and +//! gated buffers until they are closed. use super::{ Cell, Context, DenseGeometry, DenseKv, DeviceBuffer, Error, KV, KvWindow, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs index f062d5d3..ff0c392f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/attention_transport.rs @@ -1,5 +1,6 @@ -//! Methods of `AttendBuffers`: `upload_window`, `attend`, `attend_ring`. Methods of `GateBuffers`: `apply`. -//! Functions: `release_transport`, `close_transport`, `note_transport`, `upload_transport` and 7 more. +//! Device transport of the draft attention: window upload, attend (with or without the actor's K/V ring), gate and +//! the release of every step-local buffer. Each buffer is released explicitly whatever failed; a failed launch or +//! release withholds the readback and flags the step transport as failed. use super::{ Cell, Context, DenseGeometry, DeviceBuffer, Error, KvWindow, Q, Rc, Result, RetainedAttended, RetainedGated, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs index 1923060f..09552f82 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/dense_geometry.rs @@ -1,5 +1,6 @@ -//! Functions: `geometry`, `validate_window`, `norm_rope_launch`, `norm_rope` and 6 more. -//! Split out of `mtp_attention` to keep its files under the line limit. +//! Geometry and launches of the dense draft attention: causal window shape for a position, the budget of its scratch, +//! norm and rope, K/V packing, query and gate split, the attend launch and the gate application. Windows are half- +//! precision cells checked against the geometry before any launch. use super::{ Context, DenseGeometry, DeviceBuffer, Error, HALF_CELL, KV, NormGamma, PackedKv, Q, QGate, Result, WINDOW, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs index 282b5669..8e0eb2e1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_attention/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the draft attention shape rules: the causal geometry and its budget boundaries, and the window shape, half +//! domains and preservation of caller buffers. use super::{Error, geometry, validate_window}; #[test] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs index 745ca460..ea9edd93 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded.rs @@ -1,5 +1,5 @@ -//! Defines `Shared`, `Refs`, `Chain` and 2 more. -//! Split out of `batch_gpu` to keep its files under the line limit. +//! State types of the loaded batched-MTP proof: the loan of the loaded stages, the reference tokens and snapshots, +//! the scalar chain and prefix, and the flow every phase runs on (GPU tests only). use super::{ Collection, DenseWeightCache, Dimension, Error, Expected, KarPleCache, ModelBinding, MoeWeightCache, MtpDecoder, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs index 91589bdb..7c605da8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow.rs @@ -1,5 +1,6 @@ -//! Methods of `Flow`: `step`, `warm`, `observe`, `matches_state` and 8 more. Defines `CancelledWindow`. -//! Split out of `check_loaded` to keep its files under the line limit. +//! Phases of the loaded batched-MTP proof: the scalar references, the candidate seed, refused windows and the +//! cancelled T3 publication. Each phase compares the batched window with the scalar reference on the same loaded +//! model and requires a cancelled window to leave the session state unchanged (GPU tests only). use super::{ Chain, Collection, Error, Expected, Flow, MoeWeightCache, MtpDecoder, MtpWindowError, MtpWindowSpec, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs index afa75bc8..375c452b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/flow_decode_edge_scenarios.rs @@ -1,5 +1,6 @@ -//! Methods of `Flow`: `eos_prefix`, `max_one`, `idle_window`, `no_advance`. Functions: `check_loaded`. -//! Split out of `check_loaded` to keep its files under the line limit. +//! Edge scenarios of the loaded batched-MTP proof and its entry point: an accepted prefix ending in EOS, a window +//! limited to one token (which exercises rewind and head-free catch-up), and windows with nothing to advance. A +//! window with zero remaining or an authoritative EOS must do no draft work and publish nothing (GPU tests only). use super::{ Chain, Collection, Expected, Flow, MoeWeightCache, MtpDecoder, MtpWindowSpec, QwenForward, Rc, Refs, Report, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs index 240090a4..199031fd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/check_loaded/position_at.rs @@ -1,5 +1,5 @@ -//! Methods of `Shared`: `step`, `window`. Methods of `Flow`: `open`. Functions: `position_at`, `admit_binding`. -//! Split out of `check_loaded` to keep its files under the line limit. +//! Shared loan of the loaded stages for the batched-MTP proof: scalar steps, window preparation and opening a flow. +//! Also the position helper and the host cap check for the snapshots and draft copies (GPU tests only). use super::{ Dimension, Flow, ModelBinding, MoeWeightCache, MtpDecoder, MtpVerifiedWindow, MtpWindowError, MtpWindowSpec, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs index a7e11f07..fee32aa3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/batch_gpu/collection.rs @@ -1,5 +1,6 @@ -//! Methods of `Collection`: `begin`, `finish`. Methods of `PostcommitCancellation`: `arm`, `cancelled`. -//! Implements `Drop for Collection`, `Drop for PostcommitCancellation`. +//! Row observation of the batched-MTP proof: a collector that records the head words, residual and state of up to +//! three rows while a window runs, and a post-commit cancellation trigger. Both are armed for one scope and cleared +//! on drop. Heads and state stay private; the report holds counts and predicates only (GPU tests only). use super::{ COLLECTOR, Collection, Collector, Dimension, Error, Expected, ModelBinding, OutputStage, POSTCOMMIT_CANCEL, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs index 723120dc..16afe095 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/first_seed_reuse_enabled.rs @@ -1,5 +1,7 @@ -//! Functions: `first_seed_reuse_enabled`, `needed_draft_predictions`, `window_limit`, `window_stage_error`. -//! Split out of `mtp_decode` to keep its files under the line limit. +//! Policy and bounds of an MTP decoder window: whether the first draft seed may be reused, how many draft predictions +//! a window needs, its position limit, and how a cancelled stage maps to a window error. Reuse is on only with the +//! adaptive expert policy and no numerical observer active. The seed already fills slot zero, so the bounds change +//! speculative work only; verification and accepted-prefix limits are unchanged. use super::{Error, MoeWeightCache, MtpWindowError, Result}; #[cfg(all(test, target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs index 678df959..5a7aa4a3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_decode/mtp_window_spec.rs @@ -1,5 +1,6 @@ -//! Methods of `MtpWindowSpec`: `new`. Methods of `MtpVerifiedWindow`: `tokens`, `draft_steps`, `into_parts`. -//! Implements `From for MtpWindowError`. Functions: `kv_prefill_host_charge`. +//! Request and result types of one verified MTP window: depth, remaining tokens and EOS of the spec, the window +//! error, and the verified tokens with the draft step count. Also holds the conservative host charge of the draft K/V +//! prefill of a prompt. use super::{Dimension, Error, MtpVerifiedWindow, MtpWindowError, MtpWindowSpec, Result, TargetStepProduct, TokenId}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs index 147bdac3..212fbe33 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/append_row.rs @@ -1,5 +1,5 @@ -//! Functions: `append_row`. -//! Split out of `mtp_experts` to keep its files under the line limit. +//! Splits one Q2_0 expert row into the separate scale and code planes of an `S2Tile`, byte for byte. +//! Each 18-byte block is a half-precision scale plus 16 code bytes; a non-finite scale is refused. use super::{Error, Result, S2Tile}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs index 6d833944..8fdecc7c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_buffers.rs @@ -1,5 +1,6 @@ -//! Methods of `FixedBuffers`: `new`, `check`, `take`, `put` and 1 more. -//! Methods of `MtpExpertWorkspace`: `new`, `compose`, `close`. Implements `Drop for FixedBuffers`. +//! Pre-allocated device buffers of the fixed-ABI draft MoE workspace (`FixedBuffers`) and its public owner +//! `MtpExpertWorkspace`. Buffers are taken for an invocation and put back after it; a failed context or a missing +//! buffer is refused, and every buffer is released on close or drop. use super::{ ALLOCATED_BYTES, BindingIdentity, CHARGES, Cell, Context, DEVICE_PEAK, DeviceBuffer, Error, ExpertInputs, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs index 08e23edf..378fdfa5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/fixed_workspace_gpu.rs @@ -1,4 +1,6 @@ -//! GPU proof of the fixed-ABI draft MoE workspace (moved out of mtp_expert_workspace.rs; test builds only). +//! GPU proof of the fixed-ABI draft MoE workspace (test builds only): repeated invocations over the leased buffers +//! match the reference bit for bit, and an abort, a late non-finite value, bad input or a failed flag is refused +//! cleanly. use super::super::mtp_expert_transport::{ExpertWeights, FixedReference, SelectedRoute, fixed_reference}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs index d2b727b2..44c02fc0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/role.rs @@ -1,5 +1,7 @@ -//! Methods of `Role`: `slot`, `output_slot`, `count`. -//! Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 11 more. +//! The roles of the fixed draft MoE workspace (which routed or shared stage a buffer serves, its slot and element +//! count) and the per-invocation `Transport` that leases buffers from it: upload, produce, finite readback, release. +//! Also runs the original FP32-scale quantizers, whose completed scales are inspected before any grouped dot uses +//! them. use super::{ Cell, DEVICE_PEAK, DeviceBuffer, Error, FF, Finite, FixedBuffers, N, Rc, Result, Role, Slot, Transport, at, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs index aca3f382..2c100937 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/fixed_workspace/transport_drop.rs @@ -1,5 +1,6 @@ -//! Methods of `Packed`: `new`, `pack`, `observe_packed`, `combine`. Methods of `Slot`: `bytes`. -//! Implements `Drop for Transport`. Functions: `at`, `routed_hidden`, `routed_down`, `routed` and 8 more. +//! Expert math of the fixed workspace transport: routed hidden and Down per expert, the shared expert (gate, up, +//! scaled by its scalar), the packed routed Downs and the final combine in router slot order. Also releases every +//! leased buffer when a transport drops; the first failure stops before any later expert runs. use super::{ CHARGES, Cell, DenseFormat, DeviceBuffer, Error, ExpertInputs, FF, Finite, FixedBuffers, K, N, Packed, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs index ed66185b..84481737 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_block.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpBlock`: `frame`, `output`. Methods of `MtpExpertStage`: `run`, `run_checked`. -//! Functions: `admit_input`, `route_mixed`, `compose_bound`, `moe_driver_error` and 1 more. +//! Entry of the draft MoE block: `MtpExpertStage::run` routes the mixed row and composes the routed and shared +//! experts into a pending `MtpBlock`. All fixed dense roles are admitted before the first model row or CUDA call. The +//! composed device products live only in the current frame-bound invocation, so none escapes to a later draft +//! position or rollback epoch. use super::mtp_expert_transport::SelectedRoute; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs index 020194da..e08d9cd4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/exact.rs @@ -1,5 +1,6 @@ -//! Methods of `Env`: `compare_observed`. Functions: `exact`, `bytes`, `fill_blob_part`, `bank_fixture` and 12 more. -//! Defines `SharedStage`. +//! Original reference chain and fixtures of the MTP expert transport proof (GPU tests only). +//! Builds a synthetic expert bank, runs each routed expert and the shared expert through the original stages with +//! every stage read back, and checks the retained transport matches that baseline bit for bit. use super::{ BANK_BYTES, BLOB_BYTES, Cell, Context, DenseFormat, DeviceBuffer, Env, Error, ExpertWeights, FF, IDS, N, Original, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs index 781050cf..7e3c7800 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/mtp_expert_transport_gpu/owner_guards.rs @@ -1,5 +1,6 @@ -//! Methods of `Env`: `private_owner_guards`. Functions: `gate_guards`, `slot_guards`. Defines `Count`. -//! Split out of `mtp_expert_transport_gpu` to keep its files under the line limit. +//! Owner guards of the MTP expert transport proof (GPU tests only): a released or foreign-invocation product is never +//! accepted by another transport, a Down of the wrong slot cannot be packed, and the packed destination cannot +//! combine early. use super::{ Cell, Context, DeviceBuffer, Env, Error, IDS, Packed, ROUTE, Role, RoutedExpert, Transport, refusal, routed, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs index 34d3c647..a9049856 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/role.rs @@ -1,5 +1,7 @@ -//! Methods of `Role`: `count`. Methods of `Transport`: `new`, `note`, `allocate`, `buffer` and 9 more. -//! Implements `Drop for Transport`. +//! The per-invocation `Transport` of the MTP expert stage: allocates, uploads, produces and reads back device buffers +//! for one invocation, plus the routed expert Down and hidden steps. A product is accepted only with its exact role +//! and current invocation owner; every buffer is released on close or drop, and the original quantizers run with +//! their scales inspected before any dot. use super::{ Cell, Context, DEVICE_PEAK, DeviceBuffer, Error, FF, Finite, K, N, Rc, Result, Role, Transport, download, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs index fe6cff1e..b6041e1a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/mtp_expert_transport/shared_project.rs @@ -1,5 +1,6 @@ -//! Methods of `Packed`: `new`, `pack`, `observe_packed`, `combine`. -//! Functions: `shared_project`, `shared_hidden`, `shared_down`, `shared_scaled` and 6 more. +//! Shared expert, packing and combine of the MTP expert transport: shared gate, up, hidden, down and scalar scaling, +//! the routed Downs packed in slot order, and the weighted combine. Entry points `compose` and `compose_observed` run +//! a whole block; the first failure stops before any later expert runs. use super::{ Cell, Context, DenseFormat, DeviceBuffer, Error, FF, Finite, K, N, Packed, ProjectionKind, ProjectionSpec, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/routed_and_shared_experts.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/routed_and_shared_experts.rs index f74804f5..24705c45 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/routed_and_shared_experts.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/routed_and_shared_experts.rs @@ -1,5 +1,6 @@ -//! Functions: `route`, `route_on_device`, `compose`, `routed_parts` and 9 more. Defines `MtpRoutingScope`. -//! Split out of `mtp_experts` to keep its files under the line limit. +//! Expert math of the MTP block on uploaded activations: route on the device, routed Gate/Up/hidden/Down parts, +//! shared expert, and the original ordered combine in router slot order. Also repacks Q2_0 expert rows into the +//! separate scale and code planes of `S2Tile`. use super::{ Context, DeviceBuffer, Error, FF, K, ModelBinding, MoeWeightCache, MtpRole, N, Result, S2Tile, allocate, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs index efae8aa1..7936f0e5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_experts/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the MTP expert adapter: gate/up and down tiles keep every byte label (signed-zero and subnormal scales +//! included), a bad shape or non-finite scale is refused, and a route with duplicate, out-of-range or bad weights is +//! refused. use super::{Error, K, down_tile, gate_up_tile, validate_route}; fn fixture(rows: usize, blocks: usize, salt: u8) -> Vec { diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs index fa00280e..4d16cc36 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/driver_error.rs @@ -1,5 +1,7 @@ -//! Methods of `MtpAttentionRead`: `frame`, `streams`, `mixed`, `inject`. -//! Methods of `MtpMlpReady`: `frame`, `streams`, `mixed`, `inject`. +//! The fused GR reads of the MTP draft step: `MtpAttentionRead` and `MtpMlpReady` (residual streams, mixed row and +//! injection) and the fused launches that produce them. Products are bound to their draft frame and never commit +//! target or draft state; the four dense matrices are admitted before the launch, and each completed component is +//! validated before the next entry consumes it. use super::{ Candidate, Context, Error, FUSED_PEAK, H, ModelBinding, MoeWeightCache, MtpAttentionRead, MtpAttentionReady, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs index cc458628..006fe3d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/mtp_gr/finalize.rs @@ -1,5 +1,7 @@ -//! Functions: `admit_final_inputs`, `finalize`, `finalize_checked`, `final_matrix` and 7 more. -//! Defines `FinalStageInputs`. +//! Final chain of the MTP draft step: the MTP block output and MLP streams are normalized, gated and injected into +//! the draft's final mixed row (`MtpDraftFinal`). Frame, finiteness and dense-shape admission precede any launch. The +//! legacy host-transfer chain stays as the numerical baseline that the retained chain is proved against, never as a +//! fallback. use super::{ Cell, Context, Error, FINAL_PEAK, H, ModelBinding, MoeWeightCache, MtpBlock, MtpDraftFinal, MtpFinalMixed, MtpKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs index 0532d79a..a166474c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/mtp_full_owner_actor_close.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalMtpFullOwner`: `validate`, `actor_mut`, `actor`, `close` and 1 more. -//! Implements `Drop for OriginalMtpFullOwner`. Functions: `driver_error`. +//! Access and teardown of `OriginalMtpFullOwner`: the validated, exclusive loan of its MTP actor, a read-only actor +//! view, and close. The actor drains its stream and closes the drafter before the retained weights it holds are +//! released, in the source order. No mutable ring reference escapes the owner, and drop closes best-effort. use super::{Context, Error, ModelBinding, OriginalMtpActor, OriginalMtpFullOwner, Result, Stage}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_full_owner_methods.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_full_owner_methods.rs index 9d85da25..245a2544 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_full_owner_methods.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_full_owner_methods.rs @@ -1,5 +1,7 @@ -//! Methods of `OriginalMtpFullOwner`: `bind_reserve`, `assemble_rt`, `assemble`, `assemble_core` and 5 more. -//! Split out of `original_mtp_full_owner` to keep its files under the line limit. +//! Assembly of the full MTP draft owner: the startup byte reserve, and the load from an RT directory or from the +//! pinned pack held by the MoE cache. Follows the source order: load meter and native head, checked plan, optional +//! draft head, shared drafter, then the actor that adopts drafter, ring and weights; a failed step closes everything +//! built so far. use super::{ AdoptParts, Context, DraftAttachmentTables, DraftAttachmentTarget, Error, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs index 98a2a695..c0dce4cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_full_owner/original_mtp_request.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalMtpRequest`: `ring_int8`. -//! Implements `From for OriginalMtpLoadError`, `From for OriginalMtpLoadError`. Functions: `plan_error`, `capture_of`. +//! The load request of the Original MTP drafter (`OriginalMtpRequest`, with the Original defaults of window 32768 and +//! the INT8 window-ring draft state) and the mapping of plan, driver and engine failures onto `OriginalMtpLoadError`. +//! Also builds the load capture (device, expert count, cells of the primary QSA state) the plan is checked against. use super::{ Context, Error, ModelBinding, OriginalMtpCapture, OriginalMtpKvStartup, OriginalMtpLoadError, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs index df7e03da..2c9fafe8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/driver_error.rs @@ -1,5 +1,6 @@ -//! Functions: `driver_error`. -//! Split out of `original_mtp_verified_adapter` to keep its files under the line limit. +//! Maps a CUDA driver error onto the engine error of the verified MTP adapter: a context mismatch is an identity +//! mismatch, size and shape errors are dimension errors, budget errors are allocation errors, anything else is a CUDA +//! execution failure. use super::Error; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs index f4ab3d3c..5c64e9a6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_mtp_draft_receipt.rs @@ -1,5 +1,7 @@ -//! Methods of `OriginalMtpDraftReceipt`: `ids`, `probabilities`, `count`, `first_position` and 2 more. -//! Methods of `OriginalVerifiedMtpReceipt`: `new`, `commit_origin_foreign`, `after_target_commit`. +//! Receipts that carry a verifier window into an MTP draft: the draft receipt (ids, probabilities, first position and +//! accepted row), the verified-window receipt before the target commit, and the published-window variant. A draft is +//! valid only while the real target prefix still equals the commit that produced it; skipped, extra or cross-branch +//! publication is refused before MTP capture. use super::{ Context, Error, ModelBinding, NativeHeadSelection, OriginalCommittedMtpReceipt, OriginalDraftSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs index 0d766959..b13408e2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_mtp_verified_adapter/original_prompt_executor.rs @@ -1,5 +1,7 @@ -//! Methods of `OriginalPromptExecutor`: `launch_committing_mtp`, `admit_launch`, `launch_origin`, `finish_committing... -//! Split out of `original_mtp_verified_adapter` to keep its files under the line limit. +//! The MTP drafting calls of `OriginalPromptExecutor` on a committed verifier window: launch the draft behind the +//! commit and finish it after the commit is published, the full draft, the first draft after the prompt, and the +//! draft sampling and history setters. Follows the source order verifier completion, target commit, draft; this +//! neither commits target state nor accepts tokens, and a draft is sealed into the receipt of the committed origin. use super::{ AcceptedWindow, CompletedOriginalMtpDraft, DraftLaunch, DraftTarget, Error, ModelBinding, MtpDraftOwners, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs index e2ecd974..e5a50f94 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_config/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the Mode17 values derived for the Original serve path: pack expert bank and footprint switches, blob sizes, +//! rope theta scale, MTP policies, sampler path flags, request parameter mapping and the geometry and prefill carve. use super::{ Error, ExpertBlobSizes, OriginalMtpGrVariant, RopeConstants, SamplerPath, driver_sampler_params, greedy_params, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs index e4d1fb4b..dece4ef9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `original_serve_engine_original_spec_engine`, `serve_engine_draft_commit`. -//! Split out of `original_serve_engine` to keep its files under the line limit. +//! The draft half of OriginalServeEngine: the commit-before-draft protocol (`serve_engine_draft_commit`) and the +//! OriginalSpecEngine face the speculative controller drives (`spec_engine_for_serve_engine`). use super::{ CommittedWindow, DraftCompletion, DraftLimits, DraftPick, DraftStage, Error, FirstStage, MAX_T, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs index 3889d20e..5f2ca3ee 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/draft_completion/serve_engine_draft_commit.rs @@ -1,5 +1,6 @@ -//! Methods of `DraftCompletion`: `validate`. Methods of `ServedWindow`: `rows`, `committed_rows`. -//! Implements `OriginalDraftEngine for OriginalServeEngine`. +//! OriginalServeEngine: constructor, window admission and checks, and the one-shot MTP draft (replay, seed, chain) +//! cached for the controller's callbacks, with commit enqueued before any draft reads the branch. +//! The engine only keeps the protocol discipline; every number comes from the `OriginalServePort` owners behind it. use super::{ CommittedWindow, DraftCompletion, DraftLimits, DraftPick, DraftStage, Error, FirstStage, MAX_T, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs index 5e5b0d8a..2e576a2b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally.rs @@ -1,5 +1,5 @@ -//! Defines `RoundTally`. -//! Split out of `original_serve_engine` to keep its files under the line limit. +//! RoundTally, the produced-token and round counters of one served request and why it stopped, with the submodules +//! that run the request: settings, the round loop and the first-draft stage. use super::{ ADAPTIVE_DEFAULT, AdaptiveConfig, CommittedWindow, DraftCompletion, DraftLimits, DraftPick, DraftStage, EnvSource, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs index 3750c636..a9325d3c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/original_serve_settings.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalServeSettings`: `mode17`, `from_environment`, `adaptive_wanted`, `arms_from_environment` and ... -//! Methods of `SpeculativeRequest`: `from_request`. Functions: `serve_request`. +//! OriginalServeSettings: the speculative window policy of a served request (mode17 defaults, `LELEKA_SPEC_*` and +//! `LELEKA_SPEC_ARMS` overrides, adaptive or fixed window, window cap), and `serve_request`, the per-request loop. +//! The loop runs begin, verify/commit, emit, finish round until the request stops; `emit` runs only after the commit. use super::{ ADAPTIVE_DEFAULT, AdaptiveConfig, EnvSource, MAX_T, NanGuard, OriginalServeSettings, OriginalSpecController, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs index 532074f8..78498f83 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/round_tally/serve_rounds.rs @@ -1,5 +1,6 @@ -//! Implements `OriginalServePort for TracePort`. Functions: `serve_rounds`, `serve_round`, `tr_port`. -//! Split out of `round_tally` to keep its files under the line limit. +//! The round loop of a served request (`serve_rounds`, `serve_round`: verify and commit, emit, finish) and the +//! timing wrappers that trace each port call under the bring-up trace (`TracePort`, `tr_port`). +//! A failed emit still finishes its round (drain and join) before the error is reported. use super::{ CommittedWindow, DraftCompletion, DraftLimits, FirstDraftSeed, OriginalServePort, OriginalSpecController, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs index 6494bad2..9b31660b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Test world of the serve engine: a scripted port (`Fake`) with an event log and a deterministic model, and the +//! helpers that drive a request through the engine and the controller. The scenarios sit in the submodules. use super::super::original_spec_controller::{NanGuard, OriginalSpecController, SpecConfig, SpecError, SpecWindow}; use super::super::original_spec_draft::{DraftPreparation, DraftSampling, VerifiedWindow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs index 7db09501..905ca612 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/constructor_validates_dimensions.rs @@ -1,6 +1,5 @@ -//! Tests of `tests` by topic: constructor_validates_dimensions, -//! verify_returns_all_t_outputs_and_requires_a_drained_window, out_of_range_tokens_never_reach_the_port, -//! a_short_or_invalid_window_is_drained_not_leaked .... +//! Pins the engine's admission rules: constructor dimension checks, a verify returning all T outputs only over a +//! drained window, out-of-range tokens never reaching the port, and short or invalid windows drained, not leaked. use super::{ Error, Fake, OriginalDraftEngine, OriginalServeEngine, OriginalSpecEngine, VOCAB, engine, events, idx, model, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs index a2834156..098dc35b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_engine/tests/restore_attempts_do_not_depend.rs @@ -1,7 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! restore_attempts_do_not_depend_on_engine_health_and_reset_draft_state, -//! a_refused_window_is_taken_back_only_after_it_drained_and_a_failed_take_back_poisons, -//! first_draft_path_is_cached_and_drains, controller_over_the_engine_emits_the_greedy_continuation .... +//! Pins restore and draft behaviour: restore attempts independent of engine health, a refused window taken back only +//! after it drained (a failed take-back poisons), the cached first-draft path and the greedy end-to-end continuation. use super::{ ADAPTIVE_DEFAULT, AdaptiveConfig, DraftPreparation, DraftSampling, Error, Fake, OriginalDraftEngine, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs index 9dce20ea..b960bfb6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/original_serve_host_native_serve_host.rs @@ -1,5 +1,5 @@ -//! Implements `NativeServeHost for OriginalServeHost`. -//! Split out of `original_serve_host` to keep its files under the line limit. +//! The `NativeServeHost` face of OriginalServeHost: lineage checkpoints and restores, the verified-window run, commit +//! and publication, the adaptive swaps around the commit, and the MTP draft launch and drain, in generate.cpp order. use super::{ AcceptedWindow, DraftCompletion, DraftLaunch, Error, LedgerCheckpoint, MtpDraftOwners, NativeServeHost, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs index 7ca6ca10..29434adb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/request_sampling.rs @@ -1,5 +1,6 @@ -//! Methods of `RequestSampling`: `new`, `enabled`. -//! Methods of `OriginalServeHost`: `new`, `from_owners`, `position`, `settle_state` and 10 more. +//! The state OriginalServeHost carries for one request: sampling setup (`RequestSampling`), construction from the +//! session owners, the position and token lineage it ends on, and the settle of the recurrent GDN and PLE priors. +//! Also the A/B switches of the publication (`LELEKA_SERVE_PUBLISH`, `LELEKA_SERVE_ADAPT_DEFER`) and the draft cap. use super::{ BoundLayerKind, DraftCompletion, Error, GdnPrior, HostOutcome, HostOwners, OriginalNativeHeadGraphResources, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs index 10f5d4b7..f3fac337 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_host/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the host's request setup: a greedy request without penalties keeps the plain argmax head, invalid sampler +//! parameters are refused before any window, and the host outcome carries the four things the stack decides on. use super::{HostOutcome, RequestSampling, SamplerParams, SamplerPath}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs index 642e2022..f8c0d336 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_serve_port_original_serve_port.rs @@ -1,5 +1,5 @@ -//! Implements `OriginalServePort for NativeServePort`. Functions: `start_foreign`, `check_completed`. -//! Split out of `original_serve_native` to keep its files under the line limit. +//! The `OriginalServePort` face of NativeServePort: every port call mapped onto the driver Verifier and the host +//! owners, with the driver's own window receipt as the authority for what ran and what may be committed. use super::{ CommittedWindow, DraftCompletion, DraftLimits, Error, FirstDraftSeed, NativeServeHost, NativeServePort, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs index 1c4c78e9..8c7bb2cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_native/native_window.rs @@ -1,5 +1,6 @@ -//! Methods of `NativeWindow`: `generation`. -//! Methods of `NativeServePort`: `new`, `verifier`, `verifier_mut`, `host` and 13 more. +//! NativeServePort's window life cycle: commit wait and publication of the accepted prefix to the session, receipt +//! admission, and the overlapped or serialized draft launched behind the commit event. +//! Also the bring-up traces of windows and drafts and the `LELEKA_SERVE_OVERLAP` A/B switch. use super::{ DraftCompletion, DraftLimits, Error, NativeCommittedWindow, NativeServeHost, NativeServePort, NativeWindow, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs index cf28cdb8..1576ca38 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/cpu_expert_pool.rs @@ -1,5 +1,6 @@ -//! Methods of `CpuExpertPool`: `run_entries`, `admit_rows`, `plan_group`, `run_direct` and 6 more. -//! Functions: `legacy_batch`, `prepare_legacy_jobs`, `validate_legacy_job`, `compare_rows` and 1 more. +//! CpuExpertPool: computing one group of routed experts on the CPU (admission of the rows, planning, the direct +//! dispatch and the legacy per-expert batches) and writing every slot of the mapped sink, zeros for entries it skips. +//! The legacy path re-validates each finished job against a re-opened source and can be compared bit for bit. use super::{ BATCH_ALLOWANCE, ComputeSample, CpuExpertPool, CpuMissWorkspace, Error, ExpertJob, GroupTraceInfo, GroupWork, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs index b6c812aa..75545922 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier.rs @@ -1,5 +1,6 @@ -//! Methods of `DirectTier`: `admit_all`, `start_lookahead`, `layer_layout`, `index` and 7 more. -//! Methods of `CpuExpertPool`: `new`, `with_path`. Implements `OriginalServePool for CpuExpertPool`. +//! DirectTier: the direct CPU path's expert admission, i.e. opening a layer group's experts under one source fence, +//! checking their gate/up/down spans and caching them so later groups pay nothing; and the pool constructors. +//! Eager admission at stack open takes the first-use cost out of the first decode. use super::{ ComputeSample, CpuExpertPool, CpuMissWorkspace, CrosscheckCounts, DirectCpuPool, DirectTier, EXPERTS, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs index d51d6204..6d09ea6a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/direct_tier_drop.rs @@ -1,5 +1,5 @@ -//! Implements `Drop for DirectTier`. Functions: `admit_eager`, `sink_result`, `native_cpu_error`, `selection`. -//! Split out of `original_serve_pool` to keep its files under the line limit. +//! Closing of the direct tier (its Drop) and the small helpers of the direct path: the `LELEKA_CPU_ADMIT_EAGER` +//! switch, sink-write result mapping, native CPU error mapping and the per-row top-k selection check. use super::{DirectTier, Error, Result, TOP_K}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs index fa1e207c..9c22108b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/prefetch_off_file_exists.rs @@ -1,5 +1,6 @@ -//! Methods of `PoolPath`: `from_env`. -//! Functions: `prefetch_off_file_exists`, `plan_experts`, `plan_experts_where`, `plan_row` and 7 more. +//! Planning of a CPU expert group and the per-job source checks: router ids grouped by expert in first-use order, +//! scatter of one expert's rows into the group output, and open/admit of an expert's matrices (`open_job`). +//! Also the `LELEKA_CPU_PREFETCH_OFF_FILE` bring-up switch that skips the page-touch pass. use super::{ EXPERTS, Error, ExpertJob, HIDDEN, ModelBinding, MoeMatrixRole, MoeRoutedSourceScope, Opened, PoolPath, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs index 790b9fd9..c5350e6b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_pool/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the expert group plan: every (row, slot) pair planned once with experts in first-use order, masked GPU +//! entries left out but still validated, bad router output refused, and scatter offsets of each output slot. use super::{Error, ExpertJob, HIDDEN, TOP_K, output_offset, plan_experts_where, scatter, selection}; #[cfg(test)] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs index e0b02ba8..64e81f0b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_request/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of `original_serve_request`. +//! Pins the request flow of the serve layer: the stop set, reset and resume rules for fresh, used and resumed +//! stacks, admission as in generate.cpp, untouched owners on refusal, error classes and emit failure handling. use super::super::original_serve_engine::ServeStop; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs index 7eb4931e..0f0b7f46 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/source_spans.rs @@ -1,5 +1,5 @@ -//! Methods of `GpuExpertPool`: `admit_group`, `note_usage`, `split_group`, `current_pcie_num` and 7 more. -//! Implements `OriginalServePool for GpuExpertPool`. +//! GpuExpertPool as an `OriginalServePool`: runs a window group (split into VRAM, PCIe and CPU shares, plan published +//! before the CPU starts), applies and begins the adaptive swaps, and fetches the source spans of PCIe experts. use super::{ CpuExpertPool, EXPERTS, Error, GpuExpertPool, GroupSplit, LAYERS, MappedExpertBank, ModelBinding, MoeWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/span_cache_and_pcie_lag.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/span_cache_and_pcie_lag.rs index 0ee82e2a..9087401f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/span_cache_and_pcie_lag.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/span_cache_and_pcie_lag.rs @@ -1,5 +1,5 @@ -//! Methods of `SpanCache`: `key`, `get`, `contains`, `insert`. -//! Methods of `PcieLag`: `from_environment`, `pcie_num`, `measure`, `round`. Implements `Debug for SpanCache`. +//! Small stateful helpers of the VRAM expert tier: the span cache of bank spans per (layer, expert), the PCIe share +//! controllers (`PcieLag` from copy lateness, `PcieAuto`) and ResidencyState (usage counts, round marks). use super::{ EXPERTS, ExpertTierConfig, GpuExpertPool, LAYERS, PcieAuto, PcieLag, ResidencyState, ResidencyStats, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs index 1c6688b9..b390084a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/split_group_pcie.rs @@ -1,5 +1,6 @@ -//! Methods of `RoutedGroup`: `new`. Methods of `PcieShare`: `takes`. -//! Functions: `split_group_pcie`, `is_valid_expert`, `is_miss`, `group_firsts` and 14 more. +//! The window split of one expert group: distinct experts in routing order become VRAM groups, the last eligible +//! misses up to the PCIe share go over PCIe, the rest stay with the CPU, with the route tail skip applied first. +//! Pure planning over ids and residency; it touches no device and no source. use super::{ ADAPT_DECAY_DEFAULT, EXPERTS, Error, GroupSplit, LAYERS, MAX_WINDOW_ENTRIES, ORIGINAL_VERIFY_MAX_PCIE_FETCHES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs index 594a7c04..0124f481 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tail_skip_rank.rs @@ -1,5 +1,5 @@ -//! Methods of `PcieMode`: `graph_mode`. -//! Methods of `ExpertTierConfig`: `decode_headroom_mib`, `off`, `enabled`, `effective_slots` and 14 more. +//! Configuration of the VRAM expert tier: ExpertTierConfig (slots, reserves, PCIe share and mode, adaptation, seed; +//! defaults, validation, `LELEKA_ORIGINAL_SERVE_*` switches) and the route tail-skip rank of a decode phase. use super::{ AtomicU32, EXPERTS, EnvSource, Error, ExpertTierConfig, GroupSplit, LAYERS, Ordering, OriginalExpertCache, PathBuf, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs index 0fc54c52..a6556578 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_residency/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the expert tier rules: reserves and decode headroom, the selection-based swap ranking, the window split +//! (residents, PCIe share, tail skip, invalid ids), the lag controller, the PCIe mode and the off-by-default config. use super::{ EXPERTS, ExpertTierConfig, GroupSplit, LAYERS, PcieLag, PcieMode, PcieSplitPolicy, ResidencyState, RoutedGroup, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs index 20f401d6..e7617ff2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/conversation/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the serve conversation policy over a fake stack: a continuing request resumes at its last turn, a settled +//! session continues live, cancel and failure keep or drop checkpoints, the chain is bounded and reread mode works. use super::{ConversationConfig, Error, PromptOptions, RequestStart, ResumeDevice, ServeConversation, TURN_TOKEN}; use crate::backend::original_prompt::{PlanLimits, PromptPath, PromptPlan, ResumePoint}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs index f154bb10..ad4b52a8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_device_ports.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `settle_lent_refills`, `report_tier_request`, `pcie_num_for_report`, `report_req... -//! Implements `PrefixDevice for OriginalServeStack`, `RequestOwners for OriginalServeStack` and 1 more. +//! The ports OriginalServeStack implements for its callers: the prefix cache's device side (`PrefixDevice`), the +//! request flow (`RequestOwners`) and the serve device (`ServeDevice`), plus lent-slot refill and tier reports. use super::{ Clock, Error, OriginalServeStack, PARKED_BYTES_PER_TOKEN, PARKED_STATE_ESTIMATE, ParkedBlock, PrefixDevice, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs index d9fda73c..ec4ba579 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `decode_phase`. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! OriginalServeStack::decode_phase: hands the twelve QSA owners to a fresh verifier and runs the request's decode. +//! The steps and the read-only view of the phase are in the submodules `decode_steps` and `decode_view`. use super::{ AssembleFailure, AssembleInputs, Began, Context, CpuExpertPool, DecodeGraphKey, DecodeResources, DenseWeightCache, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs index e31a0eb7..988db864 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_steps.rs @@ -1,6 +1,5 @@ -//! The phases of `OriginalServeStack::decode_phase` (STRA-338 size4): the request's start, the assembly of the verifier -//! window, the settlement of its outcome and the serve step. The order of the operations, the error paths and the -//! log lines are those of the single function they were taken from. +//! The phases of `OriginalServeStack::decode_phase`: the request's start, the assembly of the verifier window, the +//! settlement of its outcome and the serve step. Operation order, error paths and log lines are the decode's own. use super::decode_view::{Book, DecodeView, Extra, Ids, Owners, Policy, Reads, Refill, Tier}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs index 9976d2aa..e5a9ea72 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_decode_phase/decode_view.rs @@ -1,4 +1,4 @@ -//! The stack's fields a decode works on, borrowed one by one and grouped by who reads or writes them (STRA-338 size4). +//! The stack's fields a decode works on, borrowed one by one and grouped by who reads or writes them. //! The stack's own layout is flat and the verifier window resources of an assembly borrow its caches for the whole //! phase, so the phases cannot be `&mut self` methods of the stack; each phase is a method of this view instead. diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs index 09005434..0365def4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_memory_classes.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `health`, `serve`, `apply_memory_directive`, `note_memory` and 23 more. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! Request-level surface of OriginalServeStack: stack health, `serve`, following the memory governor between +//! requests, registering allocation classes with the memory inventory, and the speculative window arms. use super::{ Error, ExpertTierConfig, OriginalServeStack, PLE_HISTORY_BYTES, PLE_SCRATCH_BYTES, PrefixMatch, PrefixSummary, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs index f35e044a..fccfed7f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_metrics_close.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `prefix_metrics`, `prefix_bytes`, `prefix_budget_bytes`, `retire_held` and 2 more. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! Prefix cache metrics of OriginalServeStack, retirement of kept decode graphs, closing of every owner in dependency +//! order (the first failure is reported after all were attempted) and marking the stack broken. use super::{Error, ModelBinding, OriginalServeStack, Result, retire_kept}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs index ddfd5a34..4f578b87 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `open`. -//! Split out of `original_serve_stack_methods` to keep its files under the line limit. +//! OriginalServeStack::open: the generate.cpp start-up over the model binding (embedding, native head, dense weights, +//! MoE cache, session, prompt executor with MTP drafter, prefill arena, per-request stages). use super::{ Context, CpuExpertPool, DenseWeightCache, DeviceRef, Error, ExecutorOpening, ExpertBlobSizes, GraphReuse, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs index 5804f06a..762f9f38 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/assemble.rs @@ -1,5 +1,5 @@ -//! The start and the end of `OriginalServeStack::open`, moved out of it by STRA-338 (size): the config-derived values -//! computed before any allocation and the final assembly of the stack from the opened parts. +//! The two ends of `OriginalServeStack::open`: the config-derived values computed before any allocation and the +//! final assembly of the stack from the opened parts. use super::open_phases::{Buffers, Core, TierParts}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs index 6c212676..365fc7cf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_open/open_phases.rs @@ -1,5 +1,5 @@ -//! Phases of `OriginalServeStack::open`, moved out of it by STRA-338 (size): each helper runs one step of the startup -//! in the order `open` called it, with the same stage marks, notes and error context. +//! The steps of `OriginalServeStack::open`: each helper runs one step of the start-up in order, with its stage +//! marks, notes and error context. use super::{ Context, CpuExpertPool, DenseWeightCache, DeviceRef, ExecutorOpening, KarPleCache, LoanTier, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs index 7ea70044..3396e3c5 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_chunk.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `prefill_chunk`, `prefix_after_prefill`, `prefix_after_decode`, `prefix_after_re... -//! Functions: `report_decode_tail`, `lend_tail`. +//! One published prompt chunk of OriginalServeStack (with or without a loan of the expert cache's last slots) and +//! the prefix and conversation checkpoints taken after a chunk, at the end of prefill and of decode, or on a cancel. use super::{ ChunkOutcome, Error, OriginalExpertCache, OriginalPrefillArena, OriginalPromptInput, OriginalServeStack, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs index 701296b1..c8818d05 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/original_serve_stack_methods/original_serve_stack_prefill_phase.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalServeStack`: `prefill_phase`, `refill_deferred`, `begin_prefill`, `refill_after_read` and 8 m... -//! Functions: `trace_action`, `seed_rows_capped`, `trace_seed_report`, `coverage_by_layer`. +//! The prefill phase of OriginalServeStack: conditions prompt[resume..n-1] chunk by chunk, refills lent expert +//! slots, seeds the expert tier from the prompt's routing and sets up the MTP actor and prompt options. use super::{ Clock, Error, ModelBinding, OriginalPromptInput, OriginalServeStack, PlanLimits, PromptOptions, PromptPath, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs index 20d4ac6d..a293cd40 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_config.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixConfig`: `auto`, `validate`, `resolved_block`, `resolve_budget`. -//! Functions: `admission_reading`, `lcp`. +//! PrefixConfig: auto defaults, validation, block size and host byte budget of the cross-session prefix cache, +//! and the memory reading a checkpoint is admitted against (re-judged once after the governor trims pages). use super::{Error, PolicyParams, PrefixBudget, PrefixConfig, TailMode, budget}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs index ce52860e..ed353f1a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `prefix_serve_after_phase_parking`, `prefix_serve_store_and_shedding`. -//! Split out of `prefix` to keep its files under the line limit. +//! PrefixServe: the per-stack prefix cache policy, split into its store, clock and shedding side and the side that +//! plans, parks and imports checkpoints around the prefill and decode phases. use super::{ AnyClock, ByteSize, ChunkOutcome, Clock, Consider, Error, PendingTail, PrefixConfig, PrefixDevice, PrefixMatch, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs index 241c511c..99378cda 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_after_phase_parking.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixServe`: `after_chunk`, `plan_chunk`, `park_chunk`, `park_missing` and 16 more. Defines `Point`. -//! Split out of `prefix_serve` to keep its files under the line limit. +//! The checkpoint side of PrefixServe: after a published chunk, at the end of prefill and of decode (or deferred +//! until after the response) it plans, parks and admits a checkpoint; a failure costs the cache, never the request. use super::{ ByteSize, ChunkOutcome, Clock, Consider, Error, PendingTail, PrefixDevice, PrefixServe, PrefixStore, TailMode, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_store_and_shedding.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_store_and_shedding.rs index 0112cd61..3710ff9f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_store_and_shedding.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/prefix_serve/prefix_serve_store_and_shedding.rs @@ -1,5 +1,5 @@ -//! Methods of `PrefixServe`: `new`, `new_store`, `with_clock`, `wall_ms` and 23 more. Defines `ImportPlan`. -//! Split out of `prefix_serve` to keep its files under the line limit. +//! The store side of PrefixServe: construction over a namespace and clock, shedding to the memory governor's +//! directive, bypass mode, and read-only accessors (bytes, budget, nodes, blocks, summary, `prefix_match`). use super::{ AnyClock, ByteSize, Clock, Error, PrefixConfig, PrefixDevice, PrefixMatch, PrefixServe, PrefixStore, PrefixSummary, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs index bc5792ca..f59a1559 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Test fixture of the stack prefix cache: a fake device with parked state and blocks, prompt and session generators +//! and helpers that drive a request through `PrefixServe` (begin, read chunks, turn). The scenarios are submodules. use super::{ByteSize, ChunkOutcome, Error, PrefixBudget, PrefixConfig, PrefixDevice, PrefixServe, Start, TailMode}; use crate::backend::original_prompt::{PlanLimits, PromptOptions, PromptPath, PromptPlan, ResumePoint}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs index d3a8198e..cd9568f1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/one_token_prompt_reads.rs @@ -1,8 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_one_token_prompt_reads_nothing_and_claims_nothing, -//! a_failed_import_is_an_error_for_the_caller_and_invalidate_forgets_everything, -//! the_budget_bounds_the_store_and_the_newest_frontier_survives, -//! a_memory_shed_evicts_to_the_target_and_the_configured_budget_comes_back .... +//! Pins the prefix cache edge cases: a one-token prompt reads and claims nothing, a failed import is the caller's +//! error and invalidate forgets everything, the budget bounds the store, and a memory shed evicts then restores. use super::{ Block, ChunkOutcome, Fake, G, PrefixBudget, PrefixConfig, PrefixServe, State, cfg, doc, full_digest, governor, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs index c1c82681..a21acf45 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prefix/tests/second_session.rs @@ -1,8 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_second_session_with_the_same_system_prompt_resumes_from_the_shared_blocks_and_ends_in_the_full_reads_state, -//! interleaved_sessions_each_resume_from_their_own_deepest_checkpoint, -//! a_miss_resets_the_owners_so_nothing_is_claimed_even_if_the_request_is_cancelled_before_its_first_chunk, -//! a_checkpoint_at_the_end_of_the_prefill_lets_the_next_turn_resume_at_the_exact_position .... +//! Pins prefix reuse across sessions: a second session with the same system prompt resumes from the shared blocks, +//! interleaved sessions use their own deepest checkpoint, a miss resets the owners, a turn resumes at its exact end. use super::{ Block, Fake, G, PrefixServe, State, TailMode, cfg, doc, full_digest, request, serve, session, tail_serve, turn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs index 01bc1ede..9a58c1fe 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/prompt_chunk.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptChunk`: `run`. Methods of `OriginalServeStack`: `prefix_resume`, `prefix_begin`. -//! Implements `ResumeDevice for OriginalServeStack`. +//! PromptChunk::run (one prefill forward over a chunk, then publication), the conversation cache's device side +//! (`ResumeDevice`) over the stack owners, and the bring-up notes (VRAM ledger, kernel selection, logs). use super::{ ChunkCaches, ChunkDraft, Context, DBG_T0, Error, OriginalPrefillArena, OriginalServeStack, PrefixServe, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config_and_ttft_marks.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config_and_ttft_marks.rs index 04758a9b..a95c73bc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config_and_ttft_marks.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_config_and_ttft_marks.rs @@ -1,5 +1,5 @@ -//! Methods of `TtftMarks`: `start`, `since`, `note_first_round`, `as_array`. -//! Methods of `StackConfig`: `new`, `kv_footprint`, `capacity_invalid`, `context_invalid` and 1 more. +//! StackConfig (defaults, KV footprint, capacity and context validation), TtftMarks (the time-to-first-token marks of +//! a request), the prefill loan ladder helpers and the byte sizes of parked stack state and blocks. use super::{ ADMITTED_CAPACITIES, AnyClock, ByteSize, CPU_WORKERS, Clock, ConversationConfig, DEFAULT_CAPACITY, Error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs index 67232669..e1df5ea1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/stack_groups.rs @@ -1,5 +1,5 @@ -//! Groups of cohesive plain-data fields of `OriginalServeStack`, moved out of it by STRA-338 (size). None owns a -//! device resource; each is declared at the position of its first member, so the stack's drop order is unchanged. +//! Groups of cohesive plain-data fields of `OriginalServeStack`. None owns a device resource; each is declared at +//! the position of its first member, so the stack's drop order is unchanged. use super::{ Error, ExpertBlobSizes, LoanTier, OriginalMtpFullPolicy, OriginalMtpScalarPolicy, OriginalServeSettings, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs index f2a4bbe0..8031996a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_stack/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the stack configuration rules: chunk loans take the smallest rung that holds them, the default chunk is an +//! admitted capacity, the conversation cache is on by default, KV defaults to INT8 and plan errors keep their class. use super::{ ADMITTED_CAPACITIES, Error, ExpertBlobSizes, KvFormat, LoanTier, PlanError, PrefillLayoutOptions, StackConfig, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs index cba5d972..83742994 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_serve_verifier/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the verifier assembly fallback: a graph out-of-memory names the widest window worth recording, assembly is +//! retried with narrower windows until one fits, any other failure stops at once, and the PLE image has nine slots. use super::{ Error, PLE_HISTORY_BYTES, PLE_HISTORY_VALUES, ServeFailure, Stage, assemble_with_window_fallback, window_cap_after, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs index e96db58b..e48c9f7c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_finish.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalSpecController`: `finish_round`, `finish_request`. -//! Split out of `original_spec_controller` to keep its files under the line limit. +//! The end of a speculative round and of a request: `finish_round` runs after the committed tokens were emitted +//! (drafts the next window, joins adaptive work, drains the verified owner) and `finish_request` waits the last +//! commit. EOS and length skip drafting; a later draft error never un-commits what was already emitted. use super::{ CommittedRound, DraftBatch, Error, OriginalSpecController, OriginalSpecEngine, Result, RoundFacts, SpecResult, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_start_request.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_start_request.rs index 5aacf40b..a005843f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_start_request.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_start_request.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalSpecController`: `planned_host_bytes`, `new`, `set_final_draft`, `begin_request` and 11 more. -//! Split out of `original_spec_controller_methods` to keep its files under the line limit. +//! Start of a request for OriginalSpecController: construction and host byte accounting, `begin_request` (precharge +//! of all append capacity, reset of the suffix state per request), read-only views, round stats and `abort`. Window +//! policy and the adaptive cadence survive across requests; the prompt history does not. use super::{ AdaptivePolicy, DraftBatch, DraftPolicy, Error, MAX_T, OriginalSpecController, OriginalSpecEngine, PrefixMemo, Rc, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_verify_commit.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_verify_commit.rs index 249028bf..4fa13d01 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_verify_commit.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/original_spec_controller_methods/original_spec_controller_verify_commit.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalSpecController`: `verify_commit`. -//! Split out of `original_spec_controller_methods` to keep its files under the line limit. +//! `OriginalSpecController::verify_commit`: one round entry point, the verify half then the commit half, with the +//! steps in `verify_round_steps` and `commit_round_steps`. use super::{CommittedRound, Error, OriginalSpecController, OriginalSpecEngine, Round, SpecResult, window_inputs}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs index d1b8c306..4b26e395 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Test world of the speculative controller: a scripted engine (`Fake`) with a deterministic model and fault trips, +//! and helpers that drive requests through the controller. The scenarios are submodules and the golden transcripts. use super::super::original_spec_draft::{DraftPick, FirstSeedPoint, OriginalFirstDraftEngine, TargetSeedRow}; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs index 85ce291a..dd7a8672 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/adaptation_join_failure_is_reported.rs @@ -1,7 +1,5 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! adaptation_join_failure_is_reported_even_after_a_good_draft, -//! finish_round_refuses_a_receipt_from_another_controller, a_request_cannot_restart_while_a_draft_is_pending, -//! policy_and_adaptive_cadence_survive_across_requests .... +//! Pins round bookkeeping: a failed adaptation join is reported even after a good draft, a receipt from another +//! controller is refused, a request cannot restart with a draft pending, and policy and cadence survive requests. use super::{ DraftPick, DraftPreparation, DraftSampling, Error, Fake, FirstSeedPoint, OriginalFirstDraftEngine, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs index 59862f8f..d3224760 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/config_rejects_out_of_range.rs @@ -1,7 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! config_rejects_out_of_range_and_mtp_zero_means_max_t, host_budget_is_checked_and_grows_with_the_request, -//! begin_request_validates_tokens_and_rejects_a_live_request, -//! the_adaptive_window_emits_the_same_text_as_a_fixed_one_under_any_drafter .... +//! Pins the controller's admission rules: out-of-range config refused (mtp zero means max T), host budget checked and +//! growing with the request, request tokens validated, and adaptive output equal to a fixed window's under any +//! drafter. use super::{ AdaptiveConfig, EndRunSetup, Error, Fake, NanGuard, OriginalSpecController, SpecConfig, SpecWindow, VOCAB, begin, config, drive, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs index 39e23214..24727893 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/tests/non_finite_window.rs @@ -1,7 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! a_non_finite_window_is_run_again_from_its_checkpoint_and_the_request_completes, -//! the_guard_costs_nothing_when_nothing_is_wrong, a_window_that_stays_non_finite_fails_the_request_after_the_retries, -//! only_a_non_finite_failure_is_retried_and_a_guard_that_is_off_retries_nothing .... +//! Pins the non-finite window guard: a bad window is run again from its checkpoint and the request completes, the +//! guard costs nothing when nothing is wrong, a persistent failure fails the request, and only a non-finite one is +//! retried. use super::{ Error, Fake, NanGuard, OriginalSpecController, OriginalSpecEngine, SpecError, VOCAB, begin, config, drive, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs index 8a3f322c..524ec46d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/original_spec_controller/trace_enabled.rs @@ -1,5 +1,5 @@ -//! Methods of `NanGuard`: `off`, `with_retries`, `with_injection`, `parse_switch` and 5 more. -//! Methods of `SpecConfig`: `new`, `with_nan_guard`, `with_adaptive`. Implements `From for SpecError`. +//! Settings of the speculative controller: NanGuard (non-finite window retry policy and its injection), SpecConfig +//! (window, context, suffix and adaptive options), the round accessors, and the `LELEKA_SPEC_TRACE/STATS` switches. use super::{AdaptiveConfig, CommittedRound, Error, MAX_T, NanGuard, Result, SpecConfig, SpecError, SpecWindow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs index 7d2d242e..31d7e2fc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/original_prompt_sample.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalPromptSample`: `greedy`, `conditioning`, `validate`, `matches_final` and 3 more. -//! Methods of `FiniteLogits`: `validate_for`. +//! OriginalPromptSample: the authentic head result of the prompt's final row (greedy next token or the known +//! conditioning token) tied to one pending final phase, checked again before MTP uses it; and +//! FiniteLogits::validate_for. use super::{ BindingIdentity, Error, FiniteLogits, LogitValues, ModelBinding, OriginalPromptSample, Position, Result, TokenId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs index 3b504d18..2cef1f5a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `output_stage_load_and_logits`, `output_stage_sampling_projection`. -//! Split out of `output` to keep its files under the line limit. +//! OutputStage: the loaded Q6_K output head, split into loading and logits (`output_stage_load_and_logits`) and the +//! sampling and projection of a mixed residual (`output_stage_sampling_projection`). use super::{ ACTIVATION_BYTES, BindingIdentity, Context, DeviceBuffer, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_load_and_logits.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_load_and_logits.rs index 78a90181..88669491 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_load_and_logits.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_load_and_logits.rs @@ -1,5 +1,5 @@ -//! Methods of `OutputStage`: `logits_original_prompt`, `finite_final_mix`, `certify_prompt_logits`, `load` and 13 more. -//! Split out of `output_stage` to keep its files under the line limit. +//! OutputStage loading and logits: uploads the fixed Q6_K head once per context, the compact (device argmax) variant, +//! the logits entry points for prompt, decode and MTP greedy, step checks and arming the per-request sampler. use super::{ BindingIdentity, Context, Dimension, EMBEDDING, Error, FiniteLogits, GrStage, HEAD_GREEDY_WORKSPACE_BYTES, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs index ea80ea78..76b1e352 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage/output_stage_sampling_projection.rs @@ -1,5 +1,6 @@ -//! Methods of `OutputStage`: `sampler_wants`, `sample_complete`, `check_projection`, `with_projected` and 8 more. -//! Split out of `output_stage` to keep its files under the line limit. +//! OutputStage projection and sampling: uploads the mixed residual, projects it through the Q6_K head into a +//! candidate logit buffer, selects greedily on the device or reads the full vector, and applies the armed request +//! sampler. Short-lived buffers are accounted before the result is published; the first error stays primary. use super::{ ACTIVATION_BYTES, BindingIdentity, Context, DeviceBuffer, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs index c4f9ece8..023dcf37 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/output_stage_test_replay.rs @@ -1,5 +1,5 @@ -//! Methods of `OutputStage`: `test_prefix_begin_target`, `test_reset_replay_record`, `test_reset_replay_capture`, `s... -//! Functions: `greedy`, `selected_token`, `validate_weight_owner`, `encode_activation` and 4 more. +//! Test-only replay hooks of OutputStage (record logits of a reset or prefix replay, count compact completions) and +//! the shared helpers of the stage: greedy pick, activation and logit encoding, weight-owner check and error mapping. use super::{ ACTIVATION_BYTES, BindingIdentity, Dimension, EMBEDDING, Error, FiniteF32, FiniteLogits, HeadGreedySelection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs index d7cb62f7..423b2ab9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/output/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the output head's rules: weights refused across bindings before extents, greedy ties take the lowest id, a +//! late strictly greater logit wins, incomplete or non-finite vectors are refused and cleanup errors take precedence. use super::{ BindingIdentity, Dimension, Error, FiniteF32, FiniteLogits, LOGIT_BYTES, LogitValues, OutputWeights, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs index 6425e09e..3f79bd2a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `produce_original_gdn`, `read_completion`. -//! Split out of `prompt_device_rows` to keep its files under the line limit. +//! PromptDeviceRead: a read of the prompt chunk's device rows at one GR role, split into producing the Original GDN +//! and QSA layers (`produce_original_gdn`) and validating and completing the read (`read_completion`). use super::{ Context, DenseWeightCache, Dimension, Error, GrRole, InputReady, LayerId, ModelBinding, OriginalDeviceBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs index 87f2787c..9948fc63 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/produce_original_gdn.rs @@ -1,5 +1,6 @@ -//! Methods of `Lap`: `new`, `off`, `at`. Methods of `GdnLayer`: `enter`, `compute`, `leave`. -//! Functions: `produce_original_gdn`, `produce_original_qsa`, `normed_gamma`, `produce_block` and 1 more. +//! Producers of one prompt layer on the device: the full GDN layer (state in, compute, state out) and the resident +//! QSA layer (setup, projections, indexer, attention, seal), plus the layer lap timing of the command profile. +//! End state enters the journal only from the completed whole-layer producer. use super::{ Context, DenseWeightCache, Error, GrRole, InputReady, LayerId, ModelBinding, OriginalDeviceBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs index 511314a3..6fe797da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_device_read/read_completion.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptDeviceRead`: `validate_original_rows`, `validate_row`, `device`, `attention_layer` and 8 more. -//! Split out of `prompt_device_read` to keep its files under the line limit. +//! Completion of a PromptDeviceRead: validates the chunk's rows against the phase, runs the GDN, FFN and GR steps +//! over the same physical arena, and checks the next role. Every current row must pass chronological validation. use super::super::super::gdn::PromptSource; use super::produce_original_gdn::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs index 45667a80..79351a38 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/prompt_ple_history.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptPleHistory`: `from_prior`, `into_completed`, `close`. -//! Functions: `micro_driver_error`, `run_transfer`. +//! PromptPleHistory: the device copy of the PLE history a prefill chunk advances, seeded from the session's prior and +//! returned as the completed history; plus the transfer helper and GR driver error mapping of the PLE micro path. use super::{ BindingIdentity, Context, Error, ModelBinding, OriginalPleHistory, OriginalPromptDevice, PlePrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs index cbdb16d7..c16c1aa6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `prompt_device_rows`, `prompt_device_rows_ple_read`, `source_input_deref`. -//! Split out of `prompt_device_rows` to keep its files under the line limit. +//! PromptDeviceRows: the prompt chunk's physical device rows, with its final-row preview, PLE application and device +//! reads (`prompt_device_rows`, `prompt_device_rows_ple_read`) and the source input views (`source_input_deref`). use super::{ BindingIdentity, Context, DenseWeightCache, Dimension, Error, FinalProduct, GrRole, InputReady, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs index 3f8ec7d5..b69b2de3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows.rs @@ -1,5 +1,6 @@ -//! Methods of `PromptDeviceRows`: `final_point`, `preview_conditioning`, `preview_final`, `with_final_residual` and ... -//! Split out of `std_ops_deref` to keep its files under the line limit. +//! PromptDeviceRows: initial staging of the chunk's rows to the device, the final point of the phase, and the +//! conditioning and final previews that keep the all-row residual for the shifted MTP input. +//! Only the final-phase owner can lend the retained residual to the MTP producer. use super::{ Context, DenseWeightCache, Error, FinalProduct, GrRole, ModelBinding, OriginalDeviceResidual, OriginalPromptDevice, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs index 4ce3a820..0aff481c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/prompt_device_rows_ple_read.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptDeviceRows`: `apply_ple`, `check_ple`, `ple_weights`, `read` and 1 more. -//! Split out of `std_ops_deref` to keep its files under the line limit. +//! PromptDeviceRows PLE and read: applies the per-layer PLE step to the staged rows, checks and resolves the PLE +//! weights of the binding, and reads the rows to the device for a GR role. use super::{ Context, DenseWeightCache, Error, GrRole, ModelBinding, OriginalDeviceGrRead, OriginalDeviceResidual, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs index 4eda4dab..507c96d0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/prompt_device_rows/std_ops_deref/source_input_deref.rs @@ -1,5 +1,5 @@ -//! Methods of `PromptDeviceSource`: `from_current`, `check_input_values`, `from_original`. -//! Methods of `PromptDeviceFinal`: `validate`, `token`, `position`, `streams` and 1 more. +//! Sources of the prompt rows: PromptDeviceSource (from the current input or the Original key), PromptDeviceFinal +//! accessors, and the checks that the sources are the ones validated before staging, a read or completion. use super::{ BindingIdentity, Context, DenseWeightCache, Dimension, Error, FinalProduct, GrRole, InputReady, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs index d4180e19..bc95cf35 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/column_projection.rs @@ -1,5 +1,6 @@ -//! Methods of `RowFactory`: `row`. -//! Functions: `check_inputs`, `check_row`, `check_successor`, `gdn_matrix_of` and 8 more. Defines `RowFactory`. +//! Q6_K projection of attention input columns (GDN QKV or a QSA role) for a run of consecutive rows: validates that +//! every input is a certified attention input of its layer, then projects and returns rows on the host or retained +//! on the device (GDN QKV only). use super::{ Cell, ColumnKey, ColumnTarget, Context, DenseWeightCache, DeviceBuffer, Error, GdnMatrixKind, GdnMatrixRole, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs index 0e1ad339..5bc3731c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/projection_row.rs @@ -1,5 +1,6 @@ -//! Methods of `Role`: `rows`, `qsa`. Methods of `RetainedColumns`: `buffer`. Implements `Drop for RetainedColumns`. -//! Functions: `project`, `project_retained`. +//! The row types of the Q6 attention-column adapter: `ProjectionRow` (host row, taken once), `RetainedRow` and +//! `RetainedColumns` (device output shared by the rows of a batch). Each is checked against the binding, session +//! and input; a host row cannot be converted into a retained one or back. use super::{ ColumnKey, ColumnTarget, Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs index ca1ff099..4dde2d5a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/q6_attention_columns/q6_numeric.rs @@ -1,5 +1,6 @@ -//! Methods of `Q6Job`: `fence_refusal`, `admit_budget`, `project`, `download` and 1 more. -//! Functions: `numeric`, `numeric`, `numeric_retained`, `numeric_retained` and 1 more. Defines `Q6Buffers`, `Q6Job`. +//! The device run of one Q6_K column projection: upload, activation quantization, projection, readback or retention +//! of the output, and cleanup. Admission and quantization are identical for both ends; every failure marks the +//! shared fence failed and the first error is returned. use super::{Cell, Context, DeviceBuffer, Error, Result, download, driver_error}; #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs index e9f83e52..469f76db 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/decode_selected_cached.rs @@ -1,5 +1,6 @@ -//! Methods of `AttendBuffers`: `upload`, `launch`. -//! Functions: `decode_selected_cached`, `attend_selected`, `settle_retained`, `attend_retained` and 8 more. +//! QSA attention over the selected cells with the retained device cache: upload query, keys and values, launch the +//! attend kernel, read the output back whole and gate it. The finite boundary stays before gating, so the gate +//! cannot mask a bad value; a failed launch or cleanup marks the shared fence failed. use super::{ Cell, Context, DenseWeightCache, DeviceBuffer, Error, ModelBinding, Q, QsaAttendBuffers, QsaAttended, QsaGated, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs index 2c4681be..1dba59a8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/native_attended.rs @@ -1,5 +1,6 @@ -//! Methods of `NativeAttended`: `identity`, `values`, `gate`, `validate` and 4 more. -//! Methods of `NativePromptAttentionBatch`: `complete`, `owner`, `publish_row`, `locate` and 6 more. +//! The attended row of native prompt QSA attention (`NativeAttended`) and the chunk batch that completes it +//! (`NativePromptAttentionBatch`). Rows are published to the causal session one at a time, never as a batch-final +//! relabel, and each is checked against its chunk, layer and transaction first. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::qsa_index::QsaPending; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs index 654ad129..981cfb73 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_attention/qsa_ready.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaReady`: `identity`, `output`, `validate_origin`. -//! Methods of `QsaAttentionStage`: `decode_native`, `complete_native`, `decode`, `decode_selected` and 4 more. +//! `QsaReady` (the output of one attention layer step) and the `QsaAttentionStage` decode entry points: native decode +//! on the device, the selected-cache path and the uncached host path. Only the native completion reaches the pending +//! journal; the joint transaction still owns publication. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs index 54fe6a15..46505962 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/context.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaOwner`: `new`, `matches`. -//! Methods of `QsaPrior`: `oracle_capture_parts`, `test_reset_replay_numeric_eq`, `same_native_kv`, `same_pages` and... +//! The immutable QSA state handles: `QsaOwner` (identity of one session's QSA state family) and `QsaPrior` (one +//! layer's KV pages, pooled index keys and tail at a position), with their equality, extent and gather checks. +//! Also the serving context size and the device headroom a QSA step requires. use super::{ BindingIdentity, Directory, Error, KV, LayerId, PackedKv, Position, QsaOwner, QsaPrior, Rc, Result, Stage, State, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/qsa_directory_sdet.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/qsa_directory_sdet.rs index f93fc3a2..688be25f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/qsa_directory_sdet.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/directory/qsa_directory_sdet.rs @@ -1,3 +1,6 @@ +//! Pins the persistent `Directory` at its 65536-entry limit: successors share their retained roots and payloads +//! (Rc identity), and iteration, replacement and fork of any earlier version leave the other versions unchanged. + use super::{Directory, Error, MAX_ENTRIES}; use std::rc::Rc; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs index 75bb6d83..9198eed9 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_kernels.rs @@ -1,5 +1,5 @@ -//! Functions: `norm`, `upload_gamma`, `release_gamma`, `run_norm` and 15 more. Defines `BlockQuery`. -//! Split out of `qsa_index` to keep its files under the line limit. +//! Kernel runners of the QSA index path: norm, RoPE, query/gate split, K/V pack, index-key append, block scoring and +//! top-k selection, and the index-side projection. Every output is read back and checked finite or in range. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, KV, ModelBinding, Norm, PackedKv, Q, QGate, QsaLayerProjection, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs index 8970e88c..e784d4c2 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/max_rows.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaIndexKeyCache`: `layer_bytes`, `new`, `with_eager`, `admit_mirror` and 9 more. -//! Functions: `max_rows`, `update`, `append_rows`, `capacity` and 2 more. +//! Legacy device mirror of the pooled index keys (`QsaIndexKeyCache`, one entry per attention layer) and the plan +//! that brings it from one `QsaPrior` to its successor: reload, append one pooled row, or change only the spare row. +//! Reset, replay and speculative branches are misses. A layer's mirror is allocated on its first selection. use super::{ BindingIdentity, BlockQuery, Cell, Context, Entry, Error, QsaIndexKeyCache, QsaPrior, QsaSelectionRequest, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs index 436d28fd..194430f0 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/index_resident/synthetic_late_prior.rs @@ -1,5 +1,4 @@ -//! Functions: `synthetic_late_prior`, `synthetic_late_prior_for`. -//! Split out of `index_resident` to keep its files under the line limit. +//! Test fixture: a `QsaPrior` of one zeroed KV page at a late position, bound to a given or test identity. #[cfg(test)] use super::{BindingIdentity, Directory, KvPage, LayerId, PAGE, QsaOwner, QsaPrior, Rc, State}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs index 38fbfce0..2d2067f8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_completed.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaCompleted`: `first`, `rows`, `layer`, `validate_rows` and 7 more. -//! Defines `ResidentSealOwners`. +//! `ResidentQsaCompleted`: the rows a resident QSA layer completed in one prompt window, before they are sealed. +//! Checks the rows against the inputs and the session, finds a transaction's row, then seals the accepted prefix +//! (index and mapped K/V commit) or aborts. `ResidentSealOwners` names the owners a seal commits through. use super::resident_qsa_layer::mint; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs index 1b9f3f5e..aae0da9c 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_layer.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaLayer`: `new`, `empty_guards`, `current`, `validate` and 11 more. -//! Functions: `check_empty`, `mint`, `rehome`, `resident_identities` and 1 more. +//! `ResidentQsaLayer` lifecycle: construction from an empty lineage, validation of a prior, prepare of a prompt +//! window, prefix prefetch, publication of a seal and restore to a session checkpoint. Holds the resident index +//! image and mapped K/V journal; rows are provenance only, never a host image. use super::{ BindingIdentity, Context, DenseWeightCache, Error, InputReady, LayerId, ModelBinding, NativeBatchWorkspace, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs index 262a2bed..4974d8cd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_prior.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaPrior`: `next_position`, `layer`, `same_prior`, `validate_for_session` and 5 more. -//! Methods of `ParkedLayerSpan`: `bytes`. +//! `ResidentQsaPrior`: the lineage witness of a resident QSA layer (index checkpoint plus mapped K/V prefix at one +//! position). Checks it against a session or model identity and re-stamps it: empty lineage onto a new branch, +//! a checkpoint onto the current branch generation, or advanced after the verifier committed rows. use super::{ BindingIdentity, Error, LayerId, ModelBinding, OriginalQsaIndexCheckpoint, OriginalQsaMappedPrefix, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs index 7147ada6..bfcc2a00 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/resident_qsa_span_export_and_seal.rs @@ -1,5 +1,6 @@ -//! Methods of `ResidentQsaLayer`: `export_span`, `export_kv`, `export_index`, `export_tail` and 5 more. -//! Methods of `ResidentQsaPublication`: `publish_validated`. Functions: `span_views`. Defines `SpanViews`. +//! Moving a resident QSA layer's state: export of a prefix span and tail for the prefix cache, import of a parked +//! prefix, the one-way handoff of the index and mapped K/V owners to the native verifier (and back), and the seal +//! and publication types that make a completed window canonical. use super::resident_qsa_layer::rehome; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs index 3fc2e878..ae9f5f54 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/gated_out_projection.rs @@ -1,5 +1,5 @@ -//! Functions: `out_matrix`, `project_gated_out`, `release_gate_buffers`, `gate_and_out`. -//! Split out of `scalar` to keep its files under the line limit. +//! The gate and Out projection of the scalar QSA continuation: the attended tensor is gated, then projected by the +//! layer's quantized Out matrix. Both the attended and the gated tensors are checked finite before Out runs. use super::{ BoundDense, Context, DenseWeightCache, DeviceBuffer, Error, GateBuffers, GateDevices, GateRows, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs index 212c632a..c1a30c86 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_admission.rs @@ -1,5 +1,5 @@ -//! Methods of `ScalarHost`: `gather`, `select`. -//! Methods of `ResidentQsaLayer`: `scalar_guards`, `check_scalar_prior`, `prepare_scalar`. +//! Admission of one scalar row (target or MTP) on a resident QSA layer: host gather and block selection, the guards +//! of the step, the lineage and the weights, and `prepare_scalar`, before any device work. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, NativeBatchWorkspace, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs index 75d8fa5d..91dce652 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/prompt_device/resident_device/scalar/scalar_row_run.rs @@ -1,5 +1,5 @@ -//! Methods of `ResidentQsaScalar`: `validate`, `check_identity`, `attend`, `gate_out` and 3 more. -//! Methods of `ResidentQsaScalarReady`: `into_parts`, `check_identity`. +//! Run of one scalar row on a resident QSA layer: append, attend over the selected blocks, gate and Out project, +//! then seal or abort. `ResidentQsaScalarReady` is consumed once, after an identity check. use super::{ BoundDense, Cell, Context, DenseWeightCache, Error, GateBuffers, GateDevices, GateRows, GrRole, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs index 666be817..baaa73bf 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_index_stage.rs @@ -1,5 +1,6 @@ -//! Methods of `QsaIndexStage`: `prepare`, `prepare_projected`, `prepare_impl`, `prepare_host_rows` and 4 more. -//! Methods of `QsaPrep`: `layer_projection`, `project`, `project_column`, `key_stage` and 5 more. Defines `QsaPrep`. +//! `QsaIndexStage::prepare`: the QSA preparation of one token step (query, gate, KV append, selected block ids). +//! Projects the host rows or the native prompt row, then builds the next prior as a pending candidate that is +//! published only at token commit. Admission checks the binding, layer, position and residual input first. use super::{ Context, DenseWeightCache, DeviceBuffer, Error, GrRole, LayerId, ModelBinding, Norm, Position, ProjectionSources, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs index 44765953..97b79c78 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_pending.rs @@ -1,5 +1,5 @@ -//! Methods of `QsaPending`: `new`, `next_pooled`, `admit`, `next_page` and 5 more. -//! Methods of `QsaPrepared`: `identity`, `validate_for`, `validate_binding`, `validate_origin` and 7 more. +//! The QSA successor candidate: `QsaPending` builds the next `QsaPrior` (one more KV cell, pooled key, tail) from a +//! prior; `QsaPrepared` carries the query, gate, selected ids and pending state to attention, with origin checks. use super::{ BindingIdentity, Directory, Error, KV, KvPage, LayerId, PAGE, PackedKv, Position, QsaPending, QsaPrepared, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs index c32ace55..1980b7b7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/qsa_projection.rs @@ -1,5 +1,5 @@ -//! Functions: `dispatch_projection`, `project_input`, `project_input_numeric`, `project_cached_out` and 4 more. -//! Defines `QsaMatrixLayout`, `QsaLayerProjection`, `ProjectionSources`. +//! Device projections of the QSA index path: dispatch by matrix layout, project an input column through the lease, +//! the resident cache or an uploaded matrix, and the Out projection. A device failure marks the transport failed. use super::{ Bf16ProjectionShape, Cell, Context, DenseFormat, DenseWeightCache, DeviceBuffer, DriverError, Error, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs index f3e52a4e..f9732e8b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/selected_cache/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of the selected-cell cache (moved out of the file by STRA-338; the test ids are unchanged). +//! Pins the selected-cell plan: page lineage, tail checkpoints, reset, refusals and order, and that weak entries +//! retire without retaining reset pages or speculative branch payloads. use super::{ BindingIdentity, Error, KV, LayerDirectory, LayerId, Plan, Position, QsaOwner, QsaPending, QsaPrior, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs index 3b1a0ee5..5588f8fb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_index/validate_ids.rs @@ -1,5 +1,5 @@ -//! Functions: `validate_ids`, `validate_half`, `validate_values`, `reserve` and 10 more. -//! Split out of `qsa_index` to keep its files under the line limit. +//! Checks and device helpers shared by the QSA index path: finite and range checks of ids, halfwords and values, +//! bounded allocation, upload and download of device buffers, and driver/binding error mapping. use super::{ Context, DenseWeightCache, DeviceBuffer, DriverError, Error, InputBindingError, ModelBinding, QsaMatrixKind, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs index a3ad4853..4eef2e3d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/native_projection_row.rs @@ -1,5 +1,6 @@ -//! Methods of `NativeProjectionRow`: `validate`, `same_row`, `check_values`, `validate_fresh` and 7 more. -//! Functions: `native_error`, `native`, `project`, `chunk_owners` and 4 more. +//! One row of the native QSA prompt projections: the five projections (K, V, Q, index K, index Q) of a whole +//! micro-batch, split into per-row capabilities. Every row is checked as the chunk's own attention row, finite, +//! at consecutive positions. use super::{ AttentionRow, ChunkAttentionSlot, Context, DenseWeightCache, Error, GrRole, LayerId, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs index a155312c..9984b500 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/qsa_prefill_batch/projection_rows.rs @@ -1,5 +1,5 @@ -//! Methods of `NativeOutRow`: `take`. -//! Functions: `concat_mixed`, `check_batches`, `check_shapes`, `retained_matrices` and 6 more. +//! The Out projection of the native QSA prompt batch: gather the attended rows and gates, project them together +//! and hand each row its slice, with the batch shapes, finite checks and retained matrices checked on the way. use super::{ AttendedRows, BindingIdentity, Context, DenseWeightCache, DeviceBuffer, Error, LayerId, ModelBinding, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs index d1a886c0..4970af3d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/report.rs @@ -1,5 +1,6 @@ -//! Methods of `Report`: `guard`, `compare`. -//! Functions: `valid_product`, `float_bytes`, `close_all`, `finish` and 12 more. +//! Original reference chain and result tally of the router scratch proof (GPU tests only). +//! Runs the original per-call projection and route with independent transport owners, snapshots the retained slots, +//! and records guards and comparisons in a `Report`. use super::{ Bf16ProjectionShape, Context, DeviceBuffer, Error, MATRIX_BYTES, Report, Result, RouterBuffers, map_driver_error, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs index 31ae8110..3771af48 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/router_scratch/gpu/valid_reset.rs @@ -1,5 +1,6 @@ -//! Methods of `Env`: `reset`, `project_refused`, `route_refused`, `project_refused_late`. Methods of `Held`: `release`. -//! Functions: `valid_reset`, `stage_buffers`, `install_workspace`, `open_proof` and 1 more. +//! Proof that the retained router scratch resets after valid, repeated and refused calls (GPU tests only). +//! Runs the original products first and the candidate over the repeat and reset order; refused inputs (non-finite, +//! wrong dimension, late NaN, foreign matrix, over budget) must leave every retained slot byte untouched. use super::{ Cell, Context, DeviceBuffer, EXTENTS, Error, MATRIX_BYTES, ROUTER_BYTES, Rc, Report, Result, RouterBuffers, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs index 79bd2f2b..3cb0b173 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/gdn_chunk_start.rs @@ -1,5 +1,6 @@ -//! Methods of `GdnChunkStart`: `prior`, `count`, `binding`, `validate_binding` and 2 more. -//! Methods of `GdnChunkRow`: `ordinal`, `identity`, `readout_key`, `matches_readout` and 1 more. +//! Accessors and validation of the capabilities a prefill chunk mints around the rolling GDN state: the chunk anchor, +//! its rows, micro windows and seal, and their construction from an Original prompt transaction. Each is checked +//! against the binding, layer extent and row cursor before the chunk accepts it. use super::{ BindingIdentity, ChunkAttentionRow, ChunkCommit, ChunkFfnRow, Error, GdnChunkAnchor, GdnChunkMicro, GdnChunkRow, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs index 9848d78b..39409dea 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/host_charge_bounded.rs @@ -1,5 +1,6 @@ -//! Functions: `host_charge_bounded`. -//! Split out of `chunk` to keep its files under the line limit. +//! Host-memory charge of a prefill chunk of `tokens` rows ending at `end`: rolling state, attention and column +//! temporaries, row metadata and the MTP half-window readback. Refused above the caller's row limit or beyond the +//! served cells. use super::{Error, Rc, Result}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs index 4a368b2b..1fca2742 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn.rs @@ -1,5 +1,6 @@ -//! Groups the submodules `qwen_chunk_txn_attention_sources`, `qwen_chunk_txn_begin`, `qwen_chunk_txn_ffn_after_atten... -//! Split out of `chunk` to keep its files under the line limit. +//! The `QwenChunkTxn` impl family, split by phase: begin, attention sources, layer batch, micro windows and inputs, +//! GDN micro windows, FFN after attention, rows and witnesses, finish and publish. The children share this import +//! list. use super::{ ActiveMicroWindow, AttentionProgress, AttentionSource, BatchProgress, ChunkAttentionRow, ChunkCommit, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs index b0308c5c..051c4925 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_attention_sources.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `check_attention_column`, `open_attention_sources`, `admit_row_ple`, `publish_attentio... -//! Defines `DeviceGdnFfn`. +//! Attention reads of a chunk layer: opens the per-row source slots, admits layer-one PLE history, mints the row +//! capability of each completed read and prepares the batch and FFN steps (host and device GDN) that consume it. use super::super::super::super::gr::DetachedGrRead; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs index e2532473..5213dba6 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_begin.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `native_prefill_host_charge`, `begin`, `begin_windowed256`, `begin_bounded` and 9 more. -//! Functions: `prompt_origin`, `prompt_end`, `check_vocab`, `admit_prompt_host` and 1 more. Defines `PromptAdmission`. +//! Admission and start of a prefill chunk transaction: vocabulary, host-byte and device-budget checks, the rows with +//! their two predecessor tokens, and the phase queries. Normal serving caps a chunk at 64 rows; the windowed 256 form +//! is private. use super::{ AttentionProgress, BatchProgress, ChunkRowResidual, Dimension, Error, MicroProgress, ModelBinding, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs index 9d5b6a47..77d3c021 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_ffn_after_attention.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `ffn_after_attention_step`, `prepare_ffn_after_attention`, `check_edge_step`, `check_e... -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! The FFN step after an attention row: validates the row's batch proof, rolls the pending PLE, GDN and QSA history +//! into the next priors (or the device GDN edge) and prepares the FFN injection. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::{gr::DetachedGrRead, moe_expert::PreparedMoeRow}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs index f091b984..b11f5878 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_finish_publish.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `finish`, `check_finishable`, `witness_for`, `run_head` and 7 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! End of a prefill chunk: every layer of every row must be complete, then the output head (or the known next token), +//! one finite residual witness per row, state slots valid at the end position and the joint target and draft +//! publication. use super::{ ChunkCommit, ChunkDraftPublication, ChunkRowResidual, Dimension, Error, GrRole, InjectedResidual, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs index 9c54ed57..93b066a1 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_gdn_micro.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `prepare_attention_device_gdn`, `gdn_micro_cursors_off`, `gdn_micro_start`, `build_gdn... -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! GDN micro windows of a prefill layer: the whole prompt GDN window completes before any row edge advances, then its +//! per-row products enter the journal; also the check and enlisting of prepared attention-output rows against their +//! causal proofs. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::{gdn::chunk_device::ChunkEdge, gr::DetachedGrRead}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs index 0ed34d29..b83f4edd 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_layer_batch.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `row_step`, `check_layer_row`, `layer`, `prepare_layer_batch` and 13 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Batched layer passes of a chunk: the row cursor of the unwindowed layer pass, opening and completing the batch of +//! a layer, minting `PreparedLayerRow` capabilities and checking batch outputs and FFN rows against their seals. use super::super::super::super::gdn::chunk_device::ChunkEdge; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs index faa83151..edafd15f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_inputs.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `input`, `settle_failure`, `ple_micro_cursors_off`, `check_ple_micro` and 11 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Inputs of a micro window: the layer-one PLE window and the attention window, prepared row by row in causal order +//! while the GR reads complete as one device batch. No row capability is published until the whole batch has +//! completed. #[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))] use super::super::super::super::gr::{DetachedGrRead, GrMicroInput}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs index 53f727f2..cb2fe6d3 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_micro_window.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `check_micro_open`, `micro_misaligned`, `phase_in_flight`, `micro_width` and 19 more. -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Lifecycle of a micro window in a windowed chunk: open on an idle transaction at the cursor, close with the exact +//! minted capability once the range is computed, advance the cursors, and the QSA priors at the start of a window. use super::{ ActiveMicroWindow, ChunkMicroWindow, Context, Error, LayerId, Position, QsaIndexPrior, QwenChunkTxn, Rc, Result, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs index e7c676cc..ade75d12 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/qwen_chunk_txn/qwen_chunk_txn_rows_and_witness.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `qsa_prior_mismatch`, `validate_prompt_qsa_prior`, `original_session`, `rows` and 16 m... -//! Split out of `qwen_chunk_txn` to keep its files under the line limit. +//! Row ids, positions and residual witnesses of a chunk transaction (what an MTP draft reads), the begin and finish +//! of a GDN chunk, and the stage view of one row. use super::{ ChunkRowResidual, Error, GdnChunkAnchor, GdnChunkJournal, GdnChunkSeal, GdnChunkStart, GdnPrior, LayerId, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs index 45411d88..afc02aad 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/test_gdn_component_rows.rs @@ -1,5 +1,5 @@ -//! Methods of `TestGdnComponentRows`: `new`, `start`, `row`, `seal`. -//! Split out of `chunk` to keep its files under the line limit. +//! Test-only GDN chunk journal of 65 fabricated rows over a given prior, so the chunk capabilities (start, row, seal) +//! can be exercised without a real chunk transaction. #[cfg(all(test, target_arch = "x86_64"))] use super::TestGdnComponentRows; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs index 14df878a..c8edd789 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/txn_groups.rs @@ -1,5 +1,5 @@ -//! Groups of cohesive fields of `QwenChunkTxn`, moved out of it by STRA-338 (size): the fields keep their declaration -//! order inside the transaction, so the drop order is unchanged. +//! Field groups of `QwenChunkTxn` by meaning (batch, attention and micro progress). Their order inside the +//! transaction fixes the drop order, so it must not change. use super::{ActiveMicroWindow, AttentionSource, LayerId, Rc}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs index 7e54be3a..0c4d8f60 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `qwen_chunk_txn_begin_verification`, `qwen_chunk_txn_verification_state`, `qwen_chunk_txn_v... -//! Split out of `verify` to keep its files under the line limit. +//! The `QwenChunkTxn` methods of MTP verification: starting a bounded window with its device GDN lease, the journal +//! of complete row states, and selecting and publishing the verified prefix. use super::{ ChunkCommit, ChunkRowResidual, Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, GrRole, HOST_LIMIT, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs index e23ed76b..7ac97543 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_begin_verification.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `validate_verification_source`, `preflight_mtp_verification`, `begin_mtp_verification`... -//! Functions: `verification_total_charge`. Defines `ReplayInputs`. +//! Start of a verification window: validates the source target step, preflights the host charge and the device GDN +//! workspace, records the device GDN proofs and replays them into the canonical prior; also the layer-one PLE row +//! checks. use super::{ Dimension, Error, GdnChunkAnchor, GdnChunkJournal, GdnPrior, HOST_LIMIT, LayerId, ModelBinding, Position, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs index 5bcdf675..70eb3bda 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verification_state.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenChunkTxn`: `record_gdn_prior`, `record_qsa_prior`, `record_verification_prior`, `validate_state_g... -//! Functions: `journal_state`, `journal_state_mut`. +//! Journal of the complete per-row states of a verification window (GDN, QSA, PLE priors at each row end), their +//! validation, and the window finish: the head on the actual row state and one residual witness per row. use super::{ ChunkRowResidual, Dimension, Error, GrRole, InjectedResidual, LayerId, Position, PrefixState, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs index 645db8a8..d47acc17 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/qwen_chunk_txn/qwen_chunk_txn_verified_prefix.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenChunkTxn`: `verified_prefix_seed`, `verified_rows`, `select_verified_prefix`, `prefix_mismatch` a... -//! Functions: `copy_streams`, `install_prefix`. +//! Selection and publication of the verified prefix: rows are accepted while their tokens follow the greedy heads +//! from the seed (a rejected tail is dropped), and the matching journaled state is installed in the session and the +//! draft. use super::{ ChunkCommit, ChunkRowResidual, Dimension, Error, LayerId, ModelBinding, Position, PrefixState, QwenChunkTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs index 09432b25..ab4401cc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the greedy accept rule (stops at the first rejection or EOS), the 512 MiB refusal of the verification journal +//! charge and that the PLE journal admits only the current layer-one GDN attention phase. use super::{ Dimension, Error, GdnChunkAnchor, GdnChunkStart, HOST_LIMIT, LayerId, PlePrior, Position, PrefixState, PromptInit, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs index e329e133..168b1746 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/chunk/verify/verified_target_prefix.rs @@ -1,5 +1,5 @@ -//! Methods of `VerifiedTargetPrefix`: `count`. Functions: `verification_extra_charge`, `greedy_prefix`. -//! Split out of `verify` to keep its files under the line limit. +//! The accepted-prefix decision of a verification window: the count, the extra host charge of the journaled states +//! and the pure greedy rule (a row is accepted while its token equals the previous head and is not EOS). use super::{Error, PrefixState, Rc, Result, TokenId, VerifiedTargetPrefix}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs index 4524ef8a..662a947e 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_checkpoint.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalDraftCheckpoint`: `host_bytes`. -//! Methods of `OriginalDraftSession`: `new`, `from_original_ring`, `validate`, `checkpoint` and 7 more. +//! The Original MTP draft session: its INT8 ring owner and immutable checkpoint, construction from the shared ring +//! layout, and lending the ring to the draft producer. Only a matching target origin may borrow it; it never advances +//! target state. use super::{ CompletedOriginalMtpDraft, Context, Error, ModelBinding, MtpInt8Snapshot, MtpOriginalInt8, OriginalDraftCheckpoint, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs index 6a929b89..6b2fc50b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/original_draft_session_ring_restore.rs @@ -1,5 +1,6 @@ -//! Methods of `OriginalDraftSession`: `with_mtp_current_ring`, `check_publication`, `prepare_publication`, `restore_... -//! Methods of `OriginalDraftPublication`: `publish_validated`. Implements `Drop for OriginalDraftSession`. +//! Publication and rollback of the draft ring: the receipt check of a completed MTP window, restore to a checkpoint, +//! reset to the empty prompt, conversation resume and rebinding to the target branch. An uncertain restore poisons +//! the owner. use super::{ CompletedDraftKv, DenseWeightCache, Error, ModelBinding, MtpInt8Snapshot, MtpOriginalInt8, OriginalDraftCheckpoint, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs index e5344008..c15fb17b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/draft/published_first_materialized.rs @@ -1,5 +1,5 @@ -//! Functions: `published_first_materialized`, `draft_driver_error`. -//! Split out of `draft` to keep its files under the line limit. +//! Ring bookkeeping after a prompt chunk: the lower bound of the cells the draft ring has materialized (a chunk that +//! continues the range keeps the earlier bound), and the mapping of driver errors of the draft. use super::{Error, Stage}; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs index e0f11dad..a53e428a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input.rs @@ -1,5 +1,5 @@ -//! Groups the submodules `original_prompt_input_qsa_seed`, `qwen_session`. -//! Split out of `original_prompt` to keep its files under the line limit. +//! The request input of an Original prompt and the session's checkpoint, park and restore over the resident QSA +//! layers. use super::{ DenseWeightCache, Dimension, Error, GdnPrior, LayerId, ModelBinding, OriginalPromptInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs index 008ff5ca..e01a528a 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/original_prompt_input_qsa_seed.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptInput`: `from_tokenized`, `len`, `window`. -//! Methods of `QwenSession`: `validate_resident_qsa_owner`, `original_qsa_seed`, `install_original_qsa_seed`, `seed_... +//! The tokenized request owner and the QSA seed of a session: prompt windows, installing the empty seed set into an +//! untouched session, and re-stamping checkpoints onto the session's current branch generation. use super::{ Dimension, Error, LayerId, ModelBinding, OriginalPromptInput, OriginalSessionCheckpoint, QsaIndexPrior, QsaOwner, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs index 4d2ec955..6d710f8f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_input/qwen_session.rs @@ -1,5 +1,6 @@ -//! Methods of `QwenSession`: `check_resident_states`, `original_checkpoint`, `check_restore_slot`, `check_restore_sl... -//! Methods of `ParkedSession`: `next_position`, `host_bytes`. Defines `RestoredLayers`. +//! Checkpoint, restore and park of a `QwenSession` over its twelve resident QSA layers: saved witnesses are +//! validated, every layer is rolled back (all attempted, the first failure returned), and prefix-cache points and +//! blocks are exported or imported. use super::{ DenseWeightCache, Dimension, Error, GdnPrior, LayerId, ModelBinding, OriginalSessionCheckpoint, ParkedBlock, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs index 5db83df4..f80e781d 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_phase.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptPhase`: `validate_role`, `initialize`, `read`, `prepare_read` and 5 more. -//! Methods of `OriginalPromptRowKey`: `validate_initial`, `validate`, `phase`, `ordinal`. +//! The phase journal of an Original prompt window (which GR role may be read, injected or sealed next) and the row +//! keys that bind a source row to it. Shared only by authentic source rows and their producers. use super::{ BindingIdentity, DevicePhase, Dimension, Error, GrRole, InputReady, LayerId, OriginalPromptPhase, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs index e1709bbb..c6bbdf5b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `original_prompt_txn_begin`, `original_prompt_txn_prior_and_abort`, `original_prompt_txn_pu... -//! Split out of `original_prompt` to keep its files under the line limit. +//! The `OriginalPromptTxn` impl family: begin and queries, prior staging and abort, publication. use super::{ Cell, Context, DenseWeightCache, DevicePhase, Dimension, DraftRollback, Error, GdnPrior, GrRole, InputReady, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs index 67809fef..a93c3ce7 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_begin.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptTxn`: `begin`, `check`, `original_session`, `origin` and 14 more. -//! Methods of `OriginalPromptPhase`: `start`. +//! Start of an Original prompt transaction: checks of the session, window and vocabulary, its queries (origin, +//! positions, full prompt length, row keys) and the staging of input rows with the true token predecessors. use super::{ Cell, Context, DevicePhase, Dimension, Error, GrRole, InputReady, LayerId, ModelBinding, OriginalPromptInput, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_prior_and_abort.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_prior_and_abort.rs index f0fa27f2..4a56faf4 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_prior_and_abort.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_prior_and_abort.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptTxn`: `gdn_start_prior`, `gdn_prior`, `stage_gdn`, `validate_ple_at` and 9 more. -//! Split out of `original_prompt_txn` to keep its files under the line limit. +//! Rolling GDN, PLE and QSA priors of a prompt transaction and their staging, and the abort: both physical restores +//! are attempted and the accepted target branch is read back from the session, never inferred. use super::{ DenseWeightCache, DraftRollback, Error, GdnPrior, GrRole, InputReady, LayerId, ModelBinding, OriginalPromptTxn, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs index 3bc72e0d..0e0530da 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_prompt/original_prompt_txn/original_prompt_txn_publish.rs @@ -1,5 +1,5 @@ -//! Methods of `OriginalPromptTxn`: `validate_publish_inputs`, `publish_gdn_slot`, `check_qsa_seal`, `publish_qsa_slo... -//! Split out of `original_prompt_txn` to keep its files under the line limit. +//! Publication of a prompt transaction into the session: every GDN and QSA slot must stand at the end position with +//! its seal, and permits are prepared first so the state installation is infallible assignment. use super::super::super::super::qsa_index::prompt_device::resident_device::ResidentQsaPublication; use super::{ diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs index fbeff6cb..1093ce3f 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/original_verified/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the verified-window publication: a refused one leaves the session untouched, rounds advance the lineage while +//! the recurrent state lags until the end-of-phase publication closes it, and priors of another owner or layer are +//! refused. use super::{Error, GdnPrior, OriginalVerifiedLineage, PlePrior, QwenSession, STATE_CAPACITY, predecessors_after}; use crate::model_binding::qwen4exp_input::BindingIdentity; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs index 5078e109..6d7c7a66 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_session.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenSession`: `note_mtp_failure`, `finish_mtp_device`, `new`, `for_binding` and 11 more. -//! Functions: `layers_of_kind`. +//! `QwenSession` itself: the constructors (unbound, on a device), `begin` of a step transaction, the single commit +//! path `transact`, reset after CUDA completion and the MTP failure notes. use super::{ BindingIdentity, BoundLayerKind, Context, Error, GdnOwner, ModelBinding, PleOwner, Position, QsaOwner, QwenSession, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs index 5ad862ad..f735cd47 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn.rs @@ -1,5 +1,4 @@ -//! Groups the submodules `qwen_step_txn_inputs`, `qwen_step_txn_prior_finish`. -//! Split out of `session` to keep its files under the line limit. +//! The `QwenStepTxn` impl family: the inputs and priors of a step, and its finish and commit. use super::{ BindingIdentity, Context, Dimension, Error, FiniteLogits, GdnPending, GdnPrior, GrRole, InjectedResidual, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs index 0a12d9c6..92af6e45 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_inputs.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenStepTxn`: `token`, `position`, `residual_handoff_owner`, `validate_projection_branch` and 18 more. -//! Split out of `qwen_step_txn` to keep its files under the line limit. +//! Inputs and priors of one step transaction: token, position, binding checks, the staged input, and the PLE, GDN and +//! QSA priors with their staging. Nothing here updates committed history. use super::{ BindingIdentity, Context, Dimension, Error, GdnPending, GdnPrior, InputReady, LayerId, PlePending, PlePrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs index fd95e9c2..5331cecb 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/qwen_step_txn/qwen_step_txn_prior_finish.rs @@ -1,5 +1,5 @@ -//! Methods of `QwenStepTxn`: `qsa_prior`, `initial_qsa_prior`, `validate_qsa_prior`, `stage_qsa` and 8 more. -//! Functions: `next_ple`, `next_gdn`, `next_qsa`, `check_forward_output` and 1 more. +//! Completion of a step: QSA priors, layer-completion proofs, the finite-logits (or known-next prefill) finish and +//! `commit`, which alone publishes the next priors and advances one position, after the executor callback succeeded. use super::{ Dimension, Error, FiniteLogits, GdnPending, GdnPrior, GrRole, InjectedResidual, LayerId, PlePending, PlePrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs index 006c184a..5af738bc 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/reset_replay_snapshot.rs @@ -1,5 +1,6 @@ -//! Methods of `ResetReplaySnapshot`: `has_prefix`, `numeric_eq`, `same_shape`, `retained_bytes`. -//! Methods of `QwenSession`: `oracle_capture_committed`, `validate_reset_states`, `validate_reset_ple`, `validate_re... +//! `ResetReplaySnapshot`, the retained numerical copy of a session used by the reset-replay proofs, with its +//! comparison, and the session's oracle capture of the committed state and validation of the retained priors after a +//! reset. #[cfg(all(test, target_arch = "x86_64"))] use super::ResetReplaySnapshot; diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs index bcd7ac97..e5e06d4b 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests.rs @@ -1,4 +1,5 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the single-step session: commit advances every owner once, failure leaves the committed state untouched, and +//! the PLE, GDN and QSA priors keep their exact identity (child modules); the helpers build tokens and positions. use super::{ Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, PlePrior, Position, QsaIndexPrior, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs index 4a8ea199..c62b2b80 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/gdn_session_commit_advances_all.rs @@ -1,8 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! gdn_session_commit_advances_all_state_once_and_failed_reset_preserves_owner, -//! full_forward_guard_refuses_skipped_layers_missing_logits_and_wrong_callback_token, -//! context_seam_missing_owner_refuses_after_identity_checks, context_seam_wrong_thread_refuses_before_backend_access -//! .... +//! Pins session commit semantics: a commit advances all GDN state once, a failed reset keeps the owner, the +//! full-forward guard and the context seam refuse skipped layers, wrong tokens, threads and CUDA failures, and +//! predecessors advance oldest first. use super::{ BindingIdentity, Dimension, Error, GdnPending, InputReady, LayerId, QwenSession, Rc, Stage, TokenId, TokenLayer, diff --git a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs index f35ba114..e72c1cc8 100644 --- a/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs +++ b/crates/engine-qwen35-cuda/src/qwen_forward/session/tests/retained_gr_handoff_identity.rs @@ -1,8 +1,6 @@ -//! Tests of tests by topic (moved out of the test file by STRA-338): -//! retained_gr_handoff_identity_is_lazy_and_refuses_same_position_rebegin, -//! headfree_prefill_refuses_metadata_completion_without_actual_final_producer, -//! headfree_prefill_refuses_zero_layer_fixture_and_preserves_history, -//! qsa_session_prior_is_private_and_required_state_cannot_be_skipped .... +//! Pins prior identity in the session: the retained GR handoff is lazy and refuses a same-position rebegin, head-free +//! prefill needs a real final producer, priors are private, a late failure discards candidates and a reset fences old +//! generations. use super::{ BindingIdentity, Dimension, Error, GdnOwner, GdnPending, GdnPrior, InputReady, LayerId, PleOwner, PlePending, diff --git a/crates/engine-qwen35-cuda/src/serve_meta/tests.rs b/crates/engine-qwen35-cuda/src/serve_meta/tests.rs index 7dcb9731..2446146e 100644 --- a/crates/engine-qwen35-cuda/src/serve_meta/tests.rs +++ b/crates/engine-qwen35-cuda/src/serve_meta/tests.rs @@ -1,4 +1,6 @@ -//! Unit tests of this module (split out of its file; the test ids are unchanged). +//! Pins the start-up meta lines: they match the golden sample byte for byte, each is one section of single-blank +//! separated key=value tokens, an unset profile prints as `none`, values cannot split a token, the values hash +//! follows only the values, model files are statted and never read, and formatting is deterministic. use super::{ BuildInfo, CacheFacts, ConfigFacts, MODEL_DIGEST_MAPPING, ModelFile, ModelInfo, Path, ProfileInfo, cache_line, diff --git a/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs b/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs index c7c5c7ac..d478f834 100644 --- a/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs +++ b/crates/engine-qwen35-cuda/src/serve_tuning/tests.rs @@ -1,3 +1,7 @@ +//! Pins run-time tuning: an empty or unknown document is refused, valid values apply and name the changed members, +//! invalid values change nothing, the resident K/V window is accepted only at its value in force, the prefix cache +//! can be switched off and on, and `describe` reports the engine's defaults. + use super::{OriginalServeOptions, PrefixCacheOptions, PrefixTail, Tuning, describe}; fn base() -> (OriginalServeOptions, u32) { diff --git a/crates/engine-qwen35-cuda/src/settings/capture_tests.rs b/crates/engine-qwen35-cuda/src/settings/capture_tests.rs index 9b9ea93b..567bf617 100644 --- a/crates/engine-qwen35-cuda/src/settings/capture_tests.rs +++ b/crates/engine-qwen35-cuda/src/settings/capture_tests.rs @@ -1,3 +1,7 @@ +//! Pins the settings capture: only the operator namespace of the environment is captured, raw values are kept, an +//! empty environment gives every topic's defaults, and the conversation-cache and memory-governor keys are read +//! from the capture. + use super::{EnvSource, MapEnv, ServeSettings, Settings}; #[test]