Skip to content

Сreate and load TQ - #8701

Merged
IvanPleshkov merged 2 commits into
devfrom
create-and-load-TQ
Apr 20, 2026
Merged

IvanPleshkov merged 2 commits into
devfrom
create-and-load-TQ

Conversation

@IvanPleshkov

Copy link
Copy Markdown
Contributor

This PR fixed todo!() for TQ create and load in the segment crate

@IvanPleshkov IvanPleshkov added this to the TurboQuant milestone Apr 16, 2026
@coderabbitai

coderabbitai Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR implements Turbo Quant support in the quantized vectors storage by replacing todo!() branches with working code. It imports Turbo Quant types, implements single- and multi-vector creation (create_turbo, create_turbo_multi) and loading (load_turbo, load_turbo_multi), adds helpers to convert TurboQuant config parameters (convert_tq_bits, convert_tq_mode), selects appropriate storage backends (RAM, mmap, chunked mmap), and updates auto-creation guards for non-appendable quantization configs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • JojiiOfficial
  • generall
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Create and load TQ' directly describes the main changes: implementing TQ (Turbo Quant) creation and loading functionality that replaces todo!() placeholders in the quantized vectors module.
Description check ✅ Passed The description 'This PR fixed todo!() for TQ create and load in the segment crate' is directly related to the changeset, which implements TQ creation and loading functionality to replace todo!() placeholders.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch create-and-load-TQ

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: 1

🧹 Nitpick comments (1)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1)

2214-2219: Prefer an exhaustive match over the _ arm.

Per coding guidelines, catch-all _ arms should be avoided in non-test code. Option<bool> has a fixed set of variants, so listing them explicitly is cheap and documents the intent (note: None currently falls through to Plus — making this explicit also surfaces that default choice for reviewers).

♻️ Suggested change
 fn convert_tq_mode(plus: Option<bool>) -> TQMode {
     match plus {
         Some(false) => TQMode::Normal,
-        _ => TQMode::Plus,
+        Some(true) | None => TQMode::Plus,
     }
 }

As per coding guidelines: "Prefer explicit exhaustive matches over catch-all _ arm in Rust match expressions, so we don't miss handling new enum variants when they are added later".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs` around lines
2214 - 2219, The match in function convert_tq_mode currently uses a catch-all
`_` arm; replace it with an exhaustive match over Option<bool> (explicitly
handle Some(true) and None) so the three cases are clear and intentional: map
Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and None =>
TQMode::Plus (or whichever explicit default is intended) to remove the `_` arm
and document the default choice for reviewers.
🤖 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/segment/src/vector_storage/quantized/quantized_vectors.rs`:
- Around line 2015-2069: The issue is that create_turbo allows
QuantizedVectorsStorageType::Mutable (creating a TQChunkedMmap) but load_turbo
rejects Mutable, causing reload failures; fix by adding a Mutable branch in
load_turbo that mirrors the BinaryChunkedMmap path: detect
QuantizedVectorsStorageType::Mutable in load_turbo, construct a
QuantizedChunkedMmapStorageBuilder (same params used in create_turbo), and call
EncodedVectorsTQ::load (or the corresponding load method) to return
QuantizedVectorStorage::TQChunkedMmap; update any error handling/arguments to
match the other load branches so load_turbo now supports TQChunkedMmap.

---

Nitpick comments:
In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs`:
- Around line 2214-2219: The match in function convert_tq_mode currently uses a
catch-all `_` arm; replace it with an exhaustive match over Option<bool>
(explicitly handle Some(true) and None) so the three cases are clear and
intentional: map Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and
None => TQMode::Plus (or whichever explicit default is intended) to remove the
`_` arm and document the default choice for reviewers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ee169287-88a9-48c8-be34-01eb98467e09

📥 Commits

Reviewing files that changed from the base of the PR and between 04b34e6 and 5243b1d.

📒 Files selected for processing (1)
  • lib/segment/src/vector_storage/quantized/quantized_vectors.rs

@IvanPleshkov IvanPleshkov changed the title create and load TQ Сreate and load TQ Apr 16, 2026
@IvanPleshkov IvanPleshkov mentioned this pull request Apr 16, 2026
63 of 69 tasks

@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.

🧹 Nitpick comments (1)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1)

2289-2294: Consider making the None default in convert_tq_mode explicit.

Some(true) and None both fall through the _ arm to TQMode::Plus, which hides that None is being treated as “enable plus.” An explicit spelling makes the default intent obvious and satisfies the exhaustive-match guideline without relying on the closed-set exception.

♻️ Proposed refactor
 fn convert_tq_mode(plus: Option<bool>) -> TQMode {
     match plus {
+        Some(true) | None => TQMode::Plus,
         Some(false) => TQMode::Normal,
-        _ => TQMode::Plus,
     }
 }

As per coding guidelines: "Prefer explicit exhaustive matches over catch-all _ arm in Rust match expressions".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs` around lines
2289 - 2294, The match in convert_tq_mode currently uses a catch-all arm that
folds Some(true) and None into TQMode::Plus; make the None case explicit to
clarify default behavior and satisfy exhaustive-match guidelines by matching on
Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and None =>
TQMode::Plus (or None => desired default) so intent is explicit for the TQMode
enum.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs`:
- Around line 2289-2294: The match in convert_tq_mode currently uses a catch-all
arm that folds Some(true) and None into TQMode::Plus; make the None case
explicit to clarify default behavior and satisfy exhaustive-match guidelines by
matching on Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and None
=> TQMode::Plus (or None => desired default) so intent is explicit for the
TQMode enum.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5117ef8f-011a-4207-8925-03c43d9fa922

📥 Commits

Reviewing files that changed from the base of the PR and between 5243b1d and 09da366.

📒 Files selected for processing (1)
  • lib/segment/src/vector_storage/quantized/quantized_vectors.rs

@IvanPleshkov
IvanPleshkov merged commit 088e7ad into dev Apr 20, 2026
15 checks passed
@IvanPleshkov
IvanPleshkov deleted the create-and-load-TQ branch April 20, 2026 08:28
VainJoker pushed a commit to VainJoker/qdrant that referenced this pull request Apr 21, 2026
* create and load TQ

* appendable TQ creation
This was referenced Apr 27, 2026
timvisee pushed a commit that referenced this pull request May 8, 2026
* create and load TQ

* appendable TQ creation
@coderabbitai coderabbitai Bot mentioned this pull request May 19, 2026
@coderabbitai coderabbitai Bot mentioned this pull request May 28, 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.

2 participants