-
Notifications
You must be signed in to change notification settings - Fork 369
Enable Miri tests in CI with non-blocking execution #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
adc532b
cd02489
3b7eeb7
b2b0400
e17c07f
f5f255b
1f8c1de
337a120
a54c9c1
7a97192
9e7d4ae
f288d34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -567,13 +567,23 @@ mod tests { | |
| #[test] | ||
| fn test_distances_in_place() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably skip this test entirely when running under |
||
| let mut rng = StdRng::seed_from_u64(0xece88a9c6cd86a8a); | ||
| #[cfg(not(miri))] | ||
| for ndata in 1..=31 { | ||
| for ncenters in 1..=5 { | ||
| for dim in 1..=4 { | ||
| test_distances_in_place_impl(ndata, ncenters, dim, TRIALS, &mut rng); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(miri)] | ||
| for ndata in 31..=31 { | ||
| for ncenters in 5..=5 { | ||
| for dim in 4..=4 { | ||
| test_distances_in_place_impl(ndata, ncenters, dim, TRIALS, &mut rng); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // We do not perform any value-dependent control-flow for memory accesses. | ||
|
|
@@ -605,13 +615,23 @@ mod tests { | |
| // | ||
| // Similarly, we need to ensure we have both an even and odd number of centers, | ||
| // so bound this up to 5. | ||
| #[cfg(not(miri))] | ||
| for ndata in 1..=35 { | ||
| for ncenters in 1..=5 { | ||
| for dim in 1..=4 { | ||
| test_miri_distances_in_place_impl(ndata, ncenters, dim); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(miri)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one we cannot short circuit with Miri. The |
||
| for ndata in 34..=35 { | ||
| for ncenters in 4..=5 { | ||
| for dim in 3..=4 { | ||
| test_miri_distances_in_place_impl(ndata, ncenters, dim); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // End-to-end test. | ||
|
|
@@ -719,13 +739,23 @@ mod tests { | |
| #[test] | ||
| fn end_to_end_test() { | ||
| let mut rng = StdRng::seed_from_u64(0xff22c38d0f0531bf); | ||
| #[cfg(not(miri))] | ||
| let setup = EndToEndSetup { | ||
| ncenters: 11, | ||
| ndim: 4, | ||
| data_per_center: 8, | ||
| step_between_clusters: 20, | ||
| ntrials: 10, | ||
| }; | ||
|
|
||
| #[cfg(miri)] | ||
| let setup = EndToEndSetup { | ||
| ncenters: 3, | ||
| ndim: 4, | ||
| data_per_center: 2, | ||
| step_between_clusters: 20, | ||
| ntrials: 2, | ||
| }; | ||
| end_to_end_test_impl(&setup, &mut rng); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,13 +417,17 @@ mod tests { | |
| // | ||
| // Subsampling results in poor preservation of inner products, so we skip it | ||
| // altogether. | ||
| #[cfg(not(miri))] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be tempted to say that we can skip all of |
||
| let subsampled_errors = test_utils::ErrorSetup { | ||
| norm: test_utils::Check::absrel(0.0, 2e-2), | ||
| l2: test_utils::Check::absrel(0.0, 2e-2), | ||
| ip: test_utils::Check::skip(), | ||
| }; | ||
|
|
||
| let target_dim = |v| TargetDim::Override(NonZeroUsize::new(v).unwrap()); | ||
|
|
||
| // Miri is extremely slow, so we skip the larger tests there. | ||
| #[cfg(not(miri))] | ||
| let dim_combos = [ | ||
| // Natural | ||
| (15, 15, true, TargetDim::Same, &natural_errors), | ||
|
|
@@ -441,9 +445,18 @@ mod tests { | |
| (1024, 1023, false, target_dim(1023), &subsampled_errors), | ||
| (1000, 999, false, target_dim(999), &subsampled_errors), | ||
| ]; | ||
| #[cfg(miri)] | ||
| let dim_combos = [(15, 15, true, target_dim(15), &natural_errors)]; | ||
|
|
||
| let trials_per_combo = 20; | ||
| let trials_per_dim = 100; | ||
| cfg_if::cfg_if! { | ||
| if #[cfg(miri)] { | ||
| let trials_per_combo = 1; | ||
| let trials_per_dim = 1; | ||
| } else { | ||
| let trials_per_combo = 20; | ||
| let trials_per_dim = 100; | ||
| } | ||
| } | ||
|
|
||
| let mut rng = StdRng::seed_from_u64(0x6d1699abe066147); | ||
| for (input, output, preserves_norms, target, errors) in dim_combos { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,6 +463,7 @@ mod tests { | |
| // | ||
| // Subsampling results in poor preservation of inner products, so we skip it | ||
| // altogether. | ||
| #[cfg(not(miri))] | ||
| let subsampled_errors = test_utils::ErrorSetup { | ||
| norm: test_utils::Check::absrel(0.0, 1e-1), | ||
| l2: test_utils::Check::absrel(0.0, 1e-1), | ||
|
|
@@ -471,6 +472,8 @@ mod tests { | |
|
|
||
| let target_dim = |v| TargetDim::Override(NonZeroUsize::new(v).unwrap()); | ||
|
|
||
| // Miri is extremely slow, so we skip the larger tests there. | ||
| #[cfg(not(miri))] | ||
| let dim_combos = [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with |
||
| // Natural | ||
| (15, 16, true, target_dim(16), &natural_errors), | ||
|
|
@@ -486,9 +489,18 @@ mod tests { | |
| (1000, 1000, false, TargetDim::Same, &subsampled_errors), | ||
| (500, 1000, false, target_dim(1000), &subsampled_errors), | ||
| ]; | ||
| #[cfg(miri)] | ||
| let dim_combos = [(15, 16, true, target_dim(16), &natural_errors)]; | ||
|
|
||
| let trials_per_combo = 20; | ||
| let trials_per_dim = 100; | ||
| cfg_if::cfg_if! { | ||
| if #[cfg(miri)] { | ||
| let trials_per_combo = 1; | ||
| let trials_per_dim = 1; | ||
| } else { | ||
| let trials_per_combo = 20; | ||
| let trials_per_dim = 100; | ||
| } | ||
| } | ||
|
|
||
| let mut rng = StdRng::seed_from_u64(0x6d1699abe0626147); | ||
| for (input, output, preserves_norms, target, errors) in dim_combos { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2003,6 +2003,12 @@ mod tests { | |
| let dist = Uniform::new_inclusive(min, max).unwrap(); | ||
|
|
||
| for dim in 0..dim_max { | ||
| // Only run the maximum dimension when running under miri. | ||
| #[cfg(miri)] | ||
| if dim != dim_max - 1 { | ||
| continue; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to be more careful about skipping values here. Unrolling in the distance kernel implementations means that there are a lot of corner cases that need checking which are not necessarily covered by a single test. An alternative is to have an audit and supply a list of specific dimensions to test. |
||
|
|
||
| let mut x_reference: Vec<u8> = vec![0; dim]; | ||
| let mut y_reference: Vec<u8> = vec![0; dim]; | ||
|
|
||
|
|
@@ -2092,7 +2098,7 @@ mod tests { | |
|
|
||
| cfg_if::cfg_if! { | ||
| if #[cfg(miri)] { | ||
| const MAX_DIM: usize = 128; | ||
| const MAX_DIM: usize = 8; | ||
| const TRIALS_PER_DIM: usize = 1; | ||
| } else { | ||
| const MAX_DIM: usize = 256; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1512,6 +1512,11 @@ mod tests { | |
| fn test_binary_dense() { | ||
| let mut rng = StdRng::seed_from_u64(0xb3c95e8e19d3842e); | ||
| for len in 0..MAX_DIM { | ||
| #[cfg(miri)] | ||
| if len != MAX_DIM - 1 { | ||
| continue; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests in |
||
|
|
||
| test_send_and_sync::<1, Binary, Dense>(); | ||
| test_empty::<1, Binary, Dense>(); | ||
| test_construction_errors::<1, Binary, Dense>(); | ||
|
|
@@ -1558,6 +1563,11 @@ mod tests { | |
| fn test_4bit_bit_transpose() { | ||
| let mut rng = StdRng::seed_from_u64(0xb3c95e8e19d3842e); | ||
| for len in 0..MAX_DIM { | ||
| #[cfg(miri)] | ||
| if len != MAX_DIM - 1 { | ||
| continue; | ||
| } | ||
|
|
||
| test_send_and_sync::<4, Unsigned, BitTranspose>(); | ||
| test_empty::<4, Unsigned, BitTranspose>(); | ||
| test_construction_errors::<4, Unsigned, BitTranspose>(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -475,6 +475,11 @@ mod minmax_quantizer_tests { | |
| let scales = [1.0, 1.1, 0.9]; | ||
| for (s, e) in scales.iter().zip($err) { | ||
| for d in 10..$dim { | ||
| #[cfg(miri)] | ||
| if d != $dim - 1 { | ||
| continue; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably skip the min-max quantizer tests under Miri. |
||
|
|
||
| for _ in 0..TRIALS { | ||
| test_quantizer_encoding_random::<$nbits>(d, &mut rng, e, *s); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,15 +752,21 @@ mod minmax_vector_tests { | |
| #[test] | ||
| fn $name() { | ||
| let mut rng = StdRng::seed_from_u64($seed); | ||
| for dim in 1..(bit_scale::<$nbits>() as usize) { | ||
| const MAX_DIM: usize = (bit_scale::<$nbits>() as usize); | ||
| for dim in 1..=MAX_DIM { | ||
| #[cfg(miri)] | ||
| if dim != MAX_DIM { | ||
| continue; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can almost skip the MinMax entirely under Miri because it does not run |
||
|
|
||
| for _ in 0..TRIALS { | ||
| test_minmax_compensated_vectors::<$nbits, _>(dim, &mut rng); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| test_minmax_compensated!(unsigned_minmax_compensated_test_u1, 1, 0xa32d5658097a1c35); | ||
| test_minmax_compensated!(unsigned_minmax_compensated_test_u1, 1, 0xa33d5658097a1c35); | ||
| test_minmax_compensated!(unsigned_minmax_compensated_test_u2, 2, 0xaedf3d2a223b7b77); | ||
| test_minmax_compensated!(unsigned_minmax_compensated_test_u4, 4, 0xf60c0c8d1aadc126); | ||
| test_minmax_compensated!(unsigned_minmax_compensated_test_u8, 8, 0x09fa14c42a9d7d98); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these bounds be set up with something like
and such to avoid the repitition?