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 map_id(&self) -> Option<MapId>
pub fn map_id(&self) -> Option<MapId>
The identity a repack cache may key on, or None for bytes that
must never be cached by address.
This replaces an address_is_stable() -> bool, and the boolean
was the bug: a yes/no answer cannot say whether the mapping that
made the address meaningful is still alive, so the cache went on
trusting an address after the mapping behind it was gone. See
MapId for the ABA that produces and how the Weak closes it.
Shared stays None, and for a different reason that a Weak
would NOT fix: it is a lease over an expert store’s recycled
buffer, so the allocation stays alive and keeps its address while
its CONTENTS are replaced by another expert’s. Identity is stable
there and still means nothing. 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 stays None too: a freed Vec’s address is reused, and
nothing holds a handle that could witness the free.
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