nlsq.streaming.adaptive_hybrid.DefenseLayerTelemetry¶
- class nlsq.streaming.adaptive_hybrid.DefenseLayerTelemetry[source]¶
Bases:
objectTelemetry for monitoring 4-layer defense strategy activations.
Tracks when each defense layer is triggered during warmup to help with production monitoring and tuning. This class maintains thread-safe statistics that can be queried or exported for monitoring dashboards.
- The 4 layers tracked are:
Layer 1: Warm start detection (skips warmup)
Layer 2: Adaptive step size selection (refinement/careful/exploration)
Layer 3: Cost-increase guard (aborts warmup if loss increases)
Layer 4: Step clipping (limits update magnitude)
- layer2_lr_mode_counts¶
Counts per LR mode: {“refinement”: n, “careful”: m, “exploration”: k}
- record_layer1_trigger(relative_loss, threshold)[source]¶
Record Layer 1 warm start detection trigger.
- record_layer3_trigger(cost_ratio, tolerance, iteration)[source]¶
Record Layer 3 cost-increase guard trigger.
- record_lbfgs_history_fill(iteration)[source]¶
Record L-BFGS history buffer fill event.
Called when the L-BFGS history buffer becomes fully populated, signaling transition from cold start to full L-BFGS mode.
- Parameters:
iteration (int) – Iteration number when history buffer filled
- record_lbfgs_line_search_failure(iteration, reason='')[source]¶
Record L-BFGS line search failure event.
Called when the L-BFGS line search fails to find an acceptable step.
- get_summary()[source]¶
Get summary statistics for all defense layers.
- Returns:
Summary with counts and rates for each layer
- Return type: