Module bundle

Module bundle 

Source
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 .apbundle file
  • 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§

BundleBuilder
Builder for creating model bundles.
BundleConfig
Configuration for model bundle creation and loading.
BundleFormat
Bundle file format constants.
BundleManifest
Manifest describing the contents of a model bundle.
BundleReader
Reader for loading bundle files.
BundleWriter
Writer for creating bundle files.
MappedFile
Memory-mapped file with zero-copy access.
MappedRegion
A region of mapped memory representing model data.
MemoryMappedFile
Memory-mapped file for efficient model access (legacy API).
ModelBundle
A bundle of machine learning models with efficient storage and loading.
ModelEntry
An entry in the bundle manifest representing a single model.
ModelMetadata
Metadata for a single model in the bundle.
PagedBundle
A model bundle with memory paging support.
PagingConfig
Configuration for paged model loading.
PagingStats
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).