Skip to main content

haagenti_adaptive/
lib.rs

1//! Adaptive Precision Scheduling
2//!
3//! This module implements dynamic precision adjustment during inference:
4//! - INT4 for high-noise early steps (structure formation)
5//! - INT8 for mid-generation (feature refinement)
6//! - FP16 for final steps (detail preservation)
7//!
8//! # Key Insight
9//!
10//! Early denoising steps operate on highly noisy latents where
11//! precision errors are masked by the noise itself. Later steps
12//! require higher precision as the signal-to-noise ratio improves.
13//!
14//! # Architecture
15//!
16//! ```text
17//! ┌─────────────────────────────────────────────────────────────┐
18//! │                 Precision Schedule                           │
19//! ├─────────────────────────────────────────────────────────────┤
20//! │                                                              │
21//! │  Noise:  ████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░     │
22//! │          High ─────────────────────────────────────> Low    │
23//! │                                                              │
24//! │  Step:   1    5    10   15   20   25   30   35   40   50    │
25//! │          │    │     │    │    │    │    │    │    │    │    │
26//! │  Prec:  INT4 INT4  INT8 INT8 INT8 FP16 FP16 FP16 FP16 FP16  │
27//! │          │    │     │    │    │    │    │    │    │    │    │
28//! │  VRAM:  25%  25%   50%  50%  50%  100% 100% 100% 100% 100%  │
29//! │          │    │     │    │    │    │    │    │    │    │    │
30//! │  Speed:  4x   4x    2x   2x   2x   1x   1x   1x   1x   1x   │
31//! │                                                              │
32//! └─────────────────────────────────────────────────────────────┘
33//! ```
34
35mod error;
36mod precision;
37mod profile;
38mod schedule;
39mod transition;
40
41pub use error::{AdaptiveError, Result};
42pub use precision::{Precision, PrecisionCapabilities};
43pub use profile::{PrecisionProfile, ProfilePreset};
44pub use schedule::{quick_schedule, PrecisionSchedule, ScheduleConfig, StepPrecision};
45pub use transition::{PrecisionTransition, TransitionPlanner, TransitionStrategy};
46
47/// Prelude for common imports
48pub mod prelude {
49    pub use super::{Precision, PrecisionProfile, PrecisionSchedule, ProfilePreset, Result};
50}