pub struct HotExpertCache { /* private fields */ }Expand description
Device slot cache for one MoE layer.
Implementations§
Source§impl HotExpertCache
impl HotExpertCache
Sourcepub fn new(num_experts: usize, num_slots: usize) -> Self
pub fn new(num_experts: usize, num_slots: usize) -> Self
New cache with the first min(num_slots, num_experts) experts pre-loaded,
matching ExpertPool::new’s initial residency so the
two structures start consistent (no spurious first-refresh reload).
pub fn num_experts(&self) -> usize
pub fn num_slots(&self) -> usize
Sourcepub fn slot_of(&self, expert: usize) -> Option<usize>
pub fn slot_of(&self, expert: usize) -> Option<usize>
Device slot holding expert, or None if the expert is cold.
Sourcepub fn is_resident(&self, expert: usize) -> bool
pub fn is_resident(&self, expert: usize) -> bool
Whether expert currently occupies a device slot.
Sourcepub fn slot_to_expert(&self) -> &[Option<usize>]
pub fn slot_to_expert(&self) -> &[Option<usize>]
slot -> expert table (None = empty slot).
Sourcepub fn expert_to_slot(&self) -> &[Option<usize>]
pub fn expert_to_slot(&self) -> &[Option<usize>]
expert -> slot table (None = cold).
Sourcepub fn reconcile(&mut self, resident_mask: &[bool]) -> Vec<SlotLoad>
pub fn reconcile(&mut self, resident_mask: &[bool]) -> Vec<SlotLoad>
Bring device slots in line with resident_mask (typically
ExpertPool::resident_mask), keeping
experts that stay resident in their existing slot (no reload). Returns the
minimal set of host→device loads for newly-resident experts.
Two clean passes so leftover slots (when fewer experts are hot than there are slots) are always left consistently empty rather than dangling on a now-cold expert.
Trait Implementations§
Source§impl Clone for HotExpertCache
impl Clone for HotExpertCache
Source§fn clone(&self) -> HotExpertCache
fn clone(&self) -> HotExpertCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for HotExpertCache
impl RefUnwindSafe for HotExpertCache
impl Send for HotExpertCache
impl Sync for HotExpertCache
impl Unpin for HotExpertCache
impl UnsafeUnpin for HotExpertCache
impl UnwindSafe for HotExpertCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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