-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimize rebuilds of RAFT code due to knowhere changes (#264)
* Minimize rebuilds of RAFT code due to knowhere changes Signed-off-by: William Hicks <[email protected]> * Revert accidental reversion of config defaults Signed-off-by: William Hicks <[email protected]> --------- Signed-off-by: William Hicks <[email protected]>
- Loading branch information
Showing
14 changed files
with
428 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* SPDX-FileCopyrightText: Copyright (c) 2023,NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#undef RAFT_EXPLICIT_INSTANTIATE_ONLY | ||
#include "common/raft/integration/type_mappers.hpp" | ||
#include "common/raft/proto/filtered_search_instantiation.cuh" | ||
#include "common/raft/proto/raft_index_kind.hpp" | ||
|
||
RAFT_FILTERED_SEARCH_INSTANTIATION(cagra, raft_knowhere::raft_data_t<raft_proto::raft_index_kind::cagra>, | ||
raft_knowhere::raft_indexing_t<raft_proto::raft_index_kind::cagra>, | ||
raft_knowhere::raft_input_indexing_t<raft_proto::raft_index_kind::cagra>, | ||
raft_knowhere::raft_data_t<raft_proto::raft_index_kind::cagra>, | ||
raft_knowhere::knowhere_bitset_data_type, | ||
raft_knowhere::knowhere_bitset_indexing_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* SPDX-FileCopyrightText: Copyright (c) 2023,NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#undef RAFT_EXPLICIT_INSTANTIATE_ONLY | ||
#include "common/raft/integration/type_mappers.hpp" | ||
#include "common/raft/proto/filtered_search_instantiation.cuh" | ||
#include "common/raft/proto/raft_index_kind.hpp" | ||
|
||
RAFT_FILTERED_SEARCH_INSTANTIATION(ivf_flat, raft_knowhere::raft_data_t<raft_proto::raft_index_kind::ivf_flat>, | ||
raft_knowhere::raft_indexing_t<raft_proto::raft_index_kind::ivf_flat>, | ||
raft_knowhere::raft_input_indexing_t<raft_proto::raft_index_kind::ivf_flat>, | ||
raft_knowhere::raft_data_t<raft_proto::raft_index_kind::ivf_flat>, | ||
raft_knowhere::knowhere_bitset_data_type, | ||
raft_knowhere::knowhere_bitset_indexing_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* SPDX-FileCopyrightText: Copyright (c) 2023,NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#undef RAFT_EXPLICIT_INSTANTIATE_ONLY | ||
#include "common/raft/integration/type_mappers.hpp" | ||
#include "common/raft/proto/filtered_search_instantiation.cuh" | ||
#include "common/raft/proto/raft_index_kind.hpp" | ||
|
||
RAFT_FILTERED_SEARCH_INSTANTIATION(ivf_pq, raft_knowhere::raft_data_t<raft_proto::raft_index_kind::ivf_pq>, | ||
raft_knowhere::raft_indexing_t<raft_proto::raft_index_kind::ivf_pq>, | ||
raft_knowhere::raft_input_indexing_t<raft_proto::raft_index_kind::ivf_pq>, | ||
raft_knowhere::raft_data_t<raft_proto::raft_index_kind::ivf_pq>, | ||
raft_knowhere::knowhere_bitset_data_type, | ||
raft_knowhere::knowhere_bitset_indexing_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* SPDX-FileCopyrightText: Copyright (c) 2023,NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
#include <cstdint> | ||
#include <type_traits> | ||
|
||
#include "common/raft/proto/raft_index_kind.hpp" | ||
|
||
namespace raft_knowhere { | ||
|
||
using knowhere_data_type = float; | ||
using knowhere_indexing_type = std::int64_t; | ||
using knowhere_bitset_data_type = std::uint8_t; | ||
using knowhere_bitset_indexing_type = std::uint32_t; | ||
|
||
namespace detail { | ||
|
||
template <bool B, raft_proto::raft_index_kind IndexKind> | ||
struct raft_io_type_mapper : std::false_type {}; | ||
|
||
template <> | ||
struct raft_io_type_mapper<true, raft_proto::raft_index_kind::ivf_flat> : std::true_type { | ||
using data_type = float; | ||
using indexing_type = std::int64_t; | ||
using input_indexing_type = std::int64_t; | ||
}; | ||
|
||
template <> | ||
struct raft_io_type_mapper<true, raft_proto::raft_index_kind::ivf_pq> : std::true_type { | ||
using data_type = float; | ||
using indexing_type = std::int64_t; | ||
using input_indexing_type = std::uint32_t; | ||
}; | ||
|
||
template <> | ||
struct raft_io_type_mapper<true, raft_proto::raft_index_kind::cagra> : std::true_type { | ||
using data_type = float; | ||
using indexing_type = std::uint32_t; | ||
using input_indexing_type = std::int64_t; | ||
}; | ||
|
||
} // namespace detail | ||
|
||
template <raft_proto::raft_index_kind IndexKind> | ||
using raft_data_t = typename detail::raft_io_type_mapper<true, IndexKind>::data_type; | ||
|
||
template <raft_proto::raft_index_kind IndexKind> | ||
using raft_indexing_t = typename detail::raft_io_type_mapper<true, IndexKind>::indexing_type; | ||
|
||
template <raft_proto::raft_index_kind IndexKind> | ||
using raft_input_indexing_t = typename detail::raft_io_type_mapper<true, IndexKind>::input_indexing_type; | ||
|
||
} // namespace raft_knowhere |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* SPDX-FileCopyrightText: Copyright (c) 2023,NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
#include <raft/core/device_mdspan.hpp> | ||
#include <raft/core/resources.hpp> | ||
#include <raft/neighbors/cagra.cuh> | ||
#include <raft/neighbors/ivf_flat.cuh> | ||
#include <raft/neighbors/ivf_pq.cuh> | ||
#include <raft/neighbors/sample_filter.cuh> | ||
|
||
#include "common/raft/proto/raft_index_kind.hpp" | ||
|
||
namespace raft_proto { | ||
namespace detail { | ||
template <raft_proto::raft_index_kind K, typename T, typename IdxT> | ||
using index_instantiation = std::conditional_t< | ||
K == raft_proto::raft_index_kind::ivf_flat, raft::neighbors::ivf_flat::index<T, IdxT>, | ||
std::conditional_t< | ||
K == raft_proto::raft_index_kind::ivf_pq, raft::neighbors::ivf_pq::index<IdxT>, | ||
std::conditional_t<K == raft_proto::raft_index_kind::cagra, raft::neighbors::cagra::index<T, IdxT>, | ||
raft::neighbors::ivf_flat::index<T, IdxT>>>>; | ||
} // namespace detail | ||
} // namespace raft_proto | ||
|
||
#define RAFT_FILTERED_SEARCH_TEMPLATE(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT) \ | ||
template void search_with_filtering<T, IdxT, raft::neighbors::filtering::bitset_filter<BitsetDataT, BitsetIdxT>>( \ | ||
raft::resources const&, search_params const&, \ | ||
raft_proto::detail::index_instantiation<raft_proto::raft_index_kind::index_type, T, IdxT> const&, \ | ||
raft::device_matrix_view<const T, InpIdxT>, raft::device_matrix_view<IdxT, InpIdxT>, \ | ||
raft::device_matrix_view<DistT, InpIdxT>, raft::neighbors::filtering::bitset_filter<BitsetDataT, BitsetIdxT>) | ||
|
||
#define RAFT_FILTERED_SEARCH_INSTANTIATION(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT) \ | ||
namespace raft::neighbors::index_type { \ | ||
RAFT_FILTERED_SEARCH_TEMPLATE(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT); \ | ||
} | ||
|
||
#define RAFT_FILTERED_SEARCH_EXTERN(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT) \ | ||
namespace raft::neighbors::index_type { \ | ||
RAFT_FILTERED_SEARCH_TEMPLATE(index_type, T, IdxT, InpIdxT, DistT, BitsetDataT, BitsetIdxT); \ | ||
} |
Oops, something went wrong.