Skip to content

fix(accuracy): constraint (K) checks the union bound over the estimates each query depends on - #1405

Merged
zzylol merged 5 commits into
mainfrom
fix/k-form-r
Nov 17, 2026
Merged

zzylol merged 5 commits into
mainfrom
fix/k-form-r

Conversation

@zzylol

@zzylol zzylol commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem. Constraint (K) kept one failure probability D per execution. It added each selected readout's δ once and checked D ≤ δ / n_q at the root. That broke in three ways:

    • Unsound. max(q) over 1,000 series could read a readout copy given to a per-value query on q. With δ 0.01 per estimate, its real union bound is 1,000 × 0.01 = 10 ([Bug] A reduction reads a readout level given for another query, and Stage 3 accepts it #1395).
    • or gets no sketch plan. On this PR's base, q or r adds both sides' δ per value (2e-4 against 1e-4).
    • Many-to-one matches get no sketch plan. q * on() group_left e divides δ by 1,000 output values that all read one estimate.
  • Change. Each execution now has:

    • P, the failure probability of one output value;
    • W, the failure probability of its whole output.

    Both are built from the same operator classes and counts Pass 2 splits δ by. Each query's one row checks the bound AccuracyTarget::failure_probability_bound names: W ≤ δ (every estimate read) or P ≤ δ / V (each covered value).

  • Effect.

  • Review fixes (head 1070e0a14): Pass 2 records each query's readout counts and Stage 3 reads them (no second walk); a set operator over a top-k counts the top-k's estimates; δ = 0 readouts add 0; the precision error reads as words. Scaling failure probabilities by the tightest limit was measured and not adopted. Details in "Review fixes".

Base: main. #1360 is merged (5e82ecb2b); this PR is rebased onto it (git rebase --onto origin/main 386ea88fb), head bf6288565. Until this merges, main leaves or and many-to-one matches with no plan at all (no wrong answers).

Review guide

Behavior: before → after

The four cases, each at δ = 0.01 over the whole result unless stated. "Before" is this PR's base, #1360.

Query (facts) Before: readout δ / outcome After: bound checked / readout δ / outcome
quantile_over_time(0.9, latency{side="a"}[5m]) or …{side="b"}… (latency 1,000 series, n_q 2,000) Pass 2 gives 5e-6. (K) adds 1e-5 against 0.01 / 2,000: no plan at all every estimate read (R 2,000 ≤ V 2,000): W = 2,000 × 5e-6 = 0.01: DDSketch plan
max_over_time(latency[5m]) * on() group_left quantile_over_time(0.99, reference[5m]) (reference 1 series) 0.01 against 0.01 / 1,000: no plan at all every estimate read (R 1): W = 0.01: DDSketch at δ 0.01
q per value at δ 0.01, and max(q) (1,000 series; copies at 0.01 for cost 1 and 1e-5 for cost 3) max(q) reads the 0.01 copy: D = 0.01 ≤ 0.01 accepted, true bound 10 every estimate read: 0.01 copy gives W 10, so the 1e-5 copy is selected for both
count(distinct user_id) by service, per value at δ 0.05 (10,000 services) KMV k = 4,323 at δ 0.05 each covered value, V = 1: P = 0.05, unchanged (rollup_controlled passes on both)

The first two are integration tests (accuracy_at_query_roots). Both fail on #1360 with no plan selected. The third is the Stage 3 unit test, in two variants: δ 0.5 / 5e-4 fails on main, δ 0.01 / 0.01 fails on #1360. Through the planner, Pass 2 drops DDSketch's looser level, because DDSketch's error does not depend on δ, so a_max_reads_the_level_its_own_split_gives passes on both and guards the end-to-end path only.

Interfaces

crates/types/src/accuracy/target/mod.rs

 impl AccuracyTarget {
-    /// The failure probability each output value must meet: δ over the values the scope covers.
-    pub fn failure_probability_per_output_value(&self, values_per_evaluation: Option<u64>) -> Option<f64>;
+    /// Which union bound checks this target's δ, and its limit, from n_q and the query's readout counts; None without a δ or with neither bound known.
+    pub fn failure_probability_bound(&self, values_per_evaluation: Option<u64>, readout_values: ReadoutValueCounts) -> Option<FailureProbabilityBound>;
+    /// Pass 2's per-readout level: the bound's limit split over the estimates it counts (R, or the fan-in).
     pub fn failure_probability_per_readout_value(&self, values_per_evaluation: Option<u64>, readout_values: ReadoutValueCounts) -> Option<f64>;
 }
+/// The union bound a query's failure probability is checked by (Pass 2 splits by it, Stage 3 checks it).
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub enum FailureProbabilityBound {
+    /// Summed δ of every estimate any output value depends on ≤ limit (δ).
+    EveryEstimateRead { limit: f64 },
+    /// Summed δ of one output value's estimates ≤ limit (δ / values_covered).
+    EachCoveredValue { values_covered: u64, limit: f64 },
+}
+impl FailureProbabilityBound {
+    /// Its limit.
+    pub fn limit(&self) -> f64;
+}

failure_probability_per_output_value is removed: dividing δ by n_q is the rule that was wrong for or, matches and reductions.

crates/types/src/stages/logical/memo/mod.rs

 impl Memo {
+    /// The estimates one evaluation of a readout group computes: its values, or for a top-k every item it ranks (states × declared distinct items, at most the rows).
+    pub fn max_estimates_per_evaluation(&self, group: MemoGroupId) -> Option<u64>;
 }

crates/accuracy/src/lib.rs, estimate_dependence.rs, readout_caps/mod.rs, metric_rule/mod.rs

+/// How many first inputs an operator reads value by value (moved from readout_caps).
+pub fn inputs_read_value_by_value(operator: &Operator<MemoGroupId>) -> Option<usize>;
+/// Whether each output value is copied from one input: or, a concatenation (moved from readout_caps).
+pub fn takes_each_value_from_one_input(operator: &Operator<MemoGroupId>) -> bool;
+/// Whether a readout chooses its output values by its estimates (a top-k).
+pub fn ranks_by_estimate(operator: &Operator<MemoGroupId>) -> bool;
+/// Per group: whether which values its output holds is chosen by estimates (a top-k, and operators reading one value by value).
+pub fn values_chosen_by_estimate(memo: &Memo, order: &[MemoGroupId]) -> Vec<bool>;
-pub fn readout_levels(memo: &Memo, error_metrics: &ErrorMetricsOfMemo, order: &[MemoGroupId], evidence: &dyn AccuracyEvidence) -> BTreeMap<CandidateForMemoGroupId, ReadoutRequiredAccuracy>;
+pub fn readout_levels(memo: &Memo, error_metrics: &ErrorMetricsOfMemo, order: &[MemoGroupId], evidence: &dyn AccuracyEvidence) -> ReadoutLevels;
+/// What readout_levels gives: each readout's levels, and per query the readout counts (R, fan-in) its δ is split over.
+pub struct ReadoutLevels {
+    pub of_readout: BTreeMap<CandidateForMemoGroupId, ReadoutRequiredAccuracy>,
+    pub readout_values_of_query: Vec<Option<ReadoutValueCounts>>,
+}
 impl ErrorMetricsOfMemo {
+    /// Whether an estimate an input depends on can make the output miss: β > 0 in some metric, or the input's values are chosen by estimates. Both stages count by it.
+    pub fn input_estimates_reach_output(&self, memo: &Memo, candidate: CandidateForMemoGroupId, input: usize) -> bool;
+    /// Whether each output value depends on one input's estimates: or / concatenation with no input chosen by estimate.
+    pub fn each_value_depends_on_one_input(&self, memo: &Memo, candidate: CandidateForMemoGroupId) -> bool;
 }

crates/types/src/stages/logical/memo_candidates.rs

 pub struct LogicalASAPMemoCandidates {
     /* memo, edges, failing_logical_edges, pruned, evaluation_grid_of_group, exact_only_groups_of_query unchanged */
+    /// Per query: the readout counts (R, fan-in) Pass 2 split its δ over; None without a target.
+    pub readout_values_of_query: Vec<Option<ReadoutValueCounts>>,
 }
 impl LogicalASAPMemoCandidates {
+    /// The bound query `query`'s δ is checked by: its target's failure_probability_bound over the recorded counts.
+    pub fn failure_probability_bound(&self, query: usize) -> Option<FailureProbabilityBound>;
 }
+/// In words for error messages: "each of 100 covered values fails with at most 0.0001".
+impl std::fmt::Display for FailureProbabilityBound;

crates/stage3-plan-selection/src/report.rs

 /// Why Stage 3 selected no plan (the type stays).
 pub enum ErrorSelectingPlan {
     InvalidSettings(AnalyticalCostError),
     EntryCount { /* fields unchanged */ },
     Cost { /* fields unchanged */ },
     NoValidCandidate(Vec<Rejection>),
     Solver(String),
     /// A query's target is below the solver's precision after the 1e-10 retry (unsatisfiable request).
     AccuracyTargetBelowSolverPrecision {
         query: usize,
-        failure_probability_per_output_value: Option<f64>,
+        failure_probability_bound: Option<FailureProbabilityBound>,
     },
     UnsupportedCostModel(String),
 }

Usage. The workload entry is what the user writes. Stage 0 lowers it, Pass 2 splits δ, and Stage 3 checks the bound. Run by an_or_of_two_quantiles_reads_sketches:

// The user's workload: `latency` 1,000 non-negative series, one query every 10 s.
let run = planning_run(workload(&[(
    r#"quantile_over_time(0.9, latency{side="a"}[5m]) or quantile_over_time(0.9, latency{side="b"}[5m])"#,
    r#"{"accuracy_metric": "relative", "max_error": 0.05, "failure_probability": 0.01}"#,
)]), false);
// Inside: Stage 0 sets n_q = 2,000 (both branches' series). Pass 2's walk
// gives R = 2,000 and fan-in 1 (recorded as readout_values_of_query), so
// failure_probability_bound names EveryEstimateRead { limit: 0.01 }, and each
// readout gets 0.01 / 2,000 = 5e-6. Stage 3's root row checks
// W_or = 1,000 · 5e-6 + 1,000 · 5e-6 = 0.01 ≤ 0.01.
let (_, selection) = run.selection.as_ref().unwrap();
assert_eq!(selection.accepted_accuracy_per_query[0].to_string(), "accepted relative (DDSketch)");
// Every readout the plan reads was required at 5e-6.
assert!(readout_failure_probabilities(&run).iter().all(|&d| (d - 5e-6).abs() <= 1e-12));

On #1360 the same run selects no plan.

Algorithm changes

Constraint (K)'s failure-probability rows

  • Problem: the three cases in the Summary.
  • Before:
    1. D_c ≥ δ_c + Σ_i H_i over every input.
    2. At each root, D_v ≤ δ / V.
  • After (compose, accuracy_constraints):
    1. Per execution, over the inputs whose error reaches the output:
      • P_c ≥ Σ_{value by value} HP + Σ_{whole} HW, with one row per input for or and a concatenation;
      • W_c ≥ Σ HW.
    2. A readout has P = δ and W = R·δ; a top-k has R·δ for both.
    3. One row per query by failure_probability_bound:
      • W_v ≤ δ or P_v ≤ δ / V;
      • a query with several roots sums its roots' terms;
      • an unbounded term forbids that answering execution.
    4. P and W exist only where some root above checks them (set_checked_failure_probabilities).
  • Also: or and a concatenation now take the larger input error in E, not the sum. That is the rule Pass 2's caps assume. With the sum, q or r at relative 0.05 was infeasible even without a δ.
  • Correctness:
    • A covered value fails only if an estimate it depends on fails, and those estimates depend on the data's keys, not on the estimates. So P(fail) ≤ max_D Σ_{e ∈ S_q(D)} δ_e, and both rows bound that sum (proof in accuracy-models.md, "Which estimates a result depends on").
    • It assumes R bounds the estimates per evaluation. Top-k is checked with max_estimates_per_evaluation; time-bucketed SQL falls back to the rows read, which memo_value_bounds executes on data.
    • union_bound_oracle checks every accepted plan, for 21 shapes × 3 scopes plus cross-query pairs with random looser copies, against the union-bound worst case over all 4,096 datasets of two 6-series metrics.
    • Mutation check: with the readout's W set back to δ, the oracle reports worst cases of 0.03–0.06 against 0.01.
  • Complexity: see the table below. When P and W were created wherever bounded, RangeHeavy-8users solved 3.1× slower with the same objective, so they are now created only where needed.
  • Assumptions and limits: an estimate reached on two paths of one query is charged once per path (max(A or B): 200 δ for 100 estimates). That costs a stricter δ, never a miss (Constraint (K): count each estimate once per query (Form X) instead of once per path #1400). Each readout is charged its required level's δ, not its build's own (DDSketch's is 0) (Constraint (K): charge the build's own failure probability (DDSketch 0) and one event per state where the guarantee is simultaneous #1401).

MILP size and planning time. One build host, Xeon E5-2660 v2 @ 2.20 GHz, taskset -c 3, release asap_planner --run-until stage3, median of 5 (interleaved). Workloads: the 2026-11-15 RollupHeavy and RangeHeavy 8-user workload files.

Workload Executions (kept) Selectable edges (y) Inputs (K) variables (K) rows MILP variables / constraints Planning wall s HiGHS solve ms Objective
RollupHeavy-8users, #1360 5,179 (3,325) 23,298 (10,104) 5,167 624 1,040 8,627 / 21,810 14.93 13,474 9.123951e5
RollupHeavy-8users, this PR same same same 660 1,100 8,663 / 21,870 15.24 13,778 9.123951e5
RangeHeavy-8users, #1360 1,771 (1,373) 9,504 (5,382) 1,767 240 392 4,297 / 9,680 9.22 7,932 9.988567e3
RangeHeavy-8users, this PR same same same 240 392 4,297 / 9,680 11.24 10,352 9.988567e3

Without the "checked only" rule, the medians of 3 were: RollupHeavy 14.82 s, 936 (K) variables; RangeHeavy 28.99 s, 360 (K) variables.

Decisions and open questions

Decided:

  • 2026-11-17, option B over option A: change (K) to the union bound over estimates, rather than give or a summed fan-in. Decided by the user.
  • Form R over Form X: decided by an independent design review standing in for the user's approval. It asked for:
    • the R assumption in the doc;
    • the subquery row to read "no contract";
    • one rule for where P and W exist;
    • this measurement;
    • Form X and the DDSketch/KLL refinement moved to issues.
  • The static row choice, taken from Pass 2's counts, not a binary variable.

Needs reviewer decision:

Verification

After the rebase onto main 5e82ecb2b (head bf6288565; cargo nextest run --workspace --no-fail-fast, compared by name): main 1845 run / 10 fail, this PR 1871 / 10, the same 10 names (joint_search_equivalence ×2, materialized_views, plan_sharing ×2, promql_to_post_asap, summary_sharing, planner_fuzz ×3). per_query_accuracy_targets (4), accuracy_at_query_roots (7), memo_value_bounds and rollup_controlled pass. Snapshot suites: corpus_plans_match_snapshots passes; sketch_plans_match_snapshots differs on main and here in ratio-of-quantiles-1h-mvp only, byte-identical between the two (#1360 merged without regenerating it). cargo fmt --check and cargo clippy --workspace --all-targets -D warnings clean. The measurements below were taken before this rebase (on #1360 386ea88fb); the rebase changed only a test helper and an import.

Workspace (cargo nextest run --workspace --no-fail-fast, compared by name): main 6b5a728b9 1721 run / 10 fail; #1360 386ea88fb 1755 / 10 (before its executor-gaps commit, also memo_value_bounds, fixed in #1360); this PR 1070e0a14 1781 / 10. The same 10 fail on all three: joint_search_equivalence ×2, materialized_views, plan_sharing ×2, promql_to_post_asap, summary_sharing, planner_fuzz ×3. Changed crates (asap-accuracy, asap-types, Pass 2, Stage 2, Stage 3): 423 pass; clippy --all-targets -D warnings and fmt clean.

Snapshot suites (--test corpus_snapshots --test devtools --run-ignored all -E 'test(snapshots)'): corpus_plans_match_snapshots passes on all three; sketch_plans_match_snapshots passes on main and differs in one file on #1360 and here (ratio-of-quantiles-1h-mvp), byte-identical between the two, so #1360's own change.

Oracles: union_bound_oracle passes. The reviewer's extension (random DAGs, not committed: large, review-only) accepts 559 plans with 0 violations; its retry assertion expected scaling and does not apply.

Planning time (one idle host, release asap_planner --run-until stage3, taskset -c 3, trees interleaved, median of 5; showcase, sketch and random-mixed sums of medians of 3 on core 7):

Workload main #1360 this PR before fixes this PR
RangeHeavy-8users 29.03 s 9.20 s 11.10 s 11.16 s
RangeHeavy-8users-counter 13.76 s 11.59 s 22.11 s 22.21 s
RollupHeavy-8users 19.67 s 19.51 s 19.42 s 19.57 s
showcase (21 workloads) 1.48 s 1.49 s 1.61 s 1.61 s
sketch snapshots (10) 2.26 s 2.22 s 2.10 s 2.10 s
random-mixed-seed-862 (10) 75.98 s 75.15 s 17.43 s 17.61 s

MILP size this PR vs #1360: RollupHeavy-8users 8,663 / 21,870 vs 8,627 / 21,810; RangeHeavy-8users 4,297 / 9,680 both.

Plan changes vs #1360 (all 47 workloads above compared by plan; the review fixes change no plan vs this PR before them):

  • random-mixed-seed-862 w08 (3784.67 → 3414.35 /s) and w09 (4711.77 → 3580.85 /s): queries 2–4 move from exact to DDSketch. Sound: their rows check every estimate read, W = R·δ ≤ 0.3, which accepts the readout at δ 3e-5; fix(accuracy): split δ over the readout values the covered output values depend on #1360's per-value D ≤ δ / n_q row did not.
  • Equal-cost ties (cost within 1e-8 relative, same accepted accuracy): RangeHeavy-8users (9988.56728909 → 9988.5673491), RangeHeavy-8users-counter, RangeHeavy 1-user and counter 1-user, showcase q5_joint__1h_10hz_60s, random-mixed w07.

Plan changes vs main: the above, plus #1360's own: the RangeHeavy ties (same objective to 1e-8) and sketch ratio-of-quantiles-1h-mvp (same objective, 196 vs 316 variables). RollupHeavy-8users, the other showcase and sketch workloads are unchanged.

New tests (28): review round: k_charges_a_set_operator_for_the_top_k_choosing_its_values (fails on abd1462ad) and a_failure_probability_bound_reads_as_words. Earlier:

  • Stage 3, cases:
    • k_accepts_an_or_whose_readouts_meet_delta_over_its_covered_values: q or r at 1e-4 per value; 2e-4 rejected.
    • k_charges_a_readout_every_series_matches_once: the group_left case.
    • k_does_not_let_a_reduction_read_a_level_given_for_a_per_value_query: [Bug] A reduction reads a readout level given for another query, and Stage 3 accepts it #1395, in both δ variants.
    • k_adds_nothing_for_an_input_whose_values_are_not_read: and, / count.
    • k_counts_an_exact_input_as_never_failing: E and W only.
  • Stage 3, scopes and paths:
    • k_does_not_divide_a_per_value_failure_probability_by_the_values;
    • k_bounds_a_whole_result_by_its_covered_values_or_every_estimate: with n_q unknown, (X) forces exact reads;
    • k_bounds_a_record_share_scope_by_its_covered_groups;
    • k_charges_an_estimate_both_sides_of_an_or_read_once_per_value;
    • k_charges_an_estimate_two_paths_reach_once_per_path: Form R's loss, pinned (Constraint (K): count each estimate once per query (Form X) instead of once per path #1400).
  • Stage 3, readouts and roots:
    • k_charges_a_top_k_readout_for_every_estimate_it_ranks;
    • k_charges_a_concatenation_one_input_per_value;
    • k_sums_the_failure_probabilities_of_a_query_s_roots;
    • contexts_whose_queries_bound_every_estimate_read_at_equal_delta_are_copies.
  • Oracle: union_bound_oracle::every_accepted_plan_meets_its_failure_probability_on_every_dataset. It computes the union-bound worst case, not the true failure probability. It randomizes copy levels and covers the record-share scope. It also checks that every shape planned alone has a plan whenever it has one without a δ.
  • asap-types: 7 failure_probability_bound tests, including the property test the_readout_split_meets_the_bound_it_names, and max_estimates_per_evaluation_counts_every_item_a_top_k_ranks.
  • Integration (accuracy_at_query_roots):
    • an_or_of_two_quantiles_reads_sketches;
    • a_quantile_matched_onto_every_series_reads_a_sketch;
    • a_max_reads_the_level_its_own_split_gives.

The first two fail on #1360.

Review fixes

  1. Plan changes vs fix(accuracy): split δ over the readout values the covered output values depend on #1360 listed with reasons (Verification). Done.
  2. Scaling failure probabilities by 1/(smallest root limit): implemented and measured on an idle host (RangeHeavy-8users 10.3 → 11.4 s, counter 20.9 → 30.8 s, medians of 5), so declined; the measurement is in accuracy-models.md. The counter slowdown comes from (K)'s W rows and big-M ceilings (the MILP size is unchanged); no cheap fix found, numbers recorded above.
  3. Single source: Pass 2 records readout_values_of_query; Stage 3 reads it through LogicalASAPMemoCandidates::failure_probability_bound. readout_value_counts_of_queries deleted. Done.
  4. values_covered dropped from RootLimits::bits (kept on the enum: the error text prints it); "Context copies" updated. Done.
  5. Stale docs (readout_groups, readout_values, "The assumption it rests on" now name max_estimates_per_evaluation). Done.
  6. accuracy_constraints counts each query's outputs once. Done.
  7. (a) top-k under or/and/unless: fixed with a test (values_chosen_by_estimate; one rule for Pass 2's walk and (K)). (b) distinct-item contract documented on max_estimates_per_evaluation and in the doc. (c) error text in words (Display). (d) δ = 0 adds 0 whatever the count (not observable at a root: a query whose count is unknown has no bound, so no test). Done.

Design scope

  • ReadoutLevels (asap-accuracy, Pass 2's readout step): the step's output, levels and per-query counts. General: every query's δ split.
  • LogicalASAPMemoCandidates::readout_values_of_query (Stage 1 → Stage 3 boundary type): what Pass 2 decided, read by selection.
  • values_chosen_by_estimate (asap-accuracy, estimate dependence): which groups' value sets depend on estimates; general for any operator choosing by estimate.

Follow-ups

Closes #1395.

@zzylol zzylol added accuracy Accuracy requirements, guarantees, and propagation bug Something isn't working optimizer Workload optimization and plan selection labels Nov 17, 2026
@zzylol
zzylol force-pushed the fix/delta-split-over-dependent-readouts branch from 793859e to 386ea88 Compare November 17, 2026 16:58
…er-value query

max(q) over 1,000 series at delta 0.01 reads a copy failing with 5e-4 that
a per-value query on q at delta 0.5 was given; its union bound is 0.5.
Fails on main: (K) adds the selected readout's delta once.
…ut depends on

Tests first for the failure-probability rows of (K): a per-value bound P and
a whole-output bound W per execution, with the root checking the bound Pass
2's split names (every estimate read, or each covered value).

- Stage 3: or, concatenation, many-to-one match, and/unless and count
  inputs, exact inputs, per-value, whole-result and record-share scopes,
  an estimate reached on two paths, a top-k readout, a query with several
  roots, context copies; the reduction regression gets the equal-delta
  case (a per-value query at 0.01 gives a 0.01 copy).
- A brute-force oracle over small shapes and every dataset of two
  6-series metrics: every accepted plan's union-bound worst case is within
  delta, with random looser copies; every shape alone has a plan whenever
  it has one without delta.
- asap-types: AccuracyTarget::failure_probability_bound and
  Memo::max_estimates_per_evaluation (top-k counts every item it ranks).
- Integration: or of two quantiles, group_left onto every series, max
  reading its own split's level.

These use new interfaces and do not compile without the next commit.
…es each query depends on

(K) carried one failure probability D per execution, added each selected
readout's delta once and checked D <= delta / V at the root. That summed
both sides of `or`, divided by V where every output reads one estimate
(`q * on() group_left e`), and trusted a readout level given for another
query: `max(q)` over 1,000 series could read a per-value query's copy
failing with 0.01 per estimate.

Each execution now has P (one output value) and W (its whole output),
composed by the operator classes Pass 2's split uses, over the inputs whose
error reaches the output. A readout has P = delta and W = R delta (a top-k
R delta for both). Each query's one row checks W <= delta (every estimate
read) or P <= delta / V (each covered value), the bound
AccuracyTarget::failure_probability_bound names from the same counts Pass 2
splits by; a query with several roots sums its roots' terms.

- asap-types: AccuracyTarget::failure_probability_bound and
  FailureProbabilityBound replace failure_probability_per_output_value;
  the per-readout split derives from the bound.
  Memo::max_estimates_per_evaluation counts every item a top-k ranks.
- asap-accuracy: the operator classes and the "error reaches the output"
  test move to estimate_dependence, shared by Pass 2 and Stage 3;
  readout_value_counts_of_queries exposes Pass 2's counts.
- Stage 3: or and a concatenation take the largest input error, not the
  sum, as Pass 2's caps assume.
- Stage 3: P and W exist only where a query root above checks them;
  created wherever bounded, RangeHeavy-8users solved about 3x slower.
- accuracy-models.md: the (K) rows, which estimates a result depends on,
  the R assumption, examples.
…hoosing its values

`p90 and topk(3, …)`, `p90 unless topk(3, …)` and `topk(3, …) or p90`
keep or take a value by which keys the top-k returns, which all of its
ranked estimates decide: each output value's failure probability adds the
top-k's to the p90's. Fails today: (K) drops the right side of
and/unless and takes the larger side of or.
…g a set operator's values

- Pass 2 records the readout values (R, fan-in) each query's δ is split
  over (LogicalASAPMemoCandidates::readout_values_of_query, from
  ReadoutLevels); Stage 3 checks the bound they name
  (LogicalASAPMemoCandidates::failure_probability_bound) instead of
  walking the memo again. readout_value_counts_of_queries is deleted.
- An input whose values a top-k chooses (values_chosen_by_estimate)
  counts its estimates even where beta = 0 (the right of and/unless), and
  `or` sums its sides' one-value failure probabilities when one side's
  values are chosen by estimate. One rule for Pass 2's count walk and
  (K): ErrorMetricsOfMemo::input_estimates_reach_output and
  each_value_depends_on_one_input.
- A readout required at delta = 0 adds 0 whatever its estimate count.
- RootLimits compares the bound's kind and limit only (values_covered
  is not read by any row); the precision error prints the bound in words
  (FailureProbabilityBound: Display).
- Docs: the count walk, R = Memo::max_estimates_per_evaluation and its
  distinct-item contract, context copies, and the measured cost of
  scaling failure probabilities by the tightest limit (not adopted).
- accuracy_constraints counts each query's outputs once.
@zzylol
zzylol changed the base branch from fix/delta-split-over-dependent-readouts to main November 17, 2026 18:14
@zzylol
zzylol marked this pull request as ready for review November 17, 2026 18:27
@zzylol
zzylol merged commit f8ee363 into main Nov 17, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accuracy Accuracy requirements, guarantees, and propagation bug Something isn't working optimizer Workload optimization and plan selection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A reduction reads a readout level given for another query, and Stage 3 accepts it

1 participant