Skip to content

Add info to test switch mode #468

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

Closed
wants to merge 7 commits into from
Closed
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
22 changes: 22 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
codecov:
require_ci_to_pass: false # Enabling Codecov to report status even if the CI fails
notify:
wait_for_ci: false # Enabling Codecov to report coverage even if the CI has not completed
coverage:
status:
project: # Configurations for the project coverage status
default:
# basic
target: auto # target coverage based on the base commit
threshold: 1% # Allow `x%` of coverage to decrease without failing
# advanced
removed_code_behavior: adjust_base # [removals_only, adjust_base, fully_covered_patch, off/False] https://docs.codecov.com/docs/commit-status#removed_code_behavior

patch: # Configurations for the pull request coverage status
default:
# basic
target: auto # target coverage based on the base commit
threshold: 5% # Allow `x%` of coverage to decrease without failing
# Not specifying paths so we get annotations on the PR
# advanced
removed_code_behavior: adjust_base # [removals_only, adjust_base, fully_covered_patch, off/False] https://docs.codecov.com/docs/commit-status#removed_code_behavior
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
# Ubuntu 22.04 128GB Storage AMI
ec2-image-id: ami-0ba430d4b7b64de57
ec2-instance-type: r6i.xlarge
ec2-instance-type: r7i.xlarge
subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_EC2_SG_ID }}

Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
# Ubuntu 20.04 AMI
ec2-image-id: ami-0f4feb99425e13b50
ec2-instance-type: t3.xlarge
# Ubuntu 22.04 AMI
ec2-image-id: ami-036cafe742923b3d9
ec2-instance-type: c7i.xlarge
subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_EC2_SG_ID }}

Expand All @@ -33,15 +33,18 @@ jobs:
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: install dependencies
run: sudo .install/install_script.sh
- name: run codecov
run: make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: /bin/Linux-x86_64-debug/cov.info
file: ./bin/Linux-x86_64-debug/cov.info
token: ${{ secrets.CODECOV_TOKEN }}
disable_safe_directory: true
disable_search: true

stop-runner:
name: Stop self-hosted EC2 runner
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/event-merge-to-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Merge a Pull-Request Flow
run-name: Validate ${{ github.ref_name }}

on:
workflow_call:
merge_group:
types: [checks_requested]

Expand All @@ -27,12 +28,6 @@ jobs:
uses: ./.github/workflows/task-unit-test.yml
with:
container: ubuntu:bionic
xenial:
needs: [check-if-docs-only]
if: ${{ needs.check-if-docs-only.outputs.only-docs-changed == 'false' }}
uses: ./.github/workflows/task-unit-test.yml
with:
container: ubuntu:xenial
bullseye:
needs: [check-if-docs-only]
if: ${{ needs.check-if-docs-only.outputs.only-docs-changed == 'false' }}
Expand Down Expand Up @@ -87,7 +82,6 @@ jobs:
- jammy
- focal
- bionic
- xenial
- bullseye
- centos7
- amazonlinux2
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/event-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jobs:
with:
container: ubuntu:bionic
run-valgrind: false
xenial:
uses: ./.github/workflows/task-unit-test.yml
with:
container: ubuntu:xenial
run-valgrind: false
bullseye:
uses: ./.github/workflows/task-unit-test.yml
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/event-pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'
- name: install dependencies
run: sudo .install/install_script.sh
- name: install python packages
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/flow-temp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: temporary testing

# This file is useful for triggering actions when you implement them.
# When the `branches-ignore` line is commented out, this workflow will run on every push.
# It is better to use this file for testing your new flows than creating a new one, to avoid cluttering the repo
# action tab with unused workflows.
# Don't worry about conflicts with other PRs - there is no "right" content of this file.
# Make sure the `branches-ignore` line is not commented out when you merge your PR.

on:
push:
branches-ignore: ['**'] # ignore all branches. Comment this line to run your workflow below on every push.

jobs:
check-if-docs-only:
uses: ./.github/workflows/task-check-docs.yml
focal:
needs: [check-if-docs-only]
if: ${{ needs.check-if-docs-only.outputs.only-docs-changed == 'false' }}
uses: ./.github/workflows/task-unit-test.yml
with:
container: ubuntu:focal
2 changes: 1 addition & 1 deletion .github/workflows/task-check-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0 # required for changed-files action to work
- name: Check if only docs were changed
id: check-docs
uses: tj-actions/changed-files@v40
uses: tj-actions/changed-files@v41
with:
# List of files we allow to be changed without running the CI. Modify as needed.
files: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/task-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
if: ${{ inputs.run-valgrind }}
run: make valgrind
- name: Archive valgrind tests reports
if: ${{ inputs.run-valgrind }}
if: ${{ inputs.run-valgrind }} && failure()
uses: actions/upload-artifact@v3
with:
name: valgrind tests reports
Expand Down
11 changes: 10 additions & 1 deletion .install/ubuntu_18.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ $MODE apt-get dist-upgrade -yqq
$MODE apt install -yqq software-properties-common
$MODE add-apt-repository ppa:ubuntu-toolchain-r/test -y
$MODE apt update
$MODE apt-get install -yqq git wget make valgrind gcc-9 g++-9
$MODE apt-get install -yqq git wget make gcc-9 g++-9 libc6-dbg
$MODE update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9

