Skip to main content

Crate ruvector_learning_wasm

Crate ruvector_learning_wasm 

Source
Expand description

MicroLoRA WASM - Ultra-fast Low-Rank Adaptation for Edge AI

This crate provides rank-2 LoRA (Low-Rank Adaptation) matrices optimized for WASM execution with <100us adaptation latency. Designed for real-time per-operator-type learning in query optimization systems.

§Key Features

  • Rank-2 LoRA: Minimal parameter count (2d parameters per adapter)
  • Per-Operator Scoping: Separate adapters for different operator types
  • <100us Adaptation: Instant weight updates for real-time learning
  • WASM-Optimized: no_std compatible, minimal allocations

§Architecture

Input Embedding (d-dim)
       |
       v
  +---------+
  | A: d x 2 |  Down projection
  +---------+
       |
       v
  +---------+
  | B: 2 x d |  Up projection
  +---------+
       |
       v
Delta W = alpha * (A @ B)
       |
       v
Output = Input + Delta W

Structs§

LoRAConfig
Configuration for MicroLoRA
LoRAPair
A single LoRA adapter pair (A and B matrices)
MicroLoRAEngine
Main MicroLoRA engine managing multiple LoRA pairs
ScopedLoRA
Scoped LoRA manager with per-operator-type adapters
Trajectory
A single trajectory recording
TrajectoryBuffer
Ring buffer for trajectory storage
TrajectoryStats
Statistics for a collection of trajectories
WasmMicroLoRA
WASM-exposed MicroLoRA engine
WasmScopedLoRA
WASM-exposed Scoped LoRA manager

Enums§

OperatorScope
Operator types for scoping (matches ruvector-dag OperatorType)