Skip to main content

Module conformal_stages

Module conformal_stages 

Source
Expand description

Multi-stage conformal prediction for render pipeline timing.

Extends conformal alerting to individual render stages (layout, diff, presenter) with Mondrian-style stage bucketing. Each stage maintains independent calibration and e-process tracking, so a regression in layout computation doesn’t pollute diff detection and vice versa.

§Render Pipeline Stages

view() → [Layout] → Buffer → [Diff] → Changes → [Present] → ANSI
           ↑               ↑                ↑
      stage monitor   stage monitor   stage monitor

§Mondrian Conformal Prediction

Mondrian conformal prediction partitions the input space into buckets and maintains separate calibration sets per bucket. Here, each render stage is a natural partition:

Bucket 0 (Layout):  calibrate on layout_time_us
Bucket 1 (Diff):    calibrate on diff_time_us
Bucket 2 (Present): calibrate on present_time_us

Stage-level alerts feed into the unified degradation decision: if any stage exceeds its conformal bound, trigger degradation.

§Usage

use ftui_runtime::conformal_stages::{StagedConformalPredictor, RenderStage, StageObservation};

let mut predictor = StagedConformalPredictor::default();

// Calibration: feed baseline timings per stage
for _ in 0..50 {
    predictor.calibrate(RenderStage::Layout, 120.0);  // ~120μs
    predictor.calibrate(RenderStage::Diff, 80.0);     // ~80μs
    predictor.calibrate(RenderStage::Present, 200.0); // ~200μs
}

// Detection: observe new frame timings
let result = predictor.observe_frame(StageObservation {
    layout_us: 500.0,  // regression!
    diff_us: 85.0,
    present_us: 210.0,
});

if result.any_alert() {
    // Trigger degradation
}

Structs§

FrameResult
Combined result from observing all stages.
StageAlert
Alert decision for a single stage.
StageObservation
Per-stage timing observation for a single frame.
StagedConfig
Configuration for staged conformal prediction.
StagedConformalPredictor
Multi-stage conformal predictor with Mondrian bucketing.

Enums§

RenderStage
Render pipeline stages for Mondrian bucketing.