Repository navigation
hydra: KLL CDF and UnivMon sum rows; KLL cell merge buffer in the footprint - #200
Merged
Merged
Conversation
zzylol
force-pushed
the
hydra/more-statistics
branch
from
October 10, 2026 04:50
3966bdb to
2ba16fb
Compare
This was referenced Oct 10, 2026
Every hydra-* row (lib and polars, all five variants and hydra-univmon's four statistics) takes `--group-columns J,K,...` (default `0`, today's behavior) in place of the hardcoded SCORED_LABEL_COLUMN. A subpopulation probe is now positioned (`Vec<Option<String>>`, Some at the grouped columns), so `hydra_shared::query` asks any non-empty subset of the key columns and the polars baselines look up `subset_key` with that subset's mask (`group_key`, generalizing `prefix_key`). Each grouped comparator reports its per-group error in its own metric (relative error; mean rank error for hydra-kll) and summarises it as err_mean, err_p50, err_p90, err_max, groups_scored, plus schema_width, records and fanned_mass. `--per-group-out PATH` writes the rows as `group_key,n_q,error`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
…curacy - Group keys escape `\`, `:` and `;` as polars_shared::subset_key does. - Groups that cannot be scored (zero true statistic, e.g. zero entropy) are written with an empty `error`, so n_q sums to the stream's records. - --per-group-out with no accuracy measurement is refused instead of writing an empty file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
- hydra-kll-cdf (lib, polars): asks the KLL grid HydraQuery::Cdf(x) at each group's own values at phi = 0.01..0.99, scored by absolute CDF error (SubpopCdfErrorGT, comparator subpop-cdf-error). The polars baseline is the exact share at or below x over the same sorted groups. - hydra-univmon-sum (lib, polars): each record inserted with count = value, so the UnivMon grid's L1 is the group's sum, scored by relative error against exact per-group sums (SubpopSumGT, comparator subpop-sum). Integer value dtypes only; f64/str and values outside [0, i32::MAX] are refused by name. - memory_hydra_kll counts each cell as kll_lib_bytes does, merge buffer of cell_k items included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
The grid clones its cells from one template, and a cloned Vec keeps no capacity, so a cell's merge buffer is empty at build and grows to about cell_k items at its first compaction. Say the footprint counts it at that bound. The CDF test now asks a group of ties (at or below) and a mixed-tie group on a grid wide enough that it shares no cell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
The lib row inserts each value as a UnivMon count and refuses negatives; the truth (and so the polars baseline) accepted them, so a spec with negatives ran on polars and failed on lib. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis
zzylol
force-pushed
the
hydra/more-statistics
branch
from
October 11, 2026 16:36
00337aa to
6253698
Compare
zzylol
force-pushed
the
hydra/target-grouping
branch
from
October 11, 2026 16:36
8f73ed3 to
bc770e3
Compare
# Conflicts: # README.md # aqpbm-cli/src/rows/mod.rs # aqpbm-cli/src/rows/statistic.rs # aqpbm-cli/tests/hydra_grouping.rs # aqpbm-core/src/accuracy/subpopulation/frequency_vector.rs # aqpbm-core/src/accuracy/subpopulation/rank_error.rs # sketch-bench/src/wrappers/hydra_univmon/sketchlib.rs
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.
PR 5 of the Hydra implementation spec, stacked on #199 (
hydra/target-grouping).What changed
hydra-kll-cdf(lib,polars): new variant, registered the same way thehydra-univmon-*rows register one row per statistic. It asks the KLL gridHydraQuery::Cdf(x)per subpopulation. The thresholdsxare the group's own values at φ = 0.01..0.99 (99 points, indexfloor(φ·n)). It is scored by absolute CDF error|F̂_q(x) − F_q(x)|through a new comparator,SubpopCdfErrorGT(subpop-cdf-error, capabilitysubpop-cdf), which reuses the rank-error truth (sorted values per group). Thepolarsbaseline takes the exact share at or belowxover the same sorted groups. Per-group output from hydra: score any target grouping; per-group error output #199 (err_*,groups_scored,--per-group-out) applies.hydra-univmon-sum(lib,polars): each record is inserted withcount = Some(value)(newhydra_shared::update_counted), so the UnivMon grid's L1 is the group's sum. It is scored by relative error against exact per-group sums: newSubpopSumGT(subpop-sum), and thepolarsbaseline isgroup_by(subset).agg(v.sum()). It builds at i64/u64 only.--dtype f64orstris refused by name, and so is a value outside[0, i32::MAX](the library's weight is ani32). The univmon drivers now take afeedfn so counted and weighted inserts share one code path.memory_hydra_kllnow useskll_lib_bytes::<f64>(cell_k)per cell, so each cell's merge buffer ofcell_kitems is counted, as it is for thekll-*lib rows. Atrows=3 cols=1024 cell_k=200this moves the footprint from 26,984,704 to 31,899,904 bytes (+1,600 B per cell).docs/concepts.mdcapabilities, and the hydra datagen yaml headers.Not done: hydra-hll
cell_lg_kasap_sketchlib 0.3.0 defines
HydraCounter::HLL(HyperLogLog<ErtlMLE>), andHyperLogLogis an alias forHyperLogLogP14. P12 and P16 exist as standalone types but can't go in a Hydra cell (this is true of every sketchlib checkout I have too). A cell lg_k sweep needs an upstream change (a generic HLL cell), so it is out of scope here. hydra-hll stays at P14.Tests (each checked by mutation)
aqpbm-core: sum truth adds the values (40/90 on the fixture,n_q= records), refuses an f64 value column by type; the CDF truth counts ties at or below (F_a(10) = 2/3), the exact answer scores 0, a zero answer misses by the share.sketch-bench: KLL footprint is hand-derived as(1004 + 200)·8 + 62·8per cell (fails without the buffer). The libCdfbelow k is exact inside the group (fails if asked asQuantile). The polars CDF baseline gives the share at or below (fails with<). Weighted L1 equals the exact sums (45, 7, 42) on a non-colliding 3×1024 grid (fails if inserted unweighted). Valuesi32::MAX+1and-1are refused by name. The polars sum baseline answers 40/30.aqpbm-cli/tests/hydra_grouping.rs:hydra-kll-cdfandhydra-univmon-sumwere added to the any-subset test (polarserr_max = 0, lib≤ 0.01on a big grid, for groupings1and0,1). A new test checks that--dtype f64is refused by name at lib and polars.cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo test --workspace: clean.Evidence (release build,
--operations query --metrics accuracy,memory --runs 1)hydra-kll-cdf,configs/datagen/hydra_columns_f64.yaml(200k rows),rows=3 cols=1024 cell_k=200:00,1hydra-univmon-sum,configs/datagen/hydra_columns.yaml(200k rows),rows=3 cols=1024 cell_heap_size=64 cell_sketch_row=3 cell_sketch_col=256 cell_layer_size=4(relative error):00,1For comparison, the unweighted
hydra-univmon-l1-normat the same config with0gives err_mean 0.330 and err_max 1.96. At0,1, about 10.2k subkeys per row land in 1,024 columns, so small groups take collision mass from heavy ones. That is the saturation the study (PR 6) maps; the exactness test above shows the rule holds on a grid without collisions.--dtype f64→hydra-univmon-sum/lib counts each value by itself, an integer weight, so builds at i64 or u64; --dtype f64 is not an integer.🤖 Generated with Claude Code
https://claude.ai/code/session_01FhcWJExZcmVqS6r6rEtjis