Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6971255
refactor(planner): plan one shared unified workload DAG
zzylol Oct 12, 2026
f0afd89
feat(planner): plan and export standalone scalar queries
zzylol Oct 12, 2026
c44ecda
fix(planner): plan non-pass-through scalar references exact
zzylol Oct 12, 2026
4af7fb6
fix(planner): check scalar plans in the contract; remove dead code
zzylol Oct 12, 2026
033a3dc
fix(planner): lower scalar(v) in Project/Filter expressions as scalar…
zzylol Oct 12, 2026
1e91555
fix(planner): reuse a top-k only over the same partitions
zzylol Oct 12, 2026
aed3f18
refactor(planner): tell logical rewrites apart by provenance
zzylol Oct 12, 2026
8455331
fix(planner): return an error when search input already holds ASAP op…
zzylol Oct 12, 2026
1d6bb7c
fix(planner): walk operator nodes read by scalar expressions
zzylol Oct 12, 2026
a3dffa7
fix(ir): do not promote a filtered count ranking to a heavy-hitter TopK
zzylol Oct 12, 2026
8c194e0
Revert "fix(planner): plan non-pass-through scalar references exact"
zzylol Oct 13, 2026
12c1b24
fix(planner): rank top-k only when the Limit partitions like its Sort
zzylol Oct 13, 2026
46127fa
fix(ir): export one ScalarRef edge per distinct referenced node
zzylol Oct 13, 2026
bf1b5c7
test(planner): cover scalar inputs, top-k partitions, scalar plan con…
zzylol Oct 13, 2026
0a81ed0
test(planner): a difference of two scalar quantiles reads summaries
zzylol Oct 13, 2026
c5e9270
fix(planner): plan structurally identical scalar references once
zzylol Oct 13, 2026
353f813
test(planner): reject a per-job Limit over a global Sort; doc cleanups
zzylol Oct 13, 2026
8837667
fix(planner): read exact-state query roots through their finalize
zzylol Oct 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/asap-aware-mapping/src/accuracy/composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@ fn composed_provenance(
}

