Metadata-Version: 2.4
Name: piper-loader
Version: 0.1.0rc1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: torch>=2.15,<2.16
Requires-Dist: piper-kernels>=0.9.0rc3,<0.10
License-File: LICENSE
Summary: End-to-end Rust-backed weight loader, 3-tier host/NVMe cache, GPU streamer, and MoE slab pool for Piper Engine.
Keywords: inference,loader,offloading,pytorch,moe,safetensors,cuda,rocm
License-Expression: Apache-2.0
Requires-Python: >=3.14
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/Boffee/piper-loader/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/Boffee/piper-loader
Project-URL: Issues, https://github.com/Boffee/piper-loader/issues
Project-URL: Repository, https://github.com/Boffee/piper-loader.git

# Piper Loader

End-to-end weight loading, multi-tier host/NVMe caching, GPU streaming, and
online LoRA hot-swapping for **Piper Engine**.

- **Rust core + thin Python wrapper** (`maturin` / `PyO3`), single wheel per OS
  covering **Linux + Windows** and **NVIDIA (CUDA) + AMD (ROCm/HIP)** via
  runtime dynamic loading of `cudart` / `amdhip64` (no build-time GPU SDK).
- **Disk-native `.safetensors` ingestion** (single + sharded index, file-identity
  fingerprinting, zero-copy dim-0 row slicing for SP/TP/EP sharding) plus
  optional in-memory CPU tensor registration.
- **Unified 3-tier `HostStore`** shared across models and 2–4 local GPUs:
  - **Tier 2a:** Portable pre-pinned slab arena ranked by H2D transfer heat.
  - **Tier 2b:** Private pageable slab arena using remaining system RAM
    (critical for Windows WDDM and fast Diffusion ↔ LLM model switching).
  - **Direct NVMe + Bounce Ring:** Multi-threaded `O_DIRECT` /
    `FILE_FLAG_NO_BUFFERING` reads streamed through a sticky pre-pinned ring.
- **Three GPU managers on one deli-ticket event ring:**
  - `ResidentStore` — one-shot all-resident load (zero per-layer overhead,
    100% CUDA/HIP Graph safe).
  - `BlockStreamer` + `UnitLoader` — explicit `use_unit(name, prefetch=next)` /
    `install_all()` for DiTs and dense layers (no hidden `nn.Module` hooks).
  - `ExpertPool` — full-VRAM static views (500+ TPS) and partial-offload
    1-DMA packed expert slabs with live GPU `expert_to_slot`, compact miss-list
    path, `waves()` fallback, 1-wave prefill scratch, and pluggable Rust
    eviction policies (`s3_fifo`, `w_tinylfu`, `lru`).
- **Format-agnostic quantized & online adapter bridge:** plugs into
  `piper-kernels` `QuantizedWeight` transcode and in-place multi-LoRA / dense /
  per-path strength / `meta` / broadcast merge with `adapter_epoch` hot-swap.

## Development

```bash
# Run pure-Rust core tests (CPU, uses FakeGpuRuntime)
cargo test --workspace

# Build & install Python extension into local uv venv
uv sync --dev
uv run maturin develop

# Run Python test suite, lint, and typecheck
uv run pytest tests -q
uv run ruff check .
uv run pyright
```

