Expand description
Pretrained model registry, download, and caching for ferrotorch.
This crate provides a central hub for discovering, downloading, and caching
pretrained model weights. It mirrors the workflow of torch.hub and
torchvision.models with pretrained weight support.
§Quick start
use ferrotorch_core::FerrotorchError;
use ferrotorch_hub::{list_models, load_pretrained};
fn main() -> Result<(), FerrotorchError> {
// Browse available models.
for model in list_models() {
println!("{}: {} ({} params)", model.name, model.description, model.num_parameters);
}
// Load pretrained weights (requires cached weights on disk).
let _state_dict = load_pretrained::<f32>("resnet50")?;
Ok(())
}§REQ status (per .design/ferrotorch-hub/lib.md)
| REQ | Status | Evidence |
|---|---|---|
| REQ-1 | SHIPPED | pub mod declarations in lib.rs (auth / discovery http-gated; cache / download / hf_config / registry unconditional); non-test consumer: ferrotorch-llama/src/config.rs imports HfTransformerConfig from the crate root. |
| REQ-2 | SHIPPED | pub use re-export block in lib.rs flattening the user-facing surface; non-test consumer: ferrotorch/src/lib.rs pub mod hub { pub use ferrotorch_hub::*; } (feature hub) re-exports the whole flat surface through the meta-crate; ferrotorch-jit/examples/jit_trace_dump.rs imports load_pretrained directly from the crate root. |
| REQ-3 | SHIPPED | crate-level #![warn(clippy::all, clippy::pedantic)] + #![deny(rust_2018_idioms)] + per-lint #![allow] block with one-line justifications in lib.rs; non-test consumer: every dependent crate (ferrotorch-llama, ferrotorch-bert, ferrotorch-diffusion, ferrotorch-jit, ferrotorch-rl, ferrotorch-graph) requires cargo clippy -p ferrotorch-hub --lib -- -D warnings to pass before its own build can succeed. |
| REQ-4 | SHIPPED | the deliberately-omitted unsafe_code deny in the lint-header block (documented in the comment); non-test consumer: auth.rs::mod tests is #[cfg(test)]-only so production callers never trip the unsafe paths; the lint posture lets the test module compile without crate-root override. |
| REQ-5 | SHIPPED | #[cfg(feature = "http")] guards on pub mod auth;, pub mod discovery;, pub use auth::…;, pub use discovery::…;, and pub use download::hf_download_model;; offline path in download.rs::download_weights; non-test consumer: ferrotorch-jit/Cargo.toml declares ferrotorch-hub = { workspace = true, features = ["http"] } for the jit_trace_dump example; the meta-crate’s hub cargo feature flows through to the same conditional. |
Re-exports§
pub use auth::hf_token;pub use auth::with_auth;pub use cache::HubCache;pub use cache::default_cache_dir;pub use discovery::HfModelInfo;pub use discovery::HfModelSummary;pub use discovery::HfRepoFile;pub use discovery::SearchQuery;pub use discovery::get_model;pub use discovery::search_models;pub use download::hf_download_model;pub use download::download_weights;pub use download::load_pretrained;pub use hf_config::HfTransformerConfig;pub use registry::EntryKind;pub use registry::ModelInfo;pub use registry::WeightsFormat;pub use registry::get_model_info;pub use registry::list_models;