Skip to content

Commit 2668580

Browse files
committed
Allow users to specify an uncompressed quantizer to bypass default quantization
1 parent b8ce749 commit 2668580

File tree

8 files changed

+79
-13
lines changed

8 files changed

+79
-13
lines changed

.github/workflows/main.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ on:
77
pull_request:
88

99
env:
10-
WEAVIATE_124: 1.24.26
1110
WEAVIATE_125: 1.25.34
1211
WEAVIATE_126: 1.26.17
1312
WEAVIATE_127: 1.27.27
1413
WEAVIATE_128: 1.28.16
15-
WEAVIATE_129: 1.29.8
16-
WEAVIATE_130: 1.30.7
17-
WEAVIATE_131: 1.31.0
18-
WEAVIATE_132: 1.32.0-rc.1
14+
WEAVIATE_129: 1.29.9
15+
WEAVIATE_130: 1.30.12
16+
WEAVIATE_131: 1.31.5
17+
WEAVIATE_132: 1.32.4-cdf9a3b
1918

2019
concurrency:
2120
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -43,7 +42,6 @@ jobs:
4342
fail-fast: false
4443
matrix:
4544
versions: [
46-
{ node: "22.x", weaviate: $WEAVIATE_124},
4745
{ node: "22.x", weaviate: $WEAVIATE_125},
4846
{ node: "22.x", weaviate: $WEAVIATE_126},
4947
{ node: "22.x", weaviate: $WEAVIATE_127},

src/collections/config/integration.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { requireAtLeast } from '../../../test/version.js';
33
import { WeaviateUnsupportedFeatureError } from '../../errors.js';
44
import weaviate, { WeaviateClient, weaviateV2 } from '../../index.js';
5+
import { WeaviateClass } from '../../openapi/types.js';
56
import {
67
GenerativeCohereConfig,
78
ModuleConfig,
@@ -833,4 +834,27 @@ describe('Testing of the collection.config namespace', () => {
833834
expect(indexConfig.multiVector?.encoding).toBeUndefined();
834835
}
835836
);
837+
838+
requireAtLeast(1, 32, 4).it.only(
839+
'should be able to create a collection with an uncompressed quantizer',
840+
async () => {
841+
const collectionName = 'TestCollectionConfigCreateWithUncompressedQuantizer';
842+
const collection = await client.collections.create({
843+
name: collectionName,
844+
vectorizers: weaviate.configure.vectors.selfProvided({
845+
quantizer: weaviate.configure.vectorIndex.quantizer.none(),
846+
}),
847+
});
848+
await collection.config
849+
.get()
850+
.then((config) =>
851+
expect((config.vectorizers.default.indexConfig as VectorIndexConfigHNSW).quantizer).toBeUndefined()
852+
);
853+
await fetch(`http://localhost:8080/v1/schema/${collectionName}`)
854+
.then((res) => res.json() as WeaviateClass)
855+
.then((schema) =>
856+
expect(schema.vectorConfig?.default.vectorIndexConfig?.skipDefaultQuantization).toBe(true)
857+
);
858+
}
859+
);
836860
});

src/collections/config/types/vectorIndex.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export type RQConfig = {
6868
type: 'rq';
6969
};
7070

71+
export type UncompressedConfig = {
72+
type: 'none';
73+
};
74+
7175
export type MultiVectorConfig = {
7276
aggregation: 'maxSim' | string;
7377
encoding?: MultiVectorEncodingConfig;

src/collections/config/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ export const parseVectorIndex = (module: ModuleConfig<VectorIndexType, VectorInd
219219
},
220220
};
221221
}
222+
if (QuantizerGuards.isUncompressedCreate(quantizer)) {
223+
return {
224+
...conf,
225+
skipDefaultQuantization: true,
226+
};
227+
}
222228
};
223229

