From 1207415a19909d8a66cafb21bcbf774ff82474ae Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 21:33:08 +0100 Subject: [PATCH 1/2] Low-level crates: 52 modules named after two things (*_and_*) are named after their responsibility; exception paths, include paths and docs updated Co-Authored-By: Claude Sonnet 5.5 --- architecture.json | 4 +-- crates/context/src/rope_scaling.rs | 4 +-- ...nd_resolve.rs => setup_rope_resolution.rs} | 0 ...ntwise.rs => checked_attention_kernels.rs} | 3 +- crates/cpu-sys/src/lib.rs | 10 +++---- crates/cpu-sys/src/simd.rs | 18 ++++++------ ...s_and_formats.rs => scalar_dot_kernels.rs} | 0 ..._elementwise.rs => scalar_tile_kernels.rs} | 0 crates/cpu-sys/src/simd/x86.rs | 20 ++++++------- ...lementwise.rs => f16_attention_kernels.rs} | 0 ...ons_and_int_dots.rs => int_dot_kernels.rs} | 0 ...and_mxfp4_tiles.rs => q8_0_dot_kernels.rs} | 0 ...avx2_and_avxvnni.rs => x86_dot_kernels.rs} | 0 .../src/closed_kernels_gpu/closed_kernels.rs | 2 +- ...d_s_gemv.rs => closed_kernels_launches.rs} | 0 ...s => context_routed_gate_up_projection.rs} | 0 crates/cuda-driver/src/device_ref/tests.rs | 4 +-- .../src/experimental_gpu/facade_launches.rs | 2 +- ...v_pool_launches.rs => kv_pool_launches.rs} | 0 .../call_shape.rs | 0 .../step_operands.rs | 0 .../stream_keyless_cvec_launches.rs | 4 +-- ..._resolve_launch.rs => q8_gather_launch.rs} | 0 crates/cuda-driver/src/lib.rs | 12 ++++---- .../mapped_expert_bank_operations.rs | 4 +-- ...rs => mapped_expert_bank_device_copies.rs} | 0 ...ng.rs => mapped_expert_bank_host_views.rs} | 0 .../resident/original_group/copy_ring/ring.rs | 2 +- ...ng_gather_and_finish.rs => ring_gather.rs} | 0 .../original_group/original_mmq_layer.rs | 2 +- ...and_quantize.rs => layer_buffer_checks.rs} | 0 .../prefill/original_mtp_prefill.rs | 2 +- ...nd_settle.rs => command_list_execution.rs} | 0 .../prefill/scalar/full_forward.rs | 2 +- ...and_shape.rs => matrix_vector_planning.rs} | 0 .../full_forward_final_gr_stages.rs | 0 .../full_forward_finite_tail_mlp_gr.rs | 0 .../full_forward_moe_block_plan.rs | 0 .../original_mtp_full_forward.rs | 0 .../original_expert_cache_operations.rs | 4 +-- .../original_expert_cache_adaptive_swaps.rs | 2 +- ...lend.rs => original_expert_cache_loans.rs} | 2 +- ...lots.rs => original_expert_cache_slots.rs} | 0 .../src/original_file_expert_source.rs | 6 ++-- .../original_file_expert_source_operations.rs | 2 +- ...d_blobs.rs => file_expert_source_blobs.rs} | 0 ...d_blob.rs => original_file_source_blob.rs} | 0 .../src/original_gpu_schedule/abi/platform.rs | 2 +- ...and_flag_writes.rs => async_copy_flags.rs} | 0 .../original_verify_gdn_journal.rs | 2 +- .../verify_gdn_fused_step.rs | 2 +- ...commit.rs => verify_gdn_journal_commit.rs} | 0 .../src/original_verify/qsa/qsa_window.rs | 2 +- ...nd.rs => qsa_window_attention_launches.rs} | 0 .../original_verify/share_window_modules.rs | 28 +++++++++---------- ...n_open.rs => verify_bank_canonical_gdn.rs} | 0 ...dow_rows.rs => verify_bank_plan_access.rs} | 0 .../src/original_verify/window_ops.rs | 2 +- .../window_ops/window_launches.rs | 2 +- ..._pcie_plan.rs => window_step_recording.rs} | 0 .../src/ple_batch_ffi/driver_backed.rs | 2 +- ...e_launch_and_close.rs => kernel_module.rs} | 0 ...s_and_bounds.rs => projection_geometry.rs} | 0 .../cuda-driver/src/qsa_prompt_attention.rs | 2 +- ...and_passes.rs => attention_launch_plan.rs} | 0 .../attention_passes.rs | 0 .../prompt_attention_owner.rs | 0 .../reject_mutual_alias.rs | 0 .../qsa_prompt_attention/device_attention.rs | 2 +- .../resident_attention.rs | 2 +- crates/cuda-driver/src/qsa_prompt_index.rs | 2 +- ...d_close.rs => qsa_prompt_index_results.rs} | 0 .../original_qsa_mapped_prefix.rs | 4 +-- ...resolve.rs => qsa_mapped_journal_arena.rs} | 0 ...s => qsa_mapped_journal_prefix_lineage.rs} | 0 .../gdn_native_batch/gdn_batch_prefix.rs | 4 +-- ...ojections.rs => gdn_batch_input_stages.rs} | 0 ...tput.rs => gdn_batch_recurrence_stages.rs} | 0 crates/cuda-driver/src/qwen_ffi.rs | 18 ++++++------ ..._and_bf16_layout.rs => asset_admission.rs} | 0 crates/experimental-ref/src/cvec.rs | 4 +-- ...c_reading_and_errors.rs => cvec_reader.rs} | 0 crates/gptoss-npu/src/lib.rs | 2 +- ..._and_estimates.rs => npu_prefill_setup.rs} | 0 .../{state_and_cache.rs => decode_state.rs} | 0 crates/gptoss/src/lib.rs | 8 +++--- .../{bytes_and_errors.rs => model_bytes.rs} | 0 .../src/{error_and_kind.rs => gpu_error.rs} | 2 +- crates/igpu/src/lib.rs | 10 +++---- ...ices_and_moe_plan.rs => matrix_uploads.rs} | 0 ...uting.rs => recorder_activation_passes.rs} | 0 ...on_and_submit.rs => recorder_attention.rs} | 0 crates/igpu/src/shaders.rs | 12 ++++---- ...d_combine.rs => expert_routing_shaders.rs} | 0 ...tize_and_swiglu.rs => quantize_shaders.rs} | 0 ...rm_and_rope.rs => rmsnorm_rope_shaders.rs} | 0 .../src/rust_general_pool.rs | 2 +- ...and_quantize_lanes.rs => phase_handoff.rs} | 0 ...pile_and_infer.rs => inference_runtime.rs} | 0 crates/openvino/src/lib.rs | 4 +-- docs/architecture/size-split-rest.md | 14 +++++----- docs/experiments/ffn-phase-loss-design.md | 6 ++-- docs/experiments/hit-gap-causes-2026-11-11.md | 2 +- docs/experiments/verify-accept-on-device.md | 6 ++-- docs/experiments/verify-gdn-fused-kernels.md | 4 +-- 105 files changed, 132 insertions(+), 131 deletions(-) rename crates/context/src/rope_scaling/{setup_rope_error_and_resolve.rs => setup_rope_resolution.rs} (100%) rename crates/cpu-sys/src/{attention_and_elementwise.rs => checked_attention_kernels.rs} (96%) rename crates/cpu-sys/src/simd/{scalar_dots_and_formats.rs => scalar_dot_kernels.rs} (100%) rename crates/cpu-sys/src/simd/{scalar_tiles_and_elementwise.rs => scalar_tile_kernels.rs} (100%) rename crates/cpu-sys/src/simd/x86/{f16_attention_and_elementwise.rs => f16_attention_kernels.rs} (100%) rename crates/cpu-sys/src/simd/x86/{reductions_and_int_dots.rs => int_dot_kernels.rs} (100%) rename crates/cpu-sys/src/simd/x86/{q8_dots_and_mxfp4_tiles.rs => q8_0_dot_kernels.rs} (100%) rename crates/cpu-sys/src/{avx2_and_avxvnni.rs => x86_dot_kernels.rs} (100%) rename crates/cuda-driver/src/closed_kernels_gpu/closed_kernels/{closed_kernels_flash_and_s_gemv.rs => closed_kernels_launches.rs} (100%) rename crates/cuda-driver/src/{context_q8_1_and_gate_up_projection.rs => context_routed_gate_up_projection.rs} (100%) rename crates/cuda-driver/src/experimental_gpu/facade_launches/{program_and_kv_pool_launches.rs => kv_pool_launches.rs} (100%) rename crates/cuda-driver/src/experimental_gpu/facade_launches/{program_and_kv_pool_launches => kv_pool_launches}/call_shape.rs (100%) rename crates/cuda-driver/src/experimental_gpu/facade_launches/{program_and_kv_pool_launches => kv_pool_launches}/step_operands.rs (100%) rename crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches/{q8_gather_and_resolve_launch.rs => q8_gather_launch.rs} (100%) rename crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/{mapped_expert_bank_pcie_and_triplets.rs => mapped_expert_bank_device_copies.rs} (100%) rename crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/{mapped_expert_bank_pieces_and_pinning.rs => mapped_expert_bank_host_views.rs} (100%) rename crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/{ring_gather_and_finish.rs => ring_gather.rs} (100%) rename crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer/{finite_and_quantize.rs => layer_buffer_checks.rs} (100%) rename crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill/{run_and_settle.rs => command_list_execution.rs} (100%) rename crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/{matrix_vector_buffers_and_shape.rs => matrix_vector_planning.rs} (100%) rename crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/{matrix_vector_buffers_and_shape => matrix_vector_planning}/full_forward_final_gr_stages.rs (100%) rename crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/{matrix_vector_buffers_and_shape => matrix_vector_planning}/full_forward_finite_tail_mlp_gr.rs (100%) rename crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/{matrix_vector_buffers_and_shape => matrix_vector_planning}/full_forward_moe_block_plan.rs (100%) rename crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/{matrix_vector_buffers_and_shape => matrix_vector_planning}/original_mtp_full_forward.rs (100%) rename crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/{original_expert_cache_verify_and_lend.rs => original_expert_cache_loans.rs} (99%) rename crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/{original_expert_cache_open_and_slots.rs => original_expert_cache_slots.rs} (100%) rename crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations/{file_expert_source_stages_and_blobs.rs => file_expert_source_blobs.rs} (100%) rename crates/cuda-driver/src/original_file_expert_source/{original_resident_options_and_blob.rs => original_file_source_blob.rs} (100%) rename crates/cuda-driver/src/original_gpu_schedule/abi/platform/{async_copies_and_flag_writes.rs => async_copy_flags.rs} (100%) rename crates/cuda-driver/src/original_verify/original_verify_gdn_journal/{verify_gdn_journal_stage_and_commit.rs => verify_gdn_journal_commit.rs} (100%) rename crates/cuda-driver/src/original_verify/qsa/qsa_window/{qsa_window_select_and_attend.rs => qsa_window_attention_launches.rs} (100%) rename crates/cuda-driver/src/original_verify/share_window_modules/{verify_bank_and_canonical_gdn_open.rs => verify_bank_canonical_gdn.rs} (100%) rename crates/cuda-driver/src/original_verify/share_window_modules/{verify_bank_plan_and_window_rows.rs => verify_bank_plan_access.rs} (100%) rename crates/cuda-driver/src/original_verify/window_ops/{window_ops_kernels_and_pcie_plan.rs => window_step_recording.rs} (100%) rename crates/cuda-driver/src/ple_batch_ffi/driver_backed/{kernel_module_launch_and_close.rs => kernel_module.rs} (100%) rename crates/cuda-driver/src/{projection_grids_and_bounds.rs => projection_geometry.rs} (100%) rename crates/cuda-driver/src/qsa_prompt_attention/{attention_kernel_plan_and_passes.rs => attention_launch_plan.rs} (100%) rename crates/cuda-driver/src/qsa_prompt_attention/{attention_kernel_plan_and_passes => attention_launch_plan}/attention_passes.rs (100%) rename crates/cuda-driver/src/qsa_prompt_attention/{attention_kernel_plan_and_passes => attention_launch_plan}/prompt_attention_owner.rs (100%) rename crates/cuda-driver/src/qsa_prompt_attention/{attention_kernel_plan_and_passes => attention_launch_plan}/reject_mutual_alias.rs (100%) rename crates/cuda-driver/src/qsa_prompt_index/{qsa_prompt_index_read_and_close.rs => qsa_prompt_index_results.rs} (100%) rename crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/{qsa_mapped_journal_append_and_resolve.rs => qsa_mapped_journal_arena.rs} (100%) rename crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/{qsa_mapped_journal_prefix_and_prefetch.rs => qsa_mapped_journal_prefix_lineage.rs} (100%) rename crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/{qkv_and_z_projections.rs => gdn_batch_input_stages.rs} (100%) rename crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/{recurrence_and_output.rs => gdn_batch_recurrence_stages.rs} (100%) rename crates/cuda-driver/src/qwen_ffi/{asset_validation_and_bf16_layout.rs => asset_admission.rs} (100%) rename crates/experimental-ref/src/cvec/{cvec_reading_and_errors.rs => cvec_reader.rs} (100%) rename crates/gptoss-npu/src/{construction_and_estimates.rs => npu_prefill_setup.rs} (100%) rename crates/gptoss/src/{state_and_cache.rs => decode_state.rs} (100%) rename crates/gptoss/src/{bytes_and_errors.rs => model_bytes.rs} (100%) rename crates/igpu/src/{error_and_kind.rs => gpu_error.rs} (89%) rename crates/igpu/src/{matrices_and_moe_plan.rs => matrix_uploads.rs} (100%) rename crates/igpu/src/{recorder_norm_and_routing.rs => recorder_activation_passes.rs} (100%) rename crates/igpu/src/{recorder_attention_and_submit.rs => recorder_attention.rs} (100%) rename crates/igpu/src/shaders/{routing_and_combine.rs => expert_routing_shaders.rs} (100%) rename crates/igpu/src/shaders/{quantize_and_swiglu.rs => quantize_shaders.rs} (100%) rename crates/igpu/src/shaders/{tiling_norm_and_rope.rs => rmsnorm_rope_shaders.rs} (100%) rename crates/native-cpu-expert/src/rust_general_pool/{shared_wait_done_and_quantize_lanes.rs => phase_handoff.rs} (100%) rename crates/openvino/src/{compile_and_infer.rs => inference_runtime.rs} (100%) diff --git a/architecture.json b/architecture.json index 2f03f810..7332f757 100644 --- a/architecture.json +++ b/architecture.json @@ -92,7 +92,7 @@ {"crate": "leleka-gptoss-npu", "file": "src/service_transfers.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: transfer wall-time measurement toward the NPU service"}, {"crate": "leleka-gpu-npu-worker", "file": "src/lib.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the split prefill passes, reported in the timing line"}, {"crate": "leleka-gpu-npu-worker", "file": "src/split_run.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: lap timers of the GPU and NPU legs of the split prefill"}, - {"crate": "leleka-igpu", "file": "src/matrices_and_moe_plan.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the weight upload, reported at load"}, + {"crate": "leleka-igpu", "file": "src/matrix_uploads.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the weight upload, reported at load"}, {"crate": "leleka-npu-service", "file": "src/engine/execution.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: lap timers of one NPU execution, summed into the profile report"}, {"crate": "leleka-model-format", "file": "src/bulk_read/for_each_chunk.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the bulk read, reported in the load report"}, {"crate": "leleka-model-format", "file": "src/huge_pages.rs", "ratchet": "instant-now", "reason": "measurement timer, not decision logic: wall-time measurement of the huge-page allocation probe, reported in the load report"}, @@ -111,7 +111,7 @@ {"crate": "leleka-experimental-ref", "file": "src/remote_experts.rs", "ratchet": "dyn-trait", "reason": "parameter struct Candidates borrows the primary's residency test from the caller's table; generic parameters would leak into every caller's signature"}, {"crate": "leleka-cpu-worker", "file": "src/engine.rs", "ratchet": "dyn-trait", "reason": "port boundary: the engine holds the prefill accelerator (iGPU, NPU or split) as Box, chosen by the worker binary"}, {"crate": "leleka-cpu-worker", "file": "src/serve.rs", "ratchet": "dyn-trait", "reason": "dyn-compatible worker trait: the progress callback of a trait method must be a trait object"}, - {"crate": "leleka-gptoss", "file": "src/state_and_cache.rs", "ratchet": "dyn-trait", "reason": "port boundary: PrefillAccelerator and LayerCache are the accelerator seams, chosen by the worker binary; their methods take the progress callback as a trait object"}, + {"crate": "leleka-gptoss", "file": "src/decode_state.rs", "ratchet": "dyn-trait", "reason": "port boundary: PrefillAccelerator and LayerCache are the accelerator seams, chosen by the worker binary; their methods take the progress callback as a trait object"}, {"crate": "leleka-gptoss", "file": "src/model.rs", "ratchet": "dyn-trait", "reason": "port boundary: the model's weights read through Arc (file, memory map or test bytes), chosen when the model is loaded"}, {"crate": "leleka-gptoss", "file": "src/tensor_loading.rs", "ratchet": "dyn-trait", "reason": "port boundary: the model's weights read through Arc (file, memory map or test bytes), chosen when the model is loaded"}, {"crate": "leleka-gptoss", "file": "src/weights.rs", "ratchet": "dyn-trait", "reason": "port boundary: the model's weights read through Arc (file, memory map or test bytes), chosen when the model is loaded"}, diff --git a/crates/context/src/rope_scaling.rs b/crates/context/src/rope_scaling.rs index f0366622..4fc65ec5 100644 --- a/crates/context/src/rope_scaling.rs +++ b/crates/context/src/rope_scaling.rs @@ -169,5 +169,5 @@ mod rope_scaling_type; pub use rope_scaling_type::*; mod rope_table; pub use rope_table::*; -mod setup_rope_error_and_resolve; -pub use setup_rope_error_and_resolve::*; +mod setup_rope_resolution; +pub use setup_rope_resolution::*; diff --git a/crates/context/src/rope_scaling/setup_rope_error_and_resolve.rs b/crates/context/src/rope_scaling/setup_rope_resolution.rs similarity index 100% rename from crates/context/src/rope_scaling/setup_rope_error_and_resolve.rs rename to crates/context/src/rope_scaling/setup_rope_resolution.rs diff --git a/crates/cpu-sys/src/attention_and_elementwise.rs b/crates/cpu-sys/src/checked_attention_kernels.rs similarity index 96% rename from crates/cpu-sys/src/attention_and_elementwise.rs rename to crates/cpu-sys/src/checked_attention_kernels.rs index 88495a46..530ee80e 100644 --- a/crates/cpu-sys/src/attention_and_elementwise.rs +++ b/crates/cpu-sys/src/checked_attention_kernels.rs @@ -1,4 +1,5 @@ -//! Attention score and weighted-sum kernels, SwiGLU, f16 conversion and the softmax exponent sum. +//! The argument-checked scalar and AVX2 entry points of the attention score and weighted-sum kernels; the elementwise +//! kernels (SwiGLU, f16 conversion, the softmax exponent sum) are the second clause of the same checked surface. use super::{AttnShape, KernelError, ScoreSpec, check_scores, check_swiglu, check_weighted_sum, simd}; #[cfg(target_arch="x86_64")] diff --git a/crates/cpu-sys/src/lib.rs b/crates/cpu-sys/src/lib.rs index 019dc521..c3dd4392 100644 --- a/crates/cpu-sys/src/lib.rs +++ b/crates/cpu-sys/src/lib.rs @@ -127,22 +127,22 @@ pub use portable::{ dot_q8_0_q8_0_scalar, dot_q8_0_q8r_multi_scalar, f32_to_f16_bits_scalar, mxfp4_q8_0_isums_scalar, q8_0_q8_0_isums_scalar, quantize_q8_0_scalar, }; -mod avx2_and_avxvnni; +mod x86_dot_kernels; #[cfg(target_arch = "x86_64")] -pub use avx2_and_avxvnni::{ +pub use x86_dot_kernels::{ dot_i4i8_avx2, dot_i4i8_avxvnni, dot_i8i8_avx2, dot_i8i8_avxvnni, dot_mxfp4_q8_0_avx2, dot_mxfp4_q8_0_avxvnni, dot_mxfp4_q8r_avx2, dot_mxfp4_q8r4_avx2, dot_mxfp4_q8r4_avxvnni, dot_mxfp4_q8r4_multi_avx2, dot_mxfp4_q8r4_multi_avxvnni, dot_q8_0_q8_0_avx2, dot_q8_0_q8_0_avxvnni, dot_q8_0_q8r_multi_avx2, dot_q8_0_q8r_multi_avxvnni, f32_to_f16_bits_f16c, mxfp4_q8_0_isums_avx2, mxfp4_q8_0_isums_avxvnni, q8_0_q8_0_isums_avx2, q8_0_q8_0_isums_avxvnni, quantize_q8_0_avx2, }; -mod attention_and_elementwise; +mod checked_attention_kernels; #[cfg(target_arch = "x86_64")] -pub use attention_and_elementwise::{ +pub use checked_attention_kernels::{ attn_scores_avx2, attn_scores_f16_avx2, attn_weighted_sum_avx2, attn_weighted_sum_f16_avx2, exp_shift_sum_avx2, f16_to_f32_slice_avx2, f32_to_f16_slice_avx2, swiglu_oai_avx2, }; -pub use attention_and_elementwise::{ +pub use checked_attention_kernels::{ attn_scores_f16_scalar, attn_scores_scalar, attn_weighted_sum_f16_scalar, attn_weighted_sum_scalar, exp_shift_sum_scalar, f16_to_f32_slice_scalar, f32_to_f16_slice_scalar, swiglu_oai_scalar, }; diff --git a/crates/cpu-sys/src/simd.rs b/crates/cpu-sys/src/simd.rs index f9a829c7..3d5fad1e 100644 --- a/crates/cpu-sys/src/simd.rs +++ b/crates/cpu-sys/src/simd.rs @@ -79,19 +79,19 @@ pub const MULTI_MAX: usize = 16; #[cfg(target_arch = "x86_64")] pub mod x86; -mod scalar_dots_and_formats; -use scalar_dots_and_formats::load_u16; -pub use scalar_dots_and_formats::{ +mod scalar_dot_kernels; +use scalar_dot_kernels::load_u16; +pub use scalar_dot_kernels::{ attn_scores_f16_scalar, attn_scores_scalar, attn_weighted_sum_f16_scalar, attn_weighted_sum_scalar, dot_mxfp4_q8_0_scalar, dot_mxfp4_q8r_scalar, dot_q8_q8r_scalar, mxfp4_q8_0_isums_scalar, }; -pub use scalar_dots_and_formats::{dot_i4i8_scalar, dot_i8i8_scalar}; -pub use scalar_dots_and_formats::{e8m0_half, f16_to_f32, f32_to_f16}; -mod scalar_tiles_and_elementwise; -use scalar_tiles_and_elementwise::dot_i4i8_tail; -pub use scalar_tiles_and_elementwise::{ +pub use scalar_dot_kernels::{dot_i4i8_scalar, dot_i8i8_scalar}; +pub use scalar_dot_kernels::{e8m0_half, f16_to_f32, f32_to_f16}; +mod scalar_tile_kernels; +use scalar_tile_kernels::dot_i4i8_tail; +pub use scalar_tile_kernels::{ dot_mxfp4_q8r_multi_scalar, dot_q8_0_q8r_multi_scalar, exp_shift_sum_scalar, f16_to_f32_slice_scalar, f32_to_f16_slice_scalar, mxfp4_q8r_tile_scalar, prepare_act, q8_q8r_tile_scalar, quantize_q8_0_scalar, swiglu_oai_scalar, }; -pub use scalar_tiles_and_elementwise::{dot_q8_0_q8_0_scalar, q8_0_q8_0_isums_scalar}; +pub use scalar_tile_kernels::{dot_q8_0_q8_0_scalar, q8_0_q8_0_isums_scalar}; diff --git a/crates/cpu-sys/src/simd/scalar_dots_and_formats.rs b/crates/cpu-sys/src/simd/scalar_dot_kernels.rs similarity index 100% rename from crates/cpu-sys/src/simd/scalar_dots_and_formats.rs rename to crates/cpu-sys/src/simd/scalar_dot_kernels.rs diff --git a/crates/cpu-sys/src/simd/scalar_tiles_and_elementwise.rs b/crates/cpu-sys/src/simd/scalar_tile_kernels.rs similarity index 100% rename from crates/cpu-sys/src/simd/scalar_tiles_and_elementwise.rs rename to crates/cpu-sys/src/simd/scalar_tile_kernels.rs diff --git a/crates/cpu-sys/src/simd/x86.rs b/crates/cpu-sys/src/simd/x86.rs index b5618cb2..3baf607f 100644 --- a/crates/cpu-sys/src/simd/x86.rs +++ b/crates/cpu-sys/src/simd/x86.rs @@ -181,30 +181,30 @@ multi_kernel!( |xb, ib| (_mm256_loadu_si256(xb.add(2) as *const __m256i), half_to_f32(xb)) ); -mod reductions_and_int_dots; -use reductions_and_int_dots::{block_p32_avx2, mx_table, mx_values}; -use reductions_and_int_dots::{cvt_f32_f16, half_to_f32, hsum_epi32, hsum_ps}; -pub use reductions_and_int_dots::{dot_i4i8_avx2, dot_i4i8_avxvnni, dot_i8i8_avx2, dot_i8i8_avxvnni}; +mod int_dot_kernels; +use int_dot_kernels::{block_p32_avx2, mx_table, mx_values}; +use int_dot_kernels::{cvt_f32_f16, half_to_f32, hsum_epi32, hsum_ps}; +pub use int_dot_kernels::{dot_i4i8_avx2, dot_i4i8_avxvnni, dot_i8i8_avx2, dot_i8i8_avxvnni}; mod mxfp4_q8_dots; use mxfp4_q8_dots::{block_p32_vnni, mxfp4_scaled_fma}; pub use mxfp4_q8_dots::{ dot_mxfp4_q8_0_avx2, dot_mxfp4_q8_0_avxvnni, dot_mxfp4_q8r_avx2, dot_mxfp4_q8r4_avx2, mxfp4_q8_0_isums_avx2, mxfp4_q8_0_isums_avxvnni, }; -mod q8_dots_and_mxfp4_tiles; -pub use q8_dots_and_mxfp4_tiles::dot_mxfp4_q8r4_avxvnni; -pub use q8_dots_and_mxfp4_tiles::{ +mod q8_0_dot_kernels; +pub use q8_0_dot_kernels::dot_mxfp4_q8r4_avxvnni; +pub use q8_0_dot_kernels::{ dot_q8_0_q8_0_avx2, dot_q8_0_q8_0_avxvnni, q8_0_q8_0_isums_avx2, q8_0_q8_0_isums_avxvnni, }; -use q8_dots_and_mxfp4_tiles::{mx_table_biased, mxfp4_tile_avx2}; +use q8_0_dot_kernels::{mx_table_biased, mxfp4_tile_avx2}; mod tile_kernels; use tile_kernels::{decoded_p32_avx2, decoded_p32_vnni, multi_reduce}; pub use tile_kernels::{mxfp4_q8r_tile_avx2, mxfp4_q8r_tile_avxvnni, q8_q8r_tile_avx2, q8_q8r_tile_avxvnni}; mod attention_kernels; use attention_kernels::{WeightedSum, attn_dot_f16, exp256, load_f16x8}; pub use attention_kernels::{attn_scores_avx2, attn_weighted_sum_avx2}; -mod f16_attention_and_elementwise; -pub use f16_attention_and_elementwise::{ +mod f16_attention_kernels; +pub use f16_attention_kernels::{ attn_scores_f16_avx2, attn_weighted_sum_f16_avx2, exp_shift_sum_avx2, f16_to_f32_slice_avx2, f32_to_f16_f16c, f32_to_f16_slice_avx2, swiglu_oai_avx2, }; diff --git a/crates/cpu-sys/src/simd/x86/f16_attention_and_elementwise.rs b/crates/cpu-sys/src/simd/x86/f16_attention_kernels.rs similarity index 100% rename from crates/cpu-sys/src/simd/x86/f16_attention_and_elementwise.rs rename to crates/cpu-sys/src/simd/x86/f16_attention_kernels.rs diff --git a/crates/cpu-sys/src/simd/x86/reductions_and_int_dots.rs b/crates/cpu-sys/src/simd/x86/int_dot_kernels.rs similarity index 100% rename from crates/cpu-sys/src/simd/x86/reductions_and_int_dots.rs rename to crates/cpu-sys/src/simd/x86/int_dot_kernels.rs diff --git a/crates/cpu-sys/src/simd/x86/q8_dots_and_mxfp4_tiles.rs b/crates/cpu-sys/src/simd/x86/q8_0_dot_kernels.rs similarity index 100% rename from crates/cpu-sys/src/simd/x86/q8_dots_and_mxfp4_tiles.rs rename to crates/cpu-sys/src/simd/x86/q8_0_dot_kernels.rs diff --git a/crates/cpu-sys/src/avx2_and_avxvnni.rs b/crates/cpu-sys/src/x86_dot_kernels.rs similarity index 100% rename from crates/cpu-sys/src/avx2_and_avxvnni.rs rename to crates/cpu-sys/src/x86_dot_kernels.rs diff --git a/crates/cuda-driver/src/closed_kernels_gpu/closed_kernels.rs b/crates/cuda-driver/src/closed_kernels_gpu/closed_kernels.rs index 734ea422..35be303d 100644 --- a/crates/cuda-driver/src/closed_kernels_gpu/closed_kernels.rs +++ b/crates/cuda-driver/src/closed_kernels_gpu/closed_kernels.rs @@ -8,5 +8,5 @@ use super::{ poison_slots, s_gemv_entry_index, s_gemv_slots, s_operand_bytes, }; -mod closed_kernels_flash_and_s_gemv; +mod closed_kernels_launches; mod closed_kernels_open_admit_run; diff --git a/crates/cuda-driver/src/closed_kernels_gpu/closed_kernels/closed_kernels_flash_and_s_gemv.rs b/crates/cuda-driver/src/closed_kernels_gpu/closed_kernels/closed_kernels_launches.rs similarity index 100% rename from crates/cuda-driver/src/closed_kernels_gpu/closed_kernels/closed_kernels_flash_and_s_gemv.rs rename to crates/cuda-driver/src/closed_kernels_gpu/closed_kernels/closed_kernels_launches.rs diff --git a/crates/cuda-driver/src/context_q8_1_and_gate_up_projection.rs b/crates/cuda-driver/src/context_routed_gate_up_projection.rs similarity index 100% rename from crates/cuda-driver/src/context_q8_1_and_gate_up_projection.rs rename to crates/cuda-driver/src/context_routed_gate_up_projection.rs diff --git a/crates/cuda-driver/src/device_ref/tests.rs b/crates/cuda-driver/src/device_ref/tests.rs index ae448b6b..b63f0dd7 100644 --- a/crates/cuda-driver/src/device_ref/tests.rs +++ b/crates/cuda-driver/src/device_ref/tests.rs @@ -67,12 +67,12 @@ fn the_window_and_journal_modules_never_clone_a_handle() { include_str!("../original_verify/window_ops/qsa_prelude_ops.rs"), include_str!("../original_verify/window_ops/side_qsa_branches.rs"), include_str!("../original_verify/window_ops/side_shared_expert.rs"), - include_str!("../original_verify/window_ops/window_ops_kernels_and_pcie_plan.rs"), + include_str!("../original_verify/window_ops/window_step_recording.rs"), ]; let journals = [ include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs"), include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs"), - include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs"), + include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_commit.rs"), include_str!("../original_verify/original_verify_gdn_journal/verify_gdn_journal_window_launches.rs"), include_str!("../qsa_prompt_index/resident_index/verification_commit/verify_qsa_journal_capture_commit.rs"), include_str!("../qsa_prompt_index/resident_index/verification_commit/verify_qsa_journal_index_image.rs"), diff --git a/crates/cuda-driver/src/experimental_gpu/facade_launches.rs b/crates/cuda-driver/src/experimental_gpu/facade_launches.rs index fe5561fb..c713509f 100644 --- a/crates/cuda-driver/src/experimental_gpu/facade_launches.rs +++ b/crates/cuda-driver/src/experimental_gpu/facade_launches.rs @@ -10,5 +10,5 @@ use super::{ }; mod attention_launch; -mod program_and_kv_pool_launches; +mod kv_pool_launches; mod stream_keyless_cvec_launches; diff --git a/crates/cuda-driver/src/experimental_gpu/facade_launches/program_and_kv_pool_launches.rs b/crates/cuda-driver/src/experimental_gpu/facade_launches/kv_pool_launches.rs similarity index 100% rename from crates/cuda-driver/src/experimental_gpu/facade_launches/program_and_kv_pool_launches.rs rename to crates/cuda-driver/src/experimental_gpu/facade_launches/kv_pool_launches.rs diff --git a/crates/cuda-driver/src/experimental_gpu/facade_launches/program_and_kv_pool_launches/call_shape.rs b/crates/cuda-driver/src/experimental_gpu/facade_launches/kv_pool_launches/call_shape.rs similarity index 100% rename from crates/cuda-driver/src/experimental_gpu/facade_launches/program_and_kv_pool_launches/call_shape.rs rename to crates/cuda-driver/src/experimental_gpu/facade_launches/kv_pool_launches/call_shape.rs diff --git a/crates/cuda-driver/src/experimental_gpu/facade_launches/program_and_kv_pool_launches/step_operands.rs b/crates/cuda-driver/src/experimental_gpu/facade_launches/kv_pool_launches/step_operands.rs similarity index 100% rename from crates/cuda-driver/src/experimental_gpu/facade_launches/program_and_kv_pool_launches/step_operands.rs rename to crates/cuda-driver/src/experimental_gpu/facade_launches/kv_pool_launches/step_operands.rs diff --git a/crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches.rs b/crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches.rs index 6f6c7224..6f672576 100644 --- a/crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches.rs +++ b/crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches.rs @@ -7,8 +7,8 @@ use super::{ experimental, i32_of, i64_of, invalid, stream_runs, }; -mod q8_gather_and_resolve_launch; -use q8_gather_and_resolve_launch::Q8Gather; +mod q8_gather_launch; +use q8_gather_launch::Q8Gather; impl<'c> Experimental<'c> { /// `kv_gather_q8_step`: dequantize the selected cells into fp16 scratch (K and V of the same pool). diff --git a/crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches/q8_gather_and_resolve_launch.rs b/crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches/q8_gather_launch.rs similarity index 100% rename from crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches/q8_gather_and_resolve_launch.rs rename to crates/cuda-driver/src/experimental_gpu/facade_launches/stream_keyless_cvec_launches/q8_gather_launch.rs diff --git a/crates/cuda-driver/src/lib.rs b/crates/cuda-driver/src/lib.rs index f2f5364c..1fe8a90a 100644 --- a/crates/cuda-driver/src/lib.rs +++ b/crates/cuda-driver/src/lib.rs @@ -257,12 +257,12 @@ mod original_serve_access; mod bringup_trace_enabled; use bringup_trace_enabled::combine; use bringup_trace_enabled::valid_size; -mod projection_grids_and_bounds; -use projection_grids_and_bounds::projection_ranges; -use projection_grids_and_bounds::projection_shape; +mod projection_geometry; +use projection_geometry::projection_ranges; +use projection_geometry::projection_shape; #[cfg(test)] -use projection_grids_and_bounds::q4_k_native_indices_fit; -use projection_grids_and_bounds::q5_k_shape; +use projection_geometry::q4_k_native_indices_fit; +use projection_geometry::q5_k_shape; mod q6_k_shape; use q6_k_shape::matvec_allocations; use q6_k_shape::matvec_shape; @@ -272,7 +272,7 @@ mod context; mod context_gate_up_projection_admission; mod context_matvec_k_quant_projections; mod context_projection_kernel_slots; -mod context_q8_1_and_gate_up_projection; +mod context_routed_gate_up_projection; mod context_unload_close_destroy; mod device_buffer; diff --git a/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations.rs b/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations.rs index c8c118b6..c8186909 100644 --- a/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations.rs +++ b/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations.rs @@ -8,5 +8,5 @@ use super::{ }; mod mapped_expert_bank_close; -mod mapped_expert_bank_pcie_and_triplets; -mod mapped_expert_bank_pieces_and_pinning; +mod mapped_expert_bank_device_copies; +mod mapped_expert_bank_host_views; diff --git a/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_pcie_and_triplets.rs b/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_device_copies.rs similarity index 100% rename from crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_pcie_and_triplets.rs rename to crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_device_copies.rs diff --git a/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_pieces_and_pinning.rs b/crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_host_views.rs similarity index 100% rename from crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_pieces_and_pinning.rs rename to crates/cuda-driver/src/mapped_expert_bank/mapped_expert_bank_operations/mapped_expert_bank_host_views.rs diff --git a/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring.rs b/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring.rs index 78d57b42..714a24a0 100644 --- a/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring.rs +++ b/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring.rs @@ -8,7 +8,7 @@ use super::{ }; mod ring_construction; -mod ring_gather_and_finish; +mod ring_gather; mod ring_init; mod ring_prefetch; pub(super) use ring_prefetch::profile_prefetch; diff --git a/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_gather_and_finish.rs b/crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_gather.rs similarity index 100% rename from crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_gather_and_finish.rs rename to crates/cuda-driver/src/mmq/resident/original_group/copy_ring/ring/ring_gather.rs diff --git a/crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer.rs b/crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer.rs index 3f3c0ae1..5eaf2902 100644 --- a/crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer.rs +++ b/crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer.rs @@ -7,6 +7,6 @@ use super::{ STATUS, TMP, WD, WG, WIDTHS, XQ, commands, ffi, format_index, kind, layout, }; -mod finite_and_quantize; +mod layer_buffer_checks; mod group_projection; mod original_mmq_layer_stage_experts; diff --git a/crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer/finite_and_quantize.rs b/crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer/layer_buffer_checks.rs similarity index 100% rename from crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer/finite_and_quantize.rs rename to crates/cuda-driver/src/mmq/resident/original_group/original_mmq_layer/layer_buffer_checks.rs diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill.rs index b4a3866b..f0775fad 100644 --- a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill.rs +++ b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill.rs @@ -16,7 +16,7 @@ mod original_mtp_prefill_close; mod projection_commands; mod record_operands; mod record_walk; -mod run_and_settle; +mod command_list_execution; use record_operands::{ Admit, AppendBlock, Block, Call, GrBufs, KernelAt, KernelShape, PageRuns, ProjectionAddresses, ProjectionDims, Stage, Staged, WEIGHT_EXTENTS, diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill/run_and_settle.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill/command_list_execution.rs similarity index 100% rename from crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill/run_and_settle.rs rename to crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/original_mtp_prefill/command_list_execution.rs diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward.rs index 66dc0382..b75c81de 100644 --- a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward.rs +++ b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward.rs @@ -331,6 +331,6 @@ use validate_scalar_prefix::push; use validate_scalar_prefix::validate_scalar_prefix; mod context_original_mtp_shared_layout; mod full_forward_prefix_program; -mod matrix_vector_buffers_and_shape; +mod matrix_vector_planning; mod original_mtp_forward_program; mod original_mtp_forward_program_original_graph; diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning.rs similarity index 100% rename from crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape.rs rename to crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning.rs diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/full_forward_final_gr_stages.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/full_forward_final_gr_stages.rs similarity index 100% rename from crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/full_forward_final_gr_stages.rs rename to crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/full_forward_final_gr_stages.rs diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/full_forward_finite_tail_mlp_gr.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/full_forward_finite_tail_mlp_gr.rs similarity index 100% rename from crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/full_forward_finite_tail_mlp_gr.rs rename to crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/full_forward_finite_tail_mlp_gr.rs diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/full_forward_moe_block_plan.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/full_forward_moe_block_plan.rs similarity index 100% rename from crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/full_forward_moe_block_plan.rs rename to crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/full_forward_moe_block_plan.rs diff --git a/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/original_mtp_full_forward.rs b/crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/original_mtp_full_forward.rs similarity index 100% rename from crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_buffers_and_shape/original_mtp_full_forward.rs rename to crates/cuda-driver/src/mtp_dense_kv/original_int8/prefill/scalar/full_forward/matrix_vector_planning/original_mtp_full_forward.rs diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations.rs index 3a015c02..39a27fc5 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations.rs @@ -12,5 +12,5 @@ mod original_expert_cache_adaptive_swaps; mod original_expert_cache_batched_refill; pub use original_expert_cache_batched_refill::RefillBatchOptions; mod original_expert_cache_file_slot_fill; -mod original_expert_cache_open_and_slots; -mod original_expert_cache_verify_and_lend; +mod original_expert_cache_slots; +mod original_expert_cache_loans; diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_adaptive_swaps.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_adaptive_swaps.rs index 7864529b..bf8788ce 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_adaptive_swaps.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_adaptive_swaps.rs @@ -1,7 +1,7 @@ //! Expert cache: the adaptive swap batch (arm event, poll/wait, publish swapped slots) and the queued fills from a //! mapped bank or probe bytes, with admission checks, the copy stream choice and the liveness guard. -use super::original_expert_cache_open_and_slots::{check_total, span_layer}; +use super::original_expert_cache_slots::{check_total, span_layer}; use super::{ Error, MappedExpertBank, OriginalExpertCache, Rc, ResidentExpertBankSpan, Result, RetainedFill, State, api, combine, ffi, diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_verify_and_lend.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_loans.rs similarity index 99% rename from crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_verify_and_lend.rs rename to crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_loans.rs index eb62a26b..bcf983c1 100644 --- a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_verify_and_lend.rs +++ b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_loans.rs @@ -1,7 +1,7 @@ //! Expert cache audits and loans: read-back byte verification of a filled slot against its source, lending the cache //! tail slots to a prefill (choose_loan, lend_prefill_tail, needs_refill), plus poison, close and leak-all teardown. -use super::original_expert_cache_open_and_slots::span_layer; +use super::original_expert_cache_slots::span_layer; use super::{ Error, MappedExpertBank, OriginalCachePrefix, OriginalExpertCache, OriginalPrefillArena, PrefillLayoutOptions, ResidentExpertBankSpan, Result, State, combine, ffi, diff --git a/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_open_and_slots.rs b/crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_slots.rs similarity index 100% rename from crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_open_and_slots.rs rename to crates/cuda-driver/src/original_expert_cache/original_expert_cache_operations/original_expert_cache_slots.rs diff --git a/crates/cuda-driver/src/original_file_expert_source.rs b/crates/cuda-driver/src/original_file_expert_source.rs index 810a99d2..92bf4751 100644 --- a/crates/cuda-driver/src/original_file_expert_source.rs +++ b/crates/cuda-driver/src/original_file_expert_source.rs @@ -116,9 +116,9 @@ pub(crate) enum OriginalFileStreamSource<'source, 'ctx> { }, } -mod original_resident_options_and_blob; -use original_resident_options_and_blob::key; -use original_resident_options_and_blob::vec_filled; +mod original_file_source_blob; +use original_file_source_blob::key; +use original_file_source_blob::vec_filled; mod file_expert_source_swap_exchanges; mod original_file_expert_source_operations; #[cfg(windows)] diff --git a/crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations.rs b/crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations.rs index 63b96dc9..3753d8af 100644 --- a/crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations.rs +++ b/crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations.rs @@ -12,6 +12,6 @@ use super::{ mod build_phases; mod file_expert_source_cache_complement; mod file_expert_source_prefetch; -mod file_expert_source_stages_and_blobs; +mod file_expert_source_blobs; mod file_expert_source_status_counters; mod fill_workers; diff --git a/crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations/file_expert_source_stages_and_blobs.rs b/crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations/file_expert_source_blobs.rs similarity index 100% rename from crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations/file_expert_source_stages_and_blobs.rs rename to crates/cuda-driver/src/original_file_expert_source/original_file_expert_source_operations/file_expert_source_blobs.rs diff --git a/crates/cuda-driver/src/original_file_expert_source/original_resident_options_and_blob.rs b/crates/cuda-driver/src/original_file_expert_source/original_file_source_blob.rs similarity index 100% rename from crates/cuda-driver/src/original_file_expert_source/original_resident_options_and_blob.rs rename to crates/cuda-driver/src/original_file_expert_source/original_file_source_blob.rs diff --git a/crates/cuda-driver/src/original_gpu_schedule/abi/platform.rs b/crates/cuda-driver/src/original_gpu_schedule/abi/platform.rs index 0763ddac..39d7389c 100644 --- a/crates/cuda-driver/src/original_gpu_schedule/abi/platform.rs +++ b/crates/cuda-driver/src/original_gpu_schedule/abi/platform.rs @@ -80,4 +80,4 @@ use library_drop::check; use library_drop::noop_host_fn; use library_drop::raise_after_copies; mod api; -mod async_copies_and_flag_writes; +mod async_copy_flags; diff --git a/crates/cuda-driver/src/original_gpu_schedule/abi/platform/async_copies_and_flag_writes.rs b/crates/cuda-driver/src/original_gpu_schedule/abi/platform/async_copy_flags.rs similarity index 100% rename from crates/cuda-driver/src/original_gpu_schedule/abi/platform/async_copies_and_flag_writes.rs rename to crates/cuda-driver/src/original_gpu_schedule/abi/platform/async_copy_flags.rs diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs index ceb53f7e..17890e10 100644 --- a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal.rs @@ -12,6 +12,6 @@ use super::{ mod original_verify_window; mod verify_gdn_fused_step; mod verify_gdn_journal_ladder_logits_scan; -mod verify_gdn_journal_stage_and_commit; +mod verify_gdn_journal_commit; mod verify_gdn_journal_window_launches; pub(crate) use original_verify_window::verify_assets_sealed; diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs index 2eb0029f..2ac0573b 100644 --- a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs +++ b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs @@ -3,7 +3,7 @@ //! `capture_layer_stage` binds for the three Original kernels. use super::super::gdn_fused::{AbUnrolledStep, FusedGdnBuffers, FusedGdnStep, GateSource, GdnGateOperands, RowSpan}; -use super::verify_gdn_journal_stage_and_commit::StageOperands; +use super::verify_gdn_journal_commit::StageOperands; use super::{EPS, Error, OriginalCapture, OriginalGraphResources, OriginalVerifyGdnJournal, Result, admit}; impl<'ctx> OriginalVerifyGdnJournal<'ctx> { diff --git a/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs b/crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_commit.rs similarity index 100% rename from crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_stage_and_commit.rs rename to crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_journal_commit.rs diff --git a/crates/cuda-driver/src/original_verify/qsa/qsa_window.rs b/crates/cuda-driver/src/original_verify/qsa/qsa_window.rs index ae08106f..594e30f9 100644 --- a/crates/cuda-driver/src/original_verify/qsa/qsa_window.rs +++ b/crates/cuda-driver/src/original_verify/qsa/qsa_window.rs @@ -11,4 +11,4 @@ use super::{ mod qsa_window_prelude_rows; mod qsa_window_query_key_paths; -mod qsa_window_select_and_attend; +mod qsa_window_attention_launches; diff --git a/crates/cuda-driver/src/original_verify/qsa/qsa_window/qsa_window_select_and_attend.rs b/crates/cuda-driver/src/original_verify/qsa/qsa_window/qsa_window_attention_launches.rs similarity index 100% rename from crates/cuda-driver/src/original_verify/qsa/qsa_window/qsa_window_select_and_attend.rs rename to crates/cuda-driver/src/original_verify/qsa/qsa_window/qsa_window_attention_launches.rs diff --git a/crates/cuda-driver/src/original_verify/share_window_modules.rs b/crates/cuda-driver/src/original_verify/share_window_modules.rs index 82e1b5b3..9fe3cc2a 100644 --- a/crates/cuda-driver/src/original_verify/share_window_modules.rs +++ b/crates/cuda-driver/src/original_verify/share_window_modules.rs @@ -9,19 +9,19 @@ use super::{ RESERVE, Rc, RefCell, Result, STATE_WORDS, StagedWindow, combine, diag, kernels, profile, resources, }; -mod verify_bank_and_canonical_gdn_open; -pub(super) use verify_bank_and_canonical_gdn_open::admission; -pub(super) use verify_bank_and_canonical_gdn_open::admit; -pub(super) use verify_bank_and_canonical_gdn_open::check_canonical_lengths; -pub(super) use verify_bank_and_canonical_gdn_open::check_commands; -pub(super) use verify_bank_and_canonical_gdn_open::command; -pub(crate) use verify_bank_and_canonical_gdn_open::gather_rows_module; -pub(super) use verify_bank_and_canonical_gdn_open::handle; -pub(super) use verify_bank_and_canonical_gdn_open::poison; -pub(super) use verify_bank_and_canonical_gdn_open::sealed_asset; -pub(super) use verify_bank_and_canonical_gdn_open::share_window_modules; -pub(super) use verify_bank_and_canonical_gdn_open::transport; -pub(super) use verify_bank_and_canonical_gdn_open::zero; +mod verify_bank_canonical_gdn; +pub(super) use verify_bank_canonical_gdn::admission; +pub(super) use verify_bank_canonical_gdn::admit; +pub(super) use verify_bank_canonical_gdn::check_canonical_lengths; +pub(super) use verify_bank_canonical_gdn::check_commands; +pub(super) use verify_bank_canonical_gdn::command; +pub(crate) use verify_bank_canonical_gdn::gather_rows_module; +pub(super) use verify_bank_canonical_gdn::handle; +pub(super) use verify_bank_canonical_gdn::poison; +pub(super) use verify_bank_canonical_gdn::sealed_asset; +pub(super) use verify_bank_canonical_gdn::share_window_modules; +pub(super) use verify_bank_canonical_gdn::transport; +pub(super) use verify_bank_canonical_gdn::zero; mod original_verify_bank; mod physical; -mod verify_bank_plan_and_window_rows; +mod verify_bank_plan_access; diff --git a/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_and_canonical_gdn_open.rs b/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_canonical_gdn.rs similarity index 100% rename from crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_and_canonical_gdn_open.rs rename to crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_canonical_gdn.rs diff --git a/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_and_window_rows.rs b/crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_access.rs similarity index 100% rename from crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_and_window_rows.rs rename to crates/cuda-driver/src/original_verify/share_window_modules/verify_bank_plan_access.rs diff --git a/crates/cuda-driver/src/original_verify/window_ops.rs b/crates/cuda-driver/src/original_verify/window_ops.rs index 7b57ba95..cf36712d 100644 --- a/crates/cuda-driver/src/original_verify/window_ops.rs +++ b/crates/cuda-driver/src/original_verify/window_ops.rs @@ -115,7 +115,7 @@ mod window_launches; mod qsa_prelude_ops; mod side_qsa_branches; mod side_shared_expert; -mod window_ops_kernels_and_pcie_plan; +mod window_step_recording; mod wait_rows; #[cfg(test)] pub(crate) use original_verifier::graph_oom_at; diff --git a/crates/cuda-driver/src/original_verify/window_ops/window_launches.rs b/crates/cuda-driver/src/original_verify/window_ops/window_launches.rs index 2995fe05..7e20a3b0 100644 --- a/crates/cuda-driver/src/original_verify/window_ops/window_launches.rs +++ b/crates/cuda-driver/src/original_verify/window_ops/window_launches.rs @@ -1,6 +1,6 @@ //! The launches and plan words of `OriginalVerifyWindowOps`: the GDN side stream, embedding, the plan and its group //! offsets, the journal and submit. -//! Apart from `window_ops_kernels_and_pcie_plan.rs`, which implements the `WindowOps` kernels. +//! Apart from `window_step_recording.rs`, which implements the `WindowOps` kernels. use super::{ Arg, Command, Error, Launch, OriginalVerifyGdnJournal, OriginalVerifyGeometry, OriginalVerifyWindowOps, PlanLayout, diff --git a/crates/cuda-driver/src/original_verify/window_ops/window_ops_kernels_and_pcie_plan.rs b/crates/cuda-driver/src/original_verify/window_ops/window_step_recording.rs similarity index 100% rename from crates/cuda-driver/src/original_verify/window_ops/window_ops_kernels_and_pcie_plan.rs rename to crates/cuda-driver/src/original_verify/window_ops/window_step_recording.rs diff --git a/crates/cuda-driver/src/ple_batch_ffi/driver_backed.rs b/crates/cuda-driver/src/ple_batch_ffi/driver_backed.rs index 3351a5ff..eb53fc24 100644 --- a/crates/cuda-driver/src/ple_batch_ffi/driver_backed.rs +++ b/crates/cuda-driver/src/ple_batch_ffi/driver_backed.rs @@ -84,4 +84,4 @@ pub(crate) struct KernelModule { mod library; use library::check; mod blas; -mod kernel_module_launch_and_close; +mod kernel_module; diff --git a/crates/cuda-driver/src/ple_batch_ffi/driver_backed/kernel_module_launch_and_close.rs b/crates/cuda-driver/src/ple_batch_ffi/driver_backed/kernel_module.rs similarity index 100% rename from crates/cuda-driver/src/ple_batch_ffi/driver_backed/kernel_module_launch_and_close.rs rename to crates/cuda-driver/src/ple_batch_ffi/driver_backed/kernel_module.rs diff --git a/crates/cuda-driver/src/projection_grids_and_bounds.rs b/crates/cuda-driver/src/projection_geometry.rs similarity index 100% rename from crates/cuda-driver/src/projection_grids_and_bounds.rs rename to crates/cuda-driver/src/projection_geometry.rs diff --git a/crates/cuda-driver/src/qsa_prompt_attention.rs b/crates/cuda-driver/src/qsa_prompt_attention.rs index c6c5a977..efdc676f 100644 --- a/crates/cuda-driver/src/qsa_prompt_attention.rs +++ b/crates/cuda-driver/src/qsa_prompt_attention.rs @@ -49,7 +49,7 @@ mod resident_attention; pub(crate) use resident_attention::OriginalQsaAttendedKv; pub use resident_attention::OriginalQsaResidentAttention; -mod attention_kernel_plan_and_passes; +mod attention_launch_plan; mod qsa_attention_inputs; mod qsa_prompt_attention_drop; pub(crate) use qsa_prompt_attention_drop::guard_grid; diff --git a/crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes.rs b/crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes.rs rename to crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan.rs diff --git a/crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes/attention_passes.rs b/crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan/attention_passes.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes/attention_passes.rs rename to crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan/attention_passes.rs diff --git a/crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes/prompt_attention_owner.rs b/crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan/prompt_attention_owner.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes/prompt_attention_owner.rs rename to crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan/prompt_attention_owner.rs diff --git a/crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes/reject_mutual_alias.rs b/crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan/reject_mutual_alias.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_attention/attention_kernel_plan_and_passes/reject_mutual_alias.rs rename to crates/cuda-driver/src/qsa_prompt_attention/attention_launch_plan/reject_mutual_alias.rs diff --git a/crates/cuda-driver/src/qsa_prompt_attention/device_attention.rs b/crates/cuda-driver/src/qsa_prompt_attention/device_attention.rs index bb1f8b37..7d5fed74 100644 --- a/crates/cuda-driver/src/qsa_prompt_attention/device_attention.rs +++ b/crates/cuda-driver/src/qsa_prompt_attention/device_attention.rs @@ -1,5 +1,5 @@ //! Same literal attention on the real selected query/IDs/steps/attn arena. -use super::attention_kernel_plan_and_passes::AttnPasses; +use super::attention_launch_plan::AttnPasses; use super::{Error, NativeBatchWorkspace, QsaAttendedKv, QsaPromptAttention, QsaPromptStage, Result}; impl<'ctx> QsaPromptAttention<'ctx> { pub(crate) fn attend_original_arena( diff --git a/crates/cuda-driver/src/qsa_prompt_attention/resident_attention.rs b/crates/cuda-driver/src/qsa_prompt_attention/resident_attention.rs index 58907c12..bb671be2 100644 --- a/crates/cuda-driver/src/qsa_prompt_attention/resident_attention.rs +++ b/crates/cuda-driver/src/qsa_prompt_attention/resident_attention.rs @@ -1,5 +1,5 @@ //! Same literal attention on the real selected query/IDs/steps/attn arena. -use super::attention_kernel_plan_and_passes::{AttnPasses, KernelEntry, admit_budget}; +use super::attention_launch_plan::{AttnPasses, KernelEntry, admit_budget}; use super::{ Arguments, Context, Error, LaunchGeometry, Module, NativeBatchWorkspace, QsaPromptAttention, Result, SelectSwitches, checked, combine, diff --git a/crates/cuda-driver/src/qsa_prompt_index.rs b/crates/cuda-driver/src/qsa_prompt_index.rs index b1ade19e..b1d06556 100644 --- a/crates/cuda-driver/src/qsa_prompt_index.rs +++ b/crates/cuda-driver/src/qsa_prompt_index.rs @@ -86,7 +86,7 @@ use max_blocks::max_blocks; use max_blocks::sizes; mod append_select; mod index_run; -mod qsa_prompt_index_read_and_close; +mod qsa_prompt_index_results; mod qsa_prompt_index_workspace; mod run_launches; mod run_phases; diff --git a/crates/cuda-driver/src/qsa_prompt_index/qsa_prompt_index_read_and_close.rs b/crates/cuda-driver/src/qsa_prompt_index/qsa_prompt_index_results.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_index/qsa_prompt_index_read_and_close.rs rename to crates/cuda-driver/src/qsa_prompt_index/qsa_prompt_index_results.rs diff --git a/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix.rs b/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix.rs index 69c31d14..795c80ca 100644 --- a/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix.rs +++ b/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix.rs @@ -7,5 +7,5 @@ use super::{ QsaPromptKv, Rc, Result, SelectedRows, checked, stage_runs, }; -mod qsa_mapped_journal_append_and_resolve; -mod qsa_mapped_journal_prefix_and_prefetch; +mod qsa_mapped_journal_arena; +mod qsa_mapped_journal_prefix_lineage; diff --git a/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_append_and_resolve.rs b/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_arena.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_append_and_resolve.rs rename to crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_arena.rs diff --git a/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_prefix_and_prefetch.rs b/crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_prefix_lineage.rs similarity index 100% rename from crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_prefix_and_prefetch.rs rename to crates/cuda-driver/src/qsa_prompt_kv/mapped_journal/original_qsa_mapped_prefix/qsa_mapped_journal_prefix_lineage.rs diff --git a/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix.rs b/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix.rs index a629a0fa..0a5bb173 100644 --- a/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix.rs +++ b/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix.rs @@ -8,5 +8,5 @@ use super::{ }; mod native_projection; -mod qkv_and_z_projections; -mod recurrence_and_output; +mod gdn_batch_input_stages; +mod gdn_batch_recurrence_stages; diff --git a/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/qkv_and_z_projections.rs b/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/gdn_batch_input_stages.rs similarity index 100% rename from crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/qkv_and_z_projections.rs rename to crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/gdn_batch_input_stages.rs diff --git a/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/recurrence_and_output.rs b/crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/gdn_batch_recurrence_stages.rs similarity index 100% rename from crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/recurrence_and_output.rs rename to crates/cuda-driver/src/qwen_dispatch/gdn_native_batch/gdn_batch_prefix/gdn_batch_recurrence_stages.rs diff --git a/crates/cuda-driver/src/qwen_ffi.rs b/crates/cuda-driver/src/qwen_ffi.rs index 9a4dc440..35c70c09 100644 --- a/crates/cuda-driver/src/qwen_ffi.rs +++ b/crates/cuda-driver/src/qwen_ffi.rs @@ -23,15 +23,15 @@ use qsa_layout::gdn_layout; use qsa_layout::moe_layout; use qsa_layout::ple_layout; pub(super) use qsa_layout::qsa_layout; -mod asset_validation_and_bf16_layout; -pub(super) use asset_validation_and_bf16_layout::bf16_layout; -use asset_validation_and_bf16_layout::gdn_asset; -use asset_validation_and_bf16_layout::gr_asset; -use asset_validation_and_bf16_layout::inspect_ptx; -pub(super) use asset_validation_and_bf16_layout::kar_ple_layout; -use asset_validation_and_bf16_layout::moe_asset; -use asset_validation_and_bf16_layout::ple_asset; -use asset_validation_and_bf16_layout::qsa_asset; +mod asset_admission; +pub(super) use asset_admission::bf16_layout; +use asset_admission::gdn_asset; +use asset_admission::gr_asset; +use asset_admission::inspect_ptx; +pub(super) use asset_admission::kar_ple_layout; +use asset_admission::moe_asset; +use asset_admission::ple_asset; +use asset_admission::qsa_asset; mod asset; pub(super) use asset::asset; pub(crate) use asset::sha256; diff --git a/crates/cuda-driver/src/qwen_ffi/asset_validation_and_bf16_layout.rs b/crates/cuda-driver/src/qwen_ffi/asset_admission.rs similarity index 100% rename from crates/cuda-driver/src/qwen_ffi/asset_validation_and_bf16_layout.rs rename to crates/cuda-driver/src/qwen_ffi/asset_admission.rs diff --git a/crates/experimental-ref/src/cvec.rs b/crates/experimental-ref/src/cvec.rs index d7a4768e..dd3015b9 100644 --- a/crates/experimental-ref/src/cvec.rs +++ b/crates/experimental-ref/src/cvec.rs @@ -108,7 +108,7 @@ pub struct CvecTables { #[cfg(test)] mod tests; -mod cvec_reading_and_errors; -pub use cvec_reading_and_errors::*; +mod cvec_reader; +pub use cvec_reader::*; mod load_control_vectors; pub use load_control_vectors::*; diff --git a/crates/experimental-ref/src/cvec/cvec_reading_and_errors.rs b/crates/experimental-ref/src/cvec/cvec_reader.rs similarity index 100% rename from crates/experimental-ref/src/cvec/cvec_reading_and_errors.rs rename to crates/experimental-ref/src/cvec/cvec_reader.rs diff --git a/crates/gptoss-npu/src/lib.rs b/crates/gptoss-npu/src/lib.rs index 29dafb3a..658b43ad 100644 --- a/crates/gptoss-npu/src/lib.rs +++ b/crates/gptoss-npu/src/lib.rs @@ -110,7 +110,7 @@ fn fail(e: impl std::fmt::Display) -> ModelError { #[cfg(test)] mod tests; -mod construction_and_estimates; +mod npu_prefill_setup; mod service_transfers; mod prefill_batch; mod prefill_part_pass; diff --git a/crates/gptoss-npu/src/construction_and_estimates.rs b/crates/gptoss-npu/src/npu_prefill_setup.rs similarity index 100% rename from crates/gptoss-npu/src/construction_and_estimates.rs rename to crates/gptoss-npu/src/npu_prefill_setup.rs diff --git a/crates/gptoss/src/state_and_cache.rs b/crates/gptoss/src/decode_state.rs similarity index 100% rename from crates/gptoss/src/state_and_cache.rs rename to crates/gptoss/src/decode_state.rs diff --git a/crates/gptoss/src/lib.rs b/crates/gptoss/src/lib.rs index 84c116b1..03f272be 100644 --- a/crates/gptoss/src/lib.rs +++ b/crates/gptoss/src/lib.rs @@ -37,8 +37,8 @@ const DEFAULT_PREFILL_CHUNK: usize = 64; #[cfg(test)] mod tests; -mod bytes_and_errors; -pub use bytes_and_errors::{ModelBytes, ModelError}; +mod model_bytes; +pub use model_bytes::{ModelBytes, ModelError}; mod config; pub use config::Config; mod weights; @@ -54,8 +54,8 @@ mod model; pub use model::Model; mod profile; pub use profile::Profile; -mod state_and_cache; -pub use state_and_cache::{LayerCache, PrefillAccelerator, PrefillJob, PrefillOffload, PrefillSpan, Reuse, State}; +mod decode_state; +pub use decode_state::{LayerCache, PrefillAccelerator, PrefillJob, PrefillOffload, PrefillSpan, Reuse, State}; mod scalar_numerics; use scalar_numerics::{argmax, dequantize_q8_0_row, f32_to_half_bits, half_to_f32}; mod parallel_jobs; diff --git a/crates/gptoss/src/bytes_and_errors.rs b/crates/gptoss/src/model_bytes.rs similarity index 100% rename from crates/gptoss/src/bytes_and_errors.rs rename to crates/gptoss/src/model_bytes.rs diff --git a/crates/igpu/src/error_and_kind.rs b/crates/igpu/src/gpu_error.rs similarity index 89% rename from crates/igpu/src/error_and_kind.rs rename to crates/igpu/src/gpu_error.rs index 9f94a291..c0e52119 100644 --- a/crates/igpu/src/error_and_kind.rs +++ b/crates/igpu/src/gpu_error.rs @@ -1,4 +1,4 @@ -//! The weight kind and the error of the GPU backend. +//! The error of the GPU backend, with the weight kind its upload and shape errors name. use super::fmt; diff --git a/crates/igpu/src/lib.rs b/crates/igpu/src/lib.rs index 912de57e..c1922951 100644 --- a/crates/igpu/src/lib.rs +++ b/crates/igpu/src/lib.rs @@ -22,8 +22,8 @@ const MXFP4_BYTES: usize = 17; #[cfg(test)] mod tests; -mod error_and_kind; -pub use error_and_kind::{GpuError, WeightKind}; +mod gpu_error; +pub use gpu_error::{GpuError, WeightKind}; mod handles; pub use handles::{Buf, GpuActivations, GpuMatrix}; mod params; @@ -43,10 +43,10 @@ pub use repacking::{repack_activations, repack_mxfp4}; mod device; pub use device::Gpu; use device::{entry, groups_1d}; -mod matrices_and_moe_plan; +mod matrix_uploads; mod readback; mod recorder_core; pub use recorder_core::Recorder; -mod recorder_attention_and_submit; +mod recorder_attention; mod recorder_moe; -mod recorder_norm_and_routing; +mod recorder_activation_passes; diff --git a/crates/igpu/src/matrices_and_moe_plan.rs b/crates/igpu/src/matrix_uploads.rs similarity index 100% rename from crates/igpu/src/matrices_and_moe_plan.rs rename to crates/igpu/src/matrix_uploads.rs diff --git a/crates/igpu/src/recorder_norm_and_routing.rs b/crates/igpu/src/recorder_activation_passes.rs similarity index 100% rename from crates/igpu/src/recorder_norm_and_routing.rs rename to crates/igpu/src/recorder_activation_passes.rs diff --git a/crates/igpu/src/recorder_attention_and_submit.rs b/crates/igpu/src/recorder_attention.rs similarity index 100% rename from crates/igpu/src/recorder_attention_and_submit.rs rename to crates/igpu/src/recorder_attention.rs diff --git a/crates/igpu/src/shaders.rs b/crates/igpu/src/shaders.rs index 8d46ac67..fcab6943 100644 --- a/crates/igpu/src/shaders.rs +++ b/crates/igpu/src/shaders.rs @@ -10,15 +10,15 @@ mod gemm; mod gemm_template; pub use gemm::*; -mod tiling_norm_and_rope; -pub use tiling_norm_and_rope::{RMSNORM_QUANT, ROPE, TILE_M, TILE_N}; +mod rmsnorm_rope_shaders; +pub use rmsnorm_rope_shaders::{RMSNORM_QUANT, ROPE, TILE_M, TILE_N}; mod kv_store; pub use kv_store::KV_STORE; mod attention; pub use attention::ATTENTION; -mod quantize_and_swiglu; -pub use quantize_and_swiglu::{QUANTIZE, SWIGLU_QUANT}; -mod routing_and_combine; -pub use routing_and_combine::{MOE_COMBINE, ROUTER}; +mod quantize_shaders; +pub use quantize_shaders::{QUANTIZE, SWIGLU_QUANT}; +mod expert_routing_shaders; +pub use expert_routing_shaders::{MOE_COMBINE, ROUTER}; mod f16_round; use f16_round::F16_ROUND; diff --git a/crates/igpu/src/shaders/routing_and_combine.rs b/crates/igpu/src/shaders/expert_routing_shaders.rs similarity index 100% rename from crates/igpu/src/shaders/routing_and_combine.rs rename to crates/igpu/src/shaders/expert_routing_shaders.rs diff --git a/crates/igpu/src/shaders/quantize_and_swiglu.rs b/crates/igpu/src/shaders/quantize_shaders.rs similarity index 100% rename from crates/igpu/src/shaders/quantize_and_swiglu.rs rename to crates/igpu/src/shaders/quantize_shaders.rs diff --git a/crates/igpu/src/shaders/tiling_norm_and_rope.rs b/crates/igpu/src/shaders/rmsnorm_rope_shaders.rs similarity index 100% rename from crates/igpu/src/shaders/tiling_norm_and_rope.rs rename to crates/igpu/src/shaders/rmsnorm_rope_shaders.rs diff --git a/crates/native-cpu-expert/src/rust_general_pool.rs b/crates/native-cpu-expert/src/rust_general_pool.rs index bdfdd016..46513a5e 100644 --- a/crates/native-cpu-expert/src/rust_general_pool.rs +++ b/crates/native-cpu-expert/src/rust_general_pool.rs @@ -118,4 +118,4 @@ use job_default::now_ms; mod epoch_scheduling; mod expert_pool; mod expert_pool_split_multi_run; -mod shared_wait_done_and_quantize_lanes; +mod phase_handoff; diff --git a/crates/native-cpu-expert/src/rust_general_pool/shared_wait_done_and_quantize_lanes.rs b/crates/native-cpu-expert/src/rust_general_pool/phase_handoff.rs similarity index 100% rename from crates/native-cpu-expert/src/rust_general_pool/shared_wait_done_and_quantize_lanes.rs rename to crates/native-cpu-expert/src/rust_general_pool/phase_handoff.rs diff --git a/crates/openvino/src/compile_and_infer.rs b/crates/openvino/src/inference_runtime.rs similarity index 100% rename from crates/openvino/src/compile_and_infer.rs rename to crates/openvino/src/inference_runtime.rs diff --git a/crates/openvino/src/lib.rs b/crates/openvino/src/lib.rs index 5191ebdc..36216641 100644 --- a/crates/openvino/src/lib.rs +++ b/crates/openvino/src/lib.rs @@ -32,8 +32,8 @@ pub use c_api_types::Element; use c_api_types::{CompileFns, CoreFns, DevicesFns, Fns, ModelFns, RawDevices, RawShape, RequestFns, Status, TensorFns}; mod library; pub use library::OpenVino; -mod compile_and_infer; -pub use compile_and_infer::{Compiled, Core, Request}; +mod inference_runtime; +pub use inference_runtime::{Compiled, Core, Request}; mod tensor; pub use tensor::Tensor; use tensor::cstring; diff --git a/docs/architecture/size-split-rest.md b/docs/architecture/size-split-rest.md index 9c9e0b8f..873d0483 100644 --- a/docs/architecture/size-split-rest.md +++ b/docs/architecture/size-split-rest.md @@ -23,19 +23,19 @@ A test id is `::`. A split changes the module path and n | Was | Now | | --- | --- | -| `gptoss/src/lib.rs` (1788 lines) | `bytes_and_errors`, `config`, `weights`, `tensor_loading`, `quant_probes`, `model`, `profile`, `state_and_cache`, `scalar_numerics`, `parallel_jobs`, `parallel_region`, `prefill`, `forward_pass`, `generation`, `tests` | -| `cpu-sys/src/lib.rs` (1007) | `checks`, `portable`, `avx2_and_avxvnni`, `attention_and_elementwise`, `tiles`, `oracle`, `tests`; the `with_avx2!` and `with_avxvnni!` macros stay in `lib.rs` so every kernel module sees them | -| `cpu-sys/src/simd.rs` (1503) | `simd/scalar_dots_and_formats`, `simd/scalar_tiles_and_elementwise`, `simd/x86` (the former inline module) with `simd/x86/{reductions_and_int_dots, mxfp4_q8_dots, q8_dots_and_mxfp4_tiles, tile_kernels, attention_kernels, f16_attention_and_elementwise, quantize_q8_0}` | -| `igpu/src/lib.rs` (1386) | `error_and_kind`, `handles`, `params`, `repacking`, `device`, `readback`, `matrices_and_moe_plan`, `recorder_core`, `recorder_norm_and_routing`, `recorder_moe`, `recorder_attention_and_submit`, `tests`; the long `impl Gpu` and `impl Recorder` blocks are cut between methods | -| `igpu/src/shaders.rs` (440) | `shaders/{tiling_norm_and_rope, kv_store, attention, quantize_and_swiglu, routing_and_combine, f16_round}` (WGSL text constants) | +| `gptoss/src/lib.rs` (1788 lines) | `model_bytes`, `config`, `weights`, `tensor_loading`, `quant_probes`, `model`, `profile`, `decode_state`, `scalar_numerics`, `parallel_jobs`, `parallel_region`, `prefill`, `forward_pass`, `generation`, `tests` | +| `cpu-sys/src/lib.rs` (1007) | `checks`, `portable`, `x86_dot_kernels`, `checked_attention_kernels`, `tiles`, `oracle`, `tests`; the `with_avx2!` and `with_avxvnni!` macros stay in `lib.rs` so every kernel module sees them | +| `cpu-sys/src/simd.rs` (1503) | `simd/scalar_dot_kernels`, `simd/scalar_tile_kernels`, `simd/x86` (the former inline module) with `simd/x86/{int_dot_kernels, mxfp4_q8_dots, q8_0_dot_kernels, tile_kernels, attention_kernels, f16_attention_kernels, quantize_q8_0}` | +| `igpu/src/lib.rs` (1386) | `gpu_error`, `handles`, `params`, `repacking`, `device`, `readback`, `matrix_uploads`, `recorder_core`, `recorder_activation_passes`, `recorder_moe`, `recorder_attention`, `tests`; the long `impl Gpu` and `impl Recorder` blocks are cut between methods | +| `igpu/src/shaders.rs` (440) | `shaders/{rmsnorm_rope_shaders, kv_store, attention, quantize_shaders, expert_routing_shaders, f16_round}` (WGSL text constants) | | `gguf/src/lib.rs` (560) | `error`, `value`, `tensor_type`, `file`, `reader` | | `tokenizer/src/lib.rs` (840) | `construction`, `encoding`, `decoding`, `bpe_merge`, `vocabulary`, `tests` | | `quant-core/src/iq2s_grid.rs` (1032) | the same table, four entries per line under `#[rustfmt::skip]` (265 lines); the entries and their order are unchanged and the SHA-256 test of the crate still pins them | -| `openvino/src/lib.rs` (676) | `error`, `c_api_types`, `library`, `compile_and_infer`, `tensor`, `tests` | +| `openvino/src/lib.rs` (676) | `error`, `c_api_types`, `library`, `inference_runtime`, `tensor`, `tests` | | `cpu-kernels/src/lib.rs` (464) | `isa`, `dispatch`, `tests` | | `shm/src/lib.rs` (432) | `unix`, `windows` (each loaded as `imp` through a `use ... as imp`), `tests` | | `gptoss-igpu/src/lib.rs` (524) | `prefill_pass`, `tests` | -| `gptoss-npu/src/lib.rs` (809) | `construction_and_estimates`, `service_transfers`, `prefill_part_pass`, `expert_pass`, `accelerator`, `tests` | +| `gptoss-npu/src/lib.rs` (809) | `npu_prefill_setup`, `service_transfers`, `prefill_part_pass`, `expert_pass`, `accelerator`, `tests` | | `gateway-domain/src/responses/render.rs` (405, one function of 385 lines) | `render.rs` (the entry), `render/instructions` (one function per system message), `render/replay` (one method per input item kind) | Every `unsafe` block and its `SAFETY` comment moved verbatim with the code it belongs to (the `unsafe` counts of `cpu-sys` diff --git a/docs/experiments/ffn-phase-loss-design.md b/docs/experiments/ffn-phase-loss-design.md index 26995b69..8ef63d9a 100644 --- a/docs/experiments/ffn-phase-loss-design.md +++ b/docs/experiments/ffn-phase-loss-design.md @@ -192,8 +192,8 @@ No pure stream-structure change is left to propose (bitwise-safe by construction | id | switch | change | where | expected, us per layer averaged over all layers (ms per graph) at T=2 / 3 / 4 | identity | | --- | --- | --- | --- | --- | --- | | D1 | `LELEKA_SM120_DOWN_SUB16` | the down projection of the routed experts with upstream's group-strided sub8/sub16 kernel, grid 80 (type 20) or 160 (type 42) x block rows; the PCIe pass with 4 block rows (`kPcieGroupRows`), the gate/up of the PCIe pass with grid.y 4 (the fused kernel already strides) | new sealed asset `sm120_down_sub16.cu/.ptx` (port of `native_down_multi_kernel`, `iq_kernels.cu:2130`), planner `GroupPlan::down` and `GroupPlan::fused_gate_up` in `original_verify_window_moe/plan_expert_groups.rs` | VRAM pass 1.7 / 2.4 / 2.4 (0.082 / 0.114 / 0.116); PCIe pass down 1.5 / 2.3 / 2.1 (0.072 / 0.108 / 0.101); PCIe pass gate/up grid 0.3 / 0.2 / 0.2 (0.016 / 0.009 / 0.011) | **needs a probe**: a different lane layout (8 lanes for K=40, 16 for Q2_0) than the literal `row_dot` of `window_moe_down_`; bit-equality is upstream's design aim (GU_SWIGLU's sub16 was byte-equal in `sm120_probe gu`) but not shown for down | -| D2 | `LELEKA_SM120_HITS_IN_COMBINE` | `add_hits` folded into the combine (upstream `combine_k10_vec4_hits`, `native_moe.cu:98`, `native_moe_combine_multi_hits_added`), -48 launches per graph | new sealed asset next to `sm120_combine_vec4.cu`; `hit_add` and `combine` in `window_ops_kernels_and_pcie_plan.rs` call a new planner in a new file | 1.2 / 1.3 / 1.3 (0.059 / 0.063 / 0.063), upper bound = the `AH` duration 1.2-1.3 us; the folded combine reads the hit rows and costs a little more | needs a probe: `add_hits` does `parts += hit_out` onto rows the CPU leg zeroed (0 + x = x except x = -0.0); the folded kernel must reproduce the +0.0 | -| D3 | `LELEKA_SM120_WAIT_M_ROWS` | the wait on flag M folded into the copy of the CPU rows (`copy_rows_from_mapped_after`, `verify.cpp:2189`), -48 launches per graph | new entry in a new `.cu` (do not touch `chain_window.cu`); `wait_cpu` and `copy_cpu_rows` in `window_ops_kernels_and_pcie_plan.rs` | 1.3 / 1.1 / 0.9 (0.062 / 0.052 / 0.043): the `WM` floor 1.4-1.6 us in F layers, 0.5 us assumed after a real wait | bitwise by construction (the same copy after the same flag), still a probe for the CPU rows; **risk**: upstream measured -1.5 % decode on a Turing card for this fold ("every row block polls the flag over PCIe"), so it stays OFF until a section delta says otherwise | +| D2 | `LELEKA_SM120_HITS_IN_COMBINE` | `add_hits` folded into the combine (upstream `combine_k10_vec4_hits`, `native_moe.cu:98`, `native_moe_combine_multi_hits_added`), -48 launches per graph | new sealed asset next to `sm120_combine_vec4.cu`; `hit_add` and `combine` in `window_step_recording.rs` call a new planner in a new file | 1.2 / 1.3 / 1.3 (0.059 / 0.063 / 0.063), upper bound = the `AH` duration 1.2-1.3 us; the folded combine reads the hit rows and costs a little more | needs a probe: `add_hits` does `parts += hit_out` onto rows the CPU leg zeroed (0 + x = x except x = -0.0); the folded kernel must reproduce the +0.0 | +| D3 | `LELEKA_SM120_WAIT_M_ROWS` | the wait on flag M folded into the copy of the CPU rows (`copy_rows_from_mapped_after`, `verify.cpp:2189`), -48 launches per graph | new entry in a new `.cu` (do not touch `chain_window.cu`); `wait_cpu` and `copy_cpu_rows` in `window_step_recording.rs` | 1.3 / 1.1 / 0.9 (0.062 / 0.052 / 0.043): the `WM` floor 1.4-1.6 us in F layers, 0.5 us assumed after a real wait | bitwise by construction (the same copy after the same flag), still a probe for the CPU rows; **risk**: upstream measured -1.5 % decode on a Turing card for this fold ("every row block polls the flag over PCIe"), so it stays OFF until a section delta says otherwise | | all | | | | **4.2 / 4.8 / 4.7 (0.199 / 0.231 / 0.227)** with the shared-chain cap; 32 % / 22 % / 8 % of the T-matched gap of 0.613 / 1.043 / 2.960 ms | | Arithmetic of D1 at T=3 (CY.1, GDN): F-layer `V_DN` 19.3 us against 14.2 us in VANL = 5.1 us, F share 52 % -> 2.6 us per layer before the slack model, 2.4 after; the empty PCIe down pass 5.5 us -> 0.7 us (the VANL value) = 4.8 us x 0.52 = 2.5 -> 2.3 us. The row S7 of the ledger (estimate 0.20-0.35 ms) is refined to 0.17-0.23 ms for D1 (VRAM pass 0.08-0.12, PCIe down pass 0.07-0.11, PCIe gate/up 0.01-0.02, T=2..4, before the cap). @@ -210,7 +210,7 @@ If D1 delivers more than the shared chain's slack (4.1 us at T=2), the combine w All in `crates/cuda-driver/src/` unless noted; the hard rules of `verify-step-brief.md` apply (switch resolved in `original_verify_window_sm120.rs`, functions <= 30 lines, files <= 400 lines, `WindowPolicy` grows by the two lines of T0 only, no GPU, PTX that cannot be built here is delivered as `.cu` marked "PTX not built"). -- **T0 (scaffold, one small commit, done first by one agent, then the three tasks start from it):** `original_verify_window_sm120.rs` gets one block: `DEFAULT_ON_DOWN_SUB16`, `DEFAULT_ON_HITS_IN_COMBINE`, `DEFAULT_ON_WAIT_M_ROWS` (all false), the `LELEKA_SM120_*` names in `Sm120Switches`/`from_env`/`resolve` with their tests (pattern: `side_qsa_follows_its_own_variable_and_the_master_switch`); a new DTO file `original_verify_window_ffn.rs` with `FfnSwitches { down_sub16, hits_in_combine, wait_m_rows }` (Copy); one field `pub ffn: super::ffn::FfnSwitches` in `WindowPolicy` (`original_verify_window_record.rs`: 398 lines on this base, 400 in the brief, so the +2 lines with the `mode17()` default are the whole headroom) and the one-line hooks in `window_ops_kernels_and_pcie_plan.rs`: `expert_groups` (tier + switches to the planner), `wait_cpu` + `copy_cpu_rows` (call `self.ffn_wait_rows(...)` when the switch is on) and `hit_add` + `combine` (call `self.ffn_hits_combine(...)`), each defined in the task's own file below as an `impl OriginalVerifyWindowOps` method that is a stub (`Err(Error::UnsupportedQwenOperation)`) until the task fills it in. This is what makes the three tasks disjoint. +- **T0 (scaffold, one small commit, done first by one agent, then the three tasks start from it):** `original_verify_window_sm120.rs` gets one block: `DEFAULT_ON_DOWN_SUB16`, `DEFAULT_ON_HITS_IN_COMBINE`, `DEFAULT_ON_WAIT_M_ROWS` (all false), the `LELEKA_SM120_*` names in `Sm120Switches`/`from_env`/`resolve` with their tests (pattern: `side_qsa_follows_its_own_variable_and_the_master_switch`); a new DTO file `original_verify_window_ffn.rs` with `FfnSwitches { down_sub16, hits_in_combine, wait_m_rows }` (Copy); one field `pub ffn: super::ffn::FfnSwitches` in `WindowPolicy` (`original_verify_window_record.rs`: 398 lines on this base, 400 in the brief, so the +2 lines with the `mode17()` default are the whole headroom) and the one-line hooks in `window_step_recording.rs`: `expert_groups` (tier + switches to the planner), `wait_cpu` + `copy_cpu_rows` (call `self.ffn_wait_rows(...)` when the switch is on) and `hit_add` + `combine` (call `self.ffn_hits_combine(...)`), each defined in the task's own file below as an `impl OriginalVerifyWindowOps` method that is a stub (`Err(Error::UnsupportedQwenOperation)`) until the task fills it in. This is what makes the three tasks disjoint. - **T1, D1 `DOWN_SUB16`:** new `sm120_down_sub16.cu` (+`.ptx`, pinned and sealed like `sm120_gu_swiglu`: `AssetSpec`, `extra-seal-plan.json`, `ptx-sm86/MANIFEST.json` note), new `original_verify_window_down.rs` (asset, entries `sm120_moe_down_20` and `_42` only, the two formats the window uses; `assert_sealed_and_fail_closed` as in `original_verify_window_draft.rs`), edits in `original_verify_window_moe/plan_expert_groups.rs` (`GroupPlan::down`, `fused_gate_up`, `plan_expert_groups`) and `original_verify_window_moe.rs` (`MoeKnobs`, `DOWN_ENTRIES`), probe in `tools/decode-sm120/sm120_probe.cpp` (+`build.sh`): new `down` mode comparing the new kernel with `window_moe_down_` byte for byte on random expert blobs, T 1-8, group counts 0-16, grid.y 4 against cap. The probe decides: if it is not byte-equal the task ends with that finding (no lossy variant). - **T2, D2 `HITS_IN_COMBINE`:** new `sm120_combine_hits.cu/.ptx` (built on `sm120_combine_vec4.cu` and `combine_k10_vec4_hits`), new `original_verify_window_hits_combine.rs` (`ffn_hits_combine`, planner, asset), probe mode `hits` in `sm120_probe.cpp` **(shared file with T1: T1 owns `sm120_probe.cpp`; T2 adds its probe as a new file `tools/decode-sm120/sm120_probe_hits.cpp` and its line in `build.sh` after T1 has merged)**. - **T3, D3 `WAIT_M_ROWS`:** new `sm120_wait_copy_rows.cu/.ptx`, new `original_verify_window_wait_rows.rs` (`ffn_wait_rows`: wait M + copy rows as one launch; grid of the existing copy, `T x 10` blocks), probe or unit test for the copied rows with a flag that rises late. diff --git a/docs/experiments/hit-gap-causes-2026-11-11.md b/docs/experiments/hit-gap-causes-2026-11-11.md index c03f3ff3..48718b6e 100644 --- a/docs/experiments/hit-gap-causes-2026-11-11.md +++ b/docs/experiments/hit-gap-causes-2026-11-11.md @@ -71,7 +71,7 @@ Hit-point sizes are for the shipped replay (-1.5 to -1.6) unless stated. ms/roun | initial fill | global: first N ranked pairs, "PROFILE, ranked by routing frequency, no eviction" (`generate.cpp:6535-6560`; per-layer is the opt-in `--expert-cache-per-layer`, `generate.cpp:577, 6333`) | **per layer**: `fill_ranked` takes each layer's first `quota` pairs and skips the rest of a full layer (`open_tier.rs:98-121`); sizes `quota` x 48 (`original_cache_startup.rs:96-102`, `open_parts.rs:101-102`); `EXPERT_PER_LAYER=yes` in all three 5090 profiles (`deploy/rust-runtime/profiles/rtx5090-32g*.json` line 16/17) | **differs** (cause 3). Log: LEL "12192 slots (23.24 GiB, per layer)", vanilla "12575 slots, 23.87 GiB" | | slot count | auto: free 24.77 GiB - 700 MiB - 218 MiB (draft head) = 23.87 GiB (`VANLP/engine.log:24-25`) | `initial_slots` and `size_per_layer`: (room - reserve 700 - decode reserve 300 ...) in 48-slot steps (`open_parts.rs:24-65`, defaults `tail_skip_rank.rs:76-83`) | differs by 383 (cause 1); account in `vram-footprint-5090.md` section 2 and `vram-footprint3-5090.md` section 1 (decode reserve 300 -> 130 = +48 measured, alias +144 measured, quota step, dense rounding) | | seed from the prompt | none (the "prompt's seed" exists only in `STRATA_RAM_ADAPT2`, `generate.cpp:15116`) | engine default on, **off in the 5090 profiles** (`LELEKA_ORIGINAL_SERVE_SEED=off`, `tail_skip_rank.rs:202-214`) | equal in the compared runs | -| lent slots | last k slots lent, `p.lent` remembers (layer, expert) and `refill` restores the same experts (`generate.cpp:13477-13530, 13450-13475`); `apply_pending(true)` first (`14068`) | `loan_slots`, `refill_lent` through `needs_refill(slot)` = the slot's own expert (`open_tier.rs:188-231`); `begin_prefill` waits for swaps (`original_serve_stack_prefill_phase.rs:51-58`); `needs_refill` returns the slot's recorded owner (`original_expert_cache_verify_and_lend.rs:112-115`) | equal; usage and decay are not touched by the prefill (no seed) | +| lent slots | last k slots lent, `p.lent` remembers (layer, expert) and `refill` restores the same experts (`generate.cpp:13477-13530, 13450-13475`); `apply_pending(true)` first (`14068`) | `loan_slots`, `refill_lent` through `needs_refill(slot)` = the slot's own expert (`open_tier.rs:188-231`); `begin_prefill` waits for swaps (`original_serve_stack_prefill_phase.rs:51-58`); `needs_refill` returns the slot's recorded owner (`original_expert_cache_loans.rs:112-115`) | equal; usage and decay are not touched by the prefill (no seed) | | what is counted into `usage` | every entry of every window row, hit or not, rejected draft rows included (`expert_source.cpp:4824-4826`) | `note_usage`: every id of the group's rows (`source_spans.rs:147-156`) | equal (per entry, not per distinct expert) | | candidates and victims | cand: non-resident with `u >= 2.0`, sorted descending; victims: resident, `partial_sort` ascending; pair while `cand >= vict + 1.5`; sort by gain, cap 96 (`generate.cpp:10443-10458`) | `partition_layer` (`>= min_count`), `trim_victims`, `push_pairs` (`c < v + margin` breaks), truncate (`split_group_pcie.rs:247-314`) | equal; only the order of exact ties is unspecified in vanilla (`std::sort`) and "ascending expert, low layer first" in LEL (`swap_tie_order.rs:22-26`); measured null (cause 6) | | decay | `usage *= 0.7` at the end of every adapt() that ran; no decay when the previous swaps are still in flight (`generate.cpp:10433, 10590`) | `begin_adaptation`: pending swaps return before the decay; then `usage *= decay` (`source_spans.rs:109-131`) | equal | diff --git a/docs/experiments/verify-accept-on-device.md b/docs/experiments/verify-accept-on-device.md index a32e7bed..36135543 100644 --- a/docs/experiments/verify-accept-on-device.md +++ b/docs/experiments/verify-accept-on-device.md @@ -37,7 +37,7 @@ Per round, in call order. File:line refer to this tree (`crates/cuda-driver/src` | hop | what happens | where | host or GPU | figure (source) | | --- | --- | --- | --- | --- | -| 1 | last kernel of the window graph (greedy argmax into the head rows' mapped words) ends | `native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs:84-104` (`greedy`), captured by `capture_head_greedy` from `original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs:244` | GPU | n/a | +| 1 | last kernel of the window graph (greedy argmax into the head rows' mapped words) ends | `native_head/original_native_head_rows/original_native_head_rows_greedy_submit.rs:84-104` (`greedy`), captured by `capture_head_greedy` from `original_verify_window_ops/window_step_recording.rs:244` | GPU | n/a | | 2 | `compute.synchronize_with_receipt()` returns, then `copy.synchronize()` (already idle), `release_pcie_sources`, `record_window_profile` (off) | `original_verify_schedule/window_phases.rs:277-285` (`drv.sync_compute`, `drv.sync_copy`) | host wake from a blocking sync | not isolated; `drv.sync_compute` + `drv.head` together 0.88 ms incl. the last layer and head on the GPU (`docs/serve-step-costs.md`, job 901) | | 3 | `verifier_head_after_drain`: stream and receipt checks, `resources_after_stream_drain` | `original_gpu_verify_bridge.rs:7-20` | host | below the noise of the spans | | 4 | **post-drain logits scan, launch and stream sync**: `verify_clear_status` + `verify_scan_logits` over all `T x vocab` words are launched on the compute stream, then `stream.synchronize()` | `original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs:116-136` (`head.validate_stream`) | host launch (2 kernels) + a second blocking sync + the scan itself on the GPU | `head.validate_logits` (the whole of hops 4 and 5): 0.05 ms per round, job 901 on `claude/ms-trim` (`docs/serve-step-costs.md`: "head validation scan 0.05") | @@ -112,7 +112,7 @@ Per the brief I stop here. | option | what | files | saves (documented / estimated) | risk | | --- | --- | --- | --- | --- | -| **A. Finite verdict in the verify graph** (vanilla's structure; the "verdict decided on the device") | capture `verify_clear_status` + `verify_scan_logits` (already in the sealed `original_verify.ptx`) after `capture_head_greedy` in `OriginalVerifyWindowOps::head`, the result in a host-mapped word; post-drain code only reads it (no launch, no stream sync, no `cuMemcpyDtoH`, no context sync) | ours: `original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs`, `verify_gdn_journal_ladder_logits_scan.rs`, `original_gpu_verify_bridge.rs`, the mapped-slot list in `original_verify.rs`; one new mapped word; no new PTX | hops 4-5: 0.05 ms per round measured on `ms-trim` (job 901); the GPU part (the scan over `T x 248k` words, 2 extra kernels) moves into the graph's own tail | the scan kernel `atomicOr`s into the status: on a device-arena word that is fine, on host-mapped memory atomics are platform dependent. The safe form is: scan into a device word (as now), then a plain 4-byte store to the mapped word at the end of the graph (the greedy kernel already stores its ids to mapped memory this way). The NaN guard behaviour must stay (`Error::NonFiniteMmqOutput("Original Verifier full logits")` before any token is used); a test with an injected non-finite logit (the vanilla analogue is `STRATA_NAN_INJECT`) is needed on the GPU. No number of the model changes | +| **A. Finite verdict in the verify graph** (vanilla's structure; the "verdict decided on the device") | capture `verify_clear_status` + `verify_scan_logits` (already in the sealed `original_verify.ptx`) after `capture_head_greedy` in `OriginalVerifyWindowOps::head`, the result in a host-mapped word; post-drain code only reads it (no launch, no stream sync, no `cuMemcpyDtoH`, no context sync) | ours: `original_verify_window_ops/window_step_recording.rs`, `verify_gdn_journal_ladder_logits_scan.rs`, `original_gpu_verify_bridge.rs`, the mapped-slot list in `original_verify.rs`; one new mapped word; no new PTX | hops 4-5: 0.05 ms per round measured on `ms-trim` (job 901); the GPU part (the scan over `T x 248k` words, 2 extra kernels) moves into the graph's own tail | the scan kernel `atomicOr`s into the status: on a device-arena word that is fine, on host-mapped memory atomics are platform dependent. The safe form is: scan into a device word (as now), then a plain 4-byte store to the mapped word at the end of the graph (the greedy kernel already stores its ids to mapped memory this way). The NaN guard behaviour must stay (`Error::NonFiniteMmqOutput("Original Verifier full logits")` before any token is used); a test with an injected non-finite logit (the vanilla analogue is `STRATA_NAN_INJECT`) is needed on the GPU. No number of the model changes | | B. Shorten the host chain between the sync and the draft launch | `begin_adaptation` (0.08), `verify_commit` bookkeeping (0.09 at 247k, O(context)), draft staging (0.03-0.04): move off the path or make O(1) | `original_spec_controller*`, `original_serve_native*`, `mtp_original_*`: hex-finish | up to 0.15-0.20 ms of the 0.24 (sum of documented spans) | owned by `hex-finish`; the two earlier trims (`decode-tail`, `draft-round`) already took 0.16 ms and 0.03 ms of it | | C. Commit pre-launched with a device `keep` | section 4, item 3 | ours | 0.01 ms host, 0 on the critical path | breaks `discard_window` unless conditioned on the finite verdict; not recommended | | D. Device-selected draft (conditional graph nodes) | section 4, item 4 | draft chain | host launch of the round graph, potentially most of hop 10 | new design in their files; not a device-part step | @@ -172,7 +172,7 @@ requested set. **Files.** `original_verify/finite_verdict.rs` (new: the commands, the verdict decode, the post-drain dispatch), `original_verify_window_sm120.rs` (switch), `original_verify_window_ops/original_verifier.rs` (marks the head rows), -`original_verify_window_ops/window_ops_kernels_and_pcie_plan.rs` (`head()` records the tail), +`original_verify_window_ops/window_step_recording.rs` (`head()` records the tail), `original_verify/original_verify_gdn_journal/verify_gdn_journal_ladder_logits_scan.rs` (shared operands, the capture), `native_head/...` (the mapped verdict word next to the ids), `original_gpu_verify_bridge.rs` (the post-drain dispatch), `original_verify.rs` (one `mod`). No PTX was added or changed, so no nvcc was needed. diff --git a/docs/experiments/verify-gdn-fused-kernels.md b/docs/experiments/verify-gdn-fused-kernels.md index 5f0c829f..0f398488 100644 --- a/docs/experiments/verify-gdn-fused-kernels.md +++ b/docs/experiments/verify-gdn-fused-kernels.md @@ -132,10 +132,10 @@ options (`original_verify_ffi.rs`). | `crates/cuda-driver/src/sm120_gdn_fused.cu`, `.ptx` | new asset | | `crates/cuda-driver/src/original_verify/original_verify_window_gdn_fused.rs` (+ `/tests.rs`) | switches resolution, asset, launch DTOs, stage plan (`GdnFusedPolicy::stages`), 18 tests | | `crates/cuda-driver/src/original_verify/original_verify_gdn_journal/verify_gdn_fused_step.rs` | `capture_fused_recurrence`, `capture_ab_unrolled` (operand spans as `capture_layer_stage`) | -| `crates/cuda-driver/src/original_verify_window_ops/gdn_stages.rs` | the three `WindowOps` GDN calls (moved out of `window_ops_kernels_and_pcie_plan.rs`) | +| `crates/cuda-driver/src/original_verify_window_ops/gdn_stages.rs` | the three `WindowOps` GDN calls (moved out of `window_step_recording.rs`) | | `original_verify_window_sm120.rs` | `fused_gdn`, `gdn_ab_unroll` in `Sm120Switches`, `DEFAULT_ON_*` (separate block) | | `original_verify.rs`, `original_verify_gdn_journal.rs`, `original_verify_window_ops.rs`, `original_verifier.rs` | one `mod` line each, the `gdn` field of the ops struct and its resolution | -| `verify_gdn_journal_stage_and_commit.rs` | `StageOperands` / `stage_operands` `pub(super)` | +| `verify_gdn_journal_commit.rs` | `StageOperands` / `stage_operands` `pub(super)` | | `ptx-sm86/MANIFEST.json`, `scripts/gpu-bringup/extra-seal-plan.json` | not-built-for-sm_86 note, plan entry | | `tools/gdn-fused/` | probe and build script | From 36ed7713354813e9ad3e1097ea314e33938a050b Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 21:43:31 +0100 Subject: [PATCH 2/2] tech-debt.md: first c3 table without placeholders --- docs/architecture/tech-debt.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/architecture/tech-debt.md b/docs/architecture/tech-debt.md index 22b71f63..a7bcd47b 100644 --- a/docs/architecture/tech-debt.md +++ b/docs/architecture/tech-debt.md @@ -215,16 +215,16 @@ workers and the small libraries), before -> after, from `scripts/check-architect | Ratchet | Before | After | How | |---|---|---|---| | `allow-unused-imports` | 552 | 0 | `scripts/dev/prune_unused_imports.py`: strips the allow, compiles with one job per feature set (`cuda-driver`, `sm86`, all features), deletes the imports the compiler reports in every compilation unit, puts `#[cfg(test)]` on the ones only the library's unit tests use. Most of the 410 `cuda-driver` allows sat on `pub use` re-exports that needed no allow at all | -| `glob-super-import` | 3 | 2 (cuda-driver, see below) | `root_exports.rs` names its paths (`crate::x`, `leleka_cuda_model::serving_context`) | -| `path-include` | 132 | 0 counted (1 in `cuda-driver`, see below) | `scripts/dev/path_to_layout.py`: walks the module tree (a file loaded by `#[path]` resolves its children next to itself, a default file in a directory of its name), moves the module files to `/.rs` with `git mv`, drops the attribute, rewrites `include_*!` paths and the paths scripts quote (`scripts/dev/update_path_refs.py`). 502 files moved (`cuda-driver` 472, `model-format` 27, `native-cpu-expert` 3); module paths did not change. The gate now treats `#[cfg(test)] #[path = "../tests/x.rs"] mod x;` as test code | -| `env-read` | 30 | 0 outside EXC_ENV exceptions | one reader per crate: new typed `settings.rs` in `cpu-worker`, `tokenizer`, `gptoss-npu`, `gpu-npu-worker`, `igpu`, `npu-service`, `leleka-memory`, `gptoss`, `model-format` (functions named after the variable, returning parsed values); `obs` parses `LELEKA_LOG*` in `level.rs`; `cuda-model` has `env_switch::EnvSwitch` (the name, a typed rule, the answer cached on first read). Exceptions: the readers above, `cpu-kernels` (parses the ISA request), `libc-shim` and `memory-os` (platform adapters), the `npu-worker` and `native-parity-bench` roots | -| `dyn-trait` | 52 outside `cuda-driver` | 0 outside EXC_DYN exceptions | callbacks and probes became generics (`&mut (impl FnMut(..) + ?Sized)`, `&(impl ProcSource + ?Sized)`); what stays is a port boundary (`MemoryPressure`, `ProcSource`, `PageLocking`, `ModelBytes`, `PageSource`, `PrefillAccelerator`, `LayerCache`, the GPU probe closure), a trait method that must be dyn-compatible, `Box` of a library boundary, or the type-erased job of the worker pool | -| `instant-now` | 54 outside the driver and the CPU pool | 0 outside EXC_INSTANT exceptions | the clock adapter (`obs/time/clock.rs`) and measurement timers (stage laps and wall times printed in the workers' timing lines, load reports); each carries a comment that says so. `leleka-memory` reads `SystemClock` | -| `process-global` | 50 outside the driver and the CPU pool | 0 outside EXC_GLOBAL exceptions | immutable tables (regex, half table), operator settings read once, the process-wide logger, the process singletons the S13/S14 injection is for (`Governor::global()`, `Inventory`, the serving context, the verify stamps) | +| `glob-super-import` | 3 | 2 (`cuda-driver`: `head_dispatch` and `copy_ring_layer`, on `claude/debt-hot-low`) | `root_exports.rs` names its paths (`crate::x`, `leleka_cuda_model::serving_context`) | +| `path-include` | 132 | 0 counted (1 in `cuda-driver`: the shared `head_dispatch`, on `claude/debt-hot-low`) | `scripts/dev/path_to_layout.py`: walks the module tree (a file loaded by `#[path]` resolves its children next to itself, a default file in a directory of its name), moves the module files to `/.rs` with `git mv`, drops the attribute, rewrites `include_*!` paths and the paths scripts quote (`scripts/dev/update_path_refs.py`). 502 files moved (`cuda-driver` 472, `model-format` 27, `native-cpu-expert` 3); module paths did not change. The gate now treats `#[cfg(test)] #[path = "../tests/x.rs"] mod x;` as test code | +| `env-read` | 30 | 0 outside the named exceptions | one reader per crate: new typed `settings.rs` in `cpu-worker`, `tokenizer`, `gptoss-npu`, `gpu-npu-worker`, `igpu`, `npu-service`, `leleka-memory`, `gptoss`, `model-format` (functions named after the variable, returning parsed values); `obs` parses `LELEKA_LOG*` in `level.rs`; `cuda-model` has `env_switch::EnvSwitch` (the name, a typed rule, the answer cached on first read). Exceptions: the readers above, `cpu-kernels` (parses the ISA request), `libc-shim` and `memory-os` (platform adapters), the `npu-worker` and `native-parity-bench` roots | +| `dyn-trait` | 52 outside `cuda-driver` | 0 outside the named exceptions | callbacks and probes became generics (`&mut (impl FnMut(..) + ?Sized)`, `&(impl ProcSource + ?Sized)`); what stays is a port boundary (`MemoryPressure`, `ProcSource`, `PageLocking`, `ModelBytes`, `PageSource`, `PrefillAccelerator`, `LayerCache`, the GPU probe closure), a trait method that must be dyn-compatible, `Box` of a library boundary, or the type-erased job of the worker pool | +| `instant-now` | 54 outside the driver and the CPU pool | 0 outside the named exceptions | the clock adapter (`obs/time/clock.rs`) and measurement timers (stage laps and wall times printed in the workers' timing lines, load reports); each carries a comment that says so. `leleka-memory` reads `SystemClock` | +| `process-global` | 50 outside the driver and the CPU pool | 0 outside the named exceptions | immutable tables (regex, half table), operator settings read once, the process-wide logger, the process singletons the S13/S14 injection is for (`Governor::global()`, `Inventory`, the serving context, the verify stamps) | The test run (`cargo test`, slim profile) of `cuda-model`, `obs`, `leleka-memory`, `tokenizer`, `model-format`, `gptoss`, `cpu-worker`, `igpu`, `memory-os`, `experimental-ref` and `npu-service`: all green except the three known `qwen_artifact_binding` tests of `model-format` -(`cargo check --workspace --all-targets` is clean; `cuda-driver` and `native-cpu-expert` follow the hot-path branch, see below). +(`cargo check --workspace --all-targets` is clean). The `dyn-trait`, `instant-now` and `process-global` rows exclude `cuda-driver` and `native-cpu-expert`: their changes and exceptions are on `claude/debt-hot-low`, which waits for the identity gate; the final table replaces this one when it is merged. ### (e) Stage 10 pass: control-plane, desktop-core, deploy and the small crates (owner order 2026-11-14, branch `claude/debt-control`)