Repository navigation
Registration axis, and columns that depend on each other - #86
Open
GordonYuanyc wants to merge 11 commits into
Open
GordonYuanyc wants to merge 11 commits into
GordonYuanyc wants to merge 11 commits into
Conversation
…s score zero A depth-1 subset key is the bare label string, carrying nothing that says which column it came from, so two label columns drawing the same string put two populations in one grid cell. `hydra_columns.yaml` gave all three columns the default alphabet, and `keys` renders a rank through a fixed positional encoding, so key2's 50 labels were key1's first 50 exactly. The overlap was total, not occasional. Measured at rows=3 cols=1024 cell_rows=3 cell_cols=1024, that put the exact `polars` baselines at are_all 0.586 (hydra-cms), 0.249 (hydra-hll) and mean_rank_err 0.00080 (hydra-kll). All three are now exactly zero, and the sketches read 0.179, 0.207 and 0.00120. The two halves are the default alphabet cut in two, which leaves the prefix width at 2 for both columns and derives key length from the rank alone, so lengths and per-column distributions are unchanged. Only which characters appear moves. Two more examples, because one spec cannot show what varies: - `hydra_skewed_groups.yaml` skews the grouped column. Uniform groups all hold 1000 records, so ranking them by true count sorts sampling noise and the top-k prefixes name an arbitrary group. Skewed, hydra-cms reads are_top1 0.003, are_top10 0.030, are_top100 0.060, are_all 0.243, monotone in the prefix, which is what a working top-k ranking looks like. - `hydra_three_labels.yaml` adds a third label, so the fan-out goes from 3 subsets per record to 7. Its header states that the two comparisons want different controls: throughput wants matched grid size (both files at cols=1024 read 1.21M against 521k records/s, a ratio of 2.32 against a fan-out ratio of 7/3), and accuracy wants matched grid load (cols=6144 holds 9 keys per cell against the two-label file's 10). Refs #74. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…framework `sketch-bench` was both the framework a catalog is built from and one catalog built with it. A second bundle wanting to publish its own rows had to depend on `sketch-bench`, and so on `asap_sketchlib`, `sketch_oxide`, `datasketches` and `polars`, to reach a struct definition. Moved to `aqpbm-core::catalog`, none of which knows which sketches exist: `Row`, `Numeric`, `RunFn`, `Comparators`, `GroundTruthCalculator` and its eight impls, the four runners, the four constructors, and the eight lookups. Kept in `sketch-bench::catalog`, all of which does: `ROWS`, the fixed-matrix dispatch (it names `asap_sketchlib::MatrixStorage`), and `run_lib_hll` (it parses this bundle's `HllParams`). Three parts are not mechanical. The lookups take the table as an argument instead of reading a global, which is the whole of what makes a second bundle possible. `sketch-bench` binds its own `ROWS` into them in one line each, so `aqpbm-cli` is unchanged. `GroundTruthCalculator for TopkGT` read its `k` through `sketch-bench`'s `TopkParams`. `TopkGT` lives in core, so the orphan rule puts the impl there too, and a bundle's params vocabulary cannot follow it. It wanted one field, so `ParamSet::field::<T>(name)` is how a comparator in core asks for a knob without naming a family. `Row::run` and `Row::comparators` are now public. This is load-bearing, not scope creep: a bundle whose row type is selected by a construction parameter builds a `Row` directly and supplies a `run` the core cannot name, and with the fields closed it does not compile. It also settles a separate question, since how many comparators a row admits is now a property of the row rather than of which constructor built it: two is written as two entries, and no `scored2` constructor has to exist. Behaviour is unchanged. The 324-metric accuracy dump over three specs matches except for `hydra-kll/lib`, whose rank error moves run to run because the library's KLL compaction is unseeded. `--list-impls` is byte-identical, and the 202 workspace tests pass. Insert throughput was A/B'd because moving code across a crate boundary can change inlining. Six independent processes each side, hydra-cms: median 1,199,850 before against 1,177,437 after, ranges [1,165,461, 1,222,848] and [1,143,298, 1,197,284]. The ranges overlap and this machine's cross-process spread is around 5%, so the difference is not measurable, which is weaker than claiming there is none. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`frequency.rs`, `cardinality.rs` and `quantile.rs` hold one ground truth each. The three grouped ones shared a single 804-line `subpopulation.rs`, so the file was the odd one out and reading any one statistic meant skipping the other two. Split into a directory, not three flat files: `accuracy::subpopulation::` stays the path both call sites already import from, so `aqpbm-core/src/catalog.rs` and `sketch-bench/src/catalog.rs` are untouched. `mod.rs` keeps what all three use and nothing else — `subset_key`, `rank_and_shuffle`, `TOP_K_REPORTED`, `ErrSummary`, `score_counting_population`, `summarise`. A fourth grouped statistic reuses those and writes its own file. Dropped `DepthTwoFreqGT` and its two tests. It existed to show what replacing a shipped ground truth costs, but it could only ever compile inside this module — the `Truth` types have private fields, so the swap it demonstrated is not one another crate can perform. A demonstration that does not generalise is not one. Comments are cut hard throughout, from 804 lines to 589. What stayed is the part the code does not announce: that `subset_key` reproduces `Hydra::update`'s format and a truth built otherwise scores a key space the sketch does not have; which half of `rank_and_shuffle`'s pair is which; and four arithmetic decisions (ARE skipping zero truths, the `[lower, upper]` rank interval, the 101 points meaning into one member, `probes` counting members and not questions). Behaviour is unchanged — a pure move. 200 tests pass, against 202 before, the difference being the two deleted demo tests. `label_column: 0` is still frozen in `aqpbm-core/src/catalog.rs`; that is the next step, not this one. Refs #54. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ain is how a sketch gets a second one Scoring one sketch two ways was unreachable through the constructor API. A row held a *list* of comparators, but every producer emitted zero or one — `scored` takes one `G` — so two entries could only be written by hand, and a hand-written `Row` re-types the six fields its constructor would have projected. That is how `fixed_matrix_row` came to claim `scores_accuracy: true` beside `comparators: &[]`. The list is gone. A row carries one `ground_truth: Option<&str>`, and a second ground truth for a sketch is a second `scored::<S, G2>` line, which keeps every field derived. `scores_accuracy` follows from it and is now a method, so it cannot be set apart from what runs. `const NAME` moves off `GroundTruthCalculator<S>` onto its own non-generic `GroundTruthName`. That is what lets `fixed_matrix_row` name `FrequencyGT::NAME` without a storage type — it could not before, which is the whole reason it shipped an empty list while scoring with `FrequencyGT`. `--ground-truth frequency` now works on `cms-fastpath-fixedmatrix` as it already did on `cms`. Resolution collapses into the row lookup: `find` keys on all three, and the comparator-matching block inside `run` deletes. `None` takes the first row for the pair, so a caller that never heard of the axis keeps what it had. Records gained `ground_truth`, or two rows of one (sketch, impl) would be indistinguishable downstream. It is stamped inside `run_scored` from `G::NAME`, so it names the type that scored rather than the request that asked; additive and optional, so records written before it still read. `tests/two_ground_truths.rs` is the property, exercised: a toy sketch answering both cardinality and frequency, registered twice, selected by name, producing different metrics under different record labels. Declared in the test, so `aqpbm-core` still knows no concrete sketch. `--comparator` is renamed `--ground-truth`, and this is the one part not forced by the rest: the mechanism works either way. The old name described a sub-selector within a row, which no longer exists, so it named a mechanism the code had stopped having. It is a user-facing break and separable — whether it stays is still open. 206 tests pass, against 200 before, the six being the new file. The accuracy numbers are not A/B'd against the old binary; the claim of unchanged behaviour rests on the suite, which is weaker than this branch's earlier standard. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`catalog` named two different things and said what neither was. The bundle's file is a table of what can be measured; the core's is the definition of what goes in one. Both are now `registry.rs`, and `Row`/`ROWS` — a spreadsheet metaphor for something selected by `--algorithm/--impl/--ground-truth` — are `Registration`/`REGISTRY`. Three things moved out of files that had no business holding them. `GroundTruthName`, `GroundTruthCalculator` and their sixteen impls were the largest section of the core's catalog at 111 lines, and none of it is about what a table entry is. They are now `accuracy/calculator.rs`, next to the structs they name and build — which puts the three `label_column: 0` literals beside `SubpopFrequencyGT` itself, where a reader meets them. The fixed-matrix and `lg_k` dispatches were 134 lines of the bundle's 536, and both already reached into their wrappers for the hard part. They now live in `wrappers/fixed_matrix.rs` and `wrappers/hll.rs`. What is left is the table: 108 lines of `REGISTRY`, the lookups bound to it, and the tests. `FixedMatrixRow` became `FixedMatrixRegistration` and the two marker types lost their `Row` suffix, so the word is gone from the bundle. Every head-of-file comment over five lines is cut to five. Two facts would have been lost and moved instead of going: why the fixed-matrix shape grid has a corner missing (a 2 MiB test thread against a stack-materialised array) now sits above `fixed_matrix_shapes!`, where someone adding a shape reads it; and why the oxide KLL wrapper holds a `RefCell` now sits on the type that holds one. `aqpbm-cli` aliases `sketch_bench::registry as catalog` so its eight call sites read unchanged. That is a stopgap, not an oversight — the old word is still spelled at those sites. 206 tests pass, unchanged. `cms-fastpath-fixedmatrix` was run through the moved dispatch and reports `ground_truth: frequency`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`hydra.rs` held three sketches and `polars.rs` held nine, so `hydra-cms` was two files filed on two different axes: most wrapper files are one algorithm family across every library, but `polars.rs` was one library across eight algorithms. Nothing about `wrappers/` told a reader which axis they were navigating. Both are directories now, one file per registered row, each named for the single public type it declares. `hydra/cms.rs` would have read as the Count-Min family and collided with `wrappers/cms.rs`, so the files carry the full algorithm: `hydra/hydra_cms.rs`, `polars/polars_subpop_frequency.rs`. What stayed shared is what more than one file needs. `hydra/mod.rs` keeps `check_grid` and `grid_overhead_bytes`; `polars/mod.rs` keeps the two cores the newtypes delegate to, and `subset_key` / `fan_out`, which the three grouped rows share and nothing else uses. The old `polars.rs` header said these types were "Real `--impl` rows, not accuracy baselines", and the body called them baselines six times and built a correctness argument on it. The new header says what they are: exact, error ~0, and a non-zero error is a finding about the harness. Two section blocks are gone with it. `// statistic membership` and `// catalog identity` collected impls for the ungrouped types only, and `PolarsTopK` sat after both, so they described part of the file and not the rest. Each type's capability and `BenchImpl` impls now sit in its own file. The fourteen hydra tests split by which type they exercise — five, four and four — with `canonical_params_build` in `mod.rs`, since it checks all three. 206 tests pass, unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…baseline scores zero Two claims that were argued rather than checked. This checks both, as an integration test, so it sees only the public API — which is what a bundle author has. The depth-2 population is reachable from a bundle. `aqpbm-core` is not edited: the struct, the three impls and the two registration lines are all here, and everything numeric comes from core and is reused — `subset_key` for the key space, `rank_and_shuffle` for the ranking and probe order, `score_counting_population` for ARE, AAE, the norms, the prefixes and the percentile. The private fields on `SubpopFreqTruth` cost a three-field struct, not the ability, which is weaker than what I claimed for them. The exact baseline scores exactly 0.0 on `are_all`, `aae_all` and `l1_err`. No shipped row has that check, and its absence is why `28ef649` was found by a human reading a number: a key-space disagreement reads as sketch error, and at that time four fifths of hydra-cms's error was the key space. This pins it at depth 2, which also says the two sides agree about a subset key deeper than the one anything currently scores. The second registration is what `c4e6df1` bought. `PolarsSubpopFrequency` is already in `REGISTRY` under `subpop-frequency`; this registers it again under `subpop-frequency-depth2`. Before that commit the two would have collided on `(algorithm, impl)` and this file would not build. 208 tests pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…as a control All three `hydra-*/lib` rows fold; none of the three `polars` baselines did, so they fell to the `MergeUnsupported` default and the merge square ran for the sketch with nothing exact to check it against. Concatenating the buffers is the whole of it. `run_merge_pass` fills shards with `update` only, times `acc.merge(other)`, and calls `prepare` on the fold, so the DataFrame work runs once over the union and outside the timed section — the same split every polars row already uses for insert. Polars does have `DataFrame::vstack` and `extend`, and neither applies: these wrappers hold a `Vec`, not a DataFrame. The frame is built inside `prepare` and consumed into a map. Holding one as state would push its construction into `update`, which is what these rows exist not to do. A test each. Frequency checks the fold against the whole stream at depth 1, depth 2 and an absent group. Cardinality checks that a value present in both shards is counted once. Quantile splits evens from odds across the two shards, so a fold that concatenated the sorted runs instead of reordering them would fail. `merge_folds_per_sec` is **not** comparable across the pair, and nothing yet says so where a reader would meet it. The `lib` row folds grid state and scales with `rows * cols * cell_rows * cell_cols`; this one memcpys records and scales with the stream. Insert throughput already has that property for every polars row — what this buys is that the square runs and its accuracy has a fold that provably lost nothing, not a throughput race. 211 tests pass, from 208. On the shipped spec `hydra-cms/polars` now reports `merge_supported: true` and 258 folds/sec at four shards, where it previously reported no merge at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nothing exercised the grouped accuracy path. `every_registration_runs` covers every registration at `(insert, throughput)` only, so the subpopulation ground truths had no end-to-end test at all: no labelled workload, no probe sweep, no metrics read back. This runs all three through the shipped `REGISTRY` and asserts their exact `polars` halves score zero, which also pins the metric names — `are_all`, `aae_all`, `l1_err`, `l2_err`, `mean_rank_err`, `max_rank_err` — that downstream readers group on. The module header says what it does not catch, because I checked rather than assumed and it is less than the name suggests. A depth-1 subset key holds one label and no separator, so changing `subset_key` from `;` to `:` leaves every assertion here passing. `bundle_ground_truth.rs` is what fails on that edit, at `are_all = 1.0`, because its population is depth 2. Nor would this have caught `28ef649`. That aliasing needs the shipped 200/50 cardinalities; at the sizes here the rank encoding gives the two columns different key lengths, so a shared alphabet does not collide. Verified by dumping generated records, not reasoned about. Covering that class needs a test over `hydra_columns.yaml` at its real size. And no comparison against these baselines can see a ground truth scoring the wrong column, since they store every label subset and answer correctly for whichever one is asked. 214 tests pass, from 211. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…s what a spec makes
Every column was drawn independently and zipped positionally, so a table could
only ever express independent labels. Real label columns are usually not — a
city determines its country, a user their tenant — and for a grouped sketch that
is not a detail: it is the size of the key space it has to store.
A column may now declare `depends_on: <earlier index>`. Each distinct value of
the source is assigned one value from the dependent column's own draw, and every
row carrying that source gets it. Seeded from the dependent column's seed, so a
spec gives one table.
What it costs is in the code because it is not a free knob: the dependent column
keeps its domain — the assigned values come from its own pool — but not its
marginal distribution, which becomes the source's pushed through the map. A
forward or self reference is refused, which makes the pass single and a cycle
unwritable, and the value column is refused because it renders as `V` and has no
pool to be assigned from.
`configs/datagen/hydra_connected_columns.yaml` is `hydra_columns.yaml` with one
line added. Counted over both at 200,000 rows, not estimated:
independent connected
subset {0} 200 200
subset {1} 50 48
subset {0,1} 9,950 200
total keys 10,200 448
So a `hydra-*` row over it pays the same `2^d - 1` fan-out per record and stores
a twentieth of the keys. `{1}` reads 48 because 200 sources are assigned into a
50-value pool at random and two are never drawn; that is the assignment, not a
cap.
`workload head --spec <file> -n 10` renders the first rows as text and writes
nothing. It generates at the spec's own size and shows the head, because a
shrunk `size` would be a different workload rather than a preview of this one. A
connected column is marked in the header (`key1<-0`), since that is the one
thing about a column invisible in the data itself.
219 tests pass, from 214.
Co-Authored-By: Claude Opus 5 (1M context) <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.
What this is
Two things a subpopulation benchmark could not express, and the reorganisation that removing them touched.
A sketch could be registered against exactly one ground truth, and no amount of table-editing could change it. A table's columns were always drawn independently, so a spec could not say that one label determines another.
It does not fix #54.
label_column: 0is still the only population the shipped rows score. What changed is that reaching a second one is now a registration line rather than impossible —tests/bundle_ground_truth.rsis that, done, from outsideaqpbm-core.1. A registration is
(algorithm, impl, ground truth)Row.comparatorswas a list, but every producer emitted zero or one entry —scored<S, G>takes oneG. Two entries could only be written by hand, and a hand-writtenRowre-types the six fields its constructor would have projected. That is howfixed_matrix_rowcame to declarescores_accuracy: truebesidecomparators: &[], so--comparator frequencyworked oncmsand errored oncms-fastpath-fixedmatrix.Underneath it,
const NAMEsat onGroundTruthCalculator<S>, whose impl is coherence-unique. One ground-truth type therefore got exactly one name, permanently — which is why the depth-2 case had been stranded in a#[cfg(test)]block since before this branch.scored::<S, G2>line, and every field stays derived.const NAMEmoved to its own non-genericGroundTruthName, so a name can be read without a sketch type. That is what letsfixed_matrix_rowdeclareFrequencyGT::NAME— it could not before, which is the whole reason it shipped an empty list while scoring withFrequencyGT.ground_truth, stamped insiderun_scoredfromG::NAME, so it names the type that scored rather than the request that asked. Additive and optional; older records still parse.Side effect:
--ground-truth frequencynow works oncms-fastpath-fixedmatrix, which previously reported it admitted no comparator while scoring withFrequencyGT.2. A column can be a function of another
A column may declare
depends_on: <earlier index>. Each distinct value of the source is assigned one value from the dependent column's own draw, and every row carrying that source gets it.The dependent column keeps its domain but not its marginal distribution, which becomes the source's pushed through the map. Forward and self references are refused, so the pass is single and a cycle unwritable; the value column is refused because it renders as
Vand has no pool.configs/datagen/hydra_connected_columns.yamlishydra_columns.yamlplus one line. Counted over both at 200,000 rows, not estimated:A
hydra-*row over it pays the same2^d - 1fan-out per record and stores a twentieth of the keys — which is the comparison the file exists for.workload head --spec <file> -n 10renders a spec's first rows as text and writes nothing, marking a connected column in the header (key1<-0).3. Reorganisation
Row/ROWS→Registration/REGISTRY; bothcatalog.rs→registry.rs.accuracy/calculator.rs, beside the structs it configures.lg_kdispatches (134 lines) left the bundle's table for the wrappers they already called into.subpopulation.rs(804 lines, three ground truths) and the two wrapper files became directories, one file per thing, named for the type it holds.merge, so the merge square runs with a control. Notemerge_folds_per_secis not comparable across a lib/polars pair: one folds grid state, the other memcpys records.Tests
219, from 202 on
main. Two deleted (a test-only swap demo that could only compile inside its own module), nineteen added.Three worth knowing what they are and are not:
bundle_ground_truth.rs— the one with teeth. Registers a depth-2 ground truth from the bundle, and catches a key-space break: changingsubset_key's;to:fails it atare_all = 1.0.exact_baselines_score_zero.rs— weaker than its name. A depth-1 key holds no separator, so the same edit passes it. It also cannot see a ground truth scoring the wrong column, since these baselines store every subset. It would not have caught28ef649. What it does pin: all three grouped registrations run end to end, and the metric names downstream readers group on.Two things a reviewer should push back on if they disagree
--comparatoris renamed--ground-truth. A user-facing break, and the one part not forced by the rest — the mechanism works either way. Say the word and it reverts, or gets an alias.4c9e5c8is titled "current status for subpopulation ground truth: big mess" with an empty body, carrying a real 299-line refactor. Worth a message or a squash before merge.Not verified
The accuracy numbers were not A/B'd against the pre-branch binary. Every "behaviour unchanged" claim rests on the test suite, which is weaker than what
91a392adid for the same kind of claim (a 324-metric dump across three specs). Nothing here is on the insert path, so throughput was not re-measured.Still open after this
label_column: 0(#54) — a default, not a defect, and now changeable from a bundle. The subset key space has four spellings agreeing only by all writing;. The six ungroupedpolarsrows still have nomerge.dis not a record field.🤖 Generated with Claude Code