pub struct WeightSource {
pub repo_id: &'static str,
pub revision: Option<&'static str>,
pub format: Format,
}Expand description
Where a model’s weights live on the HuggingFace hub, and how to read them.
Intended to be a const on each model enum:
const AMP120M: WeightSource = WeightSource::safetensors("chandar-lab/AMPLIFY_120M");Fields§
§repo_id: &'static strFull owner/name repo id.
revision: Option<&'static str>Git revision; None means the hub default (main).
format: FormatOn-disk format of the weight files.
Implementations§
Source§impl WeightSource
impl WeightSource
Sourcepub const fn safetensors(repo_id: &'static str) -> Self
pub const fn safetensors(repo_id: &'static str) -> Self
A safetensors repo at the default revision.
Sourcepub const fn pth(repo_id: &'static str, root_key: Option<&'static str>) -> Self
pub const fn pth(repo_id: &'static str, root_key: Option<&'static str>) -> Self
A PyTorch-pickle repo at the default revision.
root_key names the sub-dictionary holding the tensors, or None if
they sit at the root.
Sourcepub const fn at_revision(self, revision: &'static str) -> Self
pub const fn at_revision(self, revision: &'static str) -> Self
Pin to a specific revision.
Sourcepub fn fetch(&self, filename: &str) -> Result<PathBuf>
pub fn fetch(&self, filename: &str) -> Result<PathBuf>
Download filename, returning its cached path.
Errors name both the repo and the file — previously only ESM3 did this, so a failure elsewhere surfaced as a bare transport error.
Sourcepub fn fetch_optional(&self, filename: &str) -> Option<PathBuf>
pub fn fetch_optional(&self, filename: &str) -> Option<PathBuf>
Download filename, returning None if it is absent or unreachable.
For genuinely optional files such as ESM-2’s config.json, where the
runner falls back to a built-in config.
pub fn var_builder( &self, filename: &str, opts: &LoadOptions, ) -> Result<VarBuilder<'static>>
Sourcepub fn var_builder_sharded(
&self,
index_filename: &str,
opts: &LoadOptions,
) -> Result<VarBuilder<'static>>
pub fn var_builder_sharded( &self, index_filename: &str, opts: &LoadOptions, ) -> Result<VarBuilder<'static>>
Build a [VarBuilder] over a checkpoint split across several
safetensors shards.
Large checkpoints ship as model-0000N-of-0000M.safetensors plus a
model.safetensors.index.json whose weight_map says which shard holds
each tensor. candle’s from_mmaped_safetensors already takes a slice of
paths, so all this does is read the index, fetch every shard it names,
and hand candle the lot (ferritin-100.24).
Shard order does not matter — candle indexes by tensor name — but the shards are deduplicated and sorted so the mmap set is deterministic.
Sourcepub fn var_builder_from_path(
&self,
path: &Path,
opts: &LoadOptions,
) -> Result<VarBuilder<'static>>
pub fn var_builder_from_path( &self, path: &Path, opts: &LoadOptions, ) -> Result<VarBuilder<'static>>
Build a [VarBuilder] over an already-downloaded (or local) file.
Used by loaders that also accept a path directly, such as
ProteinMPNNRunner::from_path.
Trait Implementations§
Source§impl Clone for WeightSource
impl Clone for WeightSource
Source§fn clone(&self) -> WeightSource
fn clone(&self) -> WeightSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WeightSource
Auto Trait Implementations§
impl Freeze for WeightSource
impl RefUnwindSafe for WeightSource
impl Send for WeightSource
impl Sync for WeightSource
impl Unpin for WeightSource
impl UnsafeUnpin for WeightSource
impl UnwindSafe for WeightSource
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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