224230
export const parseVectorizerConfig = (config?: VectorizerConfig): any => {

src/collections/configure/parsing.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MuveraEncodingConfigCreate } from '../index.js';
1+
import { MuveraEncodingConfigCreate, UncompressedConfigCreate } from '../index.js';
22
import {
33
BQConfigCreate,
44
BQConfigUpdate,
@@ -49,6 +49,9 @@ export class QuantizerGuards {
4949
static isRQUpdate(config?: QuantizerConfig): config is RQConfigUpdate {
5050
return (config as RQConfigUpdate)?.type === 'rq';
5151
}
52+
static isUncompressedCreate(config?: QuantizerConfig): config is UncompressedConfigCreate {
53+
return (config as UncompressedConfigCreate)?.type === 'none';
54+
}
5255
}
5356

5457
type VectorIndexConfigCreate =

src/collections/configure/types/base.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ import { WeaviateNestedProperty, WeaviateProperty } from '../../../openapi/types
22
import {
33
InvertedIndexConfig,
44
MultiTenancyConfig,
5+
QuantizerConfig,
56
ReplicationConfig,
67
ReplicationDeletionStrategy,
78
} from '../../config/types/index.js';
8-
import { DataType } from '../../types/index.js';
9+
import { DataType, QuantizerRecursivePartial } from '../../types/index.js';
910
import { NonRefKeys, RefKeys } from '../../types/internal.js';
1011

1112
export type RecursivePartial<T> = T extends object
1213
? {
13-
[P in keyof T]?: RecursivePartial<T[P]>;
14+
[P in keyof T]?: T[P] extends QuantizerConfig
15+
? QuantizerRecursivePartial<T[P]>
16+
: RecursivePartial<T[P]>;
1417
}
1518
: T;
1619

src/collections/configure/types/vectorIndex.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
PQEncoderType,
99
RQConfig,
1010
SQConfig,
11+
UncompressedConfig,
1112
VectorDistance,
1213
VectorIndexConfigDynamic,
1314
VectorIndexConfigFlat,
@@ -57,11 +58,14 @@ export type SQConfigUpdate = {
5758
type: 'sq';
5859
};
5960

61+
export type UncompressedConfigCreate = QuantizerRecursivePartial<UncompressedConfig>;
62+
6063
export type QuantizerConfigCreate =
6164
| PQConfigCreate
6265
| BQConfigCreate
6366
| SQConfigCreate
6467
| RQConfigCreate
68+
| UncompressedConfigCreate
6569
| Record<string, any>;
6670

6771
export type QuantizerConfigUpdate =
@@ -80,11 +84,23 @@ export type MuveraEncodingConfigCreate = RecursivePartial<MuveraEncodingConfig>;
8084

8185
export type MultiVectorEncodingConfigCreate = MuveraEncodingConfigCreate;
8286

83-
export type VectorIndexConfigHNSWCreate = RecursivePartial<VectorIndexConfigHNSW>;
87+
export type VectorIndexConfigHNSWCreate = RecursivePartial<Omit<VectorIndexConfigHNSW, 'quantizer'>> & {
88+
quantizer?: QuantizerConfigCreate;
89+
};
8490

85-
export type VectorIndexConfigDynamicCreate = RecursivePartial<VectorIndexConfigDynamic>;
91+
export type VectorIndexConfigDynamicCreate = RecursivePartial<
92+
Omit<VectorIndexConfigDynamic, 'hnsw' | 'flat'>
93+
> & {
94+
hnsw?: VectorIndexConfigHNSWCreate;
95+
flat?: VectorIndexConfigFlatCreate;
96+
};
8697

87-
export type VectorIndexConfigDymamicUpdate = RecursivePartial<VectorIndexConfigDynamic>;
98+
export type VectorIndexConfigDymamicUpdate = RecursivePartial<
99+
Omit<VectorIndexConfigDynamic, 'hnsw' | 'flat'>
100+
> & {
101+
hnsw?: VectorIndexConfigHNSWUpdate;
102+
flat?: VectorIndexConfigFlatUpdate;
103+
};
88104

89105
export type VectorIndexConfigHNSWUpdate = {
90106
dynamicEfMin?: number;
@@ -107,7 +123,9 @@ export type VectorIndexConfigCreateType<I> = I extends 'hnsw'
107123
? Record<string, any>
108124
: never;
109125

110-
export type VectorIndexConfigFlatCreate = RecursivePartial<VectorIndexConfigFlat>;
126+
export type VectorIndexConfigFlatCreate = RecursivePartial<Omit<VectorIndexConfigFlat, 'quantizer'>> & {
127+
quantizer?: QuantizerConfigCreate;
128+
};
111129

112130
export type VectorIndexConfigFlatUpdate = {
113131
quantizer?: BQConfigUpdate;

src/collections/configure/vectorIndex.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ const configure = {
149149
* Define the quantizer configuration to use when creating a vector index.
150150
*/
151151
quantizer: {
152+
/**
153+
* Create an object of type `NoneConfigCreate` to be used when defining the quantizer configuration of a vector index.
154+
*
155+
* This is useful for disabling the default quantization present in Weaviate>=1.33.0.
156+
*/
157+
none: () => {
158+
return {
159+
type: 'none',
160+
};
161+
},
152162
/**
153163
* Create an object of type `BQConfigCreate` to be used when defining the quantizer configuration of a vector index.
154164
*

0 commit comments

Comments
 (0)