pub struct VramLedger { /* private fields */ }Expand description
Zero-heap VRAM budget tracker (bytes, atomics).
Implementations§
Source§impl VramLedger
impl VramLedger
Sourcepub fn try_reserve_graphics(
&self,
class: VramResourceClass,
bytes: u64,
) -> Result<VramReservation<'_>, GraphicsReservationError>
pub fn try_reserve_graphics( &self, class: VramResourceClass, bytes: u64, ) -> Result<VramReservation<'_>, GraphicsReservationError>
Atomically admit an additional graphics allocation against the existing shared inference/render budget. Call only before the cold allocation.
Sourcepub fn reserved_graphics_bytes(&self, class: VramResourceClass) -> u64
pub fn reserved_graphics_bytes(&self, class: VramResourceClass) -> u64
Live reservations in one resource class, for diagnostics and admission tests.
Source§impl VramLedger
impl VramLedger
Sourcepub const KV_CACHE_CAP_BYTES: u64
pub const KV_CACHE_CAP_BYTES: u64
Hard cap on tracked KV-cache bytes (448 MiB).
Sourcepub fn used_in_slot(&self, slot: VramLedgerSlot) -> u64
pub fn used_in_slot(&self, slot: VramLedgerSlot) -> u64
Bytes currently recorded in slot.
Sourcepub fn record_slot(&self, slot: VramLedgerSlot, bytes: u64)
pub fn record_slot(&self, slot: VramLedgerSlot, bytes: u64)
Record bytes as the new usage of slot (clamped for KV cache;
refreshes mode).
Sourcepub fn universe_used_bytes(&self, universe: ComputeUniverse) -> u64
pub fn universe_used_bytes(&self, universe: ComputeUniverse) -> u64
Total recorded bytes across universe’s slots; the Viewport
universe additionally includes live try_reserve_graphics
reservations.
Sourcepub fn universe_pressure(
&self,
orchestrator: &UniverseOrchestrator,
universe: ComputeUniverse,
) -> f32
pub fn universe_pressure( &self, orchestrator: &UniverseOrchestrator, universe: ComputeUniverse, ) -> f32
universe used-bytes ÷ its partition budget, clamped to
[0, 1.25] (0 when the partition has no budget).
Sourcepub fn can_allocate_in_universe(
&self,
orchestrator: &UniverseOrchestrator,
universe: ComputeUniverse,
extra_bytes: u64,
) -> bool
pub fn can_allocate_in_universe( &self, orchestrator: &UniverseOrchestrator, universe: ComputeUniverse, extra_bytes: u64, ) -> bool
Whether extra_bytes fits both inside universe’s partition
range (at the current usage offset) and the global budget.
Sourcepub fn slot_byte_offset(
orchestrator: &UniverseOrchestrator,
slot: VramLedgerSlot,
) -> u64
pub fn slot_byte_offset( orchestrator: &UniverseOrchestrator, slot: VramLedgerSlot, ) -> u64
Map a ledger slot to its pinned byte offset inside the adapter ledger.
Sourcepub fn record_universe(
&self,
universe: ComputeUniverse,
slot: VramLedgerSlot,
bytes: u64,
)
pub fn record_universe( &self, universe: ComputeUniverse, slot: VramLedgerSlot, bytes: u64, )
Record bytes into slot, asserting it belongs to universe.
Sourcepub fn new(budget_bytes: u64) -> Self
pub fn new(budget_bytes: u64) -> Self
Ledger with budget_bytes total and zeroed usage counters.
Sourcepub fn set_budget(&self, bytes: u64)
pub fn set_budget(&self, bytes: u64)
Overwrite the total budget (does not refresh mode).
Sourcepub fn record_tensor(&self, bytes: u64)
pub fn record_tensor(&self, bytes: u64)
Record Tensor10D (U1) usage bytes.
Sourcepub fn record_kv_cache(&self, bytes: u64)
pub fn record_kv_cache(&self, bytes: u64)
Record LLM KV-cache usage bytes (clamped to KV_CACHE_CAP_BYTES).
Sourcepub fn record_render(&self, bytes: u64)
pub fn record_render(&self, bytes: u64)
Record Viewport (U2) render usage bytes.
Sourcepub fn record_llm_staging(&self, bytes: u64)
pub fn record_llm_staging(&self, bytes: u64)
Record LLM weight-staging usage bytes.
Sourcepub fn used_bytes(&self) -> u64
pub fn used_bytes(&self) -> u64
Total used bytes — recorded slots plus live graphics reservations.
Sourcepub fn pressure(&self) -> f32
pub fn pressure(&self) -> f32
Global pressure = used ÷ budget, clamped to [0, 1.25] (0 with no budget configured).
Sourcepub fn mode(&self) -> OperationalMode
pub fn mode(&self) -> OperationalMode
Current operational mode (last refresh_mode result; Full
before any write).
Sourcepub fn refresh_mode(&self)
pub fn refresh_mode(&self)
Recompute the operational mode from live pressure and store it.
Sourcepub fn can_allocate(&self, extra_bytes: u64) -> bool
pub fn can_allocate(&self, extra_bytes: u64) -> bool
Whether extra_bytes fits inside the global budget
(overflow-safe comparison).
Trait Implementations§
Source§impl Debug for VramLedger
impl Debug for VramLedger
Auto Trait Implementations§
impl !Freeze for VramLedger
impl RefUnwindSafe for VramLedger
impl Send for VramLedger
impl Sync for VramLedger
impl Unpin for VramLedger
impl UnsafeUnpin for VramLedger
impl UnwindSafe for VramLedger
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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