pub enum WeightBytes {
Owned(Vec<u8>),
Mapped {
mmap: Arc<Mmap>,
range: Range<usize>,
},
Shared {
buf: Arc<Vec<u8>>,
range: Range<usize>,
},
}Expand description
Backing storage for a quantized weight matrix’s raw bytes: either an
owned buffer (synthetic/test weights, or any tensor that had to be
copied for some other reason) or a zero-copy view into a shared
memory-mapped GGUF file. This is the fix for the “loader read
everything into a fresh Vec
Variants§
Owned(Vec<u8>)
Mapped
A sub-range of a shared, lease-style buffer (e.g. one matrix
inside an ferrox_core::expert_store::ExpertLease’s combined
gate/up/down bytes). Holding the Arc here is exactly what
makes the store’s lease pinning structural: as long as any
WeightMatrix built over these bytes is alive, the cache entry’s
strong count stays >1 and eviction cannot reuse it.
Implementations§
Source§impl WeightBytes
impl WeightBytes
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn address_is_stable(&self) -> bool
pub fn address_is_stable(&self) -> bool
May a repack cache key on this buffer’s ADDRESS?
Only for Mapped, whose address is a fixed point in a
process-lifetime mmap. Shared is a lease over an expert
store’s recycled buffer: two different experts routinely land at
the same address, and an address-keyed cache then serves one of
them the other’s repacked bytes. That produced fluent garbage on
OLMoE with expert streaming on, while the raw weight bytes
compared equal, because the corruption was in the CACHE and not
in the weights.
Owned is excluded for the same reason: a freed Vec’s address
can be reused.
Auto Trait Implementations§
impl Freeze for WeightBytes
impl RefUnwindSafe for WeightBytes
impl Send for WeightBytes
impl Sync for WeightBytes
impl Unpin for WeightBytes
impl UnsafeUnpin for WeightBytes
impl UnwindSafe for WeightBytes
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> 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