Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
3af34ab
Iter1
mayya-sharipova Jun 17, 2025
d0da0d4
move GPU plugin to x-pack
ChrisHegarty Jun 19, 2025
34b0ce8
move GPUIndexType to it's own top-level class, and spotless
ChrisHegarty Jun 19, 2025
d3db656
Add yml rest test that can be called:
mayya-sharipova Jun 19, 2025
82f1ca5
Reload KnnVectorsFormat to allow plugins to declare a custom knn vect…
ChrisHegarty Jun 20, 2025
5207bed
Add dependency on cuVS
ChrisHegarty Jun 20, 2025
d0ee7e1
Add a supported check for cuVS - can be used in more tests eventually
ChrisHegarty Jun 20, 2025
9b6fde2
revert accidental commit
ChrisHegarty Jun 20, 2025
2ac22b3
Small edits
mayya-sharipova Jun 20, 2025
8cee75e
Build cagra index (iter1)
mayya-sharipova Jun 23, 2025
3f05ba0
Build cagra index (iter2)
mayya-sharipova Jul 3, 2025
2ac9d8b
Write Cagra index to Lucene HNSW format
mayya-sharipova Jul 6, 2025
4826da6
Enable GPU indexing test in KnnIndexTester
mayya-sharipova Jul 16, 2025
7c85493
Fix merging in GPU index writer
mayya-sharipova Jul 18, 2025
ec3330e
Attempt to use Java 22 DatasetImpl with MemorySegment
mayya-sharipova Jul 19, 2025
723bb5a
Revert "Attempt to use Java 22 DatasetImpl with MemorySegment"
mayya-sharipova Jul 22, 2025
5cb3829
Merge remote-tracking branch 'upstream/main' into es-gpu
mayya-sharipova Jul 22, 2025
0ee27d9
Fix spotless
mayya-sharipova Jul 22, 2025
d27b62f
Use off-heap Dataset when merging vector data
ChrisHegarty Jul 24, 2025
e90fcd7
Plugins can provide VectorsFormatProvider
mayya-sharipova Jul 24, 2025
9f2c96f
Fix bugs
mayya-sharipova Jul 25, 2025
4390d55
Introduce an index level setting: index.vectors.indexing.use_gpu
mayya-sharipova Jul 28, 2025
949f8af
Merge branch 'main' into es-gpu
ChrisHegarty Jul 29, 2025
8f22e28
Fix initialization of DatasetUtilTests to avoid instance check if uns…
ChrisHegarty Jul 29, 2025
5386fb8
Add unknown value test to IndexSettingsTests for GPU
ChrisHegarty Jul 29, 2025
7a2cd83
Add GPU Integration test
ChrisHegarty Jul 29, 2025
1f742f4
Add more tests
mayya-sharipova Jul 30, 2025
9ad0367
Adjust Cagra Index degree to fit the default performance of
mayya-sharipova Aug 3, 2025
446fba7
Add CuVSResourceManager for controlling parallelism and pooling of cu…
ChrisHegarty Aug 12, 2025
e6e9c17
Use new cuvs version 25.10; direct access to cagra graph via CuVSMatr…
ldematte Aug 14, 2025
c38c8aa
WIP cuvs-snapshot updating
brianseeders Aug 15, 2025
66e24c0
Update cuvs snapshot version to 25.10.0
brianseeders Aug 15, 2025
eb9dfeb
Always update cuvs-java
brianseeders Aug 15, 2025
dddadce
Implement working with sorted index
mayya-sharipova Aug 18, 2025
9c1db2d
Expose m and efConstruction params in GPU index building
mayya-sharipova Aug 19, 2025
f452dfc
Add yml test
mayya-sharipova Aug 19, 2025
47d58d0
Update cuvs snapshot version to 25.10.0
brianseeders Aug 19, 2025
6c7f49f
Working script to configure cuvs snapshot and update current one
brianseeders Aug 19, 2025
0145af0
Update cuvs snapshot version to 25.10.0
brianseeders Aug 19, 2025
e778480
Update cuvs snapshot version to 25.10.0
brianseeders Aug 19, 2025
9c8417c
Update cuvs snapshot version to 25.10.0
brianseeders Aug 19, 2025
7e0cc3d
Rename GpuVectorsFormat to EsGpuHnswVectorsFormat
mayya-sharipova Aug 20, 2025
b03d2be
Revert some of the changes made while testing bug fixes, add nvidia-s…
brianseeders Aug 20, 2025
0d51a86
And int8_hswn option
mayya-sharipova Aug 20, 2025
b20033f
Add new gpu/cuvs pipelines
brianseeders Aug 21, 2025
cb076d7
Set -u later
brianseeders Aug 21, 2025
7abc031
Set empty LD_LIBRARY_PATH
brianseeders Aug 21, 2025
c04f605
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Aug 21, 2025
877ff01
Move env to proper location
brianseeders Aug 21, 2025
026e34b
Merge branch 'cuvs-snapshot' of github.com:elastic/elasticsearch into…
brianseeders Aug 21, 2025
c281bf5
Update zones for g2 instances
brianseeders Aug 21, 2025
4ce32d6
Fix env var
brianseeders Aug 21, 2025
f8f7c39
test-gpu should be a skip-label
brianseeders Aug 21, 2025
91f676f
Adjust skip labels
brianseeders Aug 21, 2025
9327371
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Aug 21, 2025
1a727fa
Add int8 to KnnIndexTester
mayya-sharipova Aug 22, 2025
5d1ef89
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Aug 23, 2025
913430a
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Aug 26, 2025
f9dd63e
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Aug 27, 2025
cff3e94
Send quantized data to GPU for index building during merge
mayya-sharipova Aug 28, 2025
ebb36e0
Fix for int8_hnsw when the number of vectors < MIN_NUM_VECTORS_FOR_GP…
mayya-sharipova Sep 2, 2025
83aa729
PoolingCuVSResourceManager with memory availability (#133242)
ldematte Sep 3, 2025
3cd4405
Remove assertion to fix tests (#134035)
ldematte Sep 3, 2025
2f07fb7
Merge branch 'cuvs-snapshot' into es-gpu
brianseeders Sep 3, 2025
f8c9a9f
Merge remote-tracking branch 'upstream/main' into es-gpu
mayya-sharipova Sep 3, 2025
ad34a1c
Fix spotless
mayya-sharipova Sep 3, 2025
eb1c659
Merge remote-tracking branch 'upstream/es-gpu' into es-gpu
mayya-sharipova Sep 3, 2025
d8e6826
Modify GPUDenseVectorFieldMapperTests to extend DenseVectorFieldMappe…
mayya-sharipova Sep 3, 2025
9b56b5e
Add tests for int8_hnsw
mayya-sharipova Sep 5, 2025
42eff30
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 6, 2025
34670e3
Fix: `ESGpuHnswVectorsWriter#mergeOneField` now supports non memory-m…
ldematte Sep 9, 2025
2af02f1
Fix TransportResumeFollowActionTests.testDynamicIndexSettingsAreClass…
mayya-sharipova Sep 9, 2025
d3b8eeb
Fix failed tests in ":x-pack:plugin:esql:qa:server:multi-node:javaRes…
mayya-sharipova Sep 9, 2025
7917cc1
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 11, 2025
6da63ec
(HACK) Add reflection utils to server and export them to GPU
ldematte Sep 11, 2025
5849a6f
Refactor to isolate current flush logic to flushFieldsWithoutMemoryMa…
ldematte Sep 11, 2025
c34be34
Reproduce flatVectorWriter.flush() via reflection to "instrument" it
ldematte Sep 11, 2025
1061065
Using a tmp file for enabling mmap MemorySegment during flush (#134438)
ldematte Sep 11, 2025
83d4633
Merge remote-tracking branch 'upstream/es-gpu' into es-gpu
ldematte Sep 11, 2025
e9ddaa0
Enable mmapped file code path
ldematte Sep 11, 2025
c051873
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 12, 2025
367080e
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 14, 2025
2839d5b
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 16, 2025
13fbf99
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 17, 2025
b6e69bc
Merge remote-tracking branch 'upstream/main' into es-gpu
ldematte Sep 17, 2025
6a3743a
Use elastic-cuvs-java as the cuvs-java artifact name, until we switch…
brianseeders Sep 17, 2025
d954f35
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 18, 2025
3ce801a
Merge remote-tracking branch 'upstream/es-gpu' into es-gpu
ldematte Sep 18, 2025
ac3b4e5
Fix: signature changes + forbiddenApis + license file names
ldematte Sep 18, 2025
fcd49ce
Revert "Enable mmapped file code path"
ldematte Sep 18, 2025
9e9deca
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 19, 2025
8e102b1
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 20, 2025
48ebb1f
Expand gpu support checks (#135000)
ldematte Sep 22, 2025
035ab73
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 23, 2025
b427ff1
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 24, 2025
9eb25b3
Use direct heap to GPU copy for raw vector data (#135210)
ldematte Sep 24, 2025
67b0fbc
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 25, 2025
a6653ce
Merge remote-tracking branch 'upstream/main' into es-gpu
mayya-sharipova Sep 25, 2025
6890e3a
Remove 24 launcher
mayya-sharipova Sep 25, 2025
2b0007a
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 26, 2025
45708de
Rename GPU format to ES92
mayya-sharipova Sep 26, 2025
3e46a34
Update docs/changelog/135545.yaml
mayya-sharipova Sep 26, 2025
210163b
Merge branch 'main' into es-gpu
mayya-sharipova Sep 26, 2025
2cd1224
Add cuvs-java artifact to a custom GCS bucket
brianseeders Sep 26, 2025
b161ed4
Merge branch 'es-gpu' of github.com:elastic/elasticsearch into es-gpu
brianseeders Sep 26, 2025
c602e7b
Merge branch 'main' into es-gpu
mayya-sharipova Sep 26, 2025
9d926f2
Fix checksum
brianseeders Sep 26, 2025
b53d18d
Merge branch 'es-gpu' of github.com:elastic/elasticsearch into es-gpu
brianseeders Sep 26, 2025
2f07c5a
Re-enable regular CI steps in PRs
brianseeders Sep 26, 2025
9f6885a
Merge branch 'main' into es-gpu
mayya-sharipova Sep 26, 2025
b9bf617
Add GCS bucket repo where needed
brianseeders Sep 26, 2025
5301950
Small cleanups
mayya-sharipova Sep 26, 2025
ccda070
Merge branch 'main' into es-gpu
mayya-sharipova Sep 26, 2025
304bc68
Introduce feature flag "vectors_indexing_use_gpu" in IndexSettings
mayya-sharipova Sep 26, 2025
3b9364c
Merge branch 'main' into es-gpu
mayya-sharipova Sep 26, 2025
c410d92
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 27, 2025
d1481d7
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 28, 2025
ae5cc15
GPUPlugin to implement InternalVectorFormatProviderPlugin
mayya-sharipova Sep 28, 2025
70ae1cd
Change license to Lucene
mayya-sharipova Sep 28, 2025
55ee270
Switch to group varint when writing vectorIndex
mayya-sharipova Sep 28, 2025
b88f2b6
Merge branch 'main' into es-gpu
mayya-sharipova Sep 29, 2025
3cb4b71
Revert "Introduce feature flag "vectors_indexing_use_gpu" in IndexSet…
mayya-sharipova Sep 29, 2025
2d51f5a
Move "index.vectors.indexing.use_gpu" setting under GPUPlugin
mayya-sharipova Sep 29, 2025
57d37e4
Merge branch 'main' into es-gpu
mayya-sharipova Sep 29, 2025
543fafe
Add test when FF is disabled
mayya-sharipova Sep 29, 2025
dba71de
Merge branch 'main' into es-gpu
mayya-sharipova Sep 29, 2025
6d843e1
Rename formats to Lucene99HnswVectorsFormat
mayya-sharipova Sep 29, 2025
b8c190e
Merge branch 'main' into es-gpu
mayya-sharipova Sep 30, 2025
f221ff5
Merge branch 'main' into es-gpu
mayya-sharipova Sep 30, 2025
e66aca5
Update cuvs snapshot version to 25.10.0
elastic-vault-github-plugin-prod[bot] Sep 30, 2025
f324889
Merge branch 'main' into es-gpu
ChrisHegarty Sep 30, 2025
f926084
Rename feature flag to gpu_vectors_indexing
mayya-sharipova Sep 30, 2025
d48d11d
Merge branch 'main' into es-gpu
mayya-sharipova Sep 30, 2025
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
21 changes: 21 additions & 0 deletions .buildkite/pipelines/cuvs-snapshot/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
- label: "{{matrix.GRADLE_TASK}}"
command: .buildkite/scripts/cuvs-snapshot/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints {{matrix.GRADLE_TASK}}
timeout_in_minutes: 300
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2404-nvidia
machineType: g2-standard-32
buildDirectory: /dev/shm/bk
zones: us-central1-b,us-central1-c
env:
GRADLE_TASK: "{{matrix.GRADLE_TASK}}"
matrix:
setup:
GRADLE_TASK:
- checkPart1
- checkPart2
- checkPart3
- checkPart4
- checkPart5
- checkPart6
14 changes: 14 additions & 0 deletions .buildkite/pipelines/cuvs-snapshot/update-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
steps:
- label: "Smoke test and update new cuVS snapshot"
command: .buildkite/scripts/cuvs-snapshot/update-current-snapshot-version.sh
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2404-nvidia
machineType: g2-standard-16
zones: us-central1-b,us-central1-c
diskSizeGb: 150
- wait: ~
- trigger: "elasticsearch-cuvs-run-tests"
build:
branch: "${BUILDKITE_BRANCH}"
async: true
3 changes: 2 additions & 1 deletion .buildkite/pipelines/pull-request/.defaults.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
config:
skip-labels: ">test-mute"
skip-labels:
- ">test-mute"
excluded-regions:
- ^docs/.*
- ^x-pack/docs/.*
Expand Down
1 change: 0 additions & 1 deletion .buildkite/pipelines/pull-request/bwc-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ steps:
image: family/elasticsearch-ubuntu-2004
machineType: n1-standard-32
buildDirectory: /dev/shm/bk

28 changes: 28 additions & 0 deletions .buildkite/pipelines/pull-request/gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
config:
allow-labels: test-gpu
skip-labels:
- ">test-mute"
steps:
- group: gpu-tests
steps:
- label: "{{matrix.GRADLE_TASK}} / gpu-tests"
key: "packaging-tests-unix"
command: .buildkite/scripts/cuvs-snapshot/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints {{matrix.GRADLE_TASK}}
timeout_in_minutes: 300
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2404-nvidia
machineType: g2-standard-32
buildDirectory: /dev/shm/bk
zones: us-central1-b,us-central1-c
env:
GRADLE_TASK: "{{matrix.GRADLE_TASK}}"
matrix:
setup:
GRADLE_TASK:
- checkPart1
- checkPart2
- checkPart3
- checkPart4
- checkPart5
- checkPart6
43 changes: 43 additions & 0 deletions .buildkite/scripts/cuvs-snapshot/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -euo pipefail

if [[ -f /etc/profile.d/elastic-nvidia.sh ]]; then
export JAVA_HOME="$HOME/.java/openjdk24"
export PATH="$JAVA_HOME/bin:$PATH"

# Setup LD_LIBRARY_PATH, PATH

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}"
source /etc/profile.d/elastic-nvidia.sh
fi

# Not running this before the tests results in an error when running the tests
# No idea why...
nvidia-smi

CURRENT_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ELASTICSEARCH_REPO_DIR="$(cd "$CURRENT_SCRIPT_DIR/../../.." && pwd)"

CUVS_SNAPSHOT_VERSION="${CUVS_SNAPSHOT_VERSION:-$(cat "$CURRENT_SCRIPT_DIR"/current-snapshot-version)}"
CUVS_ARCHIVE="cuvs-$CUVS_SNAPSHOT_VERSION.tar.gz"
CUVS_URL="https://storage.googleapis.com/elasticsearch-cuvs-snapshots/$CUVS_ARCHIVE"

CUVS_WORKSPACE=${CUVS_WORKSPACE:-$(cd "$(mktemp -d)")}
CUVS_DIR="$(pwd)/cuvs-$CUVS_SNAPSHOT_VERSION"

curl -O "$CUVS_URL"
tar -xzf "$CUVS_ARCHIVE"

CUVS_VERSION=$(cd "$CUVS_DIR/cuvs-java/target" && mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

LD_LIBRARY_PATH=$(echo "$LD_LIBRARY_PATH" | tr ':' '\n' | grep -v "libcuvs/linux-x64" | tr '\n' ':' | sed 's/:$//')
LD_LIBRARY_PATH="$CUVS_DIR/libcuvs/linux-x64:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH

cd "$CUVS_DIR/cuvs-java/target"
mvn install:install-file -Dfile="cuvs-java-$CUVS_VERSION.jar" -DartifactId=elastic-cuvs-java -DgeneratePom=true

cd "$ELASTICSEARCH_REPO_DIR"
PLUGIN_GRADLE_FILE=x-pack/plugin/gpu/build.gradle
sed -i "s|implementation 'com.nvidia.cuvs:elastic-cuvs-java:.*'|implementation 'com.nvidia.cuvs:elastic-cuvs-java:$CUVS_VERSION'|" "$PLUGIN_GRADLE_FILE"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fdb8bfb8
9 changes: 9 additions & 0 deletions .buildkite/scripts/cuvs-snapshot/run-gradle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -euo pipefail

source .buildkite/scripts/cuvs-snapshot/configure.sh

cd "$WORKSPACE"

.ci/scripts/run-gradle.sh "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -euo pipefail

SNAPSHOT_VERSION_FILE=.buildkite/scripts/cuvs-snapshot/current-snapshot-version
BRANCH_TO_UPDATE="${BRANCH_TO_UPDATE:-${BUILDKITE_BRANCH:-cuvs-snapshot}}"

if [[ -z "${CUVS_SNAPSHOT_VERSION:-}" ]]; then
echo "CUVS_SNAPSHOT_VERSION not set. Set this to update the current snapshot version."
exit 1
fi

if [[ "$CUVS_SNAPSHOT_VERSION" == "$(cat $SNAPSHOT_VERSION_FILE)" ]]; then
echo "Current snapshot version already set to '$CUVS_SNAPSHOT_VERSION'. No need to update."
exit 0
fi

echo "--- Configuring libcuvs/cuvs-java"
source .buildkite/scripts/cuvs-snapshot/configure.sh

if [[ "${SKIP_TESTING:-}" != "true" ]]; then
echo "--- Testing snapshot before updating"
./gradlew -Druntime.java=24 :x-pack:plugin:gpu:yamlRestTest -S
fi

echo "--- Updating snapshot"

echo "$CUVS_SNAPSHOT_VERSION" > "$SNAPSHOT_VERSION_FILE"

CURRENT_SHA="$(gh api "/repos/elastic/elasticsearch/contents/$SNAPSHOT_VERSION_FILE?ref=$BRANCH_TO_UPDATE" | jq -r .sha)" || true

gh api -X PUT "/repos/elastic/elasticsearch/contents/$SNAPSHOT_VERSION_FILE" \
-f branch="$BRANCH_TO_UPDATE" \
-f message="Update cuvs snapshot version to $CUVS_VERSION" \
-f content="$(base64 -w 0 "$WORKSPACE/$SNAPSHOT_VERSION_FILE")" \
-f sha="$CURRENT_SHA"
5 changes: 5 additions & 0 deletions docs/changelog/135545.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 135545
summary: Add GPUPlugin for indexing vectors on GPU
area: Vector Search
type: feature
issues: []
5 changes: 5 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,11 @@
<sha256 value="64fab42f17bf8e0efb193dd34da716ef7abb7515234036119df1776b808dc066" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.nvidia.cuvs" name="cuvs-java" version="25.10.0">
<artifact name="cuvs-java-25.10.0.jar">
<sha256 value="2d4cca3b6b6c7c4d3c1a2f57c00cb55f7a45699536ad356699f32bcea7714539" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.perforce" name="p4java" version="2015.2.1365273">
<artifact name="p4java-2015.2.1365273.jar">
<sha256 value="fbcf286c5863a658b400ec2595ee13c5d49c656f735923088509e3f976ea421e" origin="Generated by Gradle"/>
Expand Down
7 changes: 7 additions & 0 deletions qa/vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ tasks.named("dependencyLicenses").configure {
tasks.named('forbiddenApisMain').configure {
enabled = false
}
repositories {
mavenLocal()
maven {
url = uri("https://storage.googleapis.com/elasticsearch-cuvs-snapshots")
}
}

dependencies {
api "org.apache.lucene:lucene-core:${versions.lucene}"
Expand All @@ -31,6 +37,7 @@ dependencies {
implementation project(':libs:native')
implementation project(':libs:logging')
implementation project(':server')
implementation project(':x-pack:plugin:gpu')
}
/**
* Task to run the KnnIndexTester with the provided parameters.
Expand Down
1 change: 1 addition & 0 deletions qa/vector/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
requires org.elasticsearch.logging;
requires java.management;
requires jdk.management;
requires org.elasticsearch.gpu;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentParserConfiguration;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xpack.gpu.codec.ES92GpuHnswSQVectorsFormat;
import org.elasticsearch.xpack.gpu.codec.ES92GpuHnswVectorsFormat;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -76,7 +78,8 @@ public class KnnIndexTester {
enum IndexType {
HNSW,
FLAT,
IVF
IVF,
GPU_HNSW
}

enum MergePolicyType {
Expand All @@ -90,6 +93,8 @@ private static String formatIndexPath(CmdLineArgs args) {
List<String> suffix = new ArrayList<>();
if (args.indexType() == IndexType.FLAT) {
suffix.add("flat");
} else if (args.indexType() == IndexType.GPU_HNSW) {
suffix.add("gpu_hnsw");
} else if (args.indexType() == IndexType.IVF) {
suffix.add("ivf");
suffix.add(Integer.toString(args.ivfClusterSize()));
Expand All @@ -107,6 +112,16 @@ static Codec createCodec(CmdLineArgs args) {
final KnnVectorsFormat format;
if (args.indexType() == IndexType.IVF) {
format = new ES920DiskBBQVectorsFormat(args.ivfClusterSize(), ES920DiskBBQVectorsFormat.DEFAULT_CENTROIDS_PER_PARENT_CLUSTER);
} else if (args.indexType() == IndexType.GPU_HNSW) {
if (args.quantizeBits() == 32) {
format = new ES92GpuHnswVectorsFormat();
} else if (args.quantizeBits() == 7) {
format = new ES92GpuHnswSQVectorsFormat();
} else {
throw new IllegalArgumentException(
"GPU HNSW index type only supports 7 or 32 bits quantization, but got: " + args.quantizeBits()
);
}
} else {
if (args.quantizeBits() == 1) {
if (args.indexType() == IndexType.FLAT) {
Expand Down
5 changes: 3 additions & 2 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@
org.elasticsearch.settings.secure,
org.elasticsearch.serverless.constants,
org.elasticsearch.serverless.apifiltering,
org.elasticsearch.internal.security;
org.elasticsearch.internal.security,
org.elasticsearch.gpu;

exports org.elasticsearch.telemetry.tracing;
exports org.elasticsearch.telemetry;
Expand Down Expand Up @@ -486,7 +487,7 @@
exports org.elasticsearch.plugins.internal.rewriter to org.elasticsearch.inference;
exports org.elasticsearch.lucene.util.automaton;
exports org.elasticsearch.index.codec.perfield;
exports org.elasticsearch.index.codec.vectors to org.elasticsearch.test.knn;
exports org.elasticsearch.index.codec.vectors to org.elasticsearch.test.knn, org.elasticsearch.gpu;
exports org.elasticsearch.index.codec.vectors.es818 to org.elasticsearch.test.knn;
exports org.elasticsearch.inference.telemetry;
exports org.elasticsearch.index.codec.vectors.diskbbq to org.elasticsearch.test.knn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
if (mapperService != null) {
Mapper mapper = mapperService.mappingLookup().getMapper(field);
if (mapper instanceof DenseVectorFieldMapper vectorMapper) {
return vectorMapper.getKnnVectorsFormatForField(knnVectorsFormat);
return vectorMapper.getKnnVectorsFormatForField(knnVectorsFormat, mapperService.getIndexSettings());
}
}
return knnVectorsFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public FlatVectorsReader fieldsReader(SegmentReadState state) throws IOException
);
}

static final class ES814ScalarQuantizedVectorsWriter extends FlatVectorsWriter {
public static final class ES814ScalarQuantizedVectorsWriter extends FlatVectorsWriter {

final Lucene99ScalarQuantizedVectorsWriter delegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ private static void postProcessDynamicArrayMapping(DocumentParserContext context
DenseVectorFieldMapper.Builder builder = new DenseVectorFieldMapper.Builder(
fieldName,
context.indexSettings().getIndexVersionCreated(),
IndexSettings.INDEX_MAPPING_EXCLUDE_SOURCE_VECTORS_SETTING.get(context.indexSettings().getSettings())
IndexSettings.INDEX_MAPPING_EXCLUDE_SOURCE_VECTORS_SETTING.get(context.indexSettings().getSettings()),
context.getVectorFormatProviders()
);
builder.dimensions(mappers.size());
DenseVectorFieldMapper denseVectorFieldMapper = builder.build(builderContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.index.mapper.MapperService.MergeReason;
import org.elasticsearch.index.mapper.vectors.VectorsFormatProvider;
import org.elasticsearch.xcontent.FilterXContentParserWrapper;
import org.elasticsearch.xcontent.FlatteningXContentParser;
import org.elasticsearch.xcontent.XContentBuilder;
Expand Down Expand Up @@ -305,6 +306,10 @@ public final MetadataFieldMapper getMetadataMapper(String mapperName) {
return mappingLookup.getMapping().getMetadataMapperByName(mapperName);
}

public final List<VectorsFormatProvider> getVectorFormatProviders() {
return mappingParserContext.getVectorsFormatProviders();
}

public final MappingParserContext dynamicTemplateParserContext(DateFormatter dateFormatter) {
return mappingParserContext.createDynamicTemplateContext(dateFormatter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.mapper.vectors.VectorsFormatProvider;
import org.elasticsearch.plugins.FieldPredicate;
import org.elasticsearch.plugins.MapperPlugin;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

Expand All @@ -32,21 +34,24 @@ public final class MapperRegistry {
private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers5x;
private final Function<String, FieldPredicate> fieldFilter;
private final RootObjectMapperNamespaceValidator namespaceValidator;
private final List<VectorsFormatProvider> vectorsFormatProviders;

public MapperRegistry(
Map<String, Mapper.TypeParser> mapperParsers,
Map<String, RuntimeField.Parser> runtimeFieldParsers,
Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers,
Function<String, FieldPredicate> fieldFilter
Function<String, FieldPredicate> fieldFilter,
List<VectorsFormatProvider> vectorsFormatProviders
) {
this(mapperParsers, runtimeFieldParsers, metadataMapperParsers, fieldFilter, null);
this(mapperParsers, runtimeFieldParsers, metadataMapperParsers, fieldFilter, vectorsFormatProviders, null);
}

public MapperRegistry(
Map<String, Mapper.TypeParser> mapperParsers,
Map<String, RuntimeField.Parser> runtimeFieldParsers,
Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers,
Function<String, FieldPredicate> fieldFilter,
List<VectorsFormatProvider> vectorsFormatProviders,
RootObjectMapperNamespaceValidator namespaceValidator
) {
this.mapperParsers = Collections.unmodifiableMap(new LinkedHashMap<>(mapperParsers));
Expand All @@ -62,6 +67,7 @@ public MapperRegistry(
this.metadataMapperParsers5x = metadata5x;
this.fieldFilter = fieldFilter;
this.namespaceValidator = namespaceValidator;
this.vectorsFormatProviders = vectorsFormatProviders;
}

/**
Expand All @@ -88,6 +94,10 @@ public RootObjectMapperNamespaceValidator getNamespaceValidator() {
return namespaceValidator;
}

public List<VectorsFormatProvider> getVectorsFormatProviders() {
return vectorsFormatProviders;
}

/**
* Return a map of the meta mappers that have been registered. The
* returned map uses the name of the field as a key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public MapperService(
indexSettings,
idFieldMapper,
bitSetProducer,
mapperRegistry.getVectorsFormatProviders(),
mapperRegistry.getNamespaceValidator()
);
this.documentParser = new DocumentParser(parserConfiguration, this.mappingParserContextSupplier.get());
Expand Down
Loading