Skip to main content

Module training

Module training 

Source
Expand description

Training utilities and checkpoint management

This module provides:

  • ttt: Test-Time Training for research-valid model adaptation
  • tenant_delta: Per-tenant LoRA delta for isolated TTT
  • delta_pool: Per-tenant delta registry with LRU eviction
  • merge: LoRA adapter merging strategies (DO-Merge, additive, replace) — 1-vs-1 save-time path
  • delta_reducer: order-independent N-way param-server reducer (stack + truncated SVD)
  • quality_filter: Heuristic-based output filtering (NOT for training)
  • checkpoint: Checkpoint management with git integration
  • data_loader: Training data loading utilities

Modules§

adaptation_state
checkpoint
Async checkpoint management for training
data_loader
Training data loading and processing for LoRA fine-tuning
delta_pool
Per-tenant delta registry with LRU eviction
delta_reducer
N-way delta aggregation (param-server reducer) — replaces DO-Merge for multi-contributor merges.
merge
LoRA adapter merging strategies
muon
Muon optimizer: MomentUm Orthogonalized by Newton-Schulz.
pipeline
Pipeline-split (2b) training orchestration for TTT-on-split (#316).
quality_filter
Quality Filter Module
tenant_delta
Per-tenant LoRA delta for isolated Test-Time Training
ttt
Test-Time Training (TTT) Module

Structs§

ChatTemplateDataLoader
Training data loader with chat template formatting
CheckpointConfig
Checkpoint configuration
CheckpointInfo
Information about a checkpoint
CheckpointManager
Manages asynchronous checkpointing during training
CheckpointRequest
Checkpoint request sent to background worker
Contribution
One contributor in an N-way aggregation round.
ContributionGate
Gate + weighting policy applied to each contributor before it enters the stack. Anomalous / over-norm contributors are rejected (error), never silently dropped or clamped to zero — a quiet drop would let a poisoned host shrink the merge invisibly.
ContributorState
One contributor’s full state for reduce_state_dicts.
DeltaPool
Registry managing per-tenant LoRA deltas for isolated TTT adaptation
EvictedSnapshot
Snapshot returned after eviction (for restoring delta state by the caller).
FilterResult
Result of quality filter evaluation
GradientGatingConfig
Per-layer gradient gating configuration.
GuardStatus
Guard status — proof that invariant checks were run before resolution. Returned by the guard middleware; required input to resolve().
NoopValidation
No-op validation hook (the default until the held-out-eval host lands).
Provenance
Provenance for one contributor’s delta.
QualityFilter
Quality filter for generation outputs
QualityFilterConfig
Configuration for quality filtering
RankOracle
Per-tenant rank adaptation oracle.
RankOracleConfig
Configuration for runtime rank adaptation oracle.
StackSvdReducer
Stack-in-delta-space + one truncated SVD per round to a fixed rank R.
TTTConfig
Configuration for Test-Time Training
TTTContext
Context for TTT adaptation (for future cross-model verification)
TTTOverrides
Per-request TTT overrides from the client
TTTResult
Result of TTT adaptation
TenantDelta
Per-tenant LoRA delta with per-layer accumulation tracking
TenantDeltaConfig
Configuration for creating a new tenant delta (also used by the create_lora MCP tool)
TestTimeTrainer
Test-Time Trainer
TrainStage
A single pipeline stage: the stage model plus the global layer range it owns.
TrainingDataset
Training dataset
TrainingMetrics
Training metrics to save with checkpoint
TrainingSample
A single training sample
WritebackInfo
Info returned after a successful writeback (for stats accounting by the caller).

Enums§

AdaptationStrategy
Strategy for handling a completed adaptation.
DeltaAdaptationState
The lifecycle state of a tenant delta’s pending adaptation.
FilterReason
Reason for filter failure
MergeStrategy
Merge strategy for combining tenant delta with existing adapter.
ResolveOutcome
Outcome of resolving an adaptation through the state machine.
WeightFormat
WeightSnapshot
Snapshot of model weights for checkpointing

Traits§

DeltaReducer
Order-independent N-way delta reducer.
TTTVerifier
Trait for TTT verifiers (future extension)
ValidationHook
Pluggable post-reduce validation seam.

Functions§

compute_ntp_loss_split
Compute the next-token-prediction (NTP) cross-entropy loss for a TTT step over a pipeline split, with the autograd graph intact across device boundaries.
forward_train_pipeline
Run the TTT/training forward across pipeline stages and return logits with the autograd graph intact across device boundaries.
load_state_dict_from_bytes
Load a state dict from safetensors bytes.
merge_state_dicts
Merge two state dicts using the specified strategy.
rank_cap_for_dtype_bytes
Static rank↔quant coupling cap.
reduce_state_dicts
Aggregate N contributors’ full state dicts into one reduced state dict.
serialize_state_dict_to_bytes
Serialize a state dict (HashMap<String, Tensor>) to safetensors bytes.
stage_ranges
Derive contiguous stage ranges from a LayerDeviceMap.

Type Aliases§

SharedTenantDelta
Type-safe wrapper that enforces Mutex protection for TenantDelta. All cross-thread access must go through this wrapper.