Expand description
Cross-Model Fragment Sharing Library
This module implements a shared fragment library that enables:
- Deduplication of similar tensor fragments across models
- Single-load-multi-use for shared attention patterns
- Significant storage reduction (30-50% for model families)
- Faster model switching by reusing cached fragments
§Key Concepts
- Fragment: A compressed tensor chunk (typically 64KB-1MB)
- Signature: Locality-sensitive hash for similarity detection
- Library: Collection of unique fragments with reference tracking
- Manifest: Per-model mapping from layer names to fragment refs
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ Fragment Library │
├─────────────────────────────────────────────────────────────┤
│ FragmentId → Fragment (deduplicated storage) │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │ frag_0 │ │ frag_1 │ │ frag_2 │ │ frag_3 │ ... │
│ └────────┘ └────────┘ └────────┘ └────────┘ │
└─────────────────────────────────────────────────────────────┘
↑ ↑ ↑
┌──────┴───┐ ┌───┴───┐ ┌───┴───┐
│ SDXL │ │ SD3.5 │ │ Flux │
│ manifest │ │manifest│ │manifest│
└──────────┘ └───────┘ └───────┘Modules§
- prelude
- Prelude for common imports
Structs§
- Fragment
- A compressed tensor fragment
- Fragment
Id - Unique identifier for a fragment
- Fragment
Library - Fragment library for cross-model storage
- Fragment
Metadata - Metadata about a fragment
- Fragment
Signature - Locality-sensitive hash signature for a fragment
- Layer
Mapping - Mapping of layer names to tensor references
- Library
Config - Library configuration
- Library
Stats - Library statistics
- Model
Manifest - Model manifest containing all layer-to-fragment mappings
- Signature
Config - Configuration for signature computation
- Similarity
Index - Similarity index using Locality-Sensitive Hashing
- Similarity
Match - A match found in the similarity index
- Similarity
Threshold - Threshold configuration for similarity matching
- Tensor
Ref - Reference to a fragment for a specific tensor
Enums§
- Fragment
Error - Errors that can occur during fragment operations
- Fragment
Type - Type of fragment based on neural network layer type
Constants§
- DEFAULT_
SIMILARITY_ THRESHOLD - Default similarity threshold for fragment deduplication
- LIBRARY_
FORMAT_ VERSION - Version of the fragment library format
Type Aliases§
- Result
- Result type for fragment operations