Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions crates/asap-aware-mapping/src/accuracy/budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ pub fn per_input_target(
metric: AccuracyMetric,
approximate_inputs: usize,
) -> Option<AccuracyTarget> {
if target.is_exact() || !(target.error.is_finite() && target.error > 0.0) {
if target.is_exact() || !(target.max_error.is_finite() && target.max_error > 0.0) {
return None;
}
let fraction = 1.0 / approximate_inputs.max(1) as f64;
let error = match metric {
AccuracyMetric::Relative => (1.0 + target.error).powf(fraction) - 1.0,
_ => target.error * fraction,
let max_error = match metric {
AccuracyMetric::Relative => (1.0 + target.max_error).powf(fraction) - 1.0,
_ => target.max_error * fraction,
};
Some(AccuracyTarget {
error,
max_error,
failure_probability: target.failure_probability.map(|delta| delta * fraction),
..target.clone()
})
Expand Down Expand Up @@ -70,7 +70,7 @@ mod tests {
2,
)
.unwrap();
assert!((share.error - 0.1).abs() < 1e-12);
assert!((share.max_error - 0.1).abs() < 1e-12);
}

/// No approximate input meets an exact target.
Expand Down
2 changes: 1 addition & 1 deletion crates/asap-aware-mapping/src/accuracy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl AccuracyModel for DefaultAccuracyModel {
.accuracy_metric
.is_none_or(|metric| metric_meets(guarantee.spec.accuracy_metric, metric))
&& scope_meets(guarantee, target)
&& within(guarantee.spec.error.evaluate(), target.error)
&& within(guarantee.spec.error.evaluate(), target.max_error)
&& target
.failure_probability
.is_none_or(|delta| within(guarantee.spec.failure_probability.evaluate(), delta))
Expand Down
13 changes: 7 additions & 6 deletions crates/asap-aware-mapping/src/pass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ impl PlanOutput {
nodes
}

/// The workload as one physical ASAP DAG, with shared sub-DAGs exported
/// once: operator queries become its `roots` and standalone scalar
/// The workload as one physical ASAP DAG, every node computed at query
/// time (the default [`MaterializationAssignment`]), with shared
/// sub-DAGs exported once: operator queries become its `roots` and standalone scalar
/// queries its `scalar_roots`, keyed by position in the batch. That
/// position is the entry index, because `check_contract` requires dense
/// entry indices.
Expand All @@ -272,7 +273,7 @@ impl PlanOutput {
/// ([`PhysicalASAPDAGValidationError::NoRoots`](asap_types::ir::physical_export::PhysicalASAPDAGValidationError::NoRoots)).
/// A workload of only literal scalars yields a DAG with no nodes: just
/// its `scalar_roots`.
pub fn execution_timed_dag(
pub fn physical_asap_dag(
&self,
) -> Result<asap_types::ir::physical_export::PhysicalASAPDAG, ExecutionDataStateError> {
// One memo, so a node several roots share by `Rc` is timed and exported once.
Expand Down Expand Up @@ -617,18 +618,18 @@ mod tests {
/// `InvalidPhysicalDAG`. A workload of only literal scalars exports a DAG
/// with no nodes, just its `scalar_roots`.
#[test]
fn execution_timed_dag_of_an_empty_and_a_literal_only_workload() {
fn physical_asap_dag_of_an_empty_and_a_literal_only_workload() {
use asap_types::ir::physical_export::PhysicalASAPDAGValidationError;
use asap_types::ir::ScalarExpr;
assert_eq!(
PlanOutput::new(Vec::new()).execution_timed_dag().err(),
PlanOutput::new(Vec::new()).physical_asap_dag().err(),
Some(ExecutionDataStateError::InvalidPhysicalDAG(
PhysicalASAPDAGValidationError::NoRoots
))
);
let mut literal = PlanOutput::new(Vec::new());
literal.scalar_roots = vec![(0, ScalarExpr::literal_f64(1.0))];
let dag = literal.execution_timed_dag().unwrap();
let dag = literal.physical_asap_dag().unwrap();
assert!(dag.nodes.is_empty() && dag.roots.is_empty());
let [(0, ScalarExpr::Literal(_))] = dag.scalar_roots.as_slice() else {
panic!("one literal scalar root: {:?}", dag.scalar_roots)
Expand Down
8 changes: 3 additions & 5 deletions crates/asap-aware-mapping/src/per_computation_candidates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ use crate::accuracy::estimators::{hll, univmon};
use crate::accuracy::{per_input_target, AccuracyModel, DefaultAccuracyModel, PropagationStats};
use crate::deployment_capabilities::DeploymentCapabilities;
use crate::function_rules::approximate_input_composition;
use crate::realization::{
accuracy_budget, accuracy_target, default_size_params, summary_candidates,
};
use crate::realization::{accuracy_budget, default_size_params, sizing_target, summary_candidates};

/// How one Pass 1 target is computed: exact or a summary.
///
Expand Down Expand Up @@ -456,7 +454,7 @@ pub fn computation_candidates_for_intent(
candidates: vec![exact],
pruned: vec![],
};
if let Some(target) = accuracy_target(intent) {
if let Some(target) = sizing_target(intent) {
if !target.is_exact() {
let (epsilon, delta) = accuracy_budget(&target);
let unit = |value: f64| value > 0.0 && value < 1.0;
Expand Down Expand Up @@ -3028,7 +3026,7 @@ impl Sizing {
/// requirement ([`per_input_target`]), split in the metric of the summary's own
/// bound: a relative error splits multiplicatively.
fn sized(algorithm: &SketchAlgorithm, intent: &AggIntent, share: usize) -> SketchKind {
let target = accuracy_target(intent).unwrap_or_else(AccuracyTarget::exact);
let target = sizing_target(intent).unwrap_or_else(AccuracyTarget::exact);
let size = |target: &AccuracyTarget| {
let (epsilon, delta) = accuracy_budget(target);
SketchKind::new(
Expand Down
6 changes: 3 additions & 3 deletions crates/asap-aware-mapping/src/realization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ pub fn summary_candidates(intent: &AggIntent) -> &'static [SketchAlgorithm] {

/// The [`AccuracyTarget`] an approximate-capable intent's summary is sized
/// and checked against, or `None` for every other intent (no sketch
/// candidate applies). It is the query's target restated in the intent's own metric
/// candidate applies): the query's target restated in the intent's own metric
/// (#690 §4): an L1-scaled absolute error for counts and top-k frequencies,
/// a relative error for distinct counts and L2 frequency moments, an
/// absolute error for entropy, and for a quantile the query's metric or a
/// rank error when none is set. The query's own metric, set or not, is
/// checked at its root in Stage 3.
pub fn accuracy_target(intent: &AggIntent) -> Option<AccuracyTarget> {
pub fn sizing_target(intent: &AggIntent) -> Option<AccuracyTarget> {
let (target, metric) = match intent {
AggIntent::Quantile { accuracy, .. } => (
accuracy,
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn accuracy_budget(accuracy: &AccuracyTarget) -> (f64, f64) {
return (f64::MIN_POSITIVE, DEFAULT_DELTA);
}
(
accuracy.error,
accuracy.max_error,
accuracy.failure_probability.unwrap_or(DEFAULT_DELTA),
)
}
Expand Down
Loading
Loading