pub struct MoeRouteScratch {
pub output: RouterOutput,
pub probs: Vec<f32>,
pub plan: MoeBucketPlan,
}Expand description
Reusable host-side scratch for moe_forward_bucketed. Holds the
router output, softmax scratch buffer, and bucket plan, all reused
across layers so the inner MoE forward path is allocation-free.
At c=32 / Qwen3-MoE / 48 layers, the previous fresh-Vec-per-layer
pattern accounted for ~10 ms / token of pure CPU softmax+sort+alloc
(25% of MoE wallclock — see docs/bench/cuda-rtx4090-2026-05-08-m3-moe).
Fields§
§output: RouterOutput§probs: Vec<f32>Softmax buffer reused across all rows of all layers — sized to
num_experts on first use.
plan: MoeBucketPlanImplementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MoeRouteScratch
impl RefUnwindSafe for MoeRouteScratch
impl Send for MoeRouteScratch
impl Sync for MoeRouteScratch
impl Unpin for MoeRouteScratch
impl UnsafeUnpin for MoeRouteScratch
impl UnwindSafe for MoeRouteScratch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more