Skip to main content

PlacementPlan

Struct PlacementPlan 

Source
pub struct PlacementPlan {
    pub default_placement: ExpertPlacement,
    pub overrides: HashMap<usize, ExpertPlacement>,
}
Expand description

A CPU/GPU placement plan for a layer’s experts.

Fields§

§default_placement: ExpertPlacement§overrides: HashMap<usize, ExpertPlacement>

Implementations§

Source§

impl PlacementPlan

Source

pub fn all_cpu(n_experts: usize) -> Self

Source

pub fn hot_experts_on_gpu(n_experts: usize, n_gpu_resident: usize) -> Self

Index-based placeholder: puts the first n_gpu_resident experts on GPU regardless of their actual size or how often they’re activated. Kept only as a trivial fallback for callers with no real budget/hotness data at all (e.g. ferrox smoke’s synthetic-weight demo); real deployments should use from_budget instead, which places by measured VRAM budget and observed expert hotness rather than by index.

Source

pub fn from_budget( expert_bytes: &[usize], activation_counts: Option<&[u64]>, vram_budget_bytes: u64, ) -> Self

Builds a placement plan from a real VRAM budget and each expert’s actual resident byte size (e.g. summed WeightMatrix::resident_bytes() across an expert’s gate/up/down matrices), following ik_llama.cpp’s --cpu-moe/--override-tensor pattern of deciding CPU-vs-GPU per tensor rather than by a fixed index cutoff.

activation_counts, if given (one count per expert, e.g. accumulated from RoutingDecision::expert_ids over a real or representative workload), places the most frequently activated experts on GPU first – the actual point of expert offload, since keeping a rarely-used expert resident in VRAM wastes the budget a hot expert could have used instead. Without observed counts, falls back to a documented, deterministic policy (index order) rather than guessing at hotness.

Greedy, not globally optimal (a smaller-but-colder expert can still be skipped in favor of trying the next candidate once a larger higher-priority expert doesn’t fit) – optimal knapsack packing is not worth the complexity here, and greedy-by-priority is the same approach real offload tooling uses.

Source

pub fn plan_layers_against_global_budget( expert_bytes_per_layer: &[Vec<usize>], activation_counts_per_layer: Option<&[Vec<u64>]>, vram_budget_bytes: u64, ) -> ResidencyPlan

A device-placement plan for EVERY layer’s routed experts against ONE shared VRAM budget – the fix for the real accounting bug where each layer independently called from_budget with the full budget, so a model with N layers would plan N x the configured bytes of GPU residency. All (layer, expert) candidates compete in one global priority order (hottest first, ties broken by layer then expert index for determinism), and a candidate is only placed on the device if the global running total still fits.

Source

pub fn placement_for(&self, expert_id: usize) -> ExpertPlacement

Trait Implementations§

Source§

impl Clone for PlacementPlan

Source§

fn clone(&self) -> PlacementPlan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PlacementPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.