wget https://sourceware.org/pub/valgrind/valgrind-3.18.0.tar.bz2
tar -xjf valgrind-3.18.0.tar.bz2
cd valgrind-3.18.0
./configure
make
$MODE make install
cd ..

source install_cmake.sh $MODE
2 changes: 1 addition & 1 deletion .install/ubuntu_22.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ set -e
export DEBIAN_FRONTEND=noninteractive
MODE=$1 # whether to install using sudo or not

$MODE apt-get update -qq
$MODE apt-get update -qq || true
$MODE apt-get install -yqq git wget build-essential valgrind lcov
source install_cmake.sh $MODE
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ valgrind:

flow_test:
$(SHOW)poetry install
$(SHOW)poetry run pytest tests/flow -v -s
$(SHOW)poetry run pytest tests/flow/$(TEST) -v -s

.PHONY: flow_test

Expand Down Expand Up @@ -278,7 +278,7 @@ $(COVERAGE_REPORT)
endef

coverage:
$(SHOW)$(MAKE) build COV=1
$(SHOW)$(MAKE) build COV=1 FP_64=1
$(SHOW)$(COVERAGE_RESET)
$(SHOW)cd $(TESTDIR) && GTEST_COLOR=1 ctest $(_CTEST_ARGS)
$(SHOW)$(COVERAGE_COLLECT_REPORT)
Expand Down
2 changes: 1 addition & 1 deletion cmake/cpu_features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ option(CMAKE_POSITION_INDEPENDENT_CODE "" ON)
FetchContent_Declare(
cpu_features
GIT_REPOSITORY https://github.com/google/cpu_features.git
GIT_TAG 438a66e41807cd73e0c403966041b358f5eafc68
GIT_TAG v0.9.0
)
FetchContent_MakeAvailable(cpu_features)
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.10"

[tool.poetry.dev-dependencies]
numpy = "^1.21"
numpy = "^1.26"
hnswlib = "^0.6.2"
pytest = "^6.2.4"
scipy = "^1.9.1"
scipy = "^1.10.1"
h5py = "^3.7.0"
bfloat16 = "^1.1"


[build-system]
requires = ["poetry-core>=1.0.0", "setuptools"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.build]
[tool.poetry.build]
script = "setup.py"
generate-setup-file = true
generate-setup-file = true
10 changes: 7 additions & 3 deletions src/VecSim/algorithms/brute_force/brute_force.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using spaces::dist_func_t;

