Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
adc532b
Initial plan
Copilot Jan 20, 2026
cd02489
Enable Miri tests in CI with continue-on-error and time reporting
Copilot Jan 20, 2026
3b7eeb7
Fix bash flags to allow proper error handling in Miri tests
Copilot Jan 20, 2026
b2b0400
Use set -ux for consistent error handling with || true
Copilot Jan 20, 2026
e17c07f
Simplify Miri command to use original syntax without time measurement
Copilot Jan 20, 2026
f5f255b
Fix unused imports
Jan 23, 2026
1f8c1de
Adjust the safety comment
Jan 23, 2026
337a120
Speed up miri tests
Jan 23, 2026
a54c9c1
Speed up miri tests
Jan 23, 2026
7a97192
Optimizing more tests for miri
Jan 23, 2026
9e7d4ae
Fixing unsigned_minmax_compensated_test_u1 test
Jan 23, 2026
f288d34
More test optimizations
Jan 23, 2026
56e0605
Merge branch 'main' into copilot/enable-miri-tests-ci-yml
Jan 24, 2026
7bc3e20
Disable test_double_hadamard and test_padding_hadamard for miri, reve…
Copilot Jan 24, 2026
0833183
Disable test_distances_in_place and minmax_quantizer_tests for miri, …
Copilot Jan 24, 2026
bf86fef
Revert miri-specific loop skip in minmax vectors, disable minmax_vect…
Copilot Jan 24, 2026
5a9dc32
Use #[cfg(not(miri))] instead of #[cfg_attr(miri, ignore)] for test_d…
Copilot Jan 26, 2026
a9cdeb7
Minor clean-up
Jan 26, 2026
399c945
Fixing unused code
Jan 26, 2026
f20fa83
Addressed comments
Jan 26, 2026
90d61f9
Experiment with gh pools
Jan 26, 2026
993716e
Revert "Experiment with gh pools"
Jan 26, 2026
b058217
Run Miri after PR merge only
Jan 27, 2026
caae08e
Merge branch 'main' into copilot/enable-miri-tests-ci-yml
Jan 27, 2026
4fb0297
Merge branch 'main' into copilot/enable-miri-tests-ci-yml
Jan 27, 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
48 changes: 26 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,32 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# miri:
# needs: basics
# name: miri-test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# lfs: true
miri:
needs: basics
name: miri-test
# This step is slow, so it only runs after a PR merge to avoid slowing down pre-merge checks.
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
lfs: true

# - name: Install Rust nightly with miri
# uses: dtolnay/rust-toolchain@stable
# with:
# toolchain: nightly
# components: miri
- name: Install Rust nightly with miri
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: miri

# - name: Install cargo-nextest
# uses: taiki-e/install-action@v2
# with:
# tool: cargo-nextest
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

# - uses: Swatinem/rust-cache@v2
# - name: miri
# run: cargo +nightly miri nextest run --package diskann-quantization
# env:
# MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
- uses: Swatinem/rust-cache@v2

- name: miri
run: cargo +nightly miri nextest run --package diskann-quantization
env:
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
14 changes: 9 additions & 5 deletions diskann-quantization/src/algorithms/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,15 @@ mod tests {
// Heap of size 2.
fuzz_test_impl(2, 101, &mut rng);

// Heap size not power of two.
fuzz_test_impl(1000, 1000, &mut rng);

// Heap size power of two.
fuzz_test_impl(128, 1000, &mut rng);
// Miri is extremely slow, so we skip the larger tests there.
#[cfg(not(miri))]
{
// Heap size not power of two.
fuzz_test_impl(1000, 1000, &mut rng);

// Heap size power of two.
fuzz_test_impl(128, 1000, &mut rng);
}
}

#[test]
Expand Down
14 changes: 10 additions & 4 deletions diskann-quantization/src/algorithms/kmeans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,23 @@ mod tests {

#[test]
fn test_block_transpose_16() {
for nrows in 0..128 {
for ncols in 0..5 {
let row_range = if cfg!(miri) { 127..128 } else { 0..128 };
let column_range = if cfg!(miri) { 4..5 } else { 0..5 };

for nrows in row_range {
for ncols in column_range.clone() {
test_block_transpose::<16>(nrows, ncols);
}
}
}

#[test]
fn test_block_transpose_8() {
for nrows in 0..128 {
for ncols in 0..5 {
let row_range = if cfg!(miri) { 127..128 } else { 0..128 };
let column_range = if cfg!(miri) { 4..5 } else { 0..5 };

for nrows in row_range {
for ncols in column_range.clone() {
test_block_transpose::<8>(nrows, ncols);
}
}
Expand Down
48 changes: 28 additions & 20 deletions diskann-quantization/src/algorithms/kmeans/lloyds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,15 @@ pub fn lloyds(

#[cfg(test)]
mod tests {
use diskann_utils::{lazy_format, views::Matrix};
#[cfg(not(miri))]
use diskann_utils::lazy_format;
use diskann_utils::views::Matrix;
use diskann_vector::{distance::SquaredL2, PureDistanceFunction};
use rand::{
distr::{Distribution, Uniform},
rngs::StdRng,
seq::{IndexedRandom, SliceRandom},
Rng, SeedableRng,
};
#[cfg(not(miri))]
use rand::distr::{Distribution, Uniform};
#[cfg(not(miri))]
use rand::seq::IndexedRandom;
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};

use super::*;

Expand All @@ -477,6 +478,7 @@ mod tests {
// relatively quickly.
//
// Outside of rare validations, Miri tests go through a different path for speed purposes.
#[cfg(not(miri))]
fn test_distances_in_place_impl<R: Rng>(
ndata: usize,
ncenters: usize,
Expand Down Expand Up @@ -556,15 +558,11 @@ mod tests {
}
}

cfg_if::cfg_if! {
if #[cfg(miri)] {
const TRIALS: usize = 1;
} else {
const TRIALS: usize = 100;
}
}
#[cfg(not(miri))]
const TRIALS: usize = 100;

#[test]
#[cfg(not(miri))]
fn test_distances_in_place() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably skip this test entirely when running under miri. There is a dedicated Miri test just after this that validates the indexing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, disable test_distances_in_place() test for miri. revert the changes made in this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled test_distances_in_place for miri and reverted changes. Commit: 0833183

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, Use #[cfg(not(miri))] instead of #[cfg_attr(miri, ignore)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use #[cfg(not(miri))] for conditional compilation. Commit: 5a9dc32

let mut rng = StdRng::seed_from_u64(0xece88a9c6cd86a8a);
for ndata in 1..=31 {
Expand Down Expand Up @@ -719,12 +717,22 @@ mod tests {
#[test]
fn end_to_end_test() {
let mut rng = StdRng::seed_from_u64(0xff22c38d0f0531bf);
let setup = EndToEndSetup {
ncenters: 11,
ndim: 4,
data_per_center: 8,
step_between_clusters: 20,
ntrials: 10,
let setup = if cfg!(miri) {
EndToEndSetup {
ncenters: 3,
ndim: 4,
data_per_center: 2,
step_between_clusters: 20,
ntrials: 2,
}
} else {
EndToEndSetup {
ncenters: 11,
ndim: 4,
data_per_center: 8,
step_between_clusters: 20,
ntrials: 10,
}
};
end_to_end_test_impl(&setup, &mut rng);
}
Expand Down
7 changes: 7 additions & 0 deletions diskann-quantization/src/algorithms/kmeans/plusplus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ mod tests {
fn test_update_distances() {
let mut rng = StdRng::seed_from_u64(0x56c94b53c73e4fd9);
for num_points in 0..48 {
#[cfg(miri)]
if num_points % 7 != 0 {
continue;
}

for dim in 1..4 {
test_update_distances_impl(num_points, dim, &mut rng);
}
Expand All @@ -695,6 +700,7 @@ mod tests {

// Kmeans++ sanity checks - if there are only `N` distinct and we want `N` centers,
// then all `N` should be selected without repeats.
#[cfg(not(miri))]
fn sanity_check_impl<R: Rng>(ncenters: usize, dim: usize, rng: &mut R) {
let repeats_per_center = 3;
let context = lazy_format!(
Expand Down Expand Up @@ -756,6 +762,7 @@ mod tests {

// This test is like the sanity check - but instead of exact repeats, we use slightly
// perturbed values to test that the proportionality is of distances is respected.
#[cfg(not(miri))]
fn fuzzy_sanity_check_impl<R: Rng>(ncenters: usize, dim: usize, rng: &mut R) {
let repeats_per_center = 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ where
///////////

#[cfg(test)]
#[cfg(not(miri))]
mod tests {
use diskann_utils::lazy_format;
use rand::{rngs::StdRng, SeedableRng};
Expand Down
2 changes: 2 additions & 0 deletions diskann-quantization/src/algorithms/transforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ crate::utils::features! {
mod utils;

#[cfg(test)]
#[cfg(not(miri))]
mod test_utils;

// reexports
Expand Down Expand Up @@ -355,4 +356,5 @@ pub enum TargetDim {
}

#[cfg(test)]
#[cfg(not(miri))]
test_utils::delegate_transformer!(Transform<crate::alloc::GlobalAllocator>);
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,15 @@ where

#[cfg(test)]
mod tests {
#[cfg(not(miri))]
use diskann_utils::lazy_format;
use rand::{rngs::StdRng, SeedableRng};

use super::*;
use crate::{
algorithms::transforms::{test_utils, Transform, TransformKind},
alloc::GlobalAllocator,
};

#[cfg(not(miri))]
use crate::algorithms::transforms::{test_utils, Transform, TransformKind};
use crate::alloc::GlobalAllocator;

// Since we use a slightly non-obvious strategy for applying the +/-1 permutation, we
// test its behavior explicitly.
Expand Down Expand Up @@ -441,11 +442,13 @@ mod tests {
assert_eq!(output[15], 0.0f32);
}

#[cfg(not(miri))]
test_utils::delegate_transformer!(PaddingHadamard<GlobalAllocator>);

// This tests the natural hadamard transform where the output dimension is upgraded
// to the next power of 2.
#[test]
#[cfg(not(miri))]
fn test_padding_hadamard() {
// Inner product computations are more susceptible to floating point error.
// Instead of using ULP here, we fall back to using absolute and relative error.
Expand Down
8 changes: 7 additions & 1 deletion diskann-quantization/src/algorithms/transforms/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ fn within_ulp(mut got: f32, expected: f32, ulp: usize) -> bool {
#[derive(Debug, Clone, Copy)]
pub(super) enum Check {
Ulp(usize),
AbsRel { abs: f32, rel: f32 },
AbsRel {
abs: f32,
rel: f32,
},
#[cfg(not(miri))]
Skip,
}

Expand All @@ -185,6 +189,7 @@ impl Check {
Self::AbsRel { abs, rel }
}

#[cfg(not(miri))]
pub(super) fn skip() -> Self {
Self::Skip
}
Expand Down Expand Up @@ -219,6 +224,7 @@ impl Check {
})
}
}
#[cfg(not(miri))]
Self::Skip => Ok(()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion diskann-quantization/src/bits/distances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,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;
Expand Down
1 change: 1 addition & 0 deletions diskann-quantization/src/minmax/quantizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ impl_functor!(MinMaxCosineNormalized);
// Tests //
///////////
#[cfg(test)]
#[cfg(not(miri))]
mod minmax_quantizer_tests {
use std::num::NonZeroUsize;

Expand Down
6 changes: 4 additions & 2 deletions diskann-quantization/src/minmax/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ where
///////////

#[cfg(test)]
#[cfg(not(miri))]
mod minmax_vector_tests {
use diskann_utils::Reborrow;
use rand::{
Expand Down Expand Up @@ -752,15 +753,16 @@ 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 {
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);
Expand Down
8 changes: 6 additions & 2 deletions diskann-quantization/src/product/tables/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
*/

// A collection of test helpers to ensure uniformity across tables.
use diskann_utils::views::{Matrix, MatrixView, MutMatrixView};
use diskann_utils::views::Matrix;
#[cfg(not(miri))]
use diskann_utils::views::{MatrixView, MutMatrixView};
#[cfg(not(miri))]
use rand::seq::IndexedRandom;
use rand::{
distr::{Distribution, Uniform},
seq::IndexedRandom,
Rng, SeedableRng,
};

Expand Down Expand Up @@ -290,6 +293,7 @@ pub(super) fn check_pqtable_single_compression_errors<T>(
////////////////////////////////////////////////////////////////////

// A cantralized test for error handling in `CompressInto<[f32], [u8]>`
#[cfg(not(miri))]
pub(super) fn check_pqtable_batch_compression_errors<T>(
build: &dyn Fn(Matrix<f32>, ChunkOffsets) -> T,
context: &dyn std::fmt::Display,
Expand Down
10 changes: 7 additions & 3 deletions diskann-quantization/src/product/tables/transposed/pivots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ mod tests {
fn run_test_happy_path() {
// Step dimensions by 1 to test all possible residual combinations.
let dims: Vec<usize> = if cfg!(miri) {
(1..=8).collect()
(7..=8).collect()
} else {
(1..=16).collect()
};
Expand Down Expand Up @@ -1583,8 +1583,12 @@ mod tests {
#[test]
fn test_process_into() {
let mut rng = StdRng::seed_from_u64(0x21dfb5f35dfe5639);
for total in 1..64 {
for dim in 1..5 {

let total_range = if cfg!(miri) { 1..48 } else { 1..64 };
let dim_range = if cfg!(miri) { 4..5 } else { 1..5 };

for total in total_range {
for dim in dim_range.clone() {
println!("on ({}, {})", total, dim);
test_process_into_impl(dim, total, &mut rng);
}
Expand Down
Loading
Loading