Skip to content

[ENH]: Add option to enable quantization in schema#6295

Merged
sanketkedia merged 3 commits intomainfrom
01-29-_enh_add_option_to_enable_quantization_in_schema
Feb 3, 2026
Merged

[ENH]: Add option to enable quantization in schema#6295
sanketkedia merged 3 commits intomainfrom
01-29-_enh_add_option_to_enable_quantization_in_schema

Conversation

@sanketkedia
Copy link
Copy Markdown
Contributor

@sanketkedia sanketkedia commented Jan 31, 2026

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Adds a fields in spann index config - quantize which is set to false by default
    • this field is hidden from the clients and only set in server
    • PR#6297 gives ability to set it at tenant level based on config set in frontend config
  • New functionality
    • ...

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

None

Observability plan

None

Documentation Changes

None

Copy link
Copy Markdown
Contributor Author

@github-actions
Copy link
Copy Markdown

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@propel-code-bot
Copy link
Copy Markdown
Contributor

propel-code-bot bot commented Jan 31, 2026

The update carries this quantization flag through the Go coordinator schema, Rust type layer, and generated TypeScript client to keep the SPANN schema synchronized end-to-end, and it also introduces the coordinator-side Cmek struct so CMEK-aware schema handling remains consistent with server expectations.

Affected Areas

• Go coordinator schema definitions
• Rust schema/type conversion layer
• Generated TypeScript client types

This summary was automatically generated by @propel-code-bot

EfConstruction *int `json:"ef_construction,omitempty"`
EfSearch *int `json:"ef_search,omitempty"`
MaxNeighbors *int `json:"max_neighbors,omitempty"`
Quantize bool `json:"quantize,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[Logic] The Quantize field is missing from the SpannConfiguration struct (the internal configuration used by the system), defined earlier in this file (around line 44). Adding it here to the Schema (SpannIndexConfig) without adding it to the internal configuration means the setting may be lost when converting between schema and internal representations.

Context for Agents
The `Quantize` field is missing from the `SpannConfiguration` struct (the internal configuration used by the system), defined earlier in this file (around line 44). Adding it here to the Schema (`SpannIndexConfig`) without adding it to the internal configuration means the setting may be lost when converting between schema and internal representations.

File: go/pkg/sysdb/coordinator/model/collection_configuration.go
Line: 166

64
}

pub fn default_quantize() -> bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[Logic] The quantize field appears to be missing from the InternalSpannConfiguration struct defined in this file. Without it, the quantize setting will be dropped when converting from SpannIndexConfig to InternalSpannConfiguration, preventing the index from receiving this configuration.

Context for Agents
The `quantize` field appears to be missing from the `InternalSpannConfiguration` struct defined in this file. Without it, the `quantize` setting will be dropped when converting from `SpannIndexConfig` to `InternalSpannConfiguration`, preventing the index from receiving this configuration.

File: rust/types/src/spann_configuration.rs
Line: 71

ef_construction: user.ef_construction.or(default.ef_construction),
ef_search: user.ef_search.or(default.ef_search),
max_neighbors: user.max_neighbors.or(default.max_neighbors),
quantize: user.quantize || default.quantize,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[Logic] This boolean OR logic prevents users from disabling quantization if the default configuration has it enabled (since false || true results in true).

If the intention is to allow users to override the default, consider changing quantize to Option<bool> in the config struct and using .or() logic similar to other fields:

quantize: user.quantize.or(default.quantize),
Context for Agents
This boolean OR logic prevents users from disabling quantization if the default configuration has it enabled (since `false || true` results in `true`).

If the intention is to allow users to override the default, consider changing `quantize` to `Option<bool>` in the config struct and using `.or()` logic similar to other fields:

```rust
quantize: user.quantize.or(default.quantize),
```

File: rust/types/src/collection_schema.rs
Line: 1591

ef_construction: Some(spann_config.ef_construction),
ef_search: Some(spann_config.ef_search),
max_neighbors: Some(spann_config.max_neighbors),
quantize: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[Logic] This hardcodes quantize to false when converting from InternalCollectionConfiguration. Once InternalSpannConfiguration is updated to include the quantize field, this should map the value from there (spann_config.quantize) instead of hardcoding it, otherwise the setting will be lost during conversion.

Context for Agents
This hardcodes `quantize` to `false` when converting from `InternalCollectionConfiguration`. Once `InternalSpannConfiguration` is updated to include the `quantize` field, this should map the value from there (`spann_config.quantize`) instead of hardcoding it, otherwise the setting will be lost during conversion.

File: rust/types/src/collection_schema.rs
Line: 6181

pub max_neighbors: Option<usize>,
/// Enable quantization for vector search (cloud-only feature)
#[serde(default = "default_quantize", skip_serializing_if = "is_false")]
pub quantize: bool,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[Logic] Ideally, this should be Option<bool> to match the pattern of other fields in this struct. Using bool makes it impossible to distinguish between a user explicitly setting false versus the field being missing (and defaulting to false). This distinction is crucial for proper configuration merging (allowing users to override defaults).

Context for Agents
Ideally, this should be `Option<bool>` to match the pattern of other fields in this struct. Using `bool` makes it impossible to distinguish between a user explicitly setting `false` versus the field being missing (and defaulting to `false`). This distinction is crucial for proper configuration merging (allowing users to override defaults).

File: rust/types/src/collection_schema.rs
Line: 2647

Comment on lines +560 to +563
/**
* Enable quantization for vector search (cloud-only feature)
*/
quantize?: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

[Security] You mentioned this flag should stay server-controlled and hidden from clients, but by adding it to the OpenAPI schema we now emit it in the generated client types:

    /**
     * Enable quantization for vector search (cloud-only feature)
     */
    quantize?: boolean;

Because the SDK now exposes quantize, any client can set it in schema updates, and nothing in the merge path ignores client-supplied values (the merge logic user.quantize || default.quantize will happily accept true). If the intent is for the backend to own this flag, it shouldn’t appear in the public API at all (or at minimum should be marked read-only so generators don’t surface it as writable). Please update the OpenAPI definition so the generated types don’t include a writable quantize property, otherwise we’re effectively exposing a knob we wanted to keep server-side.

Context for Agents
You mentioned this flag should stay server-controlled and hidden from clients, but by adding it to the OpenAPI schema we now emit it in the generated client types:

```ts
    /**
     * Enable quantization for vector search (cloud-only feature)
     */
    quantize?: boolean;
```

Because the SDK now exposes `quantize`, any client can set it in schema updates, and nothing in the merge path ignores client-supplied values (the merge logic `user.quantize || default.quantize` will happily accept `true`). If the intent is for the backend to own this flag, it shouldn’t appear in the public API at all (or at minimum should be marked read-only so generators don’t surface it as writable). Please update the OpenAPI definition so the generated types don’t include a writable `quantize` property, otherwise we’re effectively exposing a knob we wanted to keep server-side.

File: clients/new-js/packages/chromadb/src/api/types.gen.ts
Line: 563

@sanketkedia sanketkedia merged commit bd295a1 into main Feb 3, 2026
131 of 133 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants