You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement memory-mapped file loading for large SafeTensors models.
Motivation
Large models (70B+) exceed VRAM capacity. Memory mapping enables:
Streaming weights from disk to GPU
Layer-by-layer loading without full RAM usage
Fast model switching without full reload
Features
mmap-based SafeTensors reader
Lazy tensor loading (load on first access)
Pinned memory staging for faster H2D
Layer eviction for multi-model scenarios
Windows/Linux support
Design
frompygpukit.llmimportLazyModel# Model weights stay on disk until accessedmodel=LazyModel.from_safetensors("path/to/model", lazy=True)
# Only loads embedding layerembeddings=model.embed_tokens(input_ids)
# Loads layer 0 on demandhidden=model.blocks[0](embeddings)
Activity
m96-chan commentedon Dec 31, 2025
Implementation Plan
Approach: Rust-based LazyTensor
Extend existing
rust/pygpukit-core/src/llm/tensor_loader.rswith lazy GPU loading.Current Infrastructure (Already Implemented)
memmap2::Mmap- Memory-mapped file accessSafeTensorsFile- Header parsing, tensor metadataTensorData- Zero-copy view into mmapmemory/- LRU eviction, size-class allocatorNew Components
Data Flow
Eviction Strategy
Tasks
LazyTensorstruct with GPU cachingLazyModelLoaderfor multi-file modelsLazyModelLazyModel.from_safetensors()APIWhy Rust?
memmap2existingStarting implementation.
feat(llm): add lazy model loading with streaming strategies (#159)
feat: add cuBLAS loader, kernel profiler, and lazy model loading (#134,
m96-chan commentedon Dec 31, 2025
Closed via PR #175
feat(diffusion): add FLUX.1 image generation module (#178)
Release v0.2.19 (#188)