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
4 changes: 2 additions & 2 deletions Cargo.lock

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

46 changes: 40 additions & 6 deletions crates/asap-aware-mapping/src/empirical_cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,10 @@ fn valid_params(algorithm: &SketchAlgorithm, params: &SketchParams) -> bool {
(SketchAlgorithm::DDSketch, SketchParams::DDSketch { alpha }) => {
alpha.is_finite() && *alpha > 0.0 && *alpha < 1.0
}
(SketchAlgorithm::Cms, SketchParams::Cms { width, depth })
| (SketchAlgorithm::CountSketch, SketchParams::CountSketch { width, depth }) => {
*width > 0 && *depth > 0
(SketchAlgorithm::Cms, SketchParams::Cms { width, depth }) => *width > 0 && *depth > 0,
// A CountSketch reads the median of its rows: the depth must be odd.
(SketchAlgorithm::CountSketch, SketchParams::CountSketch { width, depth }) => {
*width > 0 && depth % 2 == 1
}
(
SketchAlgorithm::CmsWithHeap,
Expand All @@ -383,15 +384,15 @@ fn valid_params(algorithm: &SketchAlgorithm, params: &SketchParams) -> bool {
depth,
heap_size,
},
)
| (
) => *width > 0 && *depth > 0 && *heap_size > 0,
(
SketchAlgorithm::CountSketchWithHeap,
SketchParams::CountSketchWithHeap {
width,
depth,
heap_size,
},
) => *width > 0 && *depth > 0 && *heap_size > 0,
) => *width > 0 && depth % 2 == 1 && *heap_size > 0,
_ => false,
}
}
Expand Down Expand Up @@ -692,4 +693,37 @@ mod tests {
Err(EvidenceError::Ambiguous)
);
}

/// A CountSketch reads the median of its rows, so evidence for an even
/// depth describes no executable shape.
#[test]
fn count_sketch_evidence_requires_an_odd_depth() {
for (depth, valid) in [(5, true), (4, false)] {
assert_eq!(
valid_params(
&SketchAlgorithm::CountSketch,
&SketchParams::CountSketch { width: 64, depth }
),
valid
);
assert_eq!(
valid_params(
&SketchAlgorithm::CountSketchWithHeap,
&SketchParams::CountSketchWithHeap {
width: 64,
depth,
heap_size: 8
}
),
valid
);
}
assert!(valid_params(
&SketchAlgorithm::Cms,
&SketchParams::Cms {
width: 64,
depth: 4
}
));
}
}
2 changes: 1 addition & 1 deletion crates/asap-physical-operators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
chrono = { version = "0.4.39", default-features = false, features = ["std"] }
futures = "0.3"
planner-types = { package = "asap-types", path = "../types" }
asap_sketchlib = { git = "https://github.com/ProjectASAP/asap_sketchlib", rev = "e6b03142628a3109b6482ebe8512bff7e75f5b35", features = ["experimental"] }
asap_sketchlib = { git = "https://github.com/ProjectASAP/asap_sketchlib", rev = "9415c5b161237ad238e101ed9166d4dbaace3031", features = ["experimental"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
tracing = "0.1"
Expand Down
7 changes: 4 additions & 3 deletions crates/asap-physical-operators/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ pub fn validate_summary_kernel(
}
(A::Hll, P::Hll { precision }) if (4..=18).contains(precision) => false,
(A::Kmv, P::Kmv { k }) if *k >= crate::summary_kernels::kmv::KMV_MIN_K => false,
(A::Cms, P::Cms { width, depth })
| (A::CountSketch, P::CountSketch { width, depth })
if valid_matrix(*width, *depth) =>
(A::Cms, P::Cms { width, depth }) if valid_matrix(*width, *depth) => true,
// The median needs an odd row count.
(A::CountSketch, P::CountSketch { width, depth })
if valid_matrix(*width, *depth) && depth % 2 == 1 =>
{
true
}
Expand Down
99 changes: 0 additions & 99 deletions crates/asap-physical-operators/src/summary_kernels/count_sketch.rs

This file was deleted.

Loading
Loading