Repository navigation
Introduce EdgeShardConfig for edge shard - #8322
Conversation
- Add EdgeShardConfig and EdgeOptimizersConfig in lib/edge/src/config.rs
- Segment config (vector_data, sparse_vector_data, payload_storage_type)
- Global hnsw_config and per-vector HNSW in segment config
- Optimizer params: deleted_threshold, vacuum_min_vector_number,
default_segment_number, max_segment_size, indexing_threshold,
prevent_unoptimized (excludes memmap_threshold, flush_interval_sec,
max_optimization_threads)
- Persist/load as edge_config.json in shard path
- EdgeShard uses RwLock<EdgeShardConfig>; load() accepts Option<EdgeShardConfig>,
falls back to file or infer from segments; compatibility checked on load
- load_with_segment_config() for backward compatibility (SegmentConfig -> EdgeShardConfig)
- optimize() uses EdgeShardConfig for hnsw and optimizer thresholds
- Public methods: set_hnsw_config(), set_vector_hnsw_config(), set_optimizers_config()
(update and persist)
- Python and examples use load_with_segment_config with existing config API
Made-with: Cursor
- Replace SegmentConfig inside EdgeShardConfig with user-facing fields:
- on_disk_payload (bool) instead of payload_storage_type
- vectors: HashMap<VectorNameBuf, EdgeVectorParams> with on_disk per vector,
no per-vector quantization; global quantization_config only
- sparse_vectors: HashMap<VectorNameBuf, EdgeSparseVectorParams> with on_disk
- EdgeVectorParams / EdgeSparseVectorParams use on_disk (bool) instead of
storage_type; conversion to VectorDataConfig/SparseVectorDataConfig in
to_segment_config()
- Add config module: mod.rs, optimizers.rs, vectors.rs, shard.rs
- from_segment_config(&SegmentConfig) fills all inferrable params
- to_segment_config() builds SegmentConfig for segments and optimize()
- load_with_segment_config takes Option<SegmentConfig>, uses from_segment_config
Made-with: Cursor
- Add get_number_segments, get_indexing_threshold_kb, get_max_segment_size_kb, get_deferred_points_threshold_bytes in shard::optimizers::config - Collection OptimizersConfig and edge EdgeOptimizersConfig delegate to these - Single place for threshold logic; collection and edge use shard helpers Made-with: Cursor
- EdgeVectorParams: destructure VectorDataConfig in from_*, destructure self in to_vector_data_config - EdgeSparseVectorParams: destructure SparseVectorDataConfig and SparseIndexConfig in from_*, destructure self in to_sparse_vector_data_config - EdgeShardConfig: destructure SegmentConfig in from_segment_config, destructure self in to_segment_config Adding new fields to source structs will now cause compile errors until conversions are updated. Made-with: Cursor
…orage_type, and appendable quantization logic - PayloadStorageType::from_on_disk_payload(bool) in segment (Mmap/InRamMmap) - VectorStorageType::from_on_disk(bool) in segment (ChunkedMmap/InRamChunkedMmap) - QuantizationConfig::for_appendable_segment(Option<&Self>) in segment (feature flag + supports_appendable) - collection: use from_on_disk_payload in non-rocksdb branch - edge shard/vectors: use new helpers; remove duplicated conditionals - shard optimizers: use from_on_disk and for_appendable_segment Made-with: Cursor
- Add plain_segment_config() for create_appendable_segment (no HNSW) - Add segment_optimizer_config() built from EdgeShardConfig for blocking optimizers - Add vector_data_config(name) for query/MMR - build_blocking_optimizers: use segment_optimizer_config() instead of SegmentConfig - create_appendable_segment: use plain_segment_config() - search/query: use config().vectors and vector_data_config() instead of segment_config() - Remove segment_config() from EdgeShardConfig and EdgeShard - Add to_plain_vector_data_config on EdgeVectorParams Made-with: Cursor
…rseVectorParams - PyEdgeConfig now wraps EdgeShardConfig (vectors, sparse_vectors, on_disk_payload, etc.) - PyEdgeVectorParams / PyEdgeSparseVectorParams wrap edge config types - PyEdgeOptimizersConfig for optional optimizer settings - EdgeShard.load() uses EdgeShardConfig; edge::config made pub for Python crate - cargo fmt + clippy (remove map_identity) Made-with: Cursor
…EdgeConfig - Remove unused PyPayloadStorageType, PyVectorDataConfig, PyVectorStorageType, PySparseVectorDataConfig, PySparseVectorStorageType from Python bindings - Move PyEdgeOptimizersConfig to lib/edge/python/src/config/optimizers.rs - Update qdrant_edge.pyi: EdgeConfig with vectors/sparse_vectors, EdgeVectorParams, EdgeSparseVectorParams, EdgeOptimizersConfig - Update examples (common.py, repr.py) to use new config API - Run cargo fmt Made-with: Cursor
There was a problem hiding this comment.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/edge/python/examples/common.py (1)
8-8:⚠️ Potential issue | 🟡 MinorSwitch to explicit imports.
Line 8 uses
from qdrant_edge import *, which causes F405 violations onEdgeVectorParams,Distance, and other symbols used in this file. Replace with explicit imports:Suggested fix
-from qdrant_edge import * +from qdrant_edge import Distance, EdgeConfig, EdgeShard, EdgeVectorParams, Point, UpdateOperation🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/python/examples/common.py` at line 8, The star import from qdrant_edge is causing F405 name-undefined violations; replace "from qdrant_edge import *" with an explicit import list that includes every symbol referenced in this module (e.g., EdgeVectorParams, Distance and any other classes, enums or functions used in common.py) so the top-level import reads "from qdrant_edge import EdgeVectorParams, Distance, <other_used_symbols>" — enumerate all names actually referenced in the file and remove the wildcard import.
🧹 Nitpick comments (5)
lib/shard/src/optimizers/config.rs (1)
58-136: Consider building the plain and optimizer maps in one pass.
SegmentOptimizerConfig::newcurrently walks both input maps twice and keeps the field mapping duplicated between the plain and optimizer projections. Building both outputs together would remove the extra key clones and make future additions toDenseVectorOptimizerInput/SparseVectorOptimizerInputharder to miss. As per coding guidelines, "Prefer explicit field ignoring using: _over using..in Rust struct destructuring."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/shard/src/optimizers/config.rs` around lines 58 - 136, SegmentOptimizerConfig::new iterates dense_vectors and sparse_vectors twice producing duplicated mapping logic and extra key clones; refactor by consuming each input map once and in a single loop build both the "plain" maps (base_vector_data, base_sparse_vector_data) and the optimizer maps (dense_vector, sparse_vector) together. For each entry in dense_vectors, destructure the DenseVectorOptimizerInput to extract fields (use explicit ignoring like field: _ rather than ..) and push both a VectorDataConfig and a DenseVectorOptimizerConfig into their respective collections; do the same for sparse_vectors producing SparseVectorDataConfig and SparseVectorOptimizerConfig in the same pass. Ensure you still call QuantizationConfig::for_appendable_segment and VectorStorageType::from_on_disk as before and preserve the same field names when constructing SegmentOptimizerConfig.lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs (1)
134-134: UseVectorNameBuf::from(...)instead of.into()in these new inserts.The target type is already known here, and the repo guideline asks for explicit
Fromconversions in Rust.♻️ Example fix
- DEFAULT_VECTOR_NAME.into(), + VectorNameBuf::from(DEFAULT_VECTOR_NAME),As per coding guidelines,
**/*.rs: Prefer explicitSomeType::from(x)over implicitx.into()in Rust.Also applies to: 181-181, 287-287, 295-295, 452-452, 460-460
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs` at line 134, Replace implicit .into() conversions with an explicit From call for vector name inserts: change DEFAULT_VECTOR_NAME.into() and the similar occurrences to VectorNameBuf::from(DEFAULT_VECTOR_NAME) (and similarly for the other five places mentioned) so the code uses the explicit VectorNameBuf::from(...) conversion instead of .into(); locate the places in config_mismatch_optimizer.rs where DEFAULT_VECTOR_NAME and other vector-name literals are being inserted and replace .into() with VectorNameBuf::from(...) for each occurrence (e.g., the calls constructing/insert-ing vector names).lib/shard/src/optimizers/vacuum_optimizer.rs (1)
131-137: Preserve the0 == autosentinel when reducing HNSW thread limits.A plain numeric
max()turns a mixed set like{0, 2}into2, even though one vector still means “use the default Rayon thread count”. That makes this accessor under-report the effective setting once per-vector overrides diverge.Possible fix
fn max_indexing_threads(&self) -> Option<usize> { self.segment_optimizer_config .dense_vector .values() .map(|cfg| cfg.hnsw_config.max_indexing_threads) - .max() + .reduce(|acc, threads| { + if acc == 0 || threads == 0 { + 0 + } else { + acc.max(threads) + } + }) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/shard/src/optimizers/vacuum_optimizer.rs` around lines 131 - 137, The current max_indexing_threads() uses a plain max() which hides the "0 == auto" sentinel; change it to first scan segment_optimizer_config.dense_vector.values() for any hnsw_config.max_indexing_threads == 0 and if found return Some(0) (preserve the sentinel), otherwise return the numeric max of hnsw_config.max_indexing_threads as before, and still return None when dense_vector is empty; update the logic in max_indexing_threads() to implement this two-step check using the existing hnsw_config/max_indexing_threads accessors.lib/segment/src/types.rs (1)
1501-1508: Prefix nested incompatibility errors with the vector key.Once
check(config, other_config)?bubbles up, messages likeexpected vector size ...no longer say which named vector failed. Wrapping the returned error withvector_namewill make multi-vector compatibility failures actionable.♻️ Suggested change
- check(config, other_config)?; + check(config, other_config) + .map_err(|err| format!("Incompatible config for vector {vector_name:?}: {err}"))?;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/types.rs` around lines 1501 - 1508, The loop over (vector_name, config) should wrap any error returned by check(config, other_config) with the vector key so failures include which named vector failed; after obtaining other_config via other.get(vector_name) and before returning Err from check, capture the Result from check(config, other_config) and on Err map or convert it to include vector_name (e.g., prefix or annotate the error string with the vector_name) so the propagated error message reads something like "vector {vector_name}: <original error>". Ensure this uses the existing symbols vector_name, config, other_config, and the check(...) call so behavior is unchanged except for enriched error text.lib/edge/python/qdrant_edge.pyi (1)
228-247: Make sparse-only configs ergonomic in the stub.The underlying Rust config allows an empty dense map, but this signature forces callers to spell
vectors={}even when they only wantsparse_vectors. Makingvectorsoptional and validatingvectors or sparse_vectorsin the runtime binding would match the new config model better.🐍 Suggested stub change
- vectors: Union["EdgeVectorParams", Dict[str, "EdgeVectorParams"]], + vectors: Optional[Union["EdgeVectorParams", Dict[str, "EdgeVectorParams"]]] = None, sparse_vectors: Optional[Dict[str, "EdgeSparseVectorParams"]] = None,
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/edge/publish/examples/src/lib.rs`:
- Line 50: Replace the call to the non-existent
EdgeShard::load_with_segment_config with the existing method EdgeShard::load;
specifically, update the call that currently invokes
EdgeShard::load_with_segment_config(Path::new(data_dir), Some(config)) to call
EdgeShard::load(Path::new(data_dir), Some(config)) so the public
qdrant_edge::EdgeShard API is used correctly.
In `@lib/edge/python/examples/repr.py`:
- Line 3: Replace the wildcard import "from qdrant_edge import *" with explicit
imports of the exact identifiers used later in this example (i.e., the names
that ruff flags with F405); update the line to "from qdrant_edge import NameA,
NameB, ..." substituting the real symbols used in the file, or add an explicit
list after checking which names (classes/functions/constants) are referenced,
then re-run the linter to confirm F405 is resolved.
In `@lib/edge/python/qdrant_edge.pyi`:
- Around line 233-247: The HnswIndexConfig stub is missing the
max_indexing_threads parameter and property, causing config round-trip loss;
update the HnswIndexConfig class to add an optional constructor parameter
max_indexing_threads: int = 0 and expose a read-only property
max_indexing_threads -> int, so Python-side HnswIndexConfig mirrors the Rust
HnswConfig used by EdgeShardConfig.optimizer_thresholds() for sizing optimizer
work; ensure both the __init__ signature and the `@property` declaration are
present in the stub.
In `@lib/edge/python/src/config/mod.rs`:
- Around line 28-50: The PyHnswIndexConfig currently drops max_indexing_threads
(hardcoded to 0) so configs created via the Python path (both the global
hnsw_config in pub fn new and the per-vector configs produced by
PyEdgeVectorParams) cannot represent or preserve threading settings; update
PyHnswIndexConfig to accept and expose max_indexing_threads (add a getter and
include it in its From/Into conversion), modify the places that construct
internal HnswIndexConfig (e.g., the map call hnsw_config.map(|h|
h.0).unwrap_or_default() and any construction inside
PyEdgeVectorParams::peel_map) to propagate the max_indexing_threads value
instead of defaulting to 0, and ensure deserialization/loading preserves and
round-trips this field.
In `@lib/edge/src/config/shard.rs`:
- Around line 68-100: from_segment_config currently unconditionally sets
hnsw_config = HnswConfig::default(), which loses any non-default global HNSW
thread settings used by existing per-vector indexes and causes
optimizer_thresholds() to compute different results; update from_segment_config
to inspect vector_data and sparse_vector_data entries (e.g.,
EdgeVectorParams/EdgeSparseVectorParams or whatever holds per-vector HNSW
settings in the SegmentConfig) and attempt to collapse them into a single
compatible HnswConfig: if all per-vector HNSW fields (notably
max_indexing_threads) agree, set hnsw_config to that collapsed value; if they
differ in incompatible ways, return an error or choose a safe fail-fast path
instead of using HnswConfig::default(); ensure references to hnsw_config,
HnswConfig::default(), and optimizer_thresholds() are preserved so callers see
consistent behavior.
- Around line 218-223: In load, replace Path::exists() with
path.join(EDGE_CONFIG_FILE).try_exists() and explicitly handle errors: if
try_exists() returns Ok(false) return None; if Err(e) return
Some(Err(OperationError::from(e))); otherwise proceed to call
read_json(&config_path).map_err(OperationError::from). This change should be
applied inside the load function that references EDGE_CONFIG_FILE,
OperationResult, OperationError, and read_json.
In `@lib/edge/src/config/vectors.rs`:
- Around line 1-5: The docs are outdated: they claim quantization is global-only
while the EdgeVectorParams struct exposes quantization_config and the conversion
logic uses it. Update the public comments to reflect that per-vector
quantization is supported via EdgeVectorParams::quantization_config (and that
EdgeShardConfig may still hold global defaults), and ensure accompanying remarks
about on_disk/storage_type remain accurate; specifically edit the module
docstring and the docs around EdgeVectorParams and quantization_config to state
that per-vector quantization is honored and how it interacts with
EdgeShardConfig.
In `@lib/edge/src/lib.rs`:
- Around line 83-90: The current match around EdgeShardConfig::load(path)
silently continues when the on-disk edge_config.json is missing and a save
fails; change the logic so that when EdgeShardConfig::load returns None you
attempt to create and persist the default EdgeShardConfig and if that save
(EdgeShardConfig::save or the routine that writes edge_config.json) returns an
error you propagate that error (return Err(e)) instead of returning Ok; apply
the same fix to the second identical block later in the file (the other match at
the referenced section) so both places fail fast on write errors and do not let
the process continue with a missing/partial config.
- Around line 213-237: The setters currently mutate self.config then persist,
leaving the in-memory config changed if save fails; make each setter atomic by
cloning the current config, applying the change to the clone (use the same
methods: set_hnsw_config, set_vector_hnsw_config, set_optimizers_config) and
check for any method errors on the clone, then call clone.save(&self.path); only
after save succeeds acquire the write lock and replace the stored config with
the saved clone. For set_vector_hnsw_config, call the fallible
cfg.set_vector_hnsw_config on the clone and propagate its error before saving;
for all three methods ensure you clone via self.config.read().clone(), mutate
the clone, persist the clone, and then swap it into self.config under a write
lock.
In `@lib/segment/src/types.rs`:
- Around line 1686-1691: The compatibility check currently compares
Option<datatype> directly so None != Some(Float32); instead resolve omitted
datatypes to Float32 before comparing: compute left =
self.datatype.unwrap_or(Datatype::Float32) and right =
other.datatype.unwrap_or(Datatype::Float32) (or use an equivalent helper), then
compare left vs right and keep the existing Err message using those resolved
values (replace uses of `datatype`/`other.datatype` in the format with the
resolved names) so legacy `None` is treated as Float32.
In `@lib/shard/src/optimizers/segment_optimizer.rs`:
- Around line 67-71: The current max_indexing_threads() logic incorrectly uses
.max() in each optimizer impl and treats 0 as a regular value; change the trait
to provide a sentinel-aware default implementation for max_indexing_threads()
that inspects all configured values (via segment_optimizer_config()), returns
Some(0) if any configured value is 0 (preserve auto-select sentinel), otherwise
returns the maximum non-zero Option<usize> as before; remove or adapt the four
optimizer-specific overrides so they rely on this centralized trait default
rather than per-impl .max() logic.
---
Outside diff comments:
In `@lib/edge/python/examples/common.py`:
- Line 8: The star import from qdrant_edge is causing F405 name-undefined
violations; replace "from qdrant_edge import *" with an explicit import list
that includes every symbol referenced in this module (e.g., EdgeVectorParams,
Distance and any other classes, enums or functions used in common.py) so the
top-level import reads "from qdrant_edge import EdgeVectorParams, Distance,
<other_used_symbols>" — enumerate all names actually referenced in the file and
remove the wildcard import.
---
Nitpick comments:
In
`@lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs`:
- Line 134: Replace implicit .into() conversions with an explicit From call for
vector name inserts: change DEFAULT_VECTOR_NAME.into() and the similar
occurrences to VectorNameBuf::from(DEFAULT_VECTOR_NAME) (and similarly for the
other five places mentioned) so the code uses the explicit
VectorNameBuf::from(...) conversion instead of .into(); locate the places in
config_mismatch_optimizer.rs where DEFAULT_VECTOR_NAME and other vector-name
literals are being inserted and replace .into() with VectorNameBuf::from(...)
for each occurrence (e.g., the calls constructing/insert-ing vector names).
In `@lib/segment/src/types.rs`:
- Around line 1501-1508: The loop over (vector_name, config) should wrap any
error returned by check(config, other_config) with the vector key so failures
include which named vector failed; after obtaining other_config via
other.get(vector_name) and before returning Err from check, capture the Result
from check(config, other_config) and on Err map or convert it to include
vector_name (e.g., prefix or annotate the error string with the vector_name) so
the propagated error message reads something like "vector {vector_name}:
<original error>". Ensure this uses the existing symbols vector_name, config,
other_config, and the check(...) call so behavior is unchanged except for
enriched error text.
In `@lib/shard/src/optimizers/config.rs`:
- Around line 58-136: SegmentOptimizerConfig::new iterates dense_vectors and
sparse_vectors twice producing duplicated mapping logic and extra key clones;
refactor by consuming each input map once and in a single loop build both the
"plain" maps (base_vector_data, base_sparse_vector_data) and the optimizer maps
(dense_vector, sparse_vector) together. For each entry in dense_vectors,
destructure the DenseVectorOptimizerInput to extract fields (use explicit
ignoring like field: _ rather than ..) and push both a VectorDataConfig and a
DenseVectorOptimizerConfig into their respective collections; do the same for
sparse_vectors producing SparseVectorDataConfig and SparseVectorOptimizerConfig
in the same pass. Ensure you still call
QuantizationConfig::for_appendable_segment and VectorStorageType::from_on_disk
as before and preserve the same field names when constructing
SegmentOptimizerConfig.
In `@lib/shard/src/optimizers/vacuum_optimizer.rs`:
- Around line 131-137: The current max_indexing_threads() uses a plain max()
which hides the "0 == auto" sentinel; change it to first scan
segment_optimizer_config.dense_vector.values() for any
hnsw_config.max_indexing_threads == 0 and if found return Some(0) (preserve the
sentinel), otherwise return the numeric max of hnsw_config.max_indexing_threads
as before, and still return None when dense_vector is empty; update the logic in
max_indexing_threads() to implement this two-step check using the existing
hnsw_config/max_indexing_threads accessors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a1b8eb1-132c-4d18-9c80-926ce90243ae
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (38)
lib/collection/src/collection/payload_index_schema.rslib/collection/src/collection/snapshots.rslib/collection/src/collection_manager/fixtures.rslib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rslib/collection/src/collection_manager/optimizers/indexing_optimizer.rslib/collection/src/collection_manager/optimizers/merge_optimizer.rslib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/config.rslib/collection/src/optimizers_builder.rslib/collection/src/update_workers/optimization_worker.rslib/edge/Cargo.tomllib/edge/publish/examples/src/lib.rslib/edge/python/examples/common.pylib/edge/python/examples/repr.pylib/edge/python/qdrant_edge.pyilib/edge/python/src/config/mod.rslib/edge/python/src/config/optimizers.rslib/edge/python/src/config/sparse_vector_data.rslib/edge/python/src/config/vector_data.rslib/edge/python/src/lib.rslib/edge/src/config/mod.rslib/edge/src/config/optimizers.rslib/edge/src/config/shard.rslib/edge/src/config/vectors.rslib/edge/src/lib.rslib/edge/src/optimize.rslib/edge/src/query.rslib/edge/src/search.rslib/segment/src/index/sparse_index/sparse_index_config.rslib/segment/src/types.rslib/shard/src/files/mod.rslib/shard/src/optimizers/config.rslib/shard/src/optimizers/config_mismatch_optimizer.rslib/shard/src/optimizers/indexing_optimizer.rslib/shard/src/optimizers/merge_optimizer.rslib/shard/src/optimizers/segment_optimizer.rslib/shard/src/optimizers/vacuum_optimizer.rslib/storage/src/content_manager/snapshots/recover.rs
💤 Files with no reviewable changes (3)
- lib/collection/src/collection_manager/optimizers/indexing_optimizer.rs
- lib/collection/src/collection_manager/fixtures.rs
- lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs
* Address CodeRabbit review comments for PR 8322 - Python examples: explicit imports (repr.py, common.py) and new EdgeConfig API - HnswIndexConfig: add max_indexing_threads param and property in .pyi and Rust bindings - EdgeConfig: make vectors optional for sparse-only configs; validate at least one of vectors/sparse_vectors - EdgeShardConfig::load: use try_exists(), propagate I/O errors - from_segment_config: infer hnsw_config from per-vector HNSW when all agree - EdgeShard setters: atomic clone-mutate-save-then-replace; persist config save errors - Segment compat: prefix vector name in error messages; resolve None datatype to Float32 - max_indexing_threads: preserve 0 (auto) sentinel in trait default; remove per-optimizer overrides - SegmentOptimizerConfig::new: build plain and optimizer maps in single pass - config_mismatch_optimizer tests: use VectorNameBuf::from() instead of .into() - vectors.rs: doc updates for per-vector quantization Made-with: Cursor * Address @generall review: SaveOnDisk for config, resolve num_rayon_threads in optimizer - Use SaveOnDisk<EdgeShardConfig> for EdgeShard config (generall: 'We have SaveOnDisk struct for this') - Create via SaveOnDisk::new() after resolving config; setters use .write() for atomic persist - set_vector_hnsw_config: clone then mutate then write (fallible setter) - max_indexing_threads: resolve 0 (auto) via num_rayon_threads inside impl (generall: 'proper solution would be to resolve num_rayon_threads inside the optimizer impl') - max_indexing_threads_sentinel_aware() now returns Some(num_rayon_threads(raw)) so callers get actual thread count Made-with: Cursor * [manual] reorganize num_rayon_threads -> get_num_indexing_threads to better account per-vector configuration --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: generall <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/segment/src/types.rs (1)
1774-1791:⚠️ Potential issue | 🟠 MajorSparse compatibility should also validate
index.datatype.This check only looks at
modifier. A shard configured with sparsedatatype = Uint8will currently load against aFloat32sparse segment as “compatible”, even though the edge config now exposesdatatypeand writes it back intoSparseIndexConfig. Please compare the sparse datatype here too, normalizing any legacy default the same way as the dense path if needed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/types.rs` around lines 1774 - 1791, In check_compatible (the method destructuring Self { index: _, storage_type: _, modifier }), add a comparison of the sparse index datatype in addition to modifier: retrieve the sparse datatype from self.index.datatype and other.index.datatype (or from SparseIndexConfig stored in index), normalize legacy defaults the same way the dense path does, and if they differ return Err with a clear message (e.g. "expected sparse datatype X, but got Y"); keep the existing modifier check and ensure you reference the same field names (index.datatype, modifier, SparseIndexConfig) so callers like load/merge will reject mismatched sparse datatypes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/edge/src/config/vectors.rs`:
- Around line 135-150: to_plain_sparse_vector_data_config currently ignores
EdgeSparseVectorParams.on_disk and always uses SparseIndexType::default() and
SparseVectorStorageType::Mmap; make the method honor the on_disk flag by
branching on self.on_disk when building the SparseIndexConfig and storage_type:
set index_type to an appendable/on-disk index variant (e.g.,
SparseIndexType::Appendable) and storage_type to the on-disk storage (e.g.,
SparseVectorStorageType::Mmap) when on_disk is true, otherwise use the in-memory
defaults (e.g., SparseIndexType::default() and SparseVectorStorageType::Memory);
update the to_plain_sparse_vector_data_config function to reference
EdgeSparseVectorParams.on_disk, SparseIndexType, and SparseVectorStorageType so
the from_sparse_vector_data_config → to_plain_sparse_vector_data_config
round-trip preserves the on_disk behavior.
---
Outside diff comments:
In `@lib/segment/src/types.rs`:
- Around line 1774-1791: In check_compatible (the method destructuring Self {
index: _, storage_type: _, modifier }), add a comparison of the sparse index
datatype in addition to modifier: retrieve the sparse datatype from
self.index.datatype and other.index.datatype (or from SparseIndexConfig stored
in index), normalize legacy defaults the same way the dense path does, and if
they differ return Err with a clear message (e.g. "expected sparse datatype X,
but got Y"); keep the existing modifier check and ensure you reference the same
field names (index.datatype, modifier, SparseIndexConfig) so callers like
load/merge will reject mismatched sparse datatypes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e3ec7ee8-08e5-4ef4-81c1-55e4e3acbade
📒 Files selected for processing (31)
lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rslib/collection/src/optimizers_builder.rslib/collection/src/tests/mod.rslib/collection/src/update_workers/optimization_worker.rslib/edge/python/examples/common.pylib/edge/python/examples/repr.pylib/edge/python/qdrant_edge.pyilib/edge/python/src/config/mod.rslib/edge/python/src/config/vector_data.rslib/edge/src/config/shard.rslib/edge/src/config/vectors.rslib/edge/src/lib.rslib/edge/src/optimize.rslib/segment/benches/hnsw_incremental_build.rslib/segment/benches/multi_vector_search.rslib/segment/src/index/hnsw_index/mod.rslib/segment/src/index/hnsw_index/tests/test_graph_connectivity.rslib/segment/src/segment_constructor/segment_builder.rslib/segment/src/types.rslib/segment/tests/integration/batch_search_test.rslib/segment/tests/integration/exact_search_test.rslib/segment/tests/integration/gpu_hnsw_test.rslib/segment/tests/integration/hnsw_discover_test.rslib/segment/tests/integration/hnsw_incremental_build.rslib/segment/tests/integration/segment_builder_test.rslib/shard/src/optimizers/config.rslib/shard/src/optimizers/config_mismatch_optimizer.rslib/shard/src/optimizers/indexing_optimizer.rslib/shard/src/optimizers/merge_optimizer.rslib/shard/src/optimizers/segment_optimizer.rslib/shard/src/optimizers/vacuum_optimizer.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/edge/python/examples/repr.py
timvisee
left a comment
There was a problem hiding this comment.
I'd like to see another review before we merge.
| @property | ||
| def full_scan_threshold(self) -> Optional[int]: | ||
| """Full scan threshold.""" | ||
| def deleted_threshold(self) -> float: |
There was a problem hiding this comment.
Type mismatch. Rust version returns Option<T>.
| @property | ||
| def index_type(self) -> "SparseIndexType": | ||
| """Index type.""" | ||
| def vacuum_min_vector_number(self) -> int: |
There was a problem hiding this comment.
Type mismatch. Rust version returns Option<T>.
| @property | ||
| def datatype(self) -> Optional["VectorStorageDatatype"]: | ||
| """Storage datatype.""" | ||
| def default_segment_number(self) -> int: |
There was a problem hiding this comment.
Type mismatch. Rust version returns Option<T>.
| /// | ||
| /// User-facing only: `on_disk_payload`, `on_disk` per vector, global | ||
| /// `hnsw_config` and `quantization_config`. No `SegmentConfig`, no | ||
| /// `payload_storage_type`, no per-vector quantization. |
There was a problem hiding this comment.
This doc comment looks outdated: EdgeVectorParams now supports per-vector quantization_config, so saying "no per-
vector quantization" is no longer accurate.
| /// Sparse vector params per vector name. | ||
| #[serde(default)] | ||
| pub sparse_vectors: HashMap<VectorNameBuf, EdgeSparseVectorParams>, | ||
| /// Global HNSW config; per-vector override is in `vectors[].index` when `Indexes::Hnsw`. |
There was a problem hiding this comment.
The per-vector HNSW override is now exposed as vectors[].hnsw_config, not via vectors[].index / Indexes::Hnsw.
|
@generall Potential restore bug:
|
|
@dancixx I checked config logic again - we always verify config against segments, even if it was loaded from file. But then user is able to load again, with new explicit configuration to effectively resolve the config mismatch. I think current behaviour is acceptable. |
📝 WalkthroughWalkthroughThis PR performs a substantial architectural refactoring to consolidate optimizer and configuration management across the codebase. The main changes involve: relocating the Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
lib/edge/src/config/vectors.rs (1)
129-175:⚠️ Potential issue | 🟠 MajorHonor
on_diskin the sparse plain-config conversion.
to_plain_sparse_vector_data_config()dropsself.on_diskand hardcodes both the sparse storage and index settings, whilefrom_sparse_vector_data_config()later reconstructson_diskfromindex_type.is_on_disk(). That makes theEdgeSparseVectorParams↔SparseVectorDataConfiground-trip lossy and leaves the user-providedon_diskflag ineffective for newly created appendable sparse segments.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/src/config/vectors.rs` around lines 129 - 175, to_plain_sparse_vector_data_config currently ignores EdgeSparseVectorParams.on_disk and hardcodes storage/index choices, breaking round-trip with from_sparse_vector_data_config; update to_plain_sparse_vector_data_config to honor self.on_disk (use self.on_disk.unwrap_or(false)) when building SparseVectorDataConfig: set storage_type to the on-disk variant when true (otherwise Mmap) and set index.index_type to the corresponding on-disk/in-memory SparseIndexType (either via an existing helper or add a SparseIndexType::from_on_disk(bool) and use that), keeping full_scan_threshold, modifier and datatype as before so the on_disk flag round-trips with from_sparse_vector_data_config.
🧹 Nitpick comments (5)
lib/segment/src/types.rs (1)
874-880: Please route the existing conversions through these helpers.
lib/collection/src/config.rs::CollectionParams::to_base_vector_data()still duplicates both appendable-quantization selection and theon_disk→VectorStorageTypemapping, so these helpers can drift from the real conversion path on the next config change.Also applies to: 1598-1606
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/types.rs` around lines 874 - 880, The conversion logic in CollectionParams::to_base_vector_data is duplicating appendable-quantization selection and the on_disk → VectorStorageType mapping; update to call the existing helper functions instead of reimplementing the logic: use types::VectorStorageConfig::for_appendable_segment (the for_appendable_segment helper in lib/segment/src/types.rs) to pick the appendable quantization config and call the existing shared on_disk→VectorStorageType mapping helper (the conversion helper used elsewhere for VectorStorageType) rather than duplicating conditional branches inside CollectionParams::to_base_vector_data so all conversions go through the canonical helpers.lib/edge/src/config/mod.rs (1)
3-5: Clarify thatvectorsmay also carry per-vectorhnsw_config.The module docs currently read as if only the global
hnsw_configis user-facing, but this PR also exposes per-vector HNSW overrides viavectors. That makes the generated docs misleading for the new API surface.✏️ Suggested doc tweak
-//! User-facing structures only: no `SegmentConfig`, `payload_storage_type`, or -//! per-vector quantization. Use `on_disk_payload`, `on_disk` per vector, and -//! global `quantization_config` / `hnsw_config`. +//! User-facing structures only: no `SegmentConfig`, `payload_storage_type`, or +//! per-vector quantization. Use `on_disk_payload`, per-vector `on_disk`, +//! global `quantization_config`, and global or per-vector `hnsw_config`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/src/config/mod.rs` around lines 3 - 5, Module docs currently imply only a global hnsw_config is user-facing; update the module-level comment to state that individual entries in the vectors field may also include per-vector hnsw_config overrides (in addition to the global quantization_config and hnsw_config). Edit the top comment near the module documentation to mention "per-vector hnsw_config (via each entry in vectors) is supported" and ensure you reference the symbols vectors and hnsw_config so readers know per-vector overrides are part of the public API surface.lib/edge/src/config/optimizers.rs (1)
44-45: Clarify that this helper expects the resolved thread count.
get_max_segment_size_kb()forwardsnum_indexing_threadsdirectly into the shard sizing logic. Renaming the parameter or documenting that callers must pass the resolved concrete count would make this API much harder to misuse.Based on learnings, the
max_indexing_threadsfield onHnswConfiguses0as a sentinel meaning "use system CPU count", and callers should consume the resolved concrete count rather than propagating0.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/src/config/optimizers.rs` around lines 44 - 45, Rename or document the method parameter so callers know they must pass the concrete/resolved thread count (not the sentinel 0): update the method signature on the impl (pub fn get_max_segment_size_kb(&self, resolved_indexing_threads: usize) -> usize) or add a clear doc-comment on get_max_segment_size_kb(&self, num_indexing_threads: usize) stating "expects concrete resolved thread count (non-zero); do not forward HnswConfig.max_indexing_threads raw sentinel 0" and optionally assert/normalize the value inside the method (e.g., treat 0 as system CPU count) before calling the internal get_max_segment_size_kb(...) helper so callers can't accidentally pass the sentinel.lib/edge/python/src/config/vector_data.rs (1)
340-421: Consider adding a_gettersexhaustive field check for consistency.Other wrapper types in this file (e.g.,
PyHnswIndexConfig,PyMultiVectorConfig) include a_gettersfunction that destructures the inner type to ensure compile-time enforcement when fields are added.PyEdgeVectorParamslacks this pattern.♻️ Suggested addition for exhaustive field check
impl PyEdgeVectorParams { fn _getters(self) { // Every field should have a getter method let EdgeVectorParams { size: _, distance: _, on_disk: _, multivector_config: _, datatype: _, quantization_config: _, hnsw_config: _, } = self.0; } }As per coding guidelines: "Prefer explicit field ignoring using
: _over using..in Rust struct destructuring".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/python/src/config/vector_data.rs` around lines 340 - 421, PyEdgeVectorParams is missing the exhaustive-field check present on other wrappers; add a private fn _getters(self) inside the impl PyEdgeVectorParams that destructures self.0 as EdgeVectorParams { size: _, distance: _, on_disk: _, multivector_config: _, datatype: _, quantization_config: _, hnsw_config: _ } so adding new fields will force compile-time updates to the getters; place this helper alongside the existing methods (e.g., near new, size, distance) to mirror PyHnswIndexConfig/PyMultiVectorConfig patterns.lib/edge/src/config/shard.rs (1)
88-105: HNSW inference logic improved, but silent fallback when configs disagree.The implementation now correctly infers a unified
hnsw_configwhen all per-vector HNSW configs agree. When configs disagree, it falls back toHnswConfig::default(). This is reasonable behavior for inference from existing segments, though it may silently lose threading settings if vectors have differentmax_indexing_threadsvalues.Consider logging a warning when falling back to default due to disagreement:
let hnsw_config = hnsw_configs .first() .and_then(|first| { if hnsw_configs.iter().all(|h| h == first) { Some(*first) + } else { + log::warn!("Per-vector HNSW configs disagree, using default global config"); + None } else { None } }) .unwrap_or_default();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/src/config/shard.rs` around lines 88 - 105, The current inference computes hnsw_configs from vector_data and sets hnsw_config to HnswConfig::default() when per-vector HNSW configs disagree; modify the logic around hnsw_configs / hnsw_config so that if the code selects the default because the per-vector HNSW entries are not all equal you emit a warning-level log (include context like number of vectors inspected and that configs disagreed) instead of silently falling back; update the code path that constructs hnsw_config (the block using hnsw_configs.first().and_then(...).unwrap_or_default()) to detect the disagreement case and call the module’s logger (or process logger) to warn before returning HnswConfig::default(), referencing HnswConfig, hnsw_configs, hnsw_config and vector_data to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/edge/python/src/snapshots.rs`:
- Line 5: The full_recovery path currently does not handle EDGE_CONFIG_FILE, so
restore leaves the destination shard's stale edge_config.json instead of
replacing it with the snapshot or removing it when the snapshot omits it; update
the full_recovery logic (the clear_data(), move_data(), and/or unpack_dir usage
inside the full_recovery branch) to explicitly include EDGE_CONFIG_FILE: ensure
clear_data() deletes EDGE_CONFIG_FILE from the destination before unpacking, and
ensure move_data() (or the unpack step) moves the snapshot's EDGE_CONFIG_FILE
into place if present, and if the snapshot lacks EDGE_CONFIG_FILE then remove
any existing destination copy so snapshots can intentionally omit it.
In `@lib/edge/src/lib.rs`:
- Around line 221-230: The current set_vector_hnsw_config reads and clones the
config before entering the SaveOnDisk write closure, which can overwrite
concurrent updates; instead, remove the initial self.config.read().clone() and
perform validation/mutation on a fresh snapshot inside the SaveOnDisk write
closure: inside the closure given to self.config.write(...) clone the provided
config (e.g., let mut cfg = c.clone()), call
cfg.set_vector_hnsw_config(vector_name, hnsw_config) to validate/apply changes,
then assign *c = cfg and return appropriately; keep error mapping to
OperationError/service_error consistent for failures from set_vector_hnsw_config
and the write call.
---
Duplicate comments:
In `@lib/edge/src/config/vectors.rs`:
- Around line 129-175: to_plain_sparse_vector_data_config currently ignores
EdgeSparseVectorParams.on_disk and hardcodes storage/index choices, breaking
round-trip with from_sparse_vector_data_config; update
to_plain_sparse_vector_data_config to honor self.on_disk (use
self.on_disk.unwrap_or(false)) when building SparseVectorDataConfig: set
storage_type to the on-disk variant when true (otherwise Mmap) and set
index.index_type to the corresponding on-disk/in-memory SparseIndexType (either
via an existing helper or add a SparseIndexType::from_on_disk(bool) and use
that), keeping full_scan_threshold, modifier and datatype as before so the
on_disk flag round-trips with from_sparse_vector_data_config.
---
Nitpick comments:
In `@lib/edge/python/src/config/vector_data.rs`:
- Around line 340-421: PyEdgeVectorParams is missing the exhaustive-field check
present on other wrappers; add a private fn _getters(self) inside the impl
PyEdgeVectorParams that destructures self.0 as EdgeVectorParams { size: _,
distance: _, on_disk: _, multivector_config: _, datatype: _,
quantization_config: _, hnsw_config: _ } so adding new fields will force
compile-time updates to the getters; place this helper alongside the existing
methods (e.g., near new, size, distance) to mirror
PyHnswIndexConfig/PyMultiVectorConfig patterns.
In `@lib/edge/src/config/mod.rs`:
- Around line 3-5: Module docs currently imply only a global hnsw_config is
user-facing; update the module-level comment to state that individual entries in
the vectors field may also include per-vector hnsw_config overrides (in addition
to the global quantization_config and hnsw_config). Edit the top comment near
the module documentation to mention "per-vector hnsw_config (via each entry in
vectors) is supported" and ensure you reference the symbols vectors and
hnsw_config so readers know per-vector overrides are part of the public API
surface.
In `@lib/edge/src/config/optimizers.rs`:
- Around line 44-45: Rename or document the method parameter so callers know
they must pass the concrete/resolved thread count (not the sentinel 0): update
the method signature on the impl (pub fn get_max_segment_size_kb(&self,
resolved_indexing_threads: usize) -> usize) or add a clear doc-comment on
get_max_segment_size_kb(&self, num_indexing_threads: usize) stating "expects
concrete resolved thread count (non-zero); do not forward
HnswConfig.max_indexing_threads raw sentinel 0" and optionally assert/normalize
the value inside the method (e.g., treat 0 as system CPU count) before calling
the internal get_max_segment_size_kb(...) helper so callers can't accidentally
pass the sentinel.
In `@lib/edge/src/config/shard.rs`:
- Around line 88-105: The current inference computes hnsw_configs from
vector_data and sets hnsw_config to HnswConfig::default() when per-vector HNSW
configs disagree; modify the logic around hnsw_configs / hnsw_config so that if
the code selects the default because the per-vector HNSW entries are not all
equal you emit a warning-level log (include context like number of vectors
inspected and that configs disagreed) instead of silently falling back; update
the code path that constructs hnsw_config (the block using
hnsw_configs.first().and_then(...).unwrap_or_default()) to detect the
disagreement case and call the module’s logger (or process logger) to warn
before returning HnswConfig::default(), referencing HnswConfig, hnsw_configs,
hnsw_config and vector_data to locate the change.
In `@lib/segment/src/types.rs`:
- Around line 874-880: The conversion logic in
CollectionParams::to_base_vector_data is duplicating appendable-quantization
selection and the on_disk → VectorStorageType mapping; update to call the
existing helper functions instead of reimplementing the logic: use
types::VectorStorageConfig::for_appendable_segment (the for_appendable_segment
helper in lib/segment/src/types.rs) to pick the appendable quantization config
and call the existing shared on_disk→VectorStorageType mapping helper (the
conversion helper used elsewhere for VectorStorageType) rather than duplicating
conditional branches inside CollectionParams::to_base_vector_data so all
conversions go through the canonical helpers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8e97b9b0-1189-4042-a08b-6dbd1299c220
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (51)
lib/collection/src/collection/payload_index_schema.rslib/collection/src/collection/snapshots.rslib/collection/src/collection_manager/fixtures.rslib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rslib/collection/src/collection_manager/optimizers/indexing_optimizer.rslib/collection/src/collection_manager/optimizers/merge_optimizer.rslib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/config.rslib/collection/src/optimizers_builder.rslib/collection/src/tests/mod.rslib/collection/src/update_workers/optimization_worker.rslib/edge/Cargo.tomllib/edge/publish/examples/src/lib.rslib/edge/python/examples/common.pylib/edge/python/examples/repr.pylib/edge/python/qdrant_edge.pyilib/edge/python/src/config/mod.rslib/edge/python/src/config/optimizers.rslib/edge/python/src/config/sparse_vector_data.rslib/edge/python/src/config/vector_data.rslib/edge/python/src/lib.rslib/edge/python/src/snapshots.rslib/edge/src/config/mod.rslib/edge/src/config/optimizers.rslib/edge/src/config/shard.rslib/edge/src/config/vectors.rslib/edge/src/lib.rslib/edge/src/optimize.rslib/edge/src/query.rslib/edge/src/search.rslib/segment/benches/hnsw_incremental_build.rslib/segment/benches/multi_vector_search.rslib/segment/src/index/hnsw_index/mod.rslib/segment/src/index/hnsw_index/tests/test_graph_connectivity.rslib/segment/src/index/sparse_index/sparse_index_config.rslib/segment/src/segment_constructor/segment_builder.rslib/segment/src/types.rslib/segment/tests/integration/batch_search_test.rslib/segment/tests/integration/exact_search_test.rslib/segment/tests/integration/gpu_hnsw_test.rslib/segment/tests/integration/hnsw_discover_test.rslib/segment/tests/integration/hnsw_incremental_build.rslib/segment/tests/integration/segment_builder_test.rslib/shard/src/files/mod.rslib/shard/src/optimizers/config.rslib/shard/src/optimizers/config_mismatch_optimizer.rslib/shard/src/optimizers/indexing_optimizer.rslib/shard/src/optimizers/merge_optimizer.rslib/shard/src/optimizers/segment_optimizer.rslib/shard/src/optimizers/vacuum_optimizer.rslib/storage/src/content_manager/snapshots/recover.rs
💤 Files with no reviewable changes (3)
- lib/collection/src/collection_manager/optimizers/indexing_optimizer.rs
- lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs
- lib/collection/src/collection_manager/fixtures.rs
* Introduce EdgeShardConfig for edge shard
- Add EdgeShardConfig and EdgeOptimizersConfig in lib/edge/src/config.rs
- Segment config (vector_data, sparse_vector_data, payload_storage_type)
- Global hnsw_config and per-vector HNSW in segment config
- Optimizer params: deleted_threshold, vacuum_min_vector_number,
default_segment_number, max_segment_size, indexing_threshold,
prevent_unoptimized (excludes memmap_threshold, flush_interval_sec,
max_optimization_threads)
- Persist/load as edge_config.json in shard path
- EdgeShard uses RwLock<EdgeShardConfig>; load() accepts Option<EdgeShardConfig>,
falls back to file or infer from segments; compatibility checked on load
- load_with_segment_config() for backward compatibility (SegmentConfig -> EdgeShardConfig)
- optimize() uses EdgeShardConfig for hnsw and optimizer thresholds
- Public methods: set_hnsw_config(), set_vector_hnsw_config(), set_optimizers_config()
(update and persist)
- Python and examples use load_with_segment_config with existing config API
Made-with: Cursor
* Refactor EdgeShardConfig: user-facing params only, config module
- Replace SegmentConfig inside EdgeShardConfig with user-facing fields:
- on_disk_payload (bool) instead of payload_storage_type
- vectors: HashMap<VectorNameBuf, EdgeVectorParams> with on_disk per vector,
no per-vector quantization; global quantization_config only
- sparse_vectors: HashMap<VectorNameBuf, EdgeSparseVectorParams> with on_disk
- EdgeVectorParams / EdgeSparseVectorParams use on_disk (bool) instead of
storage_type; conversion to VectorDataConfig/SparseVectorDataConfig in
to_segment_config()
- Add config module: mod.rs, optimizers.rs, vectors.rs, shard.rs
- from_segment_config(&SegmentConfig) fills all inferrable params
- to_segment_config() builds SegmentConfig for segments and optimize()
- load_with_segment_config takes Option<SegmentConfig>, uses from_segment_config
Made-with: Cursor
* Move optimizer threshold helpers to shard crate
- Add get_number_segments, get_indexing_threshold_kb, get_max_segment_size_kb,
get_deferred_points_threshold_bytes in shard::optimizers::config
- Collection OptimizersConfig and edge EdgeOptimizersConfig delegate to these
- Single place for threshold logic; collection and edge use shard helpers
Made-with: Cursor
* Use destructuring in config conversions to avoid missing new fields
- EdgeVectorParams: destructure VectorDataConfig in from_*, destructure self in to_vector_data_config
- EdgeSparseVectorParams: destructure SparseVectorDataConfig and SparseIndexConfig in from_*, destructure self in to_sparse_vector_data_config
- EdgeShardConfig: destructure SegmentConfig in from_segment_config, destructure self in to_segment_config
Adding new fields to source structs will now cause compile errors until conversions are updated.
Made-with: Cursor
* refactor: centralize on_disk_payload→payload_storage_type, on_disk→storage_type, and appendable quantization logic
- PayloadStorageType::from_on_disk_payload(bool) in segment (Mmap/InRamMmap)
- VectorStorageType::from_on_disk(bool) in segment (ChunkedMmap/InRamChunkedMmap)
- QuantizationConfig::for_appendable_segment(Option<&Self>) in segment (feature flag + supports_appendable)
- collection: use from_on_disk_payload in non-rocksdb branch
- edge shard/vectors: use new helpers; remove duplicated conditionals
- shard optimizers: use from_on_disk and for_appendable_segment
Made-with: Cursor
* refactor(edge): use EdgeShardConfig directly, drop segment_config
- Add plain_segment_config() for create_appendable_segment (no HNSW)
- Add segment_optimizer_config() built from EdgeShardConfig for blocking optimizers
- Add vector_data_config(name) for query/MMR
- build_blocking_optimizers: use segment_optimizer_config() instead of SegmentConfig
- create_appendable_segment: use plain_segment_config()
- search/query: use config().vectors and vector_data_config() instead of segment_config()
- Remove segment_config() from EdgeShardConfig and EdgeShard
- Add to_plain_vector_data_config on EdgeVectorParams
Made-with: Cursor
* [manual] review changes
* refactor(edge-py): wrap EdgeShardConfig, add EdgeVectorParams/EdgeSparseVectorParams
- PyEdgeConfig now wraps EdgeShardConfig (vectors, sparse_vectors, on_disk_payload, etc.)
- PyEdgeVectorParams / PyEdgeSparseVectorParams wrap edge config types
- PyEdgeOptimizersConfig for optional optimizer settings
- EdgeShard.load() uses EdgeShardConfig; edge::config made pub for Python crate
- cargo fmt + clippy (remove map_identity)
Made-with: Cursor
* refactor(edge-py): simplify config API, remove unused Py* types, add EdgeConfig
- Remove unused PyPayloadStorageType, PyVectorDataConfig, PyVectorStorageType,
PySparseVectorDataConfig, PySparseVectorStorageType from Python bindings
- Move PyEdgeOptimizersConfig to lib/edge/python/src/config/optimizers.rs
- Update qdrant_edge.pyi: EdgeConfig with vectors/sparse_vectors,
EdgeVectorParams, EdgeSparseVectorParams, EdgeOptimizersConfig
- Update examples (common.py, repr.py) to use new config API
- Run cargo fmt
Made-with: Cursor
* [manual] review changes
* [manual] review changes
* [manual] fix test
* Address CodeRabbit review comments for PR 8322 (#8324)
* Address CodeRabbit review comments for PR 8322
- Python examples: explicit imports (repr.py, common.py) and new EdgeConfig API
- HnswIndexConfig: add max_indexing_threads param and property in .pyi and Rust bindings
- EdgeConfig: make vectors optional for sparse-only configs; validate at least one of vectors/sparse_vectors
- EdgeShardConfig::load: use try_exists(), propagate I/O errors
- from_segment_config: infer hnsw_config from per-vector HNSW when all agree
- EdgeShard setters: atomic clone-mutate-save-then-replace; persist config save errors
- Segment compat: prefix vector name in error messages; resolve None datatype to Float32
- max_indexing_threads: preserve 0 (auto) sentinel in trait default; remove per-optimizer overrides
- SegmentOptimizerConfig::new: build plain and optimizer maps in single pass
- config_mismatch_optimizer tests: use VectorNameBuf::from() instead of .into()
- vectors.rs: doc updates for per-vector quantization
Made-with: Cursor
* Address @generall review: SaveOnDisk for config, resolve num_rayon_threads in optimizer
- Use SaveOnDisk<EdgeShardConfig> for EdgeShard config (generall: 'We have SaveOnDisk struct for this')
- Create via SaveOnDisk::new() after resolving config; setters use .write() for atomic persist
- set_vector_hnsw_config: clone then mutate then write (fallible setter)
- max_indexing_threads: resolve 0 (auto) via num_rayon_threads inside impl (generall: 'proper solution would be to resolve num_rayon_threads inside the optimizer impl')
- max_indexing_threads_sentinel_aware() now returns Some(num_rayon_threads(raw)) so callers get actual thread count
Made-with: Cursor
* [manual] reorganize num_rayon_threads -> get_num_indexing_threads to better account per-vector configuration
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: generall <[email protected]>
* update docstring and pyi
* fmt
* fmt
* clipy
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: generall <[email protected]>
* Introduce EdgeShardConfig for edge shard
- Add EdgeShardConfig and EdgeOptimizersConfig in lib/edge/src/config.rs
- Segment config (vector_data, sparse_vector_data, payload_storage_type)
- Global hnsw_config and per-vector HNSW in segment config
- Optimizer params: deleted_threshold, vacuum_min_vector_number,
default_segment_number, max_segment_size, indexing_threshold,
prevent_unoptimized (excludes memmap_threshold, flush_interval_sec,
max_optimization_threads)
- Persist/load as edge_config.json in shard path
- EdgeShard uses RwLock<EdgeShardConfig>; load() accepts Option<EdgeShardConfig>,
falls back to file or infer from segments; compatibility checked on load
- load_with_segment_config() for backward compatibility (SegmentConfig -> EdgeShardConfig)
- optimize() uses EdgeShardConfig for hnsw and optimizer thresholds
- Public methods: set_hnsw_config(), set_vector_hnsw_config(), set_optimizers_config()
(update and persist)
- Python and examples use load_with_segment_config with existing config API
Made-with: Cursor
* Refactor EdgeShardConfig: user-facing params only, config module
- Replace SegmentConfig inside EdgeShardConfig with user-facing fields:
- on_disk_payload (bool) instead of payload_storage_type
- vectors: HashMap<VectorNameBuf, EdgeVectorParams> with on_disk per vector,
no per-vector quantization; global quantization_config only
- sparse_vectors: HashMap<VectorNameBuf, EdgeSparseVectorParams> with on_disk
- EdgeVectorParams / EdgeSparseVectorParams use on_disk (bool) instead of
storage_type; conversion to VectorDataConfig/SparseVectorDataConfig in
to_segment_config()
- Add config module: mod.rs, optimizers.rs, vectors.rs, shard.rs
- from_segment_config(&SegmentConfig) fills all inferrable params
- to_segment_config() builds SegmentConfig for segments and optimize()
- load_with_segment_config takes Option<SegmentConfig>, uses from_segment_config
Made-with: Cursor
* Move optimizer threshold helpers to shard crate
- Add get_number_segments, get_indexing_threshold_kb, get_max_segment_size_kb,
get_deferred_points_threshold_bytes in shard::optimizers::config
- Collection OptimizersConfig and edge EdgeOptimizersConfig delegate to these
- Single place for threshold logic; collection and edge use shard helpers
Made-with: Cursor
* Use destructuring in config conversions to avoid missing new fields
- EdgeVectorParams: destructure VectorDataConfig in from_*, destructure self in to_vector_data_config
- EdgeSparseVectorParams: destructure SparseVectorDataConfig and SparseIndexConfig in from_*, destructure self in to_sparse_vector_data_config
- EdgeShardConfig: destructure SegmentConfig in from_segment_config, destructure self in to_segment_config
Adding new fields to source structs will now cause compile errors until conversions are updated.
Made-with: Cursor
* refactor: centralize on_disk_payload→payload_storage_type, on_disk→storage_type, and appendable quantization logic
- PayloadStorageType::from_on_disk_payload(bool) in segment (Mmap/InRamMmap)
- VectorStorageType::from_on_disk(bool) in segment (ChunkedMmap/InRamChunkedMmap)
- QuantizationConfig::for_appendable_segment(Option<&Self>) in segment (feature flag + supports_appendable)
- collection: use from_on_disk_payload in non-rocksdb branch
- edge shard/vectors: use new helpers; remove duplicated conditionals
- shard optimizers: use from_on_disk and for_appendable_segment
Made-with: Cursor
* refactor(edge): use EdgeShardConfig directly, drop segment_config
- Add plain_segment_config() for create_appendable_segment (no HNSW)
- Add segment_optimizer_config() built from EdgeShardConfig for blocking optimizers
- Add vector_data_config(name) for query/MMR
- build_blocking_optimizers: use segment_optimizer_config() instead of SegmentConfig
- create_appendable_segment: use plain_segment_config()
- search/query: use config().vectors and vector_data_config() instead of segment_config()
- Remove segment_config() from EdgeShardConfig and EdgeShard
- Add to_plain_vector_data_config on EdgeVectorParams
Made-with: Cursor
* [manual] review changes
* refactor(edge-py): wrap EdgeShardConfig, add EdgeVectorParams/EdgeSparseVectorParams
- PyEdgeConfig now wraps EdgeShardConfig (vectors, sparse_vectors, on_disk_payload, etc.)
- PyEdgeVectorParams / PyEdgeSparseVectorParams wrap edge config types
- PyEdgeOptimizersConfig for optional optimizer settings
- EdgeShard.load() uses EdgeShardConfig; edge::config made pub for Python crate
- cargo fmt + clippy (remove map_identity)
Made-with: Cursor
* refactor(edge-py): simplify config API, remove unused Py* types, add EdgeConfig
- Remove unused PyPayloadStorageType, PyVectorDataConfig, PyVectorStorageType,
PySparseVectorDataConfig, PySparseVectorStorageType from Python bindings
- Move PyEdgeOptimizersConfig to lib/edge/python/src/config/optimizers.rs
- Update qdrant_edge.pyi: EdgeConfig with vectors/sparse_vectors,
EdgeVectorParams, EdgeSparseVectorParams, EdgeOptimizersConfig
- Update examples (common.py, repr.py) to use new config API
- Run cargo fmt
Made-with: Cursor
* [manual] review changes
* [manual] review changes
* [manual] fix test
* Address CodeRabbit review comments for PR 8322 (#8324)
* Address CodeRabbit review comments for PR 8322
- Python examples: explicit imports (repr.py, common.py) and new EdgeConfig API
- HnswIndexConfig: add max_indexing_threads param and property in .pyi and Rust bindings
- EdgeConfig: make vectors optional for sparse-only configs; validate at least one of vectors/sparse_vectors
- EdgeShardConfig::load: use try_exists(), propagate I/O errors
- from_segment_config: infer hnsw_config from per-vector HNSW when all agree
- EdgeShard setters: atomic clone-mutate-save-then-replace; persist config save errors
- Segment compat: prefix vector name in error messages; resolve None datatype to Float32
- max_indexing_threads: preserve 0 (auto) sentinel in trait default; remove per-optimizer overrides
- SegmentOptimizerConfig::new: build plain and optimizer maps in single pass
- config_mismatch_optimizer tests: use VectorNameBuf::from() instead of .into()
- vectors.rs: doc updates for per-vector quantization
Made-with: Cursor
* Address @generall review: SaveOnDisk for config, resolve num_rayon_threads in optimizer
- Use SaveOnDisk<EdgeShardConfig> for EdgeShard config (generall: 'We have SaveOnDisk struct for this')
- Create via SaveOnDisk::new() after resolving config; setters use .write() for atomic persist
- set_vector_hnsw_config: clone then mutate then write (fallible setter)
- max_indexing_threads: resolve 0 (auto) via num_rayon_threads inside impl (generall: 'proper solution would be to resolve num_rayon_threads inside the optimizer impl')
- max_indexing_threads_sentinel_aware() now returns Some(num_rayon_threads(raw)) so callers get actual thread count
Made-with: Cursor
* [manual] reorganize num_rayon_threads -> get_num_indexing_threads to better account per-vector configuration
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: generall <[email protected]>
* update docstring and pyi
* fmt
* fmt
* clipy
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: generall <[email protected]>
ToDo in follow-up PR: split
loadandnewfor EdgeShard