Skip to main content

Module lora

Module lora 

Source
Expand description

Zero-Copy LoRA Multiplexing — context-driven neural adaptation.

Maintains a single quantized base model in memory and streams tiny LoRA (Low-Rank Adaptation) adapters based on context triggers encoded in the NQuin 5th metadata vector. Context switching takes <10 ms; the extra memory footprint is ≤15 MB per cached adapter.

§Architecture

Prompt / NQuin
      │
      ▼
 ContextDetector  ──► ContextType (Medical / Legal / Chemical / …)
      │
      ▼
 LoRAAdapterManager (LRU-10 cache)
      ├── adapter_cache: HashMap<ContextType, LoRAAdapter>
      │      LoRAAdapter { lora_a: [rank × n_in], lora_b: [n_out × rank] }
      │
      ▼
 CPU apply: output += B @ (A @ x) * scaling
 GPU apply: lora_apply.wgsl dispatch (additive delta on hidden state)
      │
      ▼
 Modified hidden-state fed into fused_transformer.wgsl

§NQuin metadata encoding (bits 60–48)

BitsFieldNotes
63–60ContextType0=General … 5=Technical
59–56AdapterID0–15 (4 bits)
55–48Confidence0–255 → 0.0–1.0

Re-exports§

pub use adapter_manager::LoRAAdapter;
pub use adapter_manager::LoRAAdapterManager;
pub use adapter_manager::LoRAError;
pub use adapter_manager::LoRAMetadata;
pub use adapter_manager::LoRATensor;
pub use context_detector::ContextDetector;
pub use context_detector::ContextType;

Modules§

adapter_manager
LoRA adapter loading, caching, and application.
context_detector
Context detection for LoRA adapter selection.
webgpu_lora
GPU-accelerated LoRA delta application via wgpu compute shader.