pub(super) fn exact_operation_rule(operation: &ExactOperation) -> Option<CompositionOperator> {
let ExactOperation::Aggregate { measures, .. } = operation else {
return None;
};
let ExactOperation::Aggregate { measures, .. } = operation;
match measures.as_slice() {
[intent] => crate::function_rules::function_rules(intent).map(|rules| rules.accuracy),
// The remaining functions are exact over exact samples, but have
Expand Down Expand Up @@ -1035,8 +1033,8 @@ mod tests {
reduction: asap_types::pre_asap::Reduction::PerEntity,
measures: vec![intent],
output_names: vec![],
having: None,
filters: vec![],
having: None,
};
assert_eq!(
DefaultAccuracyModel.exact_operation_rule(&operation(AggIntent::Rate)),
Expand Down
2 changes: 1 addition & 1 deletion crates/asap-aware-mapping/src/accuracy/estimators/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod tests {
}

#[test]
fn heap_readout_retains_frequency_metric() {
fn heap_evaluation_retains_frequency_metric() {
use asap_types::post_asap::{GroupingStrategy, SketchKind};
let cms_heap = SketchParams::CmsWithHeap {
width: 272,
Expand Down
8 changes: 4 additions & 4 deletions crates/asap-aware-mapping/src/accuracy/estimators/hll.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Estimator-specific confidence for classic HLL's linear-counting branch.
//!
//! This is conditional on independent uniform bucket hashes and an enforced
//! upper bound on distinct items in the complete readout population (including
//! upper bound on distinct items in the complete evaluation population (including
//! all merged panes). It is not an RSE-to-normal conversion or an ERP fit.

use super::*;
Expand Down Expand Up @@ -56,13 +56,13 @@ impl ClassicHllConfidence {
value: self.relative_error,
},
failure_probability: ProbabilityExpr::Constant { value: delta },
provenance: vec![GuaranteeSource::SketchReadout {
provenance: vec![GuaranteeSource::SketchEvaluation {
algorithm: "Hll".into(),
contract: "classic_hll_linear_counting_collision_bound_v1".into(),
params: serde_json::json!({"precision": precision,
"max_distinct": self.max_distinct, "relative_error": self.relative_error,
"hash_assumption": "independent_uniform_buckets",
"population_scope": "complete_readout_including_merged_panes"}),
"population_scope": "complete_evaluation_including_merged_panes"}),
query: "Cardinality".into(),
}],
})
Expand Down Expand Up @@ -187,7 +187,7 @@ mod tests {
}
}
}
/// The model's readout formula matches the actual classic estimator after merge.
/// The model's evaluation formula matches the actual classic estimator after merge.
#[test]
fn native_classic_estimator_and_merged_registers_use_the_same_contract() {
use asap_sketchlib::sketches::hll::{Classic, HyperLogLogP16};
Expand Down
2 changes: 1 addition & 1 deletion crates/asap-aware-mapping/src/accuracy/estimators/kll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mod tests {
assert_eq!(g.approximate_layer_count(), 1);
assert!(g.provenance.iter().any(|source| matches!(
source,
GuaranteeSource::SketchReadout { contract, .. }
GuaranteeSource::SketchEvaluation { contract, .. }
if contract == "apache_datasketches_kll_empirical_99_a9b42755072b"
)));
}
Expand Down
6 changes: 3 additions & 3 deletions crates/asap-aware-mapping/src/accuracy/estimators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn bounded_guarantee(
metric,
bound: BoundExpr::Constant { value: bound },
failure_probability: delta,
provenance: vec![GuaranteeSource::SketchReadout {
provenance: vec![GuaranteeSource::SketchEvaluation {
algorithm: format!("{algorithm:?}"),
contract: contract.into(),
params: serde_json::to_value(params).unwrap_or(serde_json::Value::Null),
Expand Down Expand Up @@ -169,9 +169,9 @@ impl<'a> EstimatorAccuracy<'a> {

fn hll(&self) -> Option<hll::ClassicHllConfidence> {
let EstimatorContract::ClassicHll {
max_distinct_per_readout,
max_distinct_per_evaluation,
} = self.contract?;
hll::ClassicHllConfidence::new(max_distinct_per_readout, self.epsilon)
hll::ClassicHllConfidence::new(max_distinct_per_evaluation, self.epsilon)
}

pub(crate) fn size_params(&self, algorithm: &SketchAlgorithm) -> Option<SketchParams> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! UnivMon currently certifies only its exact unit-update total readout.
//! UnivMon currently certifies only its exact unit-update total evaluation.
use super::*;

pub(super) fn guarantee(query: &SketchStatistic) -> Option<ResultGuarantee> {
Expand Down
25 changes: 8 additions & 17 deletions crates/asap-aware-mapping/src/accuracy/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
use super::*;

/// A trusted source assertion scoped by `AccuracyEvidenceProvider` to one
/// complete readout. Choosing this variant asserts the estimator and hash
/// complete evaluation. Choosing this variant asserts the estimator and hash
/// assumptions; it must not be inferred from sampled population statistics.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EstimatorContract {
/// Classic HLL with independent uniform bucket hashing, including merged panes.
ClassicHll { max_distinct_per_readout: u32 },
ClassicHll { max_distinct_per_evaluation: u32 },
}

/// An enforced domain for every sample of a direct quantile operand, in every
Expand All @@ -18,7 +18,7 @@ pub enum EstimatorContract {
pub struct QuantileInputDomain {
pub lower: f64,
pub upper: f64,
/// Upper bound on samples per evaluation, matching the pinned readout's
/// Upper bound on samples per evaluation, matching the pinned evaluation's
/// exact Float64 rank limit. The population must also be nonempty.
pub max_samples: u64,
pub contract: String,
Expand Down Expand Up @@ -87,31 +87,22 @@ pub struct PropagationStats {
/// Supplies typed planning-time evidence required by propagation rules.
pub trait AccuracyEvidenceProvider {
/// Trusted estimator contract for this complete aggregate expression,
/// including source, filters, grouping and all panes in each readout.
/// including source, filters, grouping and all panes in each evaluation.
/// An observed cardinality is not an enforced population bound.
fn estimator_contract(
&self,
_expression: &asap_types::pre_asap::QueryExpr,
) -> Option<EstimatorContract> {
fn estimator_contract(&self, _expression: &OperatorNode) -> Option<EstimatorContract> {
None
}

/// Enforced upper bound on distinct (partition, item) identities across a
/// complete TopK readout. Used to union-bound score errors for adaptively
/// complete TopK evaluation. Used to union-bound score errors for adaptively
/// selected candidates. Observed cardinality is not sufficient evidence.
fn topk_max_distinct_items(
&self,
_expression: &asap_types::pre_asap::QueryExpr,
) -> Option<u64> {
fn topk_max_distinct_items(&self, _expression: &OperatorNode) -> Option<u64> {
None
}

/// Proof scoped to this complete quantile expression, including its source,
/// filters, grouping and window. `None` means unknown, including emptiness.
fn quantile_input_domain(
&self,
_operand: &asap_types::pre_asap::query_expr::QueryExpr,
) -> Option<QuantileInputDomain> {
fn quantile_input_domain(&self, _operand: &OperatorNode) -> Option<QuantileInputDomain> {
None
}

Expand Down
12 changes: 7 additions & 5 deletions crates/asap-aware-mapping/src/accuracy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ pub use evidence::{
QuantileInputDomain, WorkloadAccuracyEvidence,
};

use asap_types::ir::OperatorNode;
use asap_types::post_asap::{
AccuracyError, BoundExpr, CompositionOperator, ErrorMetric, ExactOperation, FieldDataType,
GuaranteeSource, ProbabilityExpr, ResultGuarantee, SketchAlgorithm, SketchParams,
SketchStatistic,
AccuracyError, BoundExpr, CompositionOperator, ErrorMetric, FieldDataType, GuaranteeSource,
ProbabilityExpr, ResultGuarantee, SketchAlgorithm, SketchParams, SketchStatistic,
};
use asap_types::types::AccuracyTarget;

use crate::exact_composition::ExactOperation;

/// The deployment-extensible accuracy algebra. `asap-aware-mapping` ships
/// [`DefaultAccuracyModel`]; a deployment with a proof for a composition the
/// default rejects (a registered cross-metric conversion, say) implements
/// this trait and passes it to
/// [`crate::replacement::SketchAlgorithmStrategy::new_with_planning_inputs`].
/// [`crate::replacement::ASAPStrategies::new_with_planning_inputs`].
pub trait AccuracyModel {
/// The definition-registered rule for applying `operation` to an
/// approximate input. `None` means the function is exact only over exact
Expand Down Expand Up @@ -78,7 +80,7 @@ pub struct DefaultAccuracyModel;
const SATISFACTION_TOLERANCE: f64 = 1e-9;

impl DefaultAccuracyModel {
/// Derive the guarantee for the committed estimator parameters and readout.
/// Derive the guarantee for the committed estimator parameters and evaluation.
pub fn sketch_guarantee(
algorithm: &SketchAlgorithm,
params: &SketchParams,
Expand Down
Loading
Loading