Skip to content

feat: add BeziCast calibrator for DBCache - #1369

Merged
DefTruth merged 2 commits into
mainfrom
dev
Nov 19, 2026
Merged

DefTruth merged 2 commits into
mainfrom
dev

Conversation

@DefTruth

Copy link
Copy Markdown
Member

Summary

Add BeziCast (arXiv:2610.16448) as an experimental DBCache calibrator for non-uniform historical anchors.

Related to #1363.

What changed

  • Add BeziCastCalibrator with a FIFO of up to six real full-compute anchors, Bernstein equivalent weights, and Tikhonov stabilization.
  • Follow the paper defaults K=6, n=4, and ridge=0.5; use pinv for exact zero-ridge interpolation.
  • Keep predictions out of the FIFO, aggregate fp16/bf16 tensors in fp32, and preserve the input dtype.
  • Add an optional equivalent-weight guardrail with risk scoring, Euclidean simplex projection, and soft blending. It remains disabled by default because the local two-run probe showed no stable benefit.
  • Support rho=auto, query clipping, explicit insufficient-anchor reuse, and observable counters for forecasts, warmup reuse, numerical fallback, clipping, and guardrail blending.
  • Narrow numerical fallback to scalar CPU fitting so tensor OOM/CUDA errors propagate; include guardrail thresholds in artifact tags.
  • Expose Python, YAML, and CLI configuration, including --calibrator bezicast --calibrator-params history=6,control_points=4,ridge=0.5,guardrail=false.
  • Add algorithm/config/reset tests, an example YAML, user documentation, and corrected versioned research records.

DBCache scheduling, Fn/Bn granularity, warmup, and cache guards are unchanged.

Tests

  • 321 passed across BeziCast, BRACE, TaylorSeer, HiCache, FoCa, DMD, SVD, config, and reset regressions.
  • All relevant pre-commit hooks pass.
  • Coverage includes independent linear/cubic interpolation, independent NumPy non-uniform ridge weights, known simplex projections, hand-derived guardrail outputs, automatic rho, query clipping, numerical/non-finite fallback, OOM propagation, unique artifact tags, real cache hits, unchanged hit sequences, and zero-cache bit-exact behavior.

FLUX.1-dev E2E

Environment: RTX PRO 5000, physical GPU 2, torch 2.15.0+cu132, 1024x1024, 28 steps, seed 0. Every cache arm reports 12/28 Cache Steps; neither BeziCast arm emits a numerical-fallback warning.

Config Latency Speedup vs base Peak memory Cache Steps PSNR / SSIM vs base PSNR / SSIM vs compile
Base eager 16.90s 1.00x 33.82GiB 0 — —
Compile 14.80s 1.14x 33.82GiB 0 29.21 / 0.9740 —
Compile + DBCache reuse 8.65s 1.95x 33.87GiB 12 28.11 / 0.9617 29.61 / 0.9634
Compile + TaylorSeer O1 8.67s 1.95x 33.95GiB 12 27.60 / 0.9643 30.60 / 0.9698
Compile + BRACE C3 8.65s 1.95x 33.92GiB 12 27.97 / 0.9698 29.42 / 0.9699
Compile + BeziCast guard off 8.67s 1.95x 34.00GiB 12 29.31 / 0.9707 30.56 / 0.9670
Compile + BeziCast guard on, rho=auto 8.68s 1.95x 34.00GiB 12 29.27 / 0.9663 30.46 / 0.9650

Repeat / noise floor

BeziCast config Repeat latency PSNR / SSIM vs base PSNR / SSIM vs compile Same-config repeat PSNR / SSIM
Guardrail off 8.67s 29.65 / 0.9710 30.90 / 0.9686 39.60 / 0.9932
Guardrail on, rho=auto 8.68s 28.35 / 0.9679 28.84 / 0.9617 32.58 / 0.9873

This is a single-prompt compile wiring probe, not a universal predictor ranking. The first-run guardrail on/off difference is about 0.10dB and is not evidence of a gain; guardrail-on also has a worse same-config repeat floor, so it remains opt-in.

Visual comparison

All outputs preserve the cat, sign, and Hello world text; no black images or structural corruption were observed.

FLUX BeziCast comparison

@DefTruth
DefTruth merged commit 2640373 into main Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant