Conversation
This was referenced Oct 3, 2026
zzylol
marked this pull request as draft
October 3, 2026 19:28
Contributor
Author
|
Parked as draft: PR priorities changed (see #528). Order is now (A) finish #511 operator sharing, (B) the #572 crate/module reorganization, (C) #509 end-to-end stages. This PR sits on the old 🤖 Generated with Claude Code |
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.
Problem: a plan with one shared UnivMon state cannot run on the native runtime
#509 Example 2 ("One summary for several computations — the summary-capability rule in Pass 2") selects one UnivMon build node feeding three estimation nodes: distinct count, entropy and L2 of
src_ip. #509 §Physical operator implementation then "converts every node to physical operators", for example "a KLL node as summary build, merge and quantile estimation operators". #509 §Scenarios, "Adding a new summary family", lists what a family must provide, including "6. Its physical kernel: build, merge and estimate". #509 §4 Execution says the deployment "runs the selected plan as given".The UnivMon kernel already existed and already answered these statistics (
summary_kernels/univmon.rs):But the native DAG gates did not let a UnivMon state in. Before this PR, in
capability.rs:Every native summary constructor calls this gate (
Operator::summary_build,summary_merge,evaluation, throughvalues::validate_family), and so doesBatch::try_newfor summary values. So the physical DAG for Example 2 failed at its first summary node:The precompute integration test also treated UnivMon as a family "without a native state" and expected its compile to fail.
Scope. This PR covers the physical part of #509 Example 2: native state validation and the native count, distinct, L2 and entropy evaluations for UnivMon. Planning the shared UnivMon candidate is #551. It does not add a UnivMon accuracy model or change planning.
Proposed method
All changes are in the physical runtime (
asap-physical-operators). No new operators or kernels.validate_native_familyaddsA::UnivMonto the families with a native DAG state. It still runsvalidate_summary_kernelafterwards, as for the other families. Because the build, merge and evaluation constructors all call this gate, a UnivMon state can now be built, merged and evaluated in aPhysicalDAG.validate_sketch_evaluationaccepts, for UnivMon, the four statistics the kernel answers: a barePointCount(value: None),Cardinality,FrequencyL2andFrequencyEntropy. Everything else (Quantile,TopK, aPointCountwithvalue: Some(..)) is still rejected with "evaluation is not implemented for this summary family". UnivMon results areFloat64; only CMS bare counts are typedInt64.values::validate_state(used byBatch::try_newwhen a row holds aValue::Summary) now downcasts a UnivMon state toUnivMonAccumulatorand requires its dimensions to equal the declaredSketchParams::UnivMon. A state with a different shape is rejected, as for KLL, DDSketch, HLL and CMS.Key code interfaces
Signatures are unchanged; the accepted sets grow.
crates/asap-physical-operators/src/capability.rs:crates/asap-physical-operators/src/values.rs(crate-private):Existing types these rely on (unchanged):
Usage, from the new test:
Fields
validate_native_family:family&SummaryFamilyTypeOkmeans the native runtime has a state for it. Now alsoOkforSketchwith algorithmUnivMon, providedvalidate_summary_kernelaccepts its parameters.validate_sketch_evaluation:family&SummaryFamilyTypevalidate_native_family.query&SketchStatisticSketchStatisticvariants accepted for UnivMon:PointCount { value: None, .. }calc_l1()Cardinalitycalc_card()FrequencyL2sqrt(Σ_v frequency(v)²)of the value frequencies.calc_l2()FrequencyEntropycalc_entropy()validate_state:family&SummaryFamilyTypestate&dyn AggregateCoreSketchParams::UnivMonfields and theUnivMonfields they must equal:UnivMonAccumulator::sketch())heap_sizeu32heap_sizesketch_rowsu32sketch_rowsketch_colsu32sketch_collayersu8layer_sizeUnivMonAccumulator::sketch()returns the wrappedasap_sketchlib::UnivMon; it is used here only to read those dimensions.Examples
One state, three evaluations
Test:
one_univmon_state_answers_distinct_l2_and_entropyincrates/asap-physical-operators/tests/univmon_execution.rs.Input. One batch with one non-null
Float64columnvalue:[1.0, 1.0, 2.0, 2.0, 2.0]. FamilySketch(UnivMon, { heap_size: 64, sketch_rows: 5, sketch_cols: 128, layers: 4 }), default grouping.DAG.
Executed with
dag.execute(&[2, 3, 4], ...)inScope::Query { evaluation_time_ms: 0, revision: 1 }. Node 1 is built once and read by all three evaluations.Output. Frequencies are
{1.0: 2, 2.0: 3}. The test checks:CardinalityFrequencyL2sqrt(2² + 3²) = sqrt(13)FrequencyEntropyresult > 0.0Accepted vs rejected
summary_build/summary_mergewith UnivMon familyevaluationUnivMon +Cardinality/FrequencyL2/FrequencyEntropyFloat64evaluationUnivMon + barePointCountFloat64evaluationUnivMon +Quantile { q }Batchrow with a UnivMon state whose dimensions differ fromSketchParams::UnivMonBatchrow with a matching UnivMon statePrecompute integration test
crates/integration-tests/tests/precompute_raw_samples.rsno longer lists UnivMon as a family without native state. A UnivMon raw-sample summary now goes through the compile-and-compare path: itsCardinality,FrequencyL2andFrequencyEntropyestimates are compared with the same kernel fed sample by sample. UnivMon is excluded from the keyed-heap per-item check, as HLL is.Out of scope
PointCountarm accepts anykeywithvalue: None. The kernel answers onlykey: ColumnRef::SampleValue; another key passes validation and fails at execution with "UnivMon does not answer".Stack and validation
Stack 10 · Base: #551 · Next: #553 · Closes #524.
Validation:
CARGO_TARGET_DIR=/mydata/cargo-target-412 cargo test --locked -p asap-physical-operators --test univmon_execution.🤖 Generated with Claude Code