Skip to content

Introduce EdgeShardConfig for edge shard - #8322

Merged
generall merged 17 commits into
devfrom
feature/edge-shard-config
Mar 9, 2026
Merged

generall merged 17 commits into
devfrom
feature/edge-shard-config

Conversation

@qdrant-cloud-bot

@qdrant-cloud-bot qdrant-cloud-bot commented Mar 7, 2026 •

Copy link
Copy Markdown
Contributor
# Introduce EdgeShard configuration


Currently, the `EdgeShard` doesn't have a dedicated configuration file.
As a configuration it uses `config: SegmentConfig` which is primarily designed for `Segment` and contains only some relevant parameters for `EdgeShard`.


`SegmentConfig` deosn't have all required parameters, and it can't be extended, as it is used in `Segment`.

On the other hand, `CollectionConfig` from `lib/collection/src/operations/types.rs` have too many parameters, and can't be used in shard, as it it on higher level of abstraction, and it is used in `Collection`.


## Proposal

Introduce `EdgeShardConfig` which will contain all required parameters for `EdgeShard` and will be used in `EdgeShard` instead of `SegmentConfig`.


What parameters of `SegmentConfig` to preserve:

- See what python wrappers `PyEdgeConfig`, `PySparseVectorDataConfig` and `PyVectorDataConfig` are exposing. 

Which extra parametes on top of `SegmentConfig` we need:

- From `CollectionConfig`:
    - `hnsw_config` - global and for each vector.
    - From `OptimizersConfig`, everything except for 
        - `memmap_threshold` - deprecated. 
        - `flush_interval_sec` - edge deosn't flush
        - `max_optimization_threads` optimizets are manual

No other parameters are needed for now.

`EdgeShardConfig` should be used instead of `SegmentConfig` in `EdgeShard`.
If it is provided on initialization - it should be persisted as json file in special path.

If it is not provided, parts of it should infered from `SegmentConfig` of existing segments, as it is currently done `config` in `EdgeShard`.
On load, it should be checked for compatibility with existing segments, as it is currently done with `config` in `EdgeShard`.

New `EdgeShardConfig` should be used in `optimize` to derive required hnsw parameters for optimization.

New public methods should be introduced to allow users to change hnsw_config and other parameters for existing `EdgeShard` and persist them in `EdgeShardConfig`.

Note: some parameters can't be changed, like dimentionality, and other can - like quantization method. 


----


## review

`SegmentConfig` should not be part of `EdgeShardConfig`, it contains paramters, which we don't want to expose to users.
For instance, we don't want to expose:

- `payload_storage_type` - user should only specify `on_disk_payload` true/fasle, same as in `CollectionParams`.
- There should be global quantization config for all vectors, same as `hnsw_config`, and no separate quantization config for each vector


Inside `VectorDataConfig`, we don't need `storage_type`, same as for payload, we can have `on_disk` true/false, and it will be used to determine storage type.

There should be conversion from `SegmentConfig` to `EdgeShardConfig`, which would fill up all paramters, which are possible to fill.

Please also do not put many structures into one file, create a module for configurations, and put all related structures there.


--- 

`get_number_segments`, `get_indexing_threshold_kb`, `get_max_segment_size_kb` and construction of `deferred_points_threshold_bytes` logic is duplicated between collection and shard, it should be moved to some common place - shard subcrate.

---


- inspect all coneversions between structures like `from_segment_config`, make sure to use deconstruction and construction, instead of manual field by field assignment, to avoid missing fields in the future when we add new ones.

---

`on_disk_payload` -> `payload_storage_type` logic is duplicated across the codebase. Move it into one common place.
Similar to `on_disk` -> `storage_type` logic for `VectorStorageType`.

Similar for `quantization_config` and check for appendable_quantization feature flag.


---


`segment_config` function of `EdgeShardConfig` should not be used.
The only place where we actually need `SegmentConfig` is when we do `create_appendable_segment`,
but even in this case I would prefer a specialized function `plain_segment_config` (it should not contain any HNSW configuration).

