Expand description
Model Bundling and Memory Paging
This module provides efficient packaging and memory management for ML models, enabling deployment on resource-constrained devices and handling of large models.
§Features
- Model Bundling: Package multiple models into a single
.apbundlefile - Memory Paging: LRU-based component loading for models larger than RAM
- Memory Mapping: OS-level memory management via mmap for efficient I/O
- Pre-fetching: Proactive loading of anticipated model components
§Example
ⓘ
use aprender::bundle::{ModelBundle, BundleConfig};
// Create a bundle from models
let bundle = ModelBundle::new("my_models.apbundle")
.add_model("classifier", classifier_weights)?
.add_model("encoder", encoder_weights)?
.build()?;
// Load with memory paging
let loaded = ModelBundle::load_paged("my_models.apbundle", 10_000_000)?; // 10MB limit
let weights = loaded.get_model("classifier")?;Structs§
- Bundle
Builder - Builder for creating model bundles.
- Bundle
Config - Configuration for model bundle creation and loading.
- Bundle
Format - Bundle file format constants.
- Bundle
Manifest - Manifest describing the contents of a model bundle.
- Bundle
Reader - Reader for loading bundle files.
- Bundle
Writer - Writer for creating bundle files.
- Mapped
File - Memory-mapped file with zero-copy access.
- Mapped
Region - A region of mapped memory representing model data.
- Memory
Mapped File - Memory-mapped file for efficient model access (legacy API).
- Model
Bundle - A bundle of machine learning models with efficient storage and loading.
- Model
Entry - An entry in the bundle manifest representing a single model.
- Model
Metadata - Metadata for a single model in the bundle.
- Paged
Bundle - A model bundle with memory paging support.
- Paging
Config - Configuration for paged model loading.
- Paging
Stats - Statistics for paged bundle access.
Constants§
- BUNDLE_
MAGIC - Magic bytes for .apbundle format.
- BUNDLE_
VERSION - Current bundle format version.
- DEFAULT_
MAX_ MEMORY - Default maximum memory for paged bundles (100MB).
- DEFAULT_
PAGE_ SIZE - Default page size for memory paging (4KB).