From fb428d3d9b815f0102f0dfb01aee53c4464b1c82 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 14 Nov 2026 14:35:23 +0100 Subject: [PATCH] Explicit imports in leleka-model-format, leleka-native-cpu-expert and leleka-cpu-sys; explicit_imports.py: own glob names, static mut, intrinsics Co-Authored-By: Claude Sonnet 5.5 --- crates/cpu-sys/src/attention_and_elementwise.rs | 5 +++-- crates/cpu-sys/src/avx2_and_avxvnni.rs | 8 ++++++-- .../src/c_reference/quantize_q8_0_scalar.rs | 5 +++-- crates/cpu-sys/src/checks.rs | 6 ++++-- crates/cpu-sys/src/portable.rs | 6 ++++-- crates/cpu-sys/src/simd/x86/attention_kernels.rs | 9 +++++++-- .../src/simd/x86/f16_attention_and_elementwise.rs | 8 ++++++-- crates/cpu-sys/src/simd/x86/mxfp4_q8_dots.rs | 7 +++++-- .../src/simd/x86/q8_dots_and_mxfp4_tiles.rs | 9 +++++++-- crates/cpu-sys/src/simd/x86/quantize_q8_0.rs | 9 +++++++-- .../src/simd/x86/reductions_and_int_dots.rs | 12 ++++++++++-- crates/cpu-sys/src/simd/x86/tile_kernels.rs | 8 ++++++-- crates/cpu-sys/src/tiles.rs | 5 +++-- crates/model-format/src/bulk_read/strategy.rs | 5 +++-- .../model-format/src/gguf/stream_buffer_bytes.rs | 7 +++++-- crates/model-format/src/gguf_digest_capture.rs | 6 +++++- crates/model-format/src/gguf_expert_file_source.rs | 5 ++++- crates/model-format/src/gguf_resident.rs | 5 ++++- .../src/gguf_resident/next_source_id.rs | 6 ++++-- .../src/gguf_resident/verified_gguf_file.rs | 7 +++++-- crates/model-format/src/kar/independent_handles.rs | 6 ++++-- crates/model-format/src/kar/kar_ple_profile.rs | 6 ++++-- crates/model-format/src/kar_levels/selection.rs | 7 +++++-- .../src/ple_reader/file_page_source.rs | 6 ++++-- crates/model-format/src/qwen4exp_digest_capture.rs | 11 ++++++++++- .../src/qwen4exp_expert_source_bank.rs | 5 ++++- .../qwen4_exp_artifact.rs | 12 ++++++++++-- .../retention_metadata_bytes.rs | 9 +++++++-- .../src/qwen4exp_file_expert_source.rs | 5 ++++- .../src/rust_bench_frontend/cpu_blob.rs | 6 ++++-- .../src/rust_bench_frontend/float_reference.rs | 6 ++++-- .../src/rust_bench_frontend/numerical.rs | 3 +-- .../src/rust_bench_frontend/parity_run.rs | 6 ++++-- crates/native-cpu-expert/src/rust_ggml/kind.rs | 3 +-- .../src/rust_ggml/native_format.rs | 9 +++++++-- .../src/rust_ggml/quantize_raw.rs | 3 +-- .../native-cpu-expert/src/rust_iq/dot_multi512.rs | 12 ++++++++++-- crates/native-cpu-expert/src/rust_iq/iq4nl_n.rs | 8 ++++++-- crates/native-cpu-expert/src/rust_iq/u16.rs | 9 +++++++-- crates/native-cpu-expert/src/rust_legacy/admit.rs | 6 ++++-- .../native-cpu-expert/src/rust_legacy/gate_each.rs | 6 ++++-- .../native-cpu-expert/src/rust_legacy/pair_rows.rs | 3 +-- .../src/rust_legacy/set_oracle_q8_zero.rs | 14 ++++++++++++-- crates/native-cpu-expert/src/rust_pool/trace.rs | 2 +- scripts/dev/explicit_imports.py | 14 ++++++++++++-- scripts/dev/rust_modtree.py | 4 ++-- 46 files changed, 234 insertions(+), 85 deletions(-) diff --git a/crates/cpu-sys/src/attention_and_elementwise.rs b/crates/cpu-sys/src/attention_and_elementwise.rs index 35681d4c..88495a46 100644 --- a/crates/cpu-sys/src/attention_and_elementwise.rs +++ b/crates/cpu-sys/src/attention_and_elementwise.rs @@ -1,7 +1,8 @@ //! Attention score and weighted-sum kernels, SwiGLU, f16 conversion and the softmax exponent sum. -#[allow(unused_imports)] -use super::*; +use super::{AttnShape, KernelError, ScoreSpec, check_scores, check_swiglu, check_weighted_sum, simd}; +#[cfg(target_arch="x86_64")] +use super::avx2_available; /// Attention scores for a group of `heads` query heads that share the keys: /// `out[g * n + i] = scale * dot(q[g * hd ..][..hd], keys[i * stride ..][..hd])` with diff --git a/crates/cpu-sys/src/avx2_and_avxvnni.rs b/crates/cpu-sys/src/avx2_and_avxvnni.rs index fb56e74b..a5202add 100644 --- a/crates/cpu-sys/src/avx2_and_avxvnni.rs +++ b/crates/cpu-sys/src/avx2_and_avxvnni.rs @@ -1,7 +1,11 @@ //! The AVX2 and AVX-VNNI dot, quantize and multi-activation kernels (x86-64 only). -#[allow(unused_imports)] -use super::*; +use super::{ + KernelError, MXFP4_BLOCK_BYTES, Q8_0_BLOCK_BYTES, Q8rRef, check_i4, check_i8, check_multi, check_mx, check_mx_out, + check_q8, check_q8r, check_quantize, simd, +}; +#[cfg(target_arch="x86_64")] +use super::{avx2_available, avxvnni_available}; /// AVX2 version of [`dot_i8i8_scalar`]. Activations must be in `[-127, 127]` to match it. #[cfg(target_arch = "x86_64")] diff --git a/crates/cpu-sys/src/c_reference/quantize_q8_0_scalar.rs b/crates/cpu-sys/src/c_reference/quantize_q8_0_scalar.rs index 4e242426..2247ae8f 100644 --- a/crates/cpu-sys/src/c_reference/quantize_q8_0_scalar.rs +++ b/crates/cpu-sys/src/c_reference/quantize_q8_0_scalar.rs @@ -1,8 +1,9 @@ //! Functions: `quantize_q8_0_scalar`, `quantize_q8_0_avx2`, `dot_q8_0_q8_0_scalar`, `q8_0_q8_0_isums_scalar` and 10 ... //! Split out of `c_reference` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{KernelError, avx2_available, check_i4, check_i8, check_mx_out, check_q8, check_quantize, ffi}; +#[cfg(target_arch="x86_64")] +use super::avxvnni_available; /// Quantize floats (a multiple of 32) to Q8_0 blocks; scale = amax / 127 as a half, quants rounded /// to nearest even and clamped to `[-127, 127]`. Non-finite input gives unspecified (but memory safe) diff --git a/crates/cpu-sys/src/checks.rs b/crates/cpu-sys/src/checks.rs index 9e9f7d35..44b3cc55 100644 --- a/crates/cpu-sys/src/checks.rs +++ b/crates/cpu-sys/src/checks.rs @@ -1,7 +1,9 @@ //! Operand length and shape checks shared by the scalar and SIMD kernels. -#[allow(unused_imports)] -use super::*; +use super::{ + ActRef, AttnShape, BLOCK_ELEMS, KernelError, MAX_DOT_LEN, MULTI_MAX, MXFP4_BLOCK_BYTES, Q8_0_BLOCK_BYTES, Q8rRef, + TILE_MAX, +}; pub(super) fn check_i8(w: &[i8], x: &[i8]) -> Result<(), KernelError> { if w.len() != x.len() { diff --git a/crates/cpu-sys/src/portable.rs b/crates/cpu-sys/src/portable.rs index 6c43ecee..25b3e110 100644 --- a/crates/cpu-sys/src/portable.rs +++ b/crates/cpu-sys/src/portable.rs @@ -1,7 +1,9 @@ //! The portable scalar reference kernels. -#[allow(unused_imports)] -use super::*; +use super::{ + KernelError, MXFP4_BLOCK_BYTES, Q8_0_BLOCK_BYTES, Q8rRef, check_i4, check_i8, check_multi, check_mx, check_mx_out, + check_q8, check_q8r, check_quantize, simd, +}; // ---------------------------------------------------------------------- portable level ---------- diff --git a/crates/cpu-sys/src/simd/x86/attention_kernels.rs b/crates/cpu-sys/src/simd/x86/attention_kernels.rs index 2a2606cf..4351abce 100644 --- a/crates/cpu-sys/src/simd/x86/attention_kernels.rs +++ b/crates/cpu-sys/src/simd/x86/attention_kernels.rs @@ -1,7 +1,12 @@ //! Attention score and weighted-sum kernels over f32 keys and values, and the vector exponential. -#[allow(unused_imports)] -use super::*; +use super::{ + __m128i, __m256, _CMP_LT_OQ, _MM_FROUND_NO_EXC, _MM_FROUND_TO_NEAREST_INT, _mm_loadu_si128, _mm256_add_epi32, + _mm256_add_ps, _mm256_andnot_ps, _mm256_castsi256_ps, _mm256_cmp_ps, _mm256_cvtph_ps, _mm256_cvtps_epi32, + _mm256_fmadd_ps, _mm256_fnmadd_ps, _mm256_loadu_ps, _mm256_min_ps, _mm256_mul_ps, _mm256_round_ps, + _mm256_set1_epi32, _mm256_set1_ps, _mm256_setzero_ps, _mm256_slli_epi32, _mm256_storeu_ps, AttnShape, ScoreSpec, + hsum_ps, +}; // ---- attention ---- diff --git a/crates/cpu-sys/src/simd/x86/f16_attention_and_elementwise.rs b/crates/cpu-sys/src/simd/x86/f16_attention_and_elementwise.rs index da6207d4..53d7196c 100644 --- a/crates/cpu-sys/src/simd/x86/f16_attention_and_elementwise.rs +++ b/crates/cpu-sys/src/simd/x86/f16_attention_and_elementwise.rs @@ -1,7 +1,11 @@ //! Attention over f16 caches, SwiGLU, f16 conversion and the softmax exponent sum. -#[allow(unused_imports)] -use super::*; +use super::{ + __m128i, _MM_FROUND_TO_NEAREST_INT, _mm_loadu_si128, _mm_storeu_si128, _mm256_add_ps, _mm256_cvtph_ps, + _mm256_cvtps_ph, _mm256_div_ps, _mm256_fmadd_ps, _mm256_loadu_ps, _mm256_max_ps, _mm256_min_ps, _mm256_mul_ps, + _mm256_set1_ps, _mm256_setzero_ps, _mm256_storeu_ps, _mm256_sub_ps, AttnShape, ScoreSpec, WeightedSum, + attn_dot_f16, cvt_f32_f16, exp256, hsum_ps, load_f16x8, +}; #[target_feature(enable = "avx2,fma,f16c")] pub unsafe fn attn_scores_f16_avx2(q: &[f32], keys: &[u16], spec: ScoreSpec, out: &mut [f32]) { diff --git a/crates/cpu-sys/src/simd/x86/mxfp4_q8_dots.rs b/crates/cpu-sys/src/simd/x86/mxfp4_q8_dots.rs index bcd06a4d..060be4cd 100644 --- a/crates/cpu-sys/src/simd/x86/mxfp4_q8_dots.rs +++ b/crates/cpu-sys/src/simd/x86/mxfp4_q8_dots.rs @@ -1,7 +1,10 @@ //! MXFP4 times Q8_0 dot products and their per-block integer sums (AVX2 and AVX-VNNI). -#[allow(unused_imports)] -use super::*; +use super::{ + __m256, __m256i, _mm_set1_epi8, _mm256_add_ps, _mm256_cvtepi32_ps, _mm256_dpbusd_avx_epi32, _mm256_fmadd_ps, + _mm256_loadu_si256, _mm256_set1_epi16, _mm256_set1_ps, _mm256_setzero_ps, _mm256_setzero_si256, _mm256_sign_epi8, + MXFP4_BYTES, Q8_0_BYTES, block_p32_avx2, e8m0_half, half_to_f32, hsum_epi32, hsum_ps, mx_table, mx_values, +}; #[inline] #[target_feature(enable = "avx2,avxvnni")] diff --git a/crates/cpu-sys/src/simd/x86/q8_dots_and_mxfp4_tiles.rs b/crates/cpu-sys/src/simd/x86/q8_dots_and_mxfp4_tiles.rs index 2dfd96ce..9da89925 100644 --- a/crates/cpu-sys/src/simd/x86/q8_dots_and_mxfp4_tiles.rs +++ b/crates/cpu-sys/src/simd/x86/q8_dots_and_mxfp4_tiles.rs @@ -1,7 +1,12 @@ //! Q8_0 times Q8_0 dot products, the q8r4 MXFP4 dot and the AVX2 MXFP4 tile. -#[allow(unused_imports)] -use super::*; +use super::{ + __m128i, __m256i, _mm_loadu_si128, _mm_set1_epi8, _mm_xor_si128, _mm256_add_ps, _mm256_cvtepi32_ps, + _mm256_dpbusd_avx_epi32, _mm256_fmadd_ps, _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, + _mm256_set_m128i, _mm256_set1_epi16, _mm256_set1_ps, _mm256_setzero_ps, _mm256_setzero_si256, _mm256_sign_epi8, + ActRef, KVALUES_MXFP4, MXFP4_BYTES, Q8_0_BYTES, block_p32_vnni, e8m0_half, half_to_f32, hsum_epi32, hsum_ps, + mx_table, mx_values, mxfp4_scaled_fma, +}; #[target_feature(enable = "avx2,fma,avxvnni")] pub unsafe fn dot_mxfp4_q8r4_avxvnni(x: &[u8], ys: &[f32], yq: &[i8]) -> f32 { diff --git a/crates/cpu-sys/src/simd/x86/quantize_q8_0.rs b/crates/cpu-sys/src/simd/x86/quantize_q8_0.rs index 07ba1549..3c67c5e1 100644 --- a/crates/cpu-sys/src/simd/x86/quantize_q8_0.rs +++ b/crates/cpu-sys/src/simd/x86/quantize_q8_0.rs @@ -1,7 +1,12 @@ //! Activation quantization to Q8_0 blocks (AVX2). -#[allow(unused_imports)] -use super::*; +use super::{ + __m256, __m256i, _MM_FROUND_NO_EXC, _MM_FROUND_TO_NEAREST_INT, _mm_cvtss_f32, _mm_max_ps, _mm_max_ss, + _mm_movehdup_ps, _mm_movehl_ps, _mm256_andnot_ps, _mm256_castps256_ps128, _mm256_cvtps_epi32, + _mm256_extractf128_ps, _mm256_loadu_ps, _mm256_max_epi8, _mm256_max_ps, _mm256_mul_ps, _mm256_packs_epi16, + _mm256_packs_epi32, _mm256_permutevar8x32_epi32, _mm256_round_ps, _mm256_set1_epi8, _mm256_set1_ps, + _mm256_setr_epi32, _mm256_storeu_si256, Q8_0_BYTES, cvt_f32_f16, +}; /// The largest absolute value of the 32 floats in `v0..v3`, reduced in the fixed lane order of the portable code. #[inline] diff --git a/crates/cpu-sys/src/simd/x86/reductions_and_int_dots.rs b/crates/cpu-sys/src/simd/x86/reductions_and_int_dots.rs index 7d1e5a29..06acda9e 100644 --- a/crates/cpu-sys/src/simd/x86/reductions_and_int_dots.rs +++ b/crates/cpu-sys/src/simd/x86/reductions_and_int_dots.rs @@ -1,7 +1,15 @@ //! Horizontal sums, f16 loads, the int8 and int4 dot products and the MXFP4 lookup tables (AVX2 and AVX-VNNI). -#[allow(unused_imports)] -use super::*; +use super::{ + __m128i, __m256, __m256i, _MM_FROUND_TO_NEAREST_INT, _mm_abs_epi8, _mm_add_epi32, _mm_add_ps, _mm_add_ss, + _mm_and_si128, _mm_cvtph_ps, _mm_cvtps_ph, _mm_cvtsi32_si128, _mm_cvtsi128_si32, _mm_cvtss_f32, + _mm_dpbusd_avx_epi32, _mm_extract_epi16, _mm_hadd_epi32, _mm_loadu_si128, _mm_movehl_ps, _mm_set_ss, _mm_set1_epi8, + _mm_setzero_si128, _mm_shuffle_ps, _mm_sign_epi8, _mm_srli_epi16, _mm_sub_epi8, _mm_unpackhi_epi8, + _mm_unpacklo_epi8, _mm256_add_epi32, _mm256_castps256_ps128, _mm256_castsi256_si128, _mm256_extractf128_ps, + _mm256_extracti128_si256, _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, _mm256_set_m128i, + _mm256_set1_epi8, _mm256_set1_epi16, _mm256_setzero_si256, _mm256_shuffle_epi8, _mm256_sign_epi8, _mm256_sub_epi8, + KVALUES_MXFP4, +}; #[inline] #[target_feature(enable = "avx2")] diff --git a/crates/cpu-sys/src/simd/x86/tile_kernels.rs b/crates/cpu-sys/src/simd/x86/tile_kernels.rs index 1ecb95d8..f0b8265e 100644 --- a/crates/cpu-sys/src/simd/x86/tile_kernels.rs +++ b/crates/cpu-sys/src/simd/x86/tile_kernels.rs @@ -1,7 +1,11 @@ //! Tile kernels over several rows and activations at once, and the multi-activation reduction. -#[allow(unused_imports)] -use super::*; +use super::{ + __m256, __m256i, _mm_set1_epi8, _mm256_add_ps, _mm256_cvtepi32_ps, _mm256_dpbusd_avx_epi32, _mm256_fmadd_ps, + _mm256_loadu_ps, _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, _mm256_mul_ps, _mm256_set1_epi8, + _mm256_set1_epi16, _mm256_set1_ps, _mm256_setzero_ps, _mm256_setzero_si256, _mm256_sign_epi8, _mm256_xor_si256, + ActRef, MXFP4_BYTES, Q8_0_BYTES, e8m0_half, half_to_f32, hsum_ps, mx_table_biased, mx_values, mxfp4_tile_avx2, +}; /// MXFP4 rows against activations, AVX-VNNI with unsigned weights. #[inline] diff --git a/crates/cpu-sys/src/tiles.rs b/crates/cpu-sys/src/tiles.rs index e23528a0..9d33ca6f 100644 --- a/crates/cpu-sys/src/tiles.rs +++ b/crates/cpu-sys/src/tiles.rs @@ -1,7 +1,8 @@ //! Prepared activations and the tile kernels that take several rows and activations at once. -#[allow(unused_imports)] -use super::*; +use super::{ActRef, BLOCK_ELEMS, KernelError, MXFP4_BLOCK_BYTES, Q8_0_BLOCK_BYTES, check_tile, simd}; +#[cfg(target_arch="x86_64")] +use super::{avx2_available, avxvnni_available}; /// Largest number of rows or activations in one tile. pub const TILE_MAX: usize = 4; diff --git a/crates/model-format/src/bulk_read/strategy.rs b/crates/model-format/src/bulk_read/strategy.rs index 557edb2a..df0387e6 100644 --- a/crates/model-format/src/bulk_read/strategy.rs +++ b/crates/model-format/src/bulk_read/strategy.rs @@ -1,8 +1,9 @@ //! Methods of `Strategy`: `as_str`. Methods of `Plan`: `from_env`, `with_overrides`. Implements `Default for Plan`. //! Functions: `open_direct`, `open_direct`, `read_at`, `read_at` and 3 more. -#[allow(unused_imports)] -use super::*; +use super::{ + ALIGN, Aligned, AtomicU64, Duration, File, Instant, Mutex, Ordering, Plan, Report, Shared, Strategy, io, strategy, +}; impl Strategy { pub fn as_str(self) -> &'static str { diff --git a/crates/model-format/src/gguf/stream_buffer_bytes.rs b/crates/model-format/src/gguf/stream_buffer_bytes.rs index 859b9f59..b4e4b282 100644 --- a/crates/model-format/src/gguf/stream_buffer_bytes.rs +++ b/crates/model-format/src/gguf/stream_buffer_bytes.rs @@ -1,8 +1,11 @@ //! Functions: `stream_buffer_bytes`, `stream_buffer_bytes`, `with_test_stream_buffer`. //! Split out of `gguf` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + BTreeMap, BufRead, BufReader, Digest, Error, File, HashSet, Path, Read, STREAM_BUFFER_BYTES, Seek, SeekFrom, Sha256, +}; +#[cfg(test)] +use super::STREAM_BUFFER_TEST_OVERRIDE; // Production always uses `STREAM_BUFFER_BYTES`. Tests may shrink the span // stream buffer on their own thread to exercise multi-chunk behaviour with diff --git a/crates/model-format/src/gguf_digest_capture.rs b/crates/model-format/src/gguf_digest_capture.rs index 4e982b45..a84014f8 100644 --- a/crates/model-format/src/gguf_digest_capture.rs +++ b/crates/model-format/src/gguf_digest_capture.rs @@ -1,5 +1,9 @@ //! Opt-in transport only. The original digest/index gates still own admission. -use super::*; +use super::{ + BTreeMap, BufRead, BufReader, Cursor, Digest, Error, File, HashSet, IndexRules, Path, Read, ResidentTensor, Result, + Seek, SeekFrom, Sha256, TensorIndex, VerifiedGgufFile, cursor, ensure_size, open_regular_file, + parse_artifact_digest, parse_index, read_index_file, resident, stream_file_span, +}; use crate::qwen4exp::ProvisionalExpertSource; pub(crate) fn open_expert_capture( diff --git a/crates/model-format/src/gguf_expert_file_source.rs b/crates/model-format/src/gguf_expert_file_source.rs index 2b702b45..59ea2e9d 100644 --- a/crates/model-format/src/gguf_expert_file_source.rs +++ b/crates/model-format/src/gguf_expert_file_source.rs @@ -1,5 +1,8 @@ //! Retained actual admitted file, not a caller pointer or an immutable-file claim. -use super::*; +use super::{ + BTreeMap, BufRead, BufReader, Digest, Error, File, HashSet, Path, Read, Result, Seek, SeekFrom, Sha256, + VerifiedGgufFile, +}; #[cfg(unix)] use std::os::unix::fs::MetadataExt; pub struct ExpertFileOwner { diff --git a/crates/model-format/src/gguf_resident.rs b/crates/model-format/src/gguf_resident.rs index 41c70326..251b1fa6 100644 --- a/crates/model-format/src/gguf_resident.rs +++ b/crates/model-format/src/gguf_resident.rs @@ -1,6 +1,9 @@ //! Actual immutable bytes loaded from one admitted retained source owner. //! No finite, runtime row, activation or device certificate is minted here. -use super::*; +use super::{ + BTreeMap, BufRead, BufReader, Digest, Error, File, GgufSourceFence, HashSet, Path, Read, Result, Seek, SeekFrom, + Sha256, VerifiedGgufFile, resident, +}; use std::sync::atomic::{AtomicU64, Ordering}; // Private source-owner identity, assigned only after actual admitted-file fill. diff --git a/crates/model-format/src/gguf_resident/next_source_id.rs b/crates/model-format/src/gguf_resident/next_source_id.rs index bfbddf8f..af54329e 100644 --- a/crates/model-format/src/gguf_resident/next_source_id.rs +++ b/crates/model-format/src/gguf_resident/next_source_id.rs @@ -1,8 +1,10 @@ //! Methods of `ResidentTensor`: `charged_bytes`, `len`, `file_mapped`, `backing`. //! Methods of `ResidentStorage`: `backing`, `as_slice`, `len`. -#[allow(unused_imports)] -use super::*; +use super::{ + AtomicU64, BTreeMap, BufRead, BufReader, Digest, Error, File, FileSpan, HashSet, NEXT_SOURCE_ID, Ordering, Path, + Read, ResidentStorage, ResidentTensor, Result, Seek, SeekFrom, Sha256, +}; pub(super) fn next_source_id() -> Result { let mut current = NEXT_SOURCE_ID.load(Ordering::Relaxed); diff --git a/crates/model-format/src/gguf_resident/verified_gguf_file.rs b/crates/model-format/src/gguf_resident/verified_gguf_file.rs index 71f3c996..fa3e1cf4 100644 --- a/crates/model-format/src/gguf_resident/verified_gguf_file.rs +++ b/crates/model-format/src/gguf_resident/verified_gguf_file.rs @@ -1,8 +1,11 @@ //! Methods of `VerifiedGgufFile`: `load_resident_tensor`, `resident_extent`, `load_huge`, `load_heap` and 7 more. //! Methods of `GgufSourceFence`: `copy_resident_tensor`. Functions: `mapping_granularity`, `mapping_granularity`. -#[allow(unused_imports)] -use super::*; +use super::{ + AtomicU64, BTreeMap, BufRead, BufReader, Digest, Error, File, FileSpan, GgufSourceFence, HashSet, Ordering, Path, + Read, ResidentLoadError, ResidentStorage, ResidentTensor, Result, Seek, SeekFrom, Sha256, VerifiedGgufFile, + next_source_id, resident, +}; type LoadResult = std::result::Result; diff --git a/crates/model-format/src/kar/independent_handles.rs b/crates/model-format/src/kar/independent_handles.rs index 09471692..d55cb52a 100644 --- a/crates/model-format/src/kar/independent_handles.rs +++ b/crates/model-format/src/kar/independent_handles.rs @@ -1,8 +1,10 @@ //! Methods of `KarPleRowReader`: `read_rows`. //! Functions: `independent_handles`, `reopen_independent`, `reopen_independent`, `read_rows_parallel` and 11 more. -#[allow(unused_imports)] -use super::*; +use super::{ + COLD_SKIP, COLD_SKIP_CALLS, Digest, File, HashSet, KarError, KarPleRowPacket, KarPleRowReader, PLE_ROWS, Read, + Seek, SeekFrom, Sha256, VerifiedPart, WARM_ROW_NS, +}; /// `n` handles on `file` that can serve reads at the same time; the file itself when no more can be had. pub(super) fn independent_handles(file: &File, n: usize) -> Vec { diff --git a/crates/model-format/src/kar/kar_ple_profile.rs b/crates/model-format/src/kar/kar_ple_profile.rs index 43cd28a9..24788255 100644 --- a/crates/model-format/src/kar/kar_ple_profile.rs +++ b/crates/model-format/src/kar/kar_ple_profile.rs @@ -1,8 +1,10 @@ //! Methods of `KarPleProfile`: `new`, `with_total_rows`, `native_shard_sha256`. //! Methods of `KarPleRowPacket`: `payload`, `partition`. -#[allow(unused_imports)] -use super::*; +use super::{ + Digest, File, HashSet, KarError, KarPlePartProvenance, KarPleProfile, KarPleProfileSpec, KarPleRowPacket, + KarStartupRead, KarTrust, PLE_ROWS, Read, Seek, SeekFrom, Sha256, +}; impl KarPleProfile { /// Bounds validation does not authenticate the manifest's origin. Only the diff --git a/crates/model-format/src/kar_levels/selection.rs b/crates/model-format/src/kar_levels/selection.rs index 4007af29..3d86852c 100644 --- a/crates/model-format/src/kar_levels/selection.rs +++ b/crates/model-format/src/kar_levels/selection.rs @@ -1,8 +1,11 @@ //! Methods of `Selection`: `window_error`, `resident_prefix_bytes`, `window`, `rows` and 1 more. //! Methods of `GpuWindow`: `new`, `staged_source_bytes`, `scratch`. -#[allow(unused_imports)] -use super::*; +use super::{ + ArchiveSlot, BTreeMap, EXPERT_ROLES, GpuRows, GpuWindow, KarError, KarInspection, KarLevelSelector, KarLevelsError, + KernelModelError, MAX_TOKENS, RangeSource, Result, RowPlan, RowShape, SCRATCH_ALIGN, STATUS_BYTES, ScratchBudget, + ScratchBytes, Selection, WindowPlan, model, selection, +}; impl Selection<'_> { pub(super) fn window_error(&self, reason: KernelModelError) -> KarLevelsError { diff --git a/crates/model-format/src/ple_reader/file_page_source.rs b/crates/model-format/src/ple_reader/file_page_source.rs index 2c7a8e74..0a4b7d7c 100644 --- a/crates/model-format/src/ple_reader/file_page_source.rs +++ b/crates/model-format/src/ple_reader/file_page_source.rs @@ -1,8 +1,10 @@ //! Methods of `PleReaderConfig`: `new`. Methods of `ReaderStats`: `percentile`. //! Implements `PageSource for File`, `Display for PleError` and 1 more. -#[allow(unused_imports)] -use super::*; +use super::{ + AlignedBuf, Arc, Condvar, Duration, EMPTY, File, HashMap, Instant, JoinHandle, Mutex, MutexGuard, PAGE, PageSource, + PlannedRead, PleError, PleReaderConfig, ROW_BYTES, ReaderStats, RowCache, State, Use, VecDeque, WAYS, fmt, io, +}; impl PageSource for File { fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { diff --git a/crates/model-format/src/qwen4exp_digest_capture.rs b/crates/model-format/src/qwen4exp_digest_capture.rs index a0ab0230..83c29461 100644 --- a/crates/model-format/src/qwen4exp_digest_capture.rs +++ b/crates/model-format/src/qwen4exp_digest_capture.rs @@ -1,6 +1,15 @@ //! Provisional transport: deliberately no byte accessor, source certificate, //! Clone, or model view. Only the genuine model's bank boundary consumes it. -use super::*; +use super::{ + BANKS, BTreeMap, BTreeSet, Bank, BankDescriptor, BindingError, Cell, Error, FUTURE_HEADROOM, LayerRole, + PINNED_IDENTITIES, Qwen4ExpArtifact, Rc, ResidentExpertBank, ResidentExpertSourceError, ResidentExpertSourceReport, + ResolvedTensor, SOURCE_CAP, TensorIndex, TensorRole, VerifiedGgufFile, checked_descriptor, expert_roles, gguf, + retention_metadata_bytes, size_of, slot, +}; +#[cfg(any(target_os="linux", windows, not(any(target_os="linux",windows))))] +use super::memory_available; +#[cfg(target_os="linux")] +use super::Read; use std::{fs::File, path::Path}; const RETAINED_KAR_BYTES: u64 = 55_295_529_472; diff --git a/crates/model-format/src/qwen4exp_expert_source_bank.rs b/crates/model-format/src/qwen4exp_expert_source_bank.rs index 4c93a7b7..c4b84cf9 100644 --- a/crates/model-format/src/qwen4exp_expert_source_bank.rs +++ b/crates/model-format/src/qwen4exp_expert_source_bank.rs @@ -1,5 +1,8 @@ //! Optional raw encoded source retention, distinct from finite/device admission. -use super::*; +use super::{ + BTreeMap, BTreeSet, BindingError, Error, LayerRole, PINNED_IDENTITIES, Qwen4ExpArtifact, ResolvedTensor, + TensorIndex, TensorRole, VerifiedGgufFile, expert_roles, fmt, gguf, io, plan_stream_rows, topology, +}; use std::{cell::Cell, mem::size_of, rc::Rc}; #[cfg(target_os = "linux")] use std::{fs::File, io::Read}; diff --git a/crates/model-format/src/qwen4exp_expert_source_bank/qwen4_exp_artifact.rs b/crates/model-format/src/qwen4exp_expert_source_bank/qwen4_exp_artifact.rs index 87c6efab..ec51f963 100644 --- a/crates/model-format/src/qwen4exp_expert_source_bank/qwen4_exp_artifact.rs +++ b/crates/model-format/src/qwen4exp_expert_source_bank/qwen4_exp_artifact.rs @@ -1,8 +1,16 @@ //! Methods of `Qwen4ExpArtifact`: `load_resident_expert_source`, `check_expert_layout`, `plan_banks`, `load_banks` a... //! Methods of `ResidentExpertBankLease`: `bank_count`, `source_bytes`, `charged_source_bytes`, `file_mapped` and 1 m... -#[allow(unused_imports)] -use super::*; +use super::{ + BANKS, BTreeMap, BTreeSet, Bank, BankDescriptor, BindingError, Cell, Error, FUTURE_HEADROOM, Qwen4ExpArtifact, Rc, + ResidentExpertBank, ResidentExpertBankLease, ResidentExpertBankMember, ResidentExpertSourceError, + ResidentExpertSourceReport, SOURCE_CAP, TensorRole, admit, checked_descriptor, expert_roles, gguf, + retention_metadata_bytes, size_of, slot, topology, +}; +#[cfg(any(target_os="linux", windows, not(any(target_os="linux",windows))))] +use super::memory_available; +#[cfg(target_os="linux")] +use super::{File, Read}; /// The memory the admission saw: `MemAvailable` bytes observed and the headroom kept for the future. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs b/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs index ba2d51f4..1285f539 100644 --- a/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs +++ b/crates/model-format/src/qwen4exp_expert_source_bank/retention_metadata_bytes.rs @@ -1,8 +1,13 @@ //! Methods of `ResidentExpertBank`: `note_copy`, `report`, `tensor`. //! Implements `Display for ResidentExpertSourceError`, `Error for ResidentExpertSourceError`. -#[allow(unused_imports)] -use super::*; +use super::{ + BANKS, BTreeMap, BTreeSet, Bank, BankDescriptor, BindingError, Cell, Error, FUTURE_HEADROOM, LayerRole, Rc, + ResidentExpertBank, ResidentExpertSourceError, ResidentExpertSourceReport, ResolvedTensor, SOURCE_CAP, TensorRole, + fmt, gguf, plan_stream_rows, size_of, +}; +#[cfg(target_os="linux")] +use super::{File, Read}; // Rc headers plus the small owners, never a second encoded payload allocation. pub(super) fn retention_metadata_bytes() -> Result { diff --git a/crates/model-format/src/qwen4exp_file_expert_source.rs b/crates/model-format/src/qwen4exp_file_expert_source.rs index 163ec373..4c1a8716 100644 --- a/crates/model-format/src/qwen4exp_file_expert_source.rs +++ b/crates/model-format/src/qwen4exp_file_expert_source.rs @@ -1,6 +1,9 @@ //! Literal FileExpertSource GGUF role directory. No payload copy, finite or //! pinning authority. The immutable directory retains the actual admitted FD. -use super::*; +use super::{ + BTreeMap, BTreeSet, BindingError, Error, LayerRole, Qwen4ExpArtifact, ResolvedTensor, TensorRole, gguf, + plan_stream_rows, +}; use std::mem::size_of; #[derive(Clone, Copy)] pub struct FileExpertExtent { diff --git a/crates/native-cpu-expert/src/rust_bench_frontend/cpu_blob.rs b/crates/native-cpu-expert/src/rust_bench_frontend/cpu_blob.rs index bbcf3e34..e468135c 100644 --- a/crates/native-cpu-expert/src/rust_bench_frontend/cpu_blob.rs +++ b/crates/native-cpu-expert/src/rust_bench_frontend/cpu_blob.rs @@ -1,8 +1,10 @@ //! Methods of `Case`: `new`, `gate_up`, `down`. //! Functions: `quantize_acts`, `cpu_blob`, `iq_gate_up`, `time_ggml_gu` and 15 more. Defines `Fail`, `Case`, `KqCase`. -#[allow(unused_imports)] -use super::*; +use super::{ + FF, H, Instant, Kind, NT, NativeActivation, NativeFormat, bench, bits, c_int, cpu, dot, elapsed, ggml_rows, + iq4nl_hq, name, numerical, outputs, printf, refs, rel, zeros, +}; use std::ffi::CStr; type Fail = std::result::Result; diff --git a/crates/native-cpu-expert/src/rust_bench_frontend/float_reference.rs b/crates/native-cpu-expert/src/rust_bench_frontend/float_reference.rs index 09852baa..fdd44937 100644 --- a/crates/native-cpu-expert/src/rust_bench_frontend/float_reference.rs +++ b/crates/native-cpu-expert/src/rust_bench_frontend/float_reference.rs @@ -1,8 +1,10 @@ //! Functions: `float_reference`, `reference_shapes_ok`, `swiglu_hidden`, `project_down` and 21 more. Defines `Fail`. //! Split out of `rust_bench_frontend` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + CString, Error, FF, H, Kind, NT, NativeFormat, ParityGpu, Q81Owner, Result, bench, bits, cpu, cpu_blob, name, + numerical, printf, rel, zeros, +}; type Fail = std::result::Result; diff --git a/crates/native-cpu-expert/src/rust_bench_frontend/numerical.rs b/crates/native-cpu-expert/src/rust_bench_frontend/numerical.rs index 88638219..c4a04d1c 100644 --- a/crates/native-cpu-expert/src/rust_bench_frontend/numerical.rs +++ b/crates/native-cpu-expert/src/rust_bench_frontend/numerical.rs @@ -1,8 +1,7 @@ //! Functions: `numerical`, `zeros`, `refs`, `outputs` and 11 more. //! Split out of `rust_bench_frontend` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{CString, Error, FF, H, Instant, Kind, NAMES, NT, NativeActivation, NativeFormat, Result, bench, cpu}; pub(super) fn numerical(r: Result) -> std::result::Result { r.map_err(|e| format!("CPU benchmark: {e:?}")) diff --git a/crates/native-cpu-expert/src/rust_bench_frontend/parity_run.rs b/crates/native-cpu-expert/src/rust_bench_frontend/parity_run.rs index 9343ed90..9b004a50 100644 --- a/crates/native-cpu-expert/src/rust_bench_frontend/parity_run.rs +++ b/crates/native-cpu-expert/src/rust_bench_frontend/parity_run.rs @@ -1,8 +1,10 @@ //! Running the parity bench: the synthetic and layer modes, the formats, `unbound_main` and `run`. //! Apart from `numerical` and `float_reference`, which hold the references the run compares to. -#[allow(unused_imports)] -use super::*; +use super::{ + CString, FF, H, NativeFormat, ParityGpu, USAGE, bench, c_int, check_bf16, check_blob, check_q5_one, gpu, model, + native_fmt, numerical, printf, setenv, setvbuf, stdout, type_of, +}; /// # Safety /// Call ONLY at process entry before any thread or native CPU dispatch exists: diff --git a/crates/native-cpu-expert/src/rust_ggml/kind.rs b/crates/native-cpu-expert/src/rust_ggml/kind.rs index f6fc90ec..58610978 100644 --- a/crates/native-cpu-expert/src/rust_ggml/kind.rs +++ b/crates/native-cpu-expert/src/rust_ggml/kind.rs @@ -1,8 +1,7 @@ //! Methods of `Kind`: `from_original`, `original_id`, `block`, `row_bytes` and 3 more. Methods of `ActKind`: `bytes`. //! Functions: `alloc`, `store_f16`, `bf16_bits`, `store_bf16` and 1 more. -#[allow(unused_imports)] -use super::*; +use super::{ActKind, Activation, Error, Kind, Result, Storage, to_half}; /// Every `Kind` in declaration order; `KIND_IDS` and `KIND_BLOCKS` are indexed by `kind as usize`. const KINDS: [Kind; 28] = [ diff --git a/crates/native-cpu-expert/src/rust_ggml/native_format.rs b/crates/native-cpu-expert/src/rust_ggml/native_format.rs index 81063317..0c203d04 100644 --- a/crates/native-cpu-expert/src/rust_ggml/native_format.rs +++ b/crates/native-cpu-expert/src/rust_ggml/native_format.rs @@ -1,8 +1,13 @@ //! Methods of `NativeFormat`: `offsets`, `new`, `validate`. //! Functions: `iq4nl_dot`, `dot_zero`, `dot_k`, `dot` and 8 more. -#[allow(unused_imports)] -use super::*; +use super::{ + __m256, _mm_loadu_si128, _mm256_add_ps, _mm256_castsi256_ps, _mm256_cvtepi32_ps, _mm256_cvtepu16_epi32, + _mm256_cvtph_ps, _mm256_fmadd_ps, _mm256_loadu_ps, _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, + _mm256_mul_ps, _mm256_set1_epi8, _mm256_set1_epi16, _mm256_set1_ps, _mm256_setzero_ps, _mm256_slli_epi32, + _mm256_sub_epi8, _mm256_xor_si256, Activation, Error, Kind, NativeFormat, Q8K, Q8Zero, Result, Storage, half, + hsum_ggml, hsum_original, +}; impl NativeFormat { /// Byte offsets of the up matrix, the down matrix and the whole blob for the given row sizes. diff --git a/crates/native-cpu-expert/src/rust_ggml/quantize_raw.rs b/crates/native-cpu-expert/src/rust_ggml/quantize_raw.rs index 8f35ff22..28c10431 100644 --- a/crates/native-cpu-expert/src/rust_ggml/quantize_raw.rs +++ b/crates/native-cpu-expert/src/rust_ggml/quantize_raw.rs @@ -1,8 +1,7 @@ //! Functions: `raw_align`, `quantize_half_raw`, `quantize_raw`, `dot_raw_zero` and 2 more. //! Split out of `rust_ggml` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ActKind, Kind, Q8K, Q8One, Q8Zero, bf16_bits, float_dot, iq4nl_dot, q1_dot, q2_generic, to_half}; /// Alignment the encoded activation of `kind` is reinterpreted with (F32: bytes, K: `Q8K`, others: `u16`/`Q8*`). fn raw_align(kind: Kind) -> usize { diff --git a/crates/native-cpu-expert/src/rust_iq/dot_multi512.rs b/crates/native-cpu-expert/src/rust_iq/dot_multi512.rs index 0673dee6..b2a76c8d 100644 --- a/crates/native-cpu-expert/src/rust_iq/dot_multi512.rs +++ b/crates/native-cpu-expert/src/rust_iq/dot_multi512.rs @@ -2,8 +2,16 @@ //! generic dots. //! Apart from `iq4nl_n` and `u16`, which hold other widths of the same kernels. -#[allow(unused_imports)] -use super::*; +use super::{ + __m128i, __m256i, __m512i, _mm_and_si128, _mm_loadu_si128, _mm_set1_epi8, _mm_shuffle_epi8, _mm_srli_epi16, + _mm256_add_epi32, _mm256_castsi128_si256, _mm256_cvtepi32_ps, _mm256_fmadd_ps, _mm256_inserti128_si256, + _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, _mm256_set1_epi16, _mm256_set1_ps, _mm256_setzero_ps, + _mm256_setzero_si256, _mm256_sign_epi8, _mm512_add_epi32, _mm512_castsi256_si512, _mm512_cvtepi32_ps, + _mm512_cvtepu8_epi32, _mm512_fmadd_ps, _mm512_i32gather_epi32, _mm512_inserti64x4, _mm512_loadu_si512, + _mm512_madd_epi16, _mm512_maddubs_epi16, _mm512_mask_add_epi32, _mm512_mask_sub_epi8, _mm512_reduce_add_ps, + _mm512_set1_epi32, _mm512_set1_ps, _mm512_setzero_ps, _mm512_setzero_si512, IQ3S_GRID, IQ3XXS_GRID, KVALUES_IQ4NL, + Q8K, Q8Zero, decode, decoded, factor, format_bytes, half, hsum_ggml, iq3_half, iq4nl_n, prefetch, signs32, u16, +}; /// IQ3 formats (`iq3_multi_fast`): both halves' grid words straight into the 512-bit register, lane order = `decode`'s /// byte order. Returns the grid bytes, the 16-bit scales and the sign mask of sub-block `j`. diff --git a/crates/native-cpu-expert/src/rust_iq/iq4nl_n.rs b/crates/native-cpu-expert/src/rust_iq/iq4nl_n.rs index 628da819..d0e72ada 100644 --- a/crates/native-cpu-expert/src/rust_iq/iq4nl_n.rs +++ b/crates/native-cpu-expert/src/rust_iq/iq4nl_n.rs @@ -1,8 +1,12 @@ //! Functions: `iq4nl_values`, `iq4nl_block`, `iq4nl_alternating`, `iq4nl_n`. //! Split out of `rust_iq` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + __m128i, __m256, __m256i, _mm_and_si128, _mm_loadu_si128, _mm_set1_epi8, _mm_shuffle_epi8, _mm_srli_epi16, + _mm256_add_ps, _mm256_castsi128_si256, _mm256_cvtepi32_ps, _mm256_fmadd_ps, _mm256_inserti128_si256, + _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, _mm256_set1_epi16, _mm256_set1_ps, _mm256_setzero_ps, + _mm256_sign_epi8, KVALUES_IQ4NL, Q8Zero, half, hsum_ggml, hsum_original, prefetch, u16, +}; /// The 32 IQ4_NL values (signed bytes) of one 18-byte block. #[target_feature(enable = "avx2,fma,f16c")] diff --git a/crates/native-cpu-expert/src/rust_iq/u16.rs b/crates/native-cpu-expert/src/rust_iq/u16.rs index c2d8cf06..e064d7b9 100644 --- a/crates/native-cpu-expert/src/rust_iq/u16.rs +++ b/crates/native-cpu-expert/src/rust_iq/u16.rs @@ -1,8 +1,13 @@ //! Functions: `u16`, `u32`, `format_bytes`, `factor` and 17 more. //! Split out of `rust_iq` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + __m256i, _mm_loadl_epi64, _mm256_add_epi32, _mm256_and_si256, _mm256_cvtepi32_ps, _mm256_cvtepu8_epi32, + _mm256_fmadd_ps, _mm256_loadu_si256, _mm256_madd_epi16, _mm256_maddubs_epi16, _mm256_or_si256, _mm256_set1_epi32, + _mm256_set1_ps, _mm256_setr_epi32, _mm256_setzero_ps, _mm256_setzero_si256, _mm256_sign_epi8, _mm256_slli_epi32, + _mm256_srlv_epi32, _mm256_storeu_si256, IQ2S_GRID, IQ2XS_GRID, IQ2XXS_GRID, IQ3S_GRID, IQ3XXS_GRID, KSIGNS_IQ2XS, + KVALUES_IQ4NL, Q8K, dot_multi512_impl, half, hsum_original, prefetch, signs32, +}; // Bounds: `row` is walked with chunks_exact/checked slicing and every activation block is safe-indexed (`y[i]`), so // a short operand panics instead of reading past it. The raw loads are 32/64 bytes at 64*j+32*h (j<4,h<2) of a diff --git a/crates/native-cpu-expert/src/rust_legacy/admit.rs b/crates/native-cpu-expert/src/rust_legacy/admit.rs index d17fe0a2..064d0472 100644 --- a/crates/native-cpu-expert/src/rust_legacy/admit.rs +++ b/crates/native-cpu-expert/src/rust_legacy/admit.rs @@ -1,8 +1,10 @@ //! Functions: `admit`, `gate_up_rows`, `down_rows`, `admit_expert` and 9 more. Defines `RowSpace`. //! Split out of `rust_legacy` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ActQ, BLOB, D_CODES, D_SCALES, Error, FF, GU_SCALES, GateUpOut, H, MAX_ROWS, PlanarActivation, PlanarScratch, + Result, act_refs, down_row, gate_up_pair, half, legacy_supported, oracle_q8_zero_enabled, silu, whole_single, +}; /// The output width of a legacy row-range entry point and the chunk count its activations must have. #[derive(Clone, Copy)] diff --git a/crates/native-cpu-expert/src/rust_legacy/gate_each.rs b/crates/native-cpu-expert/src/rust_legacy/gate_each.rs index 89f1e5ef..0b004880 100644 --- a/crates/native-cpu-expert/src/rust_legacy/gate_each.rs +++ b/crates/native-cpu-expert/src/rust_legacy/gate_each.rs @@ -1,8 +1,10 @@ //! Implements `Default for SingleScratch`. Functions: `gate_each`, `down_each`, `whole_single`. //! Split out of `rust_legacy` to keep its files under the line limit. -#[allow(unused_imports)] -use super::*; +use super::{ + ActQ, FF, GateUpOut, MAX_ROWS, PlanarActivation, SingleScratch, act_refs, down_row, gate_up_pair, + oracle_q8_zero_enabled, silu, +}; // Disjoint row cells are written by the pool callback; it never creates an // overlapping mutable whole-row slice while another worker owns another range. diff --git a/crates/native-cpu-expert/src/rust_legacy/pair_rows.rs b/crates/native-cpu-expert/src/rust_legacy/pair_rows.rs index d5f426fa..67b00e7d 100644 --- a/crates/native-cpu-expert/src/rust_legacy/pair_rows.rs +++ b/crates/native-cpu-expert/src/rust_legacy/pair_rows.rs @@ -1,8 +1,7 @@ //! STRA-338 size4: the row-pair helpers shared by the legacy planar entry points (`gate_each`, `down_each`, //! `whole_single`, `gate_up_rows`, `down_rows`, `expert_quantized`). -#[allow(unused_imports)] -use super::*; +use super::{ActQ, D_CODES, D_SCALES, GU_SCALES, MAX_ROWS, PlanarActivation, row}; /// The per-token `ActQ` references of `a` (unused slots point at `empty`). pub(super) fn act_refs<'a>(a: &'a [&PlanarActivation], empty: &'a ActQ) -> [&'a ActQ; MAX_ROWS] { diff --git a/crates/native-cpu-expert/src/rust_legacy/set_oracle_q8_zero.rs b/crates/native-cpu-expert/src/rust_legacy/set_oracle_q8_zero.rs index 98909c47..2a21a21d 100644 --- a/crates/native-cpu-expert/src/rust_legacy/set_oracle_q8_zero.rs +++ b/crates/native-cpu-expert/src/rust_legacy/set_oracle_q8_zero.rs @@ -1,8 +1,18 @@ //! Methods of `PlanarActivation`: `quantize`, `quantize_oracle`, `quantize_native`. //! Implements `Default for PlanarActivation`, `Default for PlanarScratch`. -#[allow(unused_imports)] -use super::*; +use super::{ + __cpuid, __cpuid_count, __m256, __m256i, __m512, _mm_add_epi32, _mm_cvtsi128_si32, _mm_hadd_epi32, _mm_loadl_epi64, + _mm_loadu_si128, _mm_maskz_loadu_epi16, _mm256_and_si256, _mm256_castsi256_si128, _mm256_cvtepi32_ps, + _mm256_cvtepu16_epi64, _mm256_cvtph_ps, _mm256_dpbusd_epi32, _mm256_extracti128_si256, _mm256_fmadd_ps, + _mm256_loadu_si256, _mm256_multishift_epi64_epi8, _mm256_set1_epi8, _mm256_set1_epi64x, _mm256_set1_ps, + _mm256_setzero_ps, _mm256_setzero_si256, _mm512_add_epi32, _mm512_and_si512, _mm512_castps256_ps512, + _mm512_cvtepi32_ps, _mm512_cvtepu16_epi64, _mm512_dpbusd_epi32, _mm512_fmadd_ps, _mm512_loadu_si512, + _mm512_maskz_loadu_ps, _mm512_maskz_mov_ps, _mm512_mul_ps, _mm512_multishift_epi64_epi8, _mm512_permutexvar_ps, + _mm512_reduce_add_ps, _mm512_set1_epi8, _mm512_set1_epi32, _mm512_set1_epi64, _mm512_setr_epi32, _mm512_setzero_ps, + _mm512_setzero_si512, _xgetbv, ActQ, Error, FF, H, MAX_ROWS, ORACLE, OnceLock, Ordering, PlanarActivation, + PlanarScratch, Result, SingleScratch, hsum_original, +}; pub fn set_oracle_q8_zero(enabled: bool) { ORACLE.store(enabled, Ordering::Relaxed); diff --git a/crates/native-cpu-expert/src/rust_pool/trace.rs b/crates/native-cpu-expert/src/rust_pool/trace.rs index ecab33e0..d5331014 100644 --- a/crates/native-cpu-expert/src/rust_pool/trace.rs +++ b/crates/native-cpu-expert/src/rust_pool/trace.rs @@ -3,7 +3,7 @@ //! its first task, when it finished its last one, how long it computed and how many tasks it took; the host //! snapshots the phase when all tasks are done. Times are nanoseconds from the publication of the phase. -use super::*; +use super::{AtomicU32, AtomicU64, Instant, Ordering}; /// Tasks of one phase never exceed 3 per thread of 16 threads; the table keeps a margin. const TASK_TABLE: usize = 256; diff --git a/scripts/dev/explicit_imports.py b/scripts/dev/explicit_imports.py index e1d7bcb4..5798cfaa 100644 --- a/scripts/dev/explicit_imports.py +++ b/scripts/dev/explicit_imports.py @@ -564,8 +564,18 @@ class Plan: return {p for p, _ in mod.anon} def _own_names(self, mod): - items, uses, _ = mod.parsed() - return set(items) | {n for n, _, _ in uses} | set(mod.children) + """Names the module declares, imports by name, or takes from its own globs other than `use super::*`.""" + items, uses, globs = mod.parsed() + names = set(items) | {n for n, _, _ in uses} | set(mod.children) + for path, _ in globs: + if path == ["super"]: + continue + target = self.crate.resolve_module(mod, path) + if target is not None: + inner = self.crate.names(target, self.crate.is_ancestor(target, mod)) + if inner is not OPAQUE: + names |= set(inner) + return names def apply(self, files, needs): done = [] diff --git a/scripts/dev/rust_modtree.py b/scripts/dev/rust_modtree.py index 8bb2f870..6d8bce26 100644 --- a/scripts/dev/rust_modtree.py +++ b/scripts/dev/rust_modtree.py @@ -159,7 +159,7 @@ def statements(stripped): ITEM_RE = re.compile( r"^(pub(?:\s*\([^)]*\))?\s+)?" r"(?:(?:unsafe|async|const|default)\s+|extern\s*(?:\"\"\s*)?)*" - rf"(fn|struct|enum|trait|union|type|const|static|mod)\s+({IDENT})" + rf"(fn|struct|enum|trait|union|type|const|static|mod)\s+(?:mut\s+)?({IDENT})" ) @@ -275,7 +275,7 @@ class Module: continue if re.match(r"(?:unsafe\s+)?extern\s*(?:\"\"\s*)?\{", head): for vis, kind, name in re.findall( - rf"(pub(?:\s*\([^)]*\))?\s+)?(?:safe\s+|unsafe\s+)?(fn|static)\s+({IDENT})", head + rf"(pub(?:\s*\([^)]*\))?\s+)?(?:safe\s+|unsafe\s+)?(fn|static)\s+(?:mut\s+)?({IDENT})", head ): items[name.removeprefix("r#")] = (bool(vis), kind) mark(name.removeprefix("r#"), attrs)