Skip to content

rqe-optimizer: use merged accuracy curves for KLL and top-k #158

Closed

Description

@milindsrivastava1997

Problem

KLL and top-k lose accuracy when merged. The cost table's accuracy comes from a single, un-merged sketch (#147), so a deployment that answers an RAQE by merging m = T/x panes gets credit for accuracy it doesn't have.

#131 measured how much is lost:

  • KLL error rises 1.0–1.1× at k = 50/200 and 1.12–1.32× at k = 800 when panes are saturated, and up to 3–4× at small N.
  • Top-k loses up to 40% precision at large K.

#156 only rules out the small-pane case by requiring every pane to reach N_sat. The saturated merge penalty is still not modeled.

Proposal

For KLL and top-k deployments with m > 1, take the accuracy from the merged curves at m shards (#131), instead of the single-sketch value.

Open points

  • The merged curves cover m ≤ 64 and N ≤ 1e7. Decide what happens for m > 64: reject, extrapolate, or measure more points.
  • The merged curves aren't in the repo yet (clnode109/merge_out_merge_{topk,quantile}).

Related: #156, #131, #147. Reference: ASAPQuery docs/evaluation/autosketch-vs-planner.md, section "ASAPQuery: saturated values, because it merges".

Activity

  1. milindsrivastava1997 commented on Oct 7, 2026

    @milindsrivastava1997
    ContributorAuthor

    #154 (merged just before this issue was filed) covers the code side: AtomicCostEntry.merge_accuracy holds per-merge-count scores, and eligibility (accuracy_at in rqe-optimizer/src/lib.rs) checks the metric at both measured merge counts bracketing L/x. The export measures 4..1024 shards.

    Remaining points:

    1. No merge data in current cost tables. The latest export has no merge_accuracy on any row, so merged deployments still read single-sketch accuracy. We'll re-run the export scripts with the merge-accuracy pass.
    2. m above the largest measured count reuses the largest count's scores (flat extrapolation). That's fine as is.
    3. Measure accuracy after merging m shards #131 merged curves not in the repo. Not needed: re-running the scripts regenerates merge accuracy directly.

    🤖 Generated with Claude Code

  2. reopened this on Oct 7, 2026
  3. zzylol commented on Oct 7, 2026

    @zzylol
    Collaborator

    Reopening: since #171, SaturationCurves::accuracy reads every sketch's plain curve at the lookback's item count whatever the window, and nothing reads AtomicCostEntry.merge_accuracy for sketches any more (#178 removes it). So a KLL or top-k answer merged from L/x windows got the unmerged sketch's accuracy. The AutoSketch vs. ASAP evaluation is skewed by this, because AutoSketch never merges.

    Fix: SaturationCurves loads saturation_merge_curve.csv and reads it for KLL and top-k at m = L/x. Between measured shard counts it takes the worse one, and past the largest it uses the largest. With no merge curve there's no accuracy. Merge curves at m = 1, 4, 16, 64 up to N = 1e7 are being regenerated on clnode109 along with the #178 rerun.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions