Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jparismorgan committed Oct 17, 2024
1 parent 4162605 commit 105dee3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
10 changes: 5 additions & 5 deletions apis/python/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def no_output(capfd):
libc.fflush(None)

# Fail if there is any output.
# out, err = capfd.readouterr()
# if out or err:
# pytest.fail(
# f"Test failed because output was captured. out:\n{out}\nerr:\n{err}"
# )
out, err = capfd.readouterr()
if out or err:
pytest.fail(
f"Test failed because output was captured. out:\n{out}\nerr:\n{err}"
)


@pytest.fixture(scope="session", autouse=True)
Expand Down
12 changes: 11 additions & 1 deletion src/include/index/ivf_pq_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ class ivf_pq_index {
* write.
* @param distance The distance function to use.
* @param write_to_temp_arrays Whether to write to the temp arrays. True if
* inegsting via Python.
* ingesting via Python.
*/
template <
feature_vector_array Array,
Expand Down Expand Up @@ -923,6 +923,16 @@ class ivf_pq_index {
partition_start);
}

/**
* @brief Consolidate partitions. This will read the partitioned vectors and
* ids from the temp arrays, and write them to the main arrays.
*
* @param partitions Number of partitions.
* @param work_items Number of work items.
* @param partition_id_start The starting partition id.
* @param partition_id_end The ending partition id.
* @param batch The batch size.
*/
void consolidate_partitions(
size_t partitions,
size_t work_items,
Expand Down
4 changes: 2 additions & 2 deletions src/include/test/unit_api_ivf_pq_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ TEST_CASE("write and load index with timestamps", "[api_ivf_pq_index]") {
scores_finite, ids_finite, {0, 0, 0, 0}, {1, 2, 3, 4});
}
}

CHECK(index.temporal_policy().timestamp_start() == 0);
CHECK(
index.temporal_policy().timestamp_end() ==
Expand Down Expand Up @@ -1003,13 +1004,11 @@ TEST_CASE("write and load index with timestamps", "[api_ivf_pq_index]") {
auto queries = ColMajorMatrix<feature_type_type>{{{1, 1, 1}}};
auto&& [scores, ids] =
index.query(FeatureVectorArray(queries), top_k, nprobe);

check_single_vector_equals(
scores,
ids,
{std::numeric_limits<float>::max()},
{std::numeric_limits<uint32_t>::max()});

auto&& [scores_with_reranking, ids_with_reranking] =
index.query(FeatureVectorArray(queries), top_k, nprobe, k_factor);
check_single_vector_equals(
Expand Down Expand Up @@ -1054,6 +1053,7 @@ TEST_CASE("write and load index with timestamps", "[api_ivf_pq_index]") {
convergence_tolerance);
CHECK(typed_index.group().get_reassign_ratio() == reassign_ratio);
}

// Clear history for <= 99 and then load at 99, then make sure we cannot
// query.
IndexIVFPQ::clear_history(ctx, index_uri, 99);
Expand Down
6 changes: 2 additions & 4 deletions src/include/test/unit_ivf_pq_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,10 @@ TEMPLATE_TEST_CASE(
size_t k_nn = 6;
size_t partitions = 1;

auto ivf_idx2 = ivf_pq_index<TestType, uint32_t, uint32_t>(
/*128,*/ partitions, 2, 4, 1.e-4);
auto ivf_idx2 = ivf_pq_index<TestType, uint32_t, uint32_t>(partitions, 2, 4, 1.e-4);
ivf_idx2.train_ivf(hypercube2);
ivf_idx2.add(hypercube2, ids);
auto ivf_idx4 = ivf_pq_index<TestType, uint32_t, uint32_t>(
/*128,*/ partitions, 2, 4, 1.e-4);
auto ivf_idx4 = ivf_pq_index<TestType, uint32_t, uint32_t>(partitions, 2, 4, 1.e-4);
ivf_idx4.train_ivf(hypercube4);
ivf_idx4.add(hypercube4, ids);

Expand Down

0 comments on commit 105dee3

Please sign in to comment.