From 8651f784efdd3c3d00f06f9d025504bf5be04776 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Wed, 14 Oct 2026 14:42:12 +0200 Subject: [PATCH] fix: first combined compile of the Original-literal source-port for x86_64-linux (lib + all test targets type-check) Fixes: native-cpu-expert Display bound, runtime imports/visibility/lifetimes, missing MTP_ORIGINAL_WINDOW export, MmqFormat match arms, stale test constructors. cargo check --target x86_64-unknown-linux-gnu only (no link, no GPU). Co-Authored-By: Claude Sonnet 5.5 --- crates/cuda-driver/src/lib.rs | 1 + crates/cuda-driver/src/mmq_resident_gpu.rs | 3 +++ crates/cuda-driver/src/mtp_dense_kv.rs | 1 + .../src/qwen_forward/cache_original_mtp_weights.rs | 4 ++-- .../src/qwen_forward/executor_original_prompt.rs | 2 +- crates/leleka-runtime/src/qwen_forward/gdn_row_queue_gpu.rs | 4 ++-- crates/leleka-runtime/src/qwen_forward/gr.rs | 3 ++- crates/leleka-runtime/src/qwen_forward/moe_weight_cache.rs | 4 ++-- crates/leleka-runtime/src/qwen_forward/original_sampler.rs | 2 +- crates/leleka-runtime/src/qwen_forward/qsa_index_resident.rs | 1 + crates/native-cpu-expert/src/rust_bench_cuda.rs | 2 +- 11 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/cuda-driver/src/lib.rs b/crates/cuda-driver/src/lib.rs index 7cba6fe4..b06179af 100644 --- a/crates/cuda-driver/src/lib.rs +++ b/crates/cuda-driver/src/lib.rs @@ -64,6 +64,7 @@ mod qwen_dispatch; pub use qwen_dispatch::gr_batch_read::{GrMicroValues, GrMicrobatchRead}; mod qsa_selected_kv; pub use mtp_dense_kv::MtpDenseKvRing; +pub use mtp_dense_kv::MTP_ORIGINAL_WINDOW; pub use mtp_dense_kv::{ CompletedMtpAttention, CompletedMtpKvReplay, MtpInt8OwnerId, MtpInt8Snapshot, MtpOriginalInt8, MtpOriginalMixed, MtpOriginalQuery, diff --git a/crates/cuda-driver/src/mmq_resident_gpu.rs b/crates/cuda-driver/src/mmq_resident_gpu.rs index f18dcdb0..a4fe8c9f 100644 --- a/crates/cuda-driver/src/mmq_resident_gpu.rs +++ b/crates/cuda-driver/src/mmq_resident_gpu.rs @@ -251,6 +251,9 @@ fn raw_format(format: MmqFormat) -> RoutedFormat { MmqFormat::Iq2SGateUp => RoutedFormat::IQ2_S, MmqFormat::Iq4NlDown => RoutedFormat::IQ4_NL, MmqFormat::Q2Down => RoutedFormat::Q2_0, + MmqFormat::Iq3SGateUp => RoutedFormat::IQ3_S, + MmqFormat::Iq4XsGateUp => RoutedFormat::IQ4_XS, + MmqFormat::Iq4NlGateUp => RoutedFormat::IQ4_NL, } } fn native_owner(c: &Context<'_>, dual: &MmqWeights<'_>, raw: &[u8], data: &[u8]) { diff --git a/crates/cuda-driver/src/mtp_dense_kv.rs b/crates/cuda-driver/src/mtp_dense_kv.rs index 667ca772..83034a71 100644 --- a/crates/cuda-driver/src/mtp_dense_kv.rs +++ b/crates/cuda-driver/src/mtp_dense_kv.rs @@ -196,6 +196,7 @@ mod gpu_tests; // Separate literal Original INT8 drafter; the historical F16 owner stays unchanged. #[path = "mtp_original_int8.rs"] mod original_int8; +pub use original_int8::MTP_ORIGINAL_WINDOW; pub use original_int8::{ CompletedMtpAttention, CompletedMtpKvReplay, MtpInt8OwnerId, MtpInt8Snapshot, MtpOriginalInt8, MtpOriginalMixed, MtpOriginalQuery, OriginalMtpSkippedPrefix, diff --git a/crates/leleka-runtime/src/qwen_forward/cache_original_mtp_weights.rs b/crates/leleka-runtime/src/qwen_forward/cache_original_mtp_weights.rs index 9b50543f..9f9bd7e3 100644 --- a/crates/leleka-runtime/src/qwen_forward/cache_original_mtp_weights.rs +++ b/crates/leleka-runtime/src/qwen_forward/cache_original_mtp_weights.rs @@ -1,7 +1,7 @@ //! Model-lifetime immutable MTP allocations. Cached CUDA graphs own real Rc //! allocations, so a per-call matrix borrow can never outlive its weight bank. use super::*; -use super::output_native::OriginalMtpNativeHead; +use super::super::output_native::OriginalMtpNativeHead; struct RetainedDense<'ctx>{role:MtpRole,kind:MtpKind,rows:usize,columns:usize,buffer:Rc>} pub(in crate::qwen_forward) struct RetainedOriginalMtpWeights<'ctx>{ binding:BindingIdentity,context:&'ctx Context<'ctx>,dense:Vec>, @@ -80,7 +80,7 @@ impl<'ctx> RetainedOriginalMtpWeights<'ctx>{ /// cache never fabricates a replacement head buffer or dispatch profile. #[allow(clippy::too_many_arguments)] pub(in crate::qwen_forward) fn full_forward_weights( - &self,binding:&ModelBinding,context:&Context<'ctx>, + &self,binding:&ModelBinding,context:&'ctx Context<'ctx>, prefix:Rc>, head:&OriginalMtpNativeHead<'ctx>,id_vocab:usize, subset:Option<(Rc>,Rc>)>, diff --git a/crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs b/crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs index f5f01439..56d7928d 100644 --- a/crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs +++ b/crates/leleka-runtime/src/qwen_forward/executor_original_prompt.rs @@ -19,7 +19,7 @@ use leleka_cuda_driver::{Context,OriginalPromptDevice,OriginalGdnPromptDevice,Or OriginalMtpScalarPrefill,OriginalMtpRetainedScalarWeights,OriginalMtpScalarPolicy}; pub(in crate::qwen_forward) struct OriginalPromptExecutor<'ctx>{ - context:&'ctx Context<'ctx>,binding:BindingIdentity,capacity:usize,fused:bool, + pub(in crate::qwen_forward) context:&'ctx Context<'ctx>,binding:BindingIdentity,capacity:usize,fused:bool, prompt:Option>,gdn:Option>, qsa:Option>,transport:Option>, attention:Option>, diff --git a/crates/leleka-runtime/src/qwen_forward/gdn_row_queue_gpu.rs b/crates/leleka-runtime/src/qwen_forward/gdn_row_queue_gpu.rs index 452d87fd..d10bd086 100644 --- a/crates/leleka-runtime/src/qwen_forward/gdn_row_queue_gpu.rs +++ b/crates/leleka-runtime/src/qwen_forward/gdn_row_queue_gpu.rs @@ -198,7 +198,7 @@ fn queued_gdn_chain_matches_scalar_oracles_refuses_and_cleans_up() { .unwrap(); // The three device-only products refuse a wrong role and a roleless use. assert_eq!( - chain.device_buffer(&alpha, Role::Z).err(), + chain.operand_buffer(&alpha, Role::Z).err(), Some(Error::IdentityMismatch) ); assert_eq!( @@ -263,7 +263,7 @@ fn queued_gdn_chain_matches_scalar_oracles_refuses_and_cleans_up() { .project_device(&weights.alpha, GdnMatrixKind::Bf16, &source, Role::Alpha) .unwrap(); assert_eq!( - chain.device_buffer(&foreign, Role::Alpha).err(), + chain.operand_buffer(&foreign, Role::Alpha).err(), Some(Error::IdentityMismatch) ); other.finish().unwrap(); diff --git a/crates/leleka-runtime/src/qwen_forward/gr.rs b/crates/leleka-runtime/src/qwen_forward/gr.rs index b7c9c8b3..248c769b 100644 --- a/crates/leleka-runtime/src/qwen_forward/gr.rs +++ b/crates/leleka-runtime/src/qwen_forward/gr.rs @@ -7,8 +7,9 @@ use super::dense_weight_cache::DenseWeightCache; use super::input::PleReady; use super::session::QwenStepTxn; use crate::model_binding::qwen4exp_input::{ - BindingIdentity, GrRole, GrWeights, InputBindingError, ModelBinding, + BindingIdentity, GrWeights, InputBindingError, ModelBinding, }; +pub(crate) use crate::model_binding::qwen4exp_input::GrRole; use leleka_cuda_driver::{Context, DeviceBuffer, Error as DriverError}; use std::{ cell::{Cell, RefCell, RefMut}, diff --git a/crates/leleka-runtime/src/qwen_forward/moe_weight_cache.rs b/crates/leleka-runtime/src/qwen_forward/moe_weight_cache.rs index dbb1c45d..81ab9805 100644 --- a/crates/leleka-runtime/src/qwen_forward/moe_weight_cache.rs +++ b/crates/leleka-runtime/src/qwen_forward/moe_weight_cache.rs @@ -1383,7 +1383,7 @@ impl<'ctx> MoeWeightCache<'ctx> { if self .bank .as_ref() - .is_none_or(|actual| !std::ptr::eq(actual, bank)) + .is_none_or(|actual| !std::ptr::eq(&**actual, bank)) { return Err(Error::IdentityMismatch); } @@ -1401,7 +1401,7 @@ impl<'ctx> MoeWeightCache<'ctx> { .iter() .find(|entry| entry.role == role) .ok_or(Error::IdentityMismatch)?; - if !std::ptr::eq(&actual.buffer, buffer) { + if !std::ptr::eq(&*actual.buffer, buffer) { return Err(Error::IdentityMismatch); } } diff --git a/crates/leleka-runtime/src/qwen_forward/original_sampler.rs b/crates/leleka-runtime/src/qwen_forward/original_sampler.rs index 0296b852..7dc98ece 100644 --- a/crates/leleka-runtime/src/qwen_forward/original_sampler.rs +++ b/crates/leleka-runtime/src/qwen_forward/original_sampler.rs @@ -1,7 +1,7 @@ //! Literal Original sampler host histories and absolute coupled draw positions. //! These are metadata helpers, never model/session/commit capabilities. The //! caller must pass the actual consumed tail and genuine current verify window. -use cuda_driver::SamplerParams; +use leleka_cuda_driver::SamplerParams; use super::contract::{Error, Result}; pub(crate) const PENALTY_WINDOW_CAP: usize = 4096; diff --git a/crates/leleka-runtime/src/qwen_forward/qsa_index_resident.rs b/crates/leleka-runtime/src/qwen_forward/qsa_index_resident.rs index 740e2769..e9abcb32 100644 --- a/crates/leleka-runtime/src/qwen_forward/qsa_index_resident.rs +++ b/crates/leleka-runtime/src/qwen_forward/qsa_index_resident.rs @@ -348,6 +348,7 @@ fn synthetic_late_prior(position: u64) -> QsaPrior { pooled: Directory::from_entries(vec![row; position as usize / 4]).unwrap(), tail: [0.; 384], dead: [0.25; 128], + native_kv: None, })) } #[cfg(test)] diff --git a/crates/native-cpu-expert/src/rust_bench_cuda.rs b/crates/native-cpu-expert/src/rust_bench_cuda.rs index 49b189db..c6c38584 100644 --- a/crates/native-cpu-expert/src/rust_bench_cuda.rs +++ b/crates/native-cpu-expert/src/rust_bench_cuda.rs @@ -8,7 +8,7 @@ mod platform{ impl<'ctx> NativeGpu<'ctx>{pub fn new(context:&'ctx Context<'ctx>)->Result{Ok(Self{owner:context.native_parity()?})}} impl<'ctx> ParityGpu for NativeGpu<'ctx>{ type Expert=NativeParityExpert<'ctx>; - fn prepare_expert(&mut self,f:&NativeFormat,blob:&[u8],input:&[f32])->Result{f.validate().map_err(|e|e.to_string())?;if f.n_embd!=2560||f.n_ff!=640{return Err("Original benchmark geometry".into());}self.owner.prepare_expert(f.gu.original_id(),f.down.original_id(),blob,input)} + fn prepare_expert(&mut self,f:&NativeFormat,blob:&[u8],input:&[f32])->Result{f.validate().map_err(|e|format!("{e:?}"))?;if f.n_embd!=2560||f.n_ff!=640{return Err("Original benchmark geometry".into());}self.owner.prepare_expert(f.gu.original_id(),f.down.original_id(),blob,input)} fn enqueue_expert(&mut self,e:&mut Self::Expert)->Result<(),String>{self.owner.enqueue_expert(e)} fn download_expert(&mut self,e:&mut Self::Expert)->Result,String>{self.owner.download_expert(e)} fn old_kernels(&self)->bool{self.owner.old_kernels()}