Repository navigation
rqe-optimizer: check accuracy at the query's merge count - #154
Merged
Merged
Conversation
This was referenced Oct 6, 2026
Collaborator
Author
|
These commits cover the four review answers you approved:
🤖 Generated with Claude Code |
Export measures merge accuracy at 4, 16 and 64 shards as one --flat row per count; atomic-costs joins them by cell (--merge-accuracy) into a new AtomicCostEntry.merge_accuracy map, omitted when empty. Eligibility checks accuracy at L/x merged windows: the smallest measured count >= L/x, else the largest; one window or no measurements reads query_accuracy. Part of #147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eligibility now requires the metric to pass at both measured merge counts bracketing L/x (count 1 is query_accuracy), since error is not monotone in the count. Export measures 4..1024 shards and documents the fixed-total split. atomic-costs skips a row missing any merge count in the grid. Part of #147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…better bracket test - docs: eligibility rule 3 checks both bracketing merge counts; replace the single-instance accuracy TODO. - export: merge-accuracy passes score once, so --runs 1 --warmup-runs 0; note 1024 shards on 200k-row specs come out as 1021. - same_cell: note it has no comparator. - test: both brackets must clear a higher-is-better metric. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
rqe-cost-merge-accuracy
branch
from
October 6, 2026 20:49
2b63cc7 to
3234bd4
Compare
This was referenced Oct 6, 2026
zzylol
added a commit
that referenced
this pull request
Oct 6, 2026
Runner for ASAPQuery#777's comparison on main's planner: one metric per stream of the evaluation table, ASAP by milp::minimize, PerQuery by minimize per RQE, AutoSketch by autosketch::plan, all scored by analytical_cost_model::score (#145) at #777's weights (CPU only; Fargate $/vCPU-h and $/GB-h) and SLA grid {0.01, 0.1, 1, 10} ms and none. Each RQE's accuracy rides in the cost entries: acc@<id> (with merged values in merge_accuracy, #154) for ASAP, as@<id> for AutoSketch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #147 ("Accuracy at several merge counts").
Why
A query over lookback
Lserved by windows of sizexfoldsL/xwindow sketches. Before this PR the optimizer checked a candidate's accuracy against the single-instance score, measured on one sketch fed the whole stream. For sketches whose merge is lossy (KLL, the CMS/CountSketch top-k heaps, UnivMon), the folded result can be worse, so a candidate could be judged feasible when the query it serves is not. This decides feasibility, not just cost, so it matters most of the #147 items.What
scripts/export_rqe_optimizer_costs.shalso measures each row's accuracy after folding m shards, for m = 4, 16, 64, 256, 1024.AtomicCostEntrygainsmerge_accuracy: {m: scores}, using the same comparator keys asquery_accuracy.L/x.How
Measurement. For each row and each m, the script runs one
--operations merge --metrics accuracy --merge-shards mpass with--runs 1 --warmup-runs 0on the same data, seed and dtype as the cost pass. Each run is written as a--flatrow torqe_merge_accuracy_grid.jsonl. These rows stay out of the raw file becauseflattenkeeps one merge slot per cell, so different counts would collide.Fixed total. One stream is split m ways, so a larger m means smaller shards. That matches the optimizer's choice: for a fixed query
L, pickingxsplits the query's total overL/xwindows.Join.
atomic-costs --merge-accuracy FILEattaches each merge row to its cell withsame_cell(sketch, impl, config, workload; the identityflattengroups by).Feasibility.
accuracy_at(config, L/x)returns two score maps:L/x, with count 1 =query_accuracy;L/x, or the largest measured count beyond the grid.accuracy_ok_forrequires both to clear the SLA in the metric's own direction, because merge error is not monotone in m (see Evidence).is_eligiblepassesL/x.Compatibility.
merge_accuracyis#[serde(default)]and omitted when empty, so older tables still load and ASAPQuery's export, which doesn't measure it, is unchanged.Before this PR
query_accuracy, measured on one instance.is_eligiblechecked that value whatever the query'sL/x. WithL= 1 h andx= 15 s, the query folds 240 windows, yet a KLL candidate was judged on its unmerged rank error.After this PR
Each row carries, for example:
The optimizer checks
L/x= 1 againstquery_accuracy,L/x= 8 against counts 4 and 16,L/x= 240 against 64 and 256, and anything above 1024 against 1024.Evidence
Reduced end-to-end run of this branch (
--size 20000, runs 1; not the full export): 10 rows, 0 skipped, every row with all five counts. Score at each merge count:KLL is worst at m=16 and better again at 64. That is why one bracket alone isn't conservative and both are checked. At 20k items the shards are tiny, so the full export will give the real values.
Verification
merge_runs_attach_to_their_cell_by_merge_count: rows join by cell and count; other cells are ignored.two_merge_runs_at_one_count_skip_the_row: a duplicated export is refused.a_row_missing_a_grid_merge_count_is_skipped: a partial grid fails the "0 skipped" check.merge_accuracy_round_trips_and_is_omitted_when_empty: serde round trip; older tables and ASAPQuery's export are unchanged.accuracy_at_reads_both_measured_merge_counts_bracketing_the_query: brackets at 0, 1, 2, exact counts, between counts and beyond the grid.both_brackets_must_clear_a_higher_is_better_metric: precision at k with a bad count between two good ones.eligibility_checks_accuracy_at_the_queries_merge_count:is_eligibleusesL/x.cargo test --workspace(514 passed),cargo clippy --workspace --all-targets -- -D warnings.Architectural decisions
xfor a fixed query. How large the real totalλ·L/card(G)is belongs to the Tracking: make the rqe-optimizer cost export fit the per-phase cost model #147 size sweep.flattento keep several merge slots per cell.Limitations and follow-up
λ·L/card(G); the size sweep in Tracking: make the rqe-optimizer cost export fit the per-phase cost model #147 covers this.ceil(200000/1024)rows come out as 1021.same_cellhas no comparator. A cell scored by two comparators would be skipped loudly; no current row does that.Human review — do not complete with an agent
🤖 Generated with Claude Code