pub struct BankResidency { /* private fields */ }Expand description
The validated per-layer residency of an attached set of expert banks.
Constructing one is the check; holding one is the proof the three invariants in the module docs hold for this configuration.
Implementations§
Source§impl BankResidency
impl BankResidency
Sourcepub fn new(
labels: &[HostResidency],
num_layers: usize,
cpu_layers: &BTreeSet<u32>,
prefill_overlap: bool,
) -> Result<Self, ResidencyError>
pub fn new( labels: &[HostResidency], num_layers: usize, cpu_layers: &BTreeSet<u32>, prefill_overlap: bool, ) -> Result<Self, ResidencyError>
Attach labels (the achieved ones) to a model of
num_layers MoE layers.
cpu_layers is the set already routed to the CPU executor and
prefill_overlap is whether the overlap path is still enabled.
Both are inputs, not outputs: this refuses a bad combination
rather than repairing it, because repairing it here would mean
silently moving a layer to another executor after the cache
geometry was already sized against the old answer.
Sourcepub fn all_pinned(num_layers: usize) -> Self
pub fn all_pinned(num_layers: usize) -> Self
The default when no plan was in force: every layer pinned, no invariant to check, prefill overlap free to stay on.
pub fn num_layers(&self) -> usize
pub fn labels(&self) -> &[HostResidency]
Sourcepub fn label(&self, layer_id: u32) -> HostResidency
pub fn label(&self, layer_id: u32) -> HostResidency
§Panics
If layer_id is not a layer of this model.
Sourcepub fn unpinned_layers(&self) -> &BTreeSet<u32>
pub fn unpinned_layers(&self) -> &BTreeSet<u32>
Layers with no device address. The copy plan skips their rows entirely.
pub fn is_unpinned(&self, layer_id: u32) -> bool
Sourcepub fn has_unpinned(&self) -> bool
pub fn has_unpinned(&self) -> bool
Whether any layer is locked or pageable – the same signal that must have turned prefill overlap off.
Sourcepub fn copy_route(
&self,
layer_id: u32,
whole_layer: bool,
) -> Result<CopyRoute, ResidencyError>
pub fn copy_route( &self, layer_id: u32, whole_layer: bool, ) -> Result<CopyRoute, ResidencyError>
How a copy staged for layer_id must be carried out.
whole_layer is whether the caller staged the whole-layer
materialize (every expert, slot e for expert e) rather than
an LRU ensure. An unpinned layer accepts only the former; a
pinned layer takes the indexed device path either way, since a
registered bank can serve both.
Trait Implementations§
Source§impl Clone for BankResidency
impl Clone for BankResidency
Source§fn clone(&self) -> BankResidency
fn clone(&self) -> BankResidency
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BankResidency
impl Debug for BankResidency
impl Eq for BankResidency
Source§impl PartialEq for BankResidency
impl PartialEq for BankResidency
impl StructuralPartialEq for BankResidency
Auto Trait Implementations§
impl Freeze for BankResidency
impl RefUnwindSafe for BankResidency
impl Send for BankResidency
impl Sync for BankResidency
impl Unpin for BankResidency
impl UnsafeUnpin for BankResidency
impl UnwindSafe for BankResidency
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