`segment_optimizer_config` in `build_blocking_optimizers` should be constructed from EdgeShardConfig directly.

For all other cases, we should use `EdgeShardConfig` directly, and not convert it to `SegmentConfig` first.


---

Update python bindings accordingly to the new `EdgeShardConfig` structure.
Change how `PyEdgeConfig` works, currently it wraps `SegmentConfig`, but it should wrap `EdgeShardConfig` instead.
Underlying types, such as `PyVectorDataConfig` and `PySparseVectorDataConfig` should also wrap proper types from `EdgeShardConfig`, and not from `SegmentConfig`.

ToDo in follow-up PR: split load and new for EdgeShard

mnaumanofficial13-svg and others added 10 commits March 7, 2026 12:08
- 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
@generall
generall requested a review from dancixx March 8, 2026 00:48
@generall
generall marked this pull request as ready for review March 8, 2026 00:51

@coderabbitai coderabbitai Bot left a comment

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.

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 | 🟡 Minor

Switch to explicit imports.

Line 8 uses from qdrant_edge import *, which causes F405 violations on EdgeVectorParams, 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::new currently 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 to DenseVectorOptimizerInput / SparseVectorOptimizerInput harder 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: Use VectorNameBuf::from(...) instead of .into() in these new inserts.

The target type is already known here, and the repo guideline asks for explicit From conversions in Rust.

♻️ Example fix
-            DEFAULT_VECTOR_NAME.into(),
+            VectorNameBuf::from(DEFAULT_VECTOR_NAME),

As per coding guidelines, **/*.rs: Prefer explicit SomeType::from(x) over implicit x.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 the 0 == auto sentinel when reducing HNSW thread limits.

A plain numeric max() turns a mixed set like {0, 2} into 2, 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 like expected vector size ... no longer say which named vector failed. Wrapping the returned error with vector_name will 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 want sparse_vectors. Making vectors optional and validating vectors or sparse_vectors in 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

📥 Commits

Reviewing files that changed from the base of the PR and between b3a6cba and 6008a95.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (38)
  • lib/collection/src/collection/payload_index_schema.rs
  • lib/collection/src/collection/snapshots.rs
  • lib/collection/src/collection_manager/fixtures.rs
  • lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs
  • lib/collection/src/collection_manager/optimizers/indexing_optimizer.rs
  • lib/collection/src/collection_manager/optimizers/merge_optimizer.rs
  • lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs
  • lib/collection/src/config.rs
  • lib/collection/src/optimizers_builder.rs
  • lib/collection/src/update_workers/optimization_worker.rs
  • lib/edge/Cargo.toml
  • lib/edge/publish/examples/src/lib.rs
  • lib/edge/python/examples/common.py
  • lib/edge/python/examples/repr.py
  • lib/edge/python/qdrant_edge.pyi
  • lib/edge/python/src/config/mod.rs
  • lib/edge/python/src/config/optimizers.rs
  • lib/edge/python/src/config/sparse_vector_data.rs
  • lib/edge/python/src/config/vector_data.rs
  • lib/edge/python/src/lib.rs
  • lib/edge/src/config/mod.rs
  • lib/edge/src/config/optimizers.rs
  • lib/edge/src/config/shard.rs
  • lib/edge/src/config/vectors.rs
  • lib/edge/src/lib.rs
  • lib/edge/src/optimize.rs
  • lib/edge/src/query.rs
  • lib/edge/src/search.rs
  • lib/segment/src/index/sparse_index/sparse_index_config.rs
  • lib/segment/src/types.rs
  • lib/shard/src/files/mod.rs
  • lib/shard/src/optimizers/config.rs
  • lib/shard/src/optimizers/config_mismatch_optimizer.rs
  • lib/shard/src/optimizers/indexing_optimizer.rs
  • lib/shard/src/optimizers/merge_optimizer.rs
  • lib/shard/src/optimizers/segment_optimizer.rs
  • lib/shard/src/optimizers/vacuum_optimizer.rs
  • lib/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

Comment thread lib/edge/publish/examples/src/lib.rs Resolved
Comment thread lib/edge/python/examples/repr.py Resolved
Comment thread lib/edge/python/qdrant_edge.pyi Resolved
Comment thread lib/edge/python/src/config/mod.rs Resolved
Comment thread lib/edge/src/config/shard.rs Resolved
Comment thread lib/edge/src/config/vectors.rs Resolved
Comment thread lib/edge/src/lib.rs Resolved
Comment thread lib/edge/src/lib.rs Resolved
Comment thread lib/segment/src/types.rs Resolved
* 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]>

@coderabbitai coderabbitai Bot left a comment

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.

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 | 🟠 Major

Sparse compatibility should also validate index.datatype.

This check only looks at modifier. A shard configured with sparse datatype = Uint8 will currently load against a Float32 sparse segment as “compatible”, even though the edge config now exposes datatype and writes it back into SparseIndexConfig. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 298618c and 66a975c.

📒 Files selected for processing (31)
  • lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs
  • lib/collection/src/optimizers_builder.rs
  • lib/collection/src/tests/mod.rs
  • lib/collection/src/update_workers/optimization_worker.rs
  • lib/edge/python/examples/common.py
  • lib/edge/python/examples/repr.py
  • lib/edge/python/qdrant_edge.pyi
  • lib/edge/python/src/config/mod.rs
  • lib/edge/python/src/config/vector_data.rs
  • lib/edge/src/config/shard.rs
  • lib/edge/src/config/vectors.rs
  • lib/edge/src/lib.rs
  • lib/edge/src/optimize.rs
  • lib/segment/benches/hnsw_incremental_build.rs
  • lib/segment/benches/multi_vector_search.rs
  • lib/segment/src/index/hnsw_index/mod.rs
  • lib/segment/src/index/hnsw_index/tests/test_graph_connectivity.rs
  • lib/segment/src/segment_constructor/segment_builder.rs
  • lib/segment/src/types.rs
  • lib/segment/tests/integration/batch_search_test.rs
  • lib/segment/tests/integration/exact_search_test.rs
  • lib/segment/tests/integration/gpu_hnsw_test.rs
  • lib/segment/tests/integration/hnsw_discover_test.rs
  • lib/segment/tests/integration/hnsw_incremental_build.rs
  • lib/segment/tests/integration/segment_builder_test.rs
  • lib/shard/src/optimizers/config.rs
  • lib/shard/src/optimizers/config_mismatch_optimizer.rs
  • lib/shard/src/optimizers/indexing_optimizer.rs
  • lib/shard/src/optimizers/merge_optimizer.rs
  • lib/shard/src/optimizers/segment_optimizer.rs
  • lib/shard/src/optimizers/vacuum_optimizer.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/edge/python/examples/repr.py

Comment thread lib/edge/src/config/vectors.rs Resolved
@qdrant qdrant deleted a comment from coderabbitai Bot Mar 9, 2026

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd like to see another review before we merge.

Comment thread lib/edge/python/qdrant_edge.pyi Outdated
@property
def full_scan_threshold(self) -> Optional[int]:
"""Full scan threshold."""
def deleted_threshold(self) -> float:

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.

Type mismatch. Rust version returns Option<T>.

Comment thread lib/edge/python/qdrant_edge.pyi Outdated
@property
def index_type(self) -> "SparseIndexType":
"""Index type."""
def vacuum_min_vector_number(self) -> int:

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.

Type mismatch. Rust version returns Option<T>.

Comment thread lib/edge/python/qdrant_edge.pyi Outdated
@property
def datatype(self) -> Optional["VectorStorageDatatype"]:
"""Storage datatype."""
def default_segment_number(self) -> int:

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.

Type mismatch. Rust version returns Option<T>.

Comment thread lib/edge/src/config/shard.rs Outdated
///
/// 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.

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.

This doc comment looks outdated: EdgeVectorParams now supports per-vector quantization_config, so saying "no per-
vector quantization" is no longer accurate.

Comment thread lib/edge/src/config/shard.rs Outdated
/// 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`.

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.

The per-vector HNSW override is now exposed as vectors[].hnsw_config, not via vectors[].index / Indexes::Hnsw.

@dancixx

dancixx commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

@generall
lib/edge/python/src/snapshots.rs#L43

Potential restore bug: edge_config.json is now persisted at shard root, but this full-recovery flow only clears/movesShardDataFiles. That can leave stale Edge config behind and then EdgeShard::load(..., None) will pick it up after restore.

lib/edge/src/lib.rs#L83

load(None) prefers EdgeShardConfig::load(path) first and only falls back to inferring config from segments if no persisted config file is found. So if edge_config.json is left behind during snapshot recovery, it will take precedence over inference.

@generall

generall commented Mar 9, 2026

Copy link
Copy Markdown
Member

@dancixx I checked config logic again - we always verify config against segments, even if it was loaded from file.
In this situation, if snapshot recoverred wth incompatible snapshot, update will fail on load, which I would consider as expected.

But then user is able to load again, with new explicit configuration to effectively resolve the config mismatch.

I think current behaviour is acceptable.

@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR performs a substantial architectural refactoring to consolidate optimizer and configuration management across the codebase. The main changes involve: relocating the PAYLOAD_INDEX_CONFIG_FILE constant to the shard module; renaming optimizer config fields from base_* to plain_* nomenclature; removing HnswConfig parameters from optimizer constructors; introducing new Edge-specific configuration types (EdgeShardConfig, EdgeVectorParams, EdgeSparseVectorParams, EdgeOptimizersConfig); refactoring SegmentOptimizerConfig with separate dense and sparse vector optimizer configs; renaming internal config fields from segment_config to segment_optimizer_config; converting compatibility checks from boolean returns to Result<(), String>; adding helper functions for thread count and optimizer threshold calculations; and renaming num_rayon_threads to get_num_indexing_threads. The changes span Rust core modules (segment, shard, collection) and Python bindings.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • PR #8065: Refactors optimizer/config and shard pieces, moving constants like PAYLOAD_INDEX_CONFIG_FILE from collection into shard modules and restructuring optimizer configuration assembly.
  • PR #8224: Relocates optimizer/edge/shard configuration types and constants, refactoring the same optimizer and edge configuration code paths.
  • PR #7643: Adds and propagates prevent_unoptimized field through optimizer configs and wires it into segment and optimization worker logic.

Suggested reviewers

  • ffuugoo
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Introduce EdgeShardConfig for edge shard' directly summarizes the main change—introducing a new EdgeShardConfig structure to replace SegmentConfig usage in EdgeShard.
Description check ✅ Passed The description comprehensively explains the motivation (EdgeShard needing dedicated configuration beyond SegmentConfig), the new EdgeShardConfig structure, parameters to include/exclude, persistence strategy, conversion requirements, and Python binding updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/edge-shard-config

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

♻️ Duplicate comments (1)
lib/edge/src/config/vectors.rs (1)

129-175: ⚠️ Potential issue | 🟠 Major

Honor on_disk in the sparse plain-config conversion.

to_plain_sparse_vector_data_config() drops self.on_disk and hardcodes both the sparse storage and index settings, while from_sparse_vector_data_config() later reconstructs on_disk from index_type.is_on_disk(). That makes the EdgeSparseVectorParams ↔ SparseVectorDataConfig round-trip lossy and leaves the user-provided on_disk flag 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 the on_disk → VectorStorageType mapping, 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 that vectors may also carry per-vector hnsw_config.

The module docs currently read as if only the global hnsw_config is user-facing, but this PR also exposes per-vector HNSW overrides via vectors. 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() forwards num_indexing_threads directly 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_threads field on HnswConfig uses 0 as a sentinel meaning "use system CPU count", and callers should consume the resolved concrete count rather than propagating 0.

🤖 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 _getters exhaustive field check for consistency.

Other wrapper types in this file (e.g., PyHnswIndexConfig, PyMultiVectorConfig) include a _getters function that destructures the inner type to ensure compile-time enforcement when fields are added. PyEdgeVectorParams lacks 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_config when all per-vector HNSW configs agree. When configs disagree, it falls back to HnswConfig::default(). This is reasonable behavior for inference from existing segments, though it may silently lose threading settings if vectors have different max_indexing_threads values.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b3a6cba and 81b95f5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (51)
  • lib/collection/src/collection/payload_index_schema.rs
  • lib/collection/src/collection/snapshots.rs
  • lib/collection/src/collection_manager/fixtures.rs
  • lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs
  • lib/collection/src/collection_manager/optimizers/indexing_optimizer.rs
  • lib/collection/src/collection_manager/optimizers/merge_optimizer.rs
  • lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs
  • lib/collection/src/config.rs
  • lib/collection/src/optimizers_builder.rs
  • lib/collection/src/tests/mod.rs
  • lib/collection/src/update_workers/optimization_worker.rs
  • lib/edge/Cargo.toml
  • lib/edge/publish/examples/src/lib.rs
  • lib/edge/python/examples/common.py
  • lib/edge/python/examples/repr.py
  • lib/edge/python/qdrant_edge.pyi
  • lib/edge/python/src/config/mod.rs
  • lib/edge/python/src/config/optimizers.rs
  • lib/edge/python/src/config/sparse_vector_data.rs
  • lib/edge/python/src/config/vector_data.rs
  • lib/edge/python/src/lib.rs
  • lib/edge/python/src/snapshots.rs
  • lib/edge/src/config/mod.rs
  • lib/edge/src/config/optimizers.rs
  • lib/edge/src/config/shard.rs
  • lib/edge/src/config/vectors.rs
  • lib/edge/src/lib.rs
  • lib/edge/src/optimize.rs
  • lib/edge/src/query.rs
  • lib/edge/src/search.rs
  • lib/segment/benches/hnsw_incremental_build.rs
  • lib/segment/benches/multi_vector_search.rs
  • lib/segment/src/index/hnsw_index/mod.rs
  • lib/segment/src/index/hnsw_index/tests/test_graph_connectivity.rs
  • lib/segment/src/index/sparse_index/sparse_index_config.rs
  • lib/segment/src/segment_constructor/segment_builder.rs
  • lib/segment/src/types.rs
  • lib/segment/tests/integration/batch_search_test.rs
  • lib/segment/tests/integration/exact_search_test.rs
  • lib/segment/tests/integration/gpu_hnsw_test.rs
  • lib/segment/tests/integration/hnsw_discover_test.rs
  • lib/segment/tests/integration/hnsw_incremental_build.rs
  • lib/segment/tests/integration/segment_builder_test.rs
  • lib/shard/src/files/mod.rs
  • lib/shard/src/optimizers/config.rs
  • lib/shard/src/optimizers/config_mismatch_optimizer.rs
  • lib/shard/src/optimizers/indexing_optimizer.rs
  • lib/shard/src/optimizers/merge_optimizer.rs
  • lib/shard/src/optimizers/segment_optimizer.rs
  • lib/shard/src/optimizers/vacuum_optimizer.rs
  • lib/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

Comment thread lib/edge/python/src/snapshots.rs Resolved
Comment thread lib/edge/src/lib.rs Resolved
@generall
generall merged commit 7e15d34 into dev Mar 9, 2026
16 checks passed
@generall
generall deleted the feature/edge-shard-config branch March 9, 2026 23:10
generall added a commit that referenced this pull request Mar 26, 2026
* 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]>
KShivendu pushed a commit that referenced this pull request Mar 30, 2026
* 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]>
@xzfc xzfc mentioned this pull request Apr 23, 2026
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.

5 participants