Merge remote-tracking branch 'upstream/master'

pull/929/head
quicksilver 2019-12-31 15:05:36 +08:00
commit 62c2c3c7bb
28 changed files with 342 additions and 97 deletions

View File

@ -22,6 +22,8 @@ Please mark all change in change log and use the issue from GitHub
- \#738 - Use Openblas / lapack from apt install
- \#758 - Enhance config description
- \#791 - Remove Arrow
- \#834 - add cpu mode for built-in Faiss
- \#848 - Add ready-to-use config files to the Milvus repo for enhanced user experince
## Task

View File

@ -15,33 +15,22 @@
Milvus is the world's fastest similarity search engine for massive-scale feature vectors. Built with heterogeneous computing architecture for the best cost efficiency. Searches over billion-scale vectors take only milliseconds with minimum computing resources.
For more detailed introduction of Milvus and its architecture, see [Milvus overview](https://www.milvus.io/docs/en/aboutmilvus/overview/).
For more detailed introduction of Milvus and its architecture, see [Milvus overview](https://www.milvus.io/docs/about_milvus/overview.md).
Milvus provides stable [Python](https://github.com/milvus-io/pymilvus), [Java](https://github.com/milvus-io/milvus-sdk-java) and [C++](https://github.com/milvus-io/milvus/tree/master/core/src/sdk) SDKs.
Milvus provides stable [Python](https://github.com/milvus-io/pymilvus), [Java](https://github.com/milvus-io/milvus-sdk-java) and [C++](https://github.com/milvus-io/milvus/tree/master/sdk) SDKs.
Keep up-to-date with newest releases and latest updates by reading Milvus [release notes](https://www.milvus.io/docs/en/release/v0.6.0/).
Keep up-to-date with newest releases and latest updates by reading Milvus [release notes](https://www.milvus.io/docs/v0.6.0/releases/v0.6.0.md).
## Get started
See the [Milvus install guide](https://www.milvus.io/docs/en/userguide/install_milvus/) for using Docker containers. To install Milvus from source code, see [build from source](install.md).
See the [Milvus install guide](https://www.milvus.io/docs/guides/get_started/install_milvus/install_milvus.md) for using Docker containers. To install Milvus from source code, see [build from source](install.md).
To edit Milvus settings, read [Milvus configuration](https://www.milvus.io/docs/en/reference/milvus_config/).
To edit Milvus settings, read [Milvus configuration](https://www.milvus.io/docs/v0.6.0/reference/milvus_config.md).
### Try your first Milvus program
Try running a program with Milvus using [Python](https://www.milvus.io/docs/en/userguide/example_code/) or [Java example code](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples).
Try running a program with Milvus using [Python](https://www.milvus.io/docs/guides/get_started/example_code.md), [Java](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples), or [C++ example code](https://github.com/milvus-io/milvus/tree/master/sdk/examples).
To use C++ example code, use below command:
```shell
# Run Milvus C++ example
$ cd [Milvus root path]/core/milvus/bin
$ ./sdk_simple
```
## Roadmap
Please read our [roadmap](https://milvus.io/docs/en/roadmap/) for upcoming features.
## Contribution guidelines
@ -83,7 +72,7 @@ Below is a list of Milvus contributors. We greatly appreciate your contributions
- [Milvus test reports](https://github.com/milvus-io/milvus/tree/master/docs)
- [Milvus FAQ](https://www.milvus.io/docs/en/faq/operational_faq/)
- [Milvus FAQ](https://www.milvus.io/docs/faq/operational_faq.md)
- [Milvus Medium](https://medium.com/@milvusio)

View File

@ -15,33 +15,22 @@
Milvus 是一款开源的、针对海量特征向量的相似性搜索引擎。基于异构众核计算框架设计,成本更低,性能更好。在有限的计算资源下,十亿向量搜索仅毫秒响应。
若要了解 Milvus 详细介绍和整体架构,请访问 [Milvus 简介](https://www.milvus.io/docs/zh-CN/aboutmilvus/overview/)。
若要了解 Milvus 详细介绍和整体架构,请访问 [Milvus 简介](https://www.milvus.io/cn/docs/about_milvus/overview.md)。
Milvus 提供稳定的 [Python](https://github.com/milvus-io/pymilvus)、[Java](https://github.com/milvus-io/milvus-sdk-java) 以及[C++](https://github.com/milvus-io/milvus/tree/master/core/src/sdk) 的 SDK。
Milvus 提供稳定的 [Python](https://github.com/milvus-io/pymilvus)、[Java](https://github.com/milvus-io/milvus-sdk-java) 以及[C++](https://github.com/milvus-io/milvus/tree/master/sdk) 的 SDK。
通过 [版本发布说明](https://milvus.io/docs/zh-CN/release/v0.6.0/) 获取最新版本的功能和更新。
通过 [版本发布说明](https://www.milvus.io/cn/docs/v0.6.0/releases/v0.6.0.md) 获取最新版本的功能和更新。
## 开始使用 Milvus
请参阅 [Milvus 安装指南](https://www.milvus.io/docs/zh-CN/userguide/install_milvus/) 使用 Docker 容器安装 Milvus。若要基于源码编译请访问 [源码安装](install.md)。
请参阅 [Milvus 安装指南](https://www.milvus.io/cn/docs/guides/get_started/install_milvus/install_milvus.md) 使用 Docker 容器安装 Milvus。若要基于源码编译请访问 [源码安装](install.md)。
若要更改 Milvus 设置,请参阅 [Milvus 配置](https://www.milvus.io/docs/zh-CN/reference/milvus_config/)。
若要更改 Milvus 设置,请参阅 [Milvus 配置](https://www.milvus.io/cn/docs/reference/milvus_config.md)。
### 开始您的第一个 Milvus 程序
您可以尝试用 [Python](https://www.milvus.io/docs/en/userguide/example_code/) 或 [Java example code](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples) 运行 Milvus 示例代码。
您可以尝试用 [Python](https://www.milvus.io/cn/docs/guides/get_started/example_code.md)[Java](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples),或者 [C++](https://github.com/milvus-io/milvus/tree/master/sdk/examples) 运行 Milvus 示例代码。
若要使用 C++ 示例代码,请使用以下命令:
```shell
# Run Milvus C++ example
$ cd [Milvus root path]/core/milvus/bin
$ ./sdk_simple
```
## 路线图
请阅读我们的[路线图](https://milvus.io/docs/zh-CN/roadmap/)以了解更多即将开发的新功能。
## 贡献者指南
@ -62,7 +51,7 @@ Milvus 提供稳定的 [Python](https://github.com/milvus-io/pymilvus)、[Java](
- [Milvus 测试报告](https://github.com/milvus-io/milvus/tree/master/docs)
- [Milvus 常见问题](https://www.milvus.io/docs/zh-CN/faq/operational_faq/)
- [Milvus 常见问题](https://www.milvus.io/cn/docs/faq/operational_faq.md)
- [Milvus Medium](https://medium.com/@milvusio)

View File

@ -16,32 +16,21 @@
Milvusは世界中一番早い特徴ベクトルにむかう類似性検索エンジンです。不均質な計算アーキテクチャーに基づいて効率を最大化出来ます。数十億のベクタの中に目標を検索できるまで数ミリ秒しかかからず、最低限の計算資源だけが必要です。
Milvusは安定的な[Python](https://github.com/milvus-io/pymilvus)、[Java](https://github.com/milvus-io/milvus-sdk-java)又は [C++](https://github.com/milvus-io/milvus/tree/master/core/src/sdk) SDKを提供します。
Milvusは安定的な[Python](https://github.com/milvus-io/pymilvus)、[Java](https://github.com/milvus-io/milvus-sdk-java)又は [C++](https://github.com/milvus-io/milvus/tree/master/sdk) SDKを提供します。
Milvus [リリースノート](https://milvus.io/docs/en/release/v0.6.0/)を読んで最新バージョンや更新情報を手に入れます。
Milvus [リリースノート](https://www.milvus.io/docs/v0.6.0/releases/v0.6.0.md)を読んで最新バージョンや更新情報を手に入れます。
## はじめに
DockerでMilvusをインストールすることは簡単です。[Milvusインストール案内](https://milvus.io/docs/en/userguide/install_milvus/) を参考してください。ソースからMilvusを構築するために、[ソースから構築する](install.md)を参考してください。
DockerでMilvusをインストールすることは簡単です。[Milvusインストール案内](https://www.milvus.io/docs/guides/get_started/install_milvus/install_milvus.md) を参考してください。ソースからMilvusを構築するために、[ソースから構築する](install.md)を参考してください。
Milvusをコンフィグするために、[Milvusコンフィグ](https://github.com/milvus-io/docs/blob/master/reference/milvus_config.md)を読んでください。
Milvusをコンフィグするために、[Milvusコンフィグ](https://www.milvus.io/docs/reference/milvus_config.md)を読んでください。
### 初めてのMilvusプログラムを試す
[Python](https://www.milvus.io/docs/en/userguide/example_code/)や[Java](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples)などのサンプルコードを使ってMilvusプログラムを試す。
[Python](https://www.milvus.io/docs/guides/get_started/example_code.md)、[Java](https://github.com/milvus-io/milvus-sdk-java/tree/master/examples)、または[C++](https://github.com/milvus-io/milvus/tree/master/sdk/examples)などのサンプルコードを使ってMilvusプログラムを試す。
C++サンプルコードを実行するために、次のコマンドをつかってください。
```shell
# Run Milvus C++ example
$ cd [Milvus root path]/core/milvus/bin
$ ./sdk_simple
```
## Milvusロードマップ
[ロードマップ](https://milvus.io/docs/en/roadmap/)を読んで、追加する予定の特性が分かります。
## 貢献規約
@ -62,7 +51,7 @@ C++サンプルコードを実行するために、次のコマンドをつか
- [Milvus テストレポート](https://github.com/milvus-io/milvus/tree/master/docs)
- [Milvusのよくある質問](https://www.milvus.io/docs/en/faq/operational_faq/)
- [Milvusのよくある質問](https://www.milvus.io/docs/faq/operational_faq.md)
- [Milvus Medium](https://medium.com/@milvusio)

View File

@ -4,7 +4,7 @@ timeout(time: 75, unit: 'MINUTES') {
def checkResult = sh(script: "./check_ccache.sh -l ${params.JFROG_ARTFACTORY_URL}/ccache", returnStatus: true)
if ("${BINARY_VERSION}" == "gpu") {
sh "/bin/bash --login -c \". ./before-install.sh && ./build.sh -t ${params.BUILD_TYPE} -o ${env.MILVUS_INSTALL_PREFIX} -l -g -x -u -c\""
sh "/bin/bash --login -c \". ./before-install.sh && ./build.sh -t ${params.BUILD_TYPE} -o ${env.MILVUS_INSTALL_PREFIX} -l -g -u -c\""
} else {
sh "/bin/bash --login -c \". ./before-install.sh && ./build.sh -t ${params.BUILD_TYPE} -o ${env.MILVUS_INSTALL_PREFIX} -l -u -c\""
}

View File

@ -17,14 +17,13 @@ BUILD_UNITTEST="OFF"
INSTALL_PREFIX="/var/lib/milvus"
FAISS_ROOT=""
PRIVILEGES="OFF"
CUSTOMIZATION="OFF" # default use origin faiss
BUILD_COVERAGE="OFF"
RUN_CPPLINT="OFF"
GPU_VERSION="OFF"
WITH_MKL="OFF"
CUDA_COMPILER=/usr/local/cuda/bin/nvcc
while getopts "o:t:b:f:pgxulcmh" arg
while getopts "o:t:b:f:pgulcmh" arg
do
case $arg in
o)
@ -49,9 +48,6 @@ do
echo "Build and run unittest cases" ;
BUILD_UNITTEST="ON";
;;
x)
CUSTOMIZATION="ON";
;;
l)
RUN_CPPLINT="ON"
;;
@ -71,7 +67,6 @@ parameter:
-f: faiss root path
-p: install command with elevated privileges
-g: gpu version
-x: milvus customization (default: OFF)
-u: building unit test options(default: OFF)
-l: run cpplint, clang-format and clang-tidy(default: OFF)
-c: code coverage(default: OFF)
@ -79,7 +74,7 @@ parameter:
-h: help
usage:
./build.sh -o \${INSTALL_PREFIX} -t \${BUILD_TYPE} -b \${CORE_BUILD_DIR} -f \${FAISS_ROOT} [-p] [-g] [-x] [-u] [-l] [-c] [-m] [-h]
./build.sh -o \${INSTALL_PREFIX} -t \${BUILD_TYPE} -b \${CORE_BUILD_DIR} -f \${FAISS_ROOT} [-p] [-g] [-u] [-l] [-c] [-m] [-h]
"
exit 0
;;
@ -104,7 +99,6 @@ CMAKE_CMD="cmake \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
-DMILVUS_GPU_VERSION=${GPU_VERSION} \
-DCUSTOMIZATION=${CUSTOMIZATION} \
-DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
-DBUILD_COVERAGE=${BUILD_COVERAGE} \
-DFAISS_ROOT=${FAISS_ROOT} \

View File

@ -160,7 +160,6 @@ if (MILVUS_USE_CCACHE)
endif ()
if (CUSTOMIZATION)
set(MILVUS_GPU_VERSION ON)
add_compile_definitions(CUSTOMIZATION)
endif ()

View File

@ -9,7 +9,6 @@ BUILD_COVERAGE="OFF"
DB_PATH="/tmp/milvus"
PROFILING="OFF"
RUN_CPPLINT="OFF"
CUSTOMIZATION="OFF" # default use ori faiss
CUDA_COMPILER=/usr/local/cuda/bin/nvcc
GPU_VERSION="OFF" #defaults to CPU version
WITH_MKL="OFF"
@ -18,7 +17,7 @@ FAISS_SOURCE="BUNDLED"
WITH_PROMETHEUS="ON"
FIU_ENABLE="OFF"
while getopts "p:d:t:f:ulrcghxzmei" arg; do
while getopts "p:d:t:f:ulrcghzmei" arg; do
case $arg in
p)
INSTALL_PREFIX=$OPTARG
@ -52,9 +51,6 @@ while getopts "p:d:t:f:ulrcghxzmei" arg; do
z)
PROFILING="ON"
;;
x)
CUSTOMIZATION="ON"
;;
g)
GPU_VERSION="ON"
;;
@ -120,7 +116,6 @@ CMAKE_CMD="cmake \
-DBUILD_COVERAGE=${BUILD_COVERAGE} \
-DMILVUS_DB_PATH=${DB_PATH} \
-DMILVUS_ENABLE_PROFILING=${PROFILING} \
-DCUSTOMIZATION=${CUSTOMIZATION} \
-DMILVUS_GPU_VERSION=${GPU_VERSION} \
-DFAISS_WITH_MKL=${WITH_MKL} \
-DMILVUS_WITH_PROMETHEUS=${WITH_PROMETHEUS} \

View File

@ -45,7 +45,7 @@ set_option_category("Milvus Build Option")
define_option(MILVUS_GPU_VERSION "Build GPU version" OFF)
define_option(CUSTOMIZATION "Build with customized FAISS library" OFF)
define_option(CUSTOMIZATION "Build with customized FAISS library" ON)
#----------------------------------------------------------------------
set_option_category("Thirdparty")

View File

@ -0,0 +1,27 @@
* GLOBAL:
FORMAT = "%datetime | %level | %logger | %msg"
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-global.log"
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = false
SUBSECOND_PRECISION = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 200MB
* DEBUG:
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-debug.log"
ENABLED = true
* WARNING:
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-warning.log"
* TRACE:
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-trace.log"
* VERBOSE:
FORMAT = "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
TO_FILE = false
TO_STANDARD_OUTPUT = false
## Error logs
* ERROR:
ENABLED = true
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-error.log"
* FATAL:
ENABLED = true
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-fatal.log"

View File

@ -0,0 +1,149 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
version: 0.1
#----------------------+------------------------------------------------------------+------------+-----------------+
# Server Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# address | IP address that Milvus server monitors. | String | 0.0.0.0 |
#----------------------+------------------------------------------------------------+------------+-----------------+
# port | Port that Milvus server monitors. Port range (1024, 65535) | Integer | 19530 |
#----------------------+------------------------------------------------------------+------------+-----------------+
# deploy_mode | Milvus deployment type: | DeployMode | single |
# | single, cluster_readonly, cluster_writable | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# time_zone | Use UTC-x or UTC+x to specify a time zone. | Timezone | UTC+8 |
#----------------------+------------------------------------------------------------+------------+-----------------+
server_config:
address: 0.0.0.0
port: 19530
deploy_mode: single
time_zone: UTC+8
#----------------------+------------------------------------------------------------+------------+-----------------+
# DataBase Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# primary_path | Primary directory used to save meta data, vector data and | Path | /var/lib/milvus |
# | index data. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# secondary_path | A semicolon-separated list of secondary directories used | Path | |
# | to save vector data and index data. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# backend_url | URL for metadata storage, using SQLite (for single server | URL | sqlite://:@:/ |
# | Milvus) or MySQL (for distributed cluster Milvus). | | |
# | Format: dialect://username:password@host:port/database | | |
# | Keep 'dialect://:@:/', 'dialect' can be either 'sqlite' or | | |
# | 'mysql', replace other texts with real values. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# insert_buffer_size | Buffer size used for data insertion. | Integer | 1 (GB) |
# | The sum of 'insert_buffer_size' and 'cpu_cache_capacity' | | |
# | must be less than system memory size. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# preload_table | A comma-separated list of table names that need to be pre- | StringList | |
# | loaded when Milvus server starts up. | | |
# | '*' means preload all existing tables. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
db_config:
primary_path: /var/lib/milvus
secondary_path:
backend_url: sqlite://:@:/
insert_buffer_size: 1
preload_table:
#----------------------+------------------------------------------------------------+------------+-----------------+
# Metric Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# enable_monitor | Enable monitoring function or not. | Boolean | false |
#----------------------+------------------------------------------------------------+------------+-----------------+
# collector | Connected monitoring system to collect metrics. | String | Prometheus |
#----------------------+------------------------------------------------------------+------------+-----------------+
# port | Port to visit Prometheus, port range (1024, 65535) | Integer | 8080 |
#----------------------+------------------------------------------------------------+------------+-----------------+
metric_config:
enable_monitor: false
collector: prometheus
prometheus_config:
port: 8080
#----------------------+------------------------------------------------------------+------------+-----------------+
# Cache Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# cpu_cache_capacity | The size of CPU memory used for caching data for faster | Integet | 4 (GB) |
# | query. The sum of 'cpu_cache_capacity' and | | |
# | 'insert_buffer_size' must be less than system memory size. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# cache_insert_data | Whether to load inserted data into cache immediately for | Boolean | false |
# | hot query. If want to simultaneously insert and query | | |
# | vectors, it's recommended to enable this config. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
cache_config:
cpu_cache_capacity: 4
cache_insert_data: false
#----------------------+------------------------------------------------------------+------------+-----------------+
# Engine Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# use_blas_threshold | A Milvus performance tuning parameter. This value will be | Integer | 1100 |
# | compared with 'nq' to decide if OpenBLAS should be used. | | |
# | If nq >= use_blas_threshold, OpenBLAS will be used, search | | |
# | response times will be stable but the search speed will be | | |
# | slower; if nq < use_blas_threshold, SSE will be used, | | |
# | search speed will be faster but search response times will | | |
# | fluctuate. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# gpu_search_threshold | A Milvus performance tuning parameter. This value will be | Integer | 1000 |
# | compared with 'nq' to decide if the search computation will| | |
# | be executed on GPUs only. | | |
# | If nq >= gpu_search_threshold, the search computation will | | |
# | be executed on GPUs only; | | |
# | if nq < gpu_search_threshold, the search computation will | | |
# | be executed on both CPUs and GPUs. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
engine_config:
use_blas_threshold: 1100
gpu_search_threshold: 1000
#----------------------+------------------------------------------------------------+------------+-----------------+
# GPU Resource Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# enable | Enable GPU resources or not. | Boolean | false |
#----------------------+------------------------------------------------------------+------------+-----------------+
# cache_capacity | The size of GPU memory per card used for cache. | Integer | 1 (GB) |
#----------------------+------------------------------------------------------------+------------+-----------------+
# search_resources | The list of GPU devices used for search computation. | DeviceList | gpu0 |
# | Must be in format gpux. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
# build_index_resources| The list of GPU devices used for index building. | DeviceList | gpu0 |
# | Must be in format gpux. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
gpu_resource_config:
enable: false
cache_capacity: 1
search_resources:
- gpu0
build_index_resources:
- gpu0
#----------------------+------------------------------------------------------------+------------+-----------------+
# Tracing Config | Description | Type | Default |
#----------------------+------------------------------------------------------------+------------+-----------------+
# json_config_path | Absolute path for tracing config file. | Path | |
# | Leave it empty, a no-op tracer will be created. | | |
#----------------------+------------------------------------------------------------+------------+-----------------+
tracing_config:
json_config_path:

View File

@ -120,6 +120,7 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) {
break;
}
#ifdef CUSTOMIZATION
#ifdef MILVUS_GPU_VERSION
case EngineType::FAISS_IVFSQ8H: {
if (gpu_resource_enable) {
index = GetVecIndexFactory(IndexType::FAISS_IVFSQ8_HYBRID);
@ -128,6 +129,7 @@ ExecutionEngineImpl::CreatetVecIndex(EngineType type) {
}
break;
}
#endif
#endif
case EngineType::FAISS_PQ: {
#ifdef MILVUS_GPU_VERSION

View File

@ -73,7 +73,6 @@ include(DefineOptionsCore)
include(BuildUtilsCore)
if (CUSTOMIZATION)
set(MILVUS_GPU_VERSION ON)
add_compile_definitions(CUSTOMIZATION)
endif ()

View File

@ -49,7 +49,7 @@ else ()
define_option(KNOWHERE_GPU_VERSION "Build GPU version" OFF)
endif ()
define_option(CUSTOMIZATION "Build with customized FAISS library" OFF)
define_option(CUSTOMIZATION "Build with customized FAISS library" ON)
#----------------------------------------------------------------------
set_option_category("Thirdparty")

View File

@ -206,11 +206,6 @@ foreach (_VERSION_ENTRY ${TOOLCHAIN_VERSIONS_TXT})
endforeach ()
set(FAISS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/faiss)
if (DEFINED ENV{FAISS_SOURCE_URL})
set(FAISS_SOURCE_URL "$ENV{FAISS_SOURCE_URL}")
else ()
set(FAISS_SOURCE_URL "https://github.com/JinHai-CN/faiss/archive/${FAISS_VERSION}.tar.gz")
endif ()
if (DEFINED ENV{KNOWHERE_ARROW_URL})
set(ARROW_SOURCE_URL "$ENV{KNOWHERE_ARROW_URL}")
@ -467,15 +462,16 @@ macro(build_faiss)
"--with-cuda-arch=-gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_75,code=sm_75"
)
else ()
set(FAISS_CONFIGURE_ARGS ${FAISS_CONFIGURE_ARGS} --without-cuda)
set(FAISS_CONFIGURE_ARGS ${FAISS_CONFIGURE_ARGS}
"CPPFLAGS=-DUSE_CPU"
--without-cuda)
endif ()
if (CUSTOMIZATION)
if (DEFINED ENV{FAISS_SOURCE_URL})
set(FAISS_SOURCE_URL "$ENV{FAISS_SOURCE_URL}")
externalproject_add(faiss_ep
DOWNLOAD_COMMAND
""
SOURCE_DIR
${FAISS_SOURCE_DIR}
URL
${FAISS_SOURCE_URL}
${EP_LOG_OPTIONS}
CONFIGURE_COMMAND
"./configure"
@ -490,8 +486,10 @@ macro(build_faiss)
${FAISS_STATIC_LIB})
else ()
externalproject_add(faiss_ep
URL
${FAISS_SOURCE_URL}
DOWNLOAD_COMMAND
""
SOURCE_DIR
${FAISS_SOURCE_DIR}
${EP_LOG_OPTIONS}
CONFIGURE_COMMAND
"./configure"

View File

@ -14,6 +14,8 @@
#include <faiss/utils/utils.h>
#include <faiss/impl/FaissAssert.h>
#ifndef USE_CPU
#include "gpu/utils/DeviceUtils.h"
#include "cuda.h"
#include "cuda_runtime.h"
@ -47,6 +49,7 @@ PageLockMemory::PageLockMemory(PageLockMemory &&other) {
other.nbytes = 0;
}
}
#endif
namespace faiss {
@ -257,6 +260,11 @@ ReadOnlyArrayInvertedLists::ReadOnlyArrayInvertedLists(size_t nlist,
auto total_size = std::accumulate(readonly_length.begin(), readonly_length.end(), 0);
readonly_offset.reserve(nlist);
#ifdef USE_CPU
readonly_codes.reserve(total_size * code_size);
readonly_ids.reserve(total_size);
#endif
size_t offset = 0;
for (auto i=0; i<readonly_length.size(); ++i) {
readonly_offset.emplace_back(offset);
@ -266,8 +274,10 @@ ReadOnlyArrayInvertedLists::ReadOnlyArrayInvertedLists(size_t nlist,
ReadOnlyArrayInvertedLists::ReadOnlyArrayInvertedLists(const ArrayInvertedLists& other)
: InvertedLists (other.nlist, other.code_size) {
#ifndef USE_CPU
std::vector <uint8_t> readonly_codes;
std::vector <idx_t> readonly_ids;
#endif
readonly_length.reserve(nlist);
size_t offset = 0;
for (auto& list_ids : other.ids) {
@ -281,6 +291,7 @@ ReadOnlyArrayInvertedLists::ReadOnlyArrayInvertedLists(const ArrayInvertedLists&
readonly_codes.insert(readonly_codes.end(), list_codes.begin(), list_codes.end());
}
#ifndef USE_CPU
// convert to page-lock memory
{
size_t size = readonly_codes.size() * sizeof(uint8_t);
@ -292,6 +303,7 @@ ReadOnlyArrayInvertedLists::ReadOnlyArrayInvertedLists(const ArrayInvertedLists&
pin_readonly_ids = std::make_shared<PageLockMemory>(size);
memcpy(pin_readonly_ids->data, readonly_ids.data(), size);
}
#endif
valid = true;
}
@ -352,25 +364,41 @@ size_t ReadOnlyArrayInvertedLists::list_size(size_t list_no) const
const uint8_t * ReadOnlyArrayInvertedLists::get_codes (size_t list_no) const
{
FAISS_ASSERT(list_no < nlist && valid);
#ifdef USE_CPU
return readonly_codes.data() + readonly_offset[list_no] * code_size;
#else
uint8_t *pcodes = (uint8_t *)(pin_readonly_codes->data);
return pcodes + readonly_offset[list_no] * code_size;
#endif
}
const InvertedLists::idx_t* ReadOnlyArrayInvertedLists::get_ids (size_t list_no) const
{
FAISS_ASSERT(list_no < nlist && valid);
#ifdef USE_CPU
return readonly_ids.data() + readonly_offset[list_no];
#else
idx_t *pids = (idx_t *)pin_readonly_ids->data;
return pids + readonly_offset[list_no];
#endif
}
const InvertedLists::idx_t* ReadOnlyArrayInvertedLists::get_all_ids() const {
FAISS_ASSERT(valid);
#ifdef USE_CPU
return readonly_ids.data();
#else
return (idx_t *)(pin_readonly_ids->data);
#endif
}
const uint8_t* ReadOnlyArrayInvertedLists::get_all_codes() const {
FAISS_ASSERT(valid);
#ifdef USE_CPU
return readonly_codes.data();
#else
return (uint8_t *)(pin_readonly_codes->data);
#endif
}
const std::vector<size_t>& ReadOnlyArrayInvertedLists::get_list_length() const {

View File

@ -19,6 +19,8 @@
#include <vector>
#include <faiss/Index.h>
#ifndef USE_CPU
namespace faiss {
struct PageLockMemory {
@ -42,6 +44,7 @@ public:
};
using PageLockMemoryPtr = std::shared_ptr<PageLockMemory>;
}
#endif
namespace faiss {
@ -232,10 +235,14 @@ struct ArrayInvertedLists: InvertedLists {
};
struct ReadOnlyArrayInvertedLists: InvertedLists {
#ifdef USE_CPU
std::vector <uint8_t> readonly_codes;
std::vector <idx_t> readonly_ids;
#else
PageLockMemoryPtr pin_readonly_codes;
PageLockMemoryPtr pin_readonly_ids;
// std::vector <uint8_t> readonly_codes;
// std::vector <idx_t> readonly_ids;
#endif
std::vector <size_t> readonly_length;
std::vector <size_t> readonly_offset;
bool valid;

View File

@ -211,12 +211,17 @@ InvertedLists *read_InvertedLists (IOReader *f, int io_flags) {
auto ails = new ReadOnlyArrayInvertedLists(nlist, code_size, list_length);
size_t n;
READ1(n);
// ails->readonly_ids.resize(n);
// ails->readonly_codes.resize(n*code_size);
#ifdef USE_CPU
ails->readonly_ids.resize(n);
ails->readonly_codes.resize(n*code_size);
READANDCHECK(ails->readonly_ids.data(), n);
READANDCHECK(ails->readonly_codes.data(), n * code_size);
#else
ails->pin_readonly_ids = std::make_shared<PageLockMemory>(n * sizeof(InvertedLists::idx_t));
ails->pin_readonly_codes = std::make_shared<PageLockMemory>(n * code_size * sizeof(uint8_t));
READANDCHECK((InvertedLists::idx_t *) ails->pin_readonly_ids->data, n);
READANDCHECK((uint8_t *) ails->pin_readonly_codes->data, n * code_size);
#endif
return ails;
} else if (h == fourcc ("ilar") && !(io_flags & IO_FLAG_MMAP)) {
auto ails = new ArrayInvertedLists (0, 0);

View File

@ -245,12 +245,17 @@ void write_InvertedLists (const InvertedLists *ils, IOWriter *f) {
WRITE1 (oa->nlist);
WRITE1 (oa->code_size);
WRITEVECTOR(oa->readonly_length);
#ifdef USE_CPU
size_t n = oa->readonly_ids.size();
WRITE1(n);
WRITEANDCHECK(oa->readonly_ids.data(), n);
WRITEANDCHECK(oa->readonly_codes.data(), n * oa->code_size);
#else
size_t n = oa->pin_readonly_ids->size() / sizeof(InvertedLists::idx_t);
WRITE1(n);
// WRITEANDCHECK(oa->readonly_ids.data(), n);
// WRITEANDCHECK(oa->readonly_codes.data(), n * oa->code_size);
WRITEANDCHECK((InvertedLists::idx_t *) oa->pin_readonly_ids->data, n);
WRITEANDCHECK((uint8_t *) oa->pin_readonly_codes->data, n * oa->code_size);
#endif
} else if (const auto & od =
dynamic_cast<const OnDiskInvertedLists *>(ils)) {
uint32_t h = fourcc ("ilod");

View File

@ -3,5 +3,4 @@ BOOST_VERSION=1.70.0
GTEST_VERSION=1.8.1
LAPACK_VERSION=v3.8.0
OPENBLAS_VERSION=v0.3.6
FAISS_VERSION=1.6.0
MKL_VERSION=2019.5.281

View File

@ -81,7 +81,7 @@ static const char* CONFIG_METRIC_PROMETHEUS_PORT_DEFAULT = "8080";
/* engine config */
static const char* CONFIG_ENGINE = "engine_config";
static const char* CONFIG_ENGINE_USE_BLAS_THRESHOLD = "use_blas_threshold";
static const char* CONFIG_ENGINE_USE_BLAS_THRESHOLD_DEFAULT = "20";
static const char* CONFIG_ENGINE_USE_BLAS_THRESHOLD_DEFAULT = "1100";
static const char* CONFIG_ENGINE_OMP_THREAD_NUM = "omp_thread_num";
static const char* CONFIG_ENGINE_OMP_THREAD_NUM_DEFAULT = "0";
static const char* CONFIG_ENGINE_GPU_SEARCH_THRESHOLD = "gpu_search_threshold";
@ -96,7 +96,7 @@ static const char* CONFIG_GPU_RESOURCE_ENABLE_DEFAULT = "true";
static const char* CONFIG_GPU_RESOURCE_ENABLE_DEFAULT = "false";
#endif
static const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY = "cache_capacity";
static const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY_DEFAULT = "4";
static const char* CONFIG_GPU_RESOURCE_CACHE_CAPACITY_DEFAULT = "1";
static const char* CONFIG_GPU_RESOURCE_CACHE_THRESHOLD = "cache_threshold";
static const char* CONFIG_GPU_RESOURCE_CACHE_THRESHOLD_DEFAULT = "0.85";
static const char* CONFIG_GPU_RESOURCE_DELIMITER = ",";

View File

@ -170,6 +170,7 @@ GetVecIndexFactory(const IndexType& type, const Config& cfg) {
#endif
#ifdef CUSTOMIZATION
#ifdef MILVUS_GPU_VERSION
case IndexType::FAISS_IVFSQ8_HYBRID: {
server::Config& config = server::Config::GetInstance();
bool gpu_resource_enable = true;
@ -181,6 +182,7 @@ GetVecIndexFactory(const IndexType& type, const Config& cfg) {
throw Exception(DB_ERROR, "No GPU resources for IndexType::FAISS_IVFSQ8_HYBRID");
}
}
#endif
#endif
case IndexType::NSG_MIX: { // TODO(linxj): bug.
index = std::make_shared<knowhere::NSG>(gpu_device);

View File

@ -510,9 +510,11 @@ TEST_F(DBTest, INDEX_TEST) {
ASSERT_TRUE(stat.ok());
#ifdef CUSTOMIZATION
#ifdef MILVUS_GPU_VERSION
index.engine_type_ = (int)milvus::engine::EngineType::FAISS_IVFSQ8H;
stat = db_->CreateIndex(table_info.table_id_, index);
ASSERT_TRUE(stat.ok());
#endif
#endif
milvus::engine::TableIndex index_out;

View File

@ -456,4 +456,24 @@ ClientProxy::DropPartition(const PartitionParam& partition_param) {
}
}
Status
ClientProxy::GetConfig(const std::string& node_name, std::string& value) const {
try {
return client_ptr_->Cmd(value, "get_config " + node_name);
} catch (std::exception& ex) {
return Status(StatusCode::UnknownError, "Fail to get config: " + node_name);
}
}
Status
ClientProxy::SetConfig(const std::string& node_name, const std::string& value) const {
try {
std::string dummy;
return client_ptr_->Cmd(dummy, "set_config " + node_name + " " + value);
} catch (std::exception& ex) {
return Status(StatusCode::UnknownError, "Fail to set config: " + node_name);
}
}
} // namespace milvus

View File

@ -104,10 +104,14 @@ class ClientProxy : public Connection {
Status
DropPartition(const PartitionParam& partition_param) override;
private:
std::shared_ptr<::grpc::Channel> channel_;
Status
GetConfig(const std::string& node_name, std::string& value) const override;
Status
SetConfig(const std::string& node_name, const std::string& value) const override;
private:
std::shared_ptr<::grpc::Channel> channel_;
std::shared_ptr<GrpcClient> client_ptr_;
bool connected_ = false;
};

View File

@ -444,6 +444,32 @@ class Connection {
*/
virtual Status
DropPartition(const PartitionParam& param) = 0;
/**
* @brief Get config method
*
* This method is used to set config.
*
* @param node_name, config node name.
* @param value, config value.
*
* @return Indicate if this operation is successful.
*/
virtual Status
GetConfig(const std::string& node_name, std::string& value) const = 0;
/**
* @brief Set config method
*
* This method is used to set config.
*
* @param node_name, config node name.
* @param value, config value.
*
* @return Indicate if this operation is successful.
*/
virtual Status
SetConfig(const std::string& node_name, const std::string& value) const = 0;
};
} // namespace milvus

View File

@ -161,4 +161,13 @@ ConnectionImpl::DropPartition(const PartitionParam& param) {
return client_proxy_->DropPartition(param);
}
Status
ConnectionImpl::GetConfig(const std::string& node_name, std::string& value) const {
return client_proxy_->GetConfig(node_name, value);
}
Status
ConnectionImpl::SetConfig(const std::string& node_name, const std::string& value) const {
return client_proxy_->SetConfig(node_name, value);
}
} // namespace milvus

View File

@ -106,7 +106,13 @@ class ConnectionImpl : public Connection {
Status
DropPartition(const PartitionParam& param) override;
private:
Status
GetConfig(const std::string& node_name, std::string& value) const override;
Status
SetConfig(const std::string& node_name, const std::string& value) const override;
private:
std::shared_ptr<ClientProxy> client_proxy_;
};