template <typename DataType, typename DistType>
class BruteForceIndex : public VecSimIndexAbstract<DistType> {
class BruteForceIndex : public VecSimIndexAbstract<DataType, DistType> {
protected:
vecsim_stl::vector<labelType> idToLabelMapping;
vecsim_stl::vector<DataBlock> vectorBlocks;
Expand Down Expand Up @@ -83,6 +83,10 @@ class BruteForceIndex : public VecSimIndexAbstract<DistType> {
*/
virtual void getDataByLabel(labelType label,
std::vector<std::vector<DataType>> &vectors_output) const = 0;
virtual void fitMemory() override {
idToLabelMapping.shrink_to_fit();
resizeLabelLookup(idToLabelMapping.size());
}
#endif

protected:
Expand Down Expand Up @@ -149,8 +153,8 @@ class BruteForceIndex : public VecSimIndexAbstract<DistType> {
template <typename DataType, typename DistType>
BruteForceIndex<DataType, DistType>::BruteForceIndex(
const BFParams *params, const AbstractIndexInitParams &abstractInitParams)
: VecSimIndexAbstract<DistType>(abstractInitParams), idToLabelMapping(this->allocator),
vectorBlocks(this->allocator), count(0) {
: VecSimIndexAbstract<DataType, DistType>(abstractInitParams),
idToLabelMapping(this->allocator), vectorBlocks(this->allocator), count(0) {
assert(VecSimType_sizeof(this->vecType) == sizeof(DataType));
// Round up the initial capacity to the nearest multiple of the block size.
size_t initialCapacity = RoundUpInitialCapacity(params->initialCapacity, this->blockSize);
Expand Down
8 changes: 6 additions & 2 deletions src/VecSim/algorithms/hnsw/hnsw.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct ElementGraphData {
//////////////////////////////////// HNSW index implementation ////////////////////////////////////

template <typename DataType, typename DistType>
class HNSWIndex : public VecSimIndexAbstract<DistType>,
class HNSWIndex : public VecSimIndexAbstract<DataType, DistType>,
public VecSimIndexTombstone
#ifdef BUILD_TESTS
,
Expand Down Expand Up @@ -366,6 +366,10 @@ class HNSWIndex : public VecSimIndexAbstract<DistType>,
*/
virtual void getDataByLabel(labelType label,
std::vector<std::vector<DataType>> &vectors_output) const = 0;
virtual void fitMemory() override {
idToMetaData.shrink_to_fit();
resizeLabelLookup(idToMetaData.size());
}
#endif

protected:
Expand Down Expand Up @@ -1640,7 +1644,7 @@ template <typename DataType, typename DistType>
HNSWIndex<DataType, DistType>::HNSWIndex(const HNSWParams *params,
const AbstractIndexInitParams &abstractInitParams,
size_t random_seed, size_t pool_initial_size)
: VecSimIndexAbstract<DistType>(abstractInitParams), VecSimIndexTombstone(),
: VecSimIndexAbstract<DataType, DistType>(abstractInitParams), VecSimIndexTombstone(),
maxElements(RoundUpInitialCapacity(params->initialCapacity, this->blockSize)),
vectorBlocks(this->allocator), graphDataBlocks(this->allocator),
idToMetaData(maxElements, this->allocator),
Expand Down
2 changes: 1 addition & 1 deletion src/VecSim/algorithms/hnsw/hnsw_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ template <typename DataType, typename DistType>
HNSWIndex<DataType, DistType>::HNSWIndex(std::ifstream &input, const HNSWParams *params,
const AbstractIndexInitParams &abstractInitParams,
Serializer::EncodingVersion version)
: VecSimIndexAbstract<DistType>(abstractInitParams), Serializer(version),
: VecSimIndexAbstract<DataType, DistType>(abstractInitParams), Serializer(version),
maxElements(RoundUpInitialCapacity(params->initialCapacity, this->blockSize)),
epsilon(params->epsilon), vectorBlocks(this->allocator), graphDataBlocks(this->allocator),
idToMetaData(maxElements, this->allocator),
Expand Down
4 changes: 4 additions & 0 deletions src/VecSim/algorithms/hnsw/hnsw_single_tests_friends.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ INDEX_TEST_FRIEND_CLASS(IndexAllocatorTest_test_hnsw_reclaim_memory_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTestParallel_parallelInsertSearch_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTest_testSizeEstimation_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTest_swapJobBasic_Test)
friend class BF16HNSWTest_testSizeEstimation_Test;
friend class BF16TieredTest_testSizeEstimation_Test;
friend class FP16HNSWTest_testSizeEstimation_Test;
friend class FP16TieredTest_testSizeEstimation_Test;
4 changes: 4 additions & 0 deletions src/VecSim/algorithms/hnsw/hnsw_tiered_tests_friends.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTestBasic_overwriteVectorBasic_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTestBasic_overwriteVectorAsync_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTestBasic_preferAdHocOptimization_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTestBasic_runGCAPI_Test)
INDEX_TEST_FRIEND_CLASS(HNSWTieredIndexTestBasic_FitMemoryTest_Test)

friend class BF16TieredTest;
friend class FP16TieredTest;

INDEX_TEST_FRIEND_CLASS(BM_VecSimBasics)
INDEX_TEST_FRIEND_CLASS(BM_VecSimCommon)
13 changes: 13 additions & 0 deletions src/VecSim/index_factories/brute_force_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include "VecSim/algorithms/brute_force/brute_force.h"
#include "VecSim/algorithms/brute_force/brute_force_single.h"
#include "VecSim/algorithms/brute_force/brute_force_multi.h"
#include "VecSim/types/bfloat16.h"
#include "VecSim/types/float16.h"

using bfloat16 = vecsim_types::bfloat16;
using float16 = vecsim_types::float16;

namespace BruteForceFactory {
template <typename DataType, typename DistType = DataType>
Expand Down Expand Up @@ -49,6 +54,10 @@ VecSimIndex *NewIndex(const BFParams *bfparams, const AbstractIndexInitParams &a
return NewIndex_ChooseMultiOrSingle<float>(bfparams, abstractInitParams);
} else if (bfparams->type == VecSimType_FLOAT64) {
return NewIndex_ChooseMultiOrSingle<double>(bfparams, abstractInitParams);
} else if (bfparams->type == VecSimType_BFLOAT16) {
return NewIndex_ChooseMultiOrSingle<bfloat16, float>(bfparams, abstractInitParams);
} else if (bfparams->type == VecSimType_FLOAT16) {
return NewIndex_ChooseMultiOrSingle<float16, float>(bfparams, abstractInitParams);
}

// If we got here something is wrong.
Expand Down Expand Up @@ -80,6 +89,10 @@ size_t EstimateInitialSize(const BFParams *params) {
est += EstimateInitialSize_ChooseMultiOrSingle<float>(params->multi);
} else if (params->type == VecSimType_FLOAT64) {
est += EstimateInitialSize_ChooseMultiOrSingle<double>(params->multi);
} else if (params->type == VecSimType_BFLOAT16) {
est += EstimateInitialSize_ChooseMultiOrSingle<bfloat16, float>(params->multi);
} else if (params->type == VecSimType_FLOAT16) {
est += EstimateInitialSize_ChooseMultiOrSingle<float16, float>(params->multi);
}
// Parameters related part.

Expand Down
Loading
Loading