Skip to content

Adding GraphParams to be able to save graph parameters of index to SavedParams#786

Open
backurs wants to merge 1 commit intomainfrom
arturs/add_graph_params
Open

Adding GraphParams to be able to save graph parameters of index to SavedParams#786
backurs wants to merge 1 commit intomainfrom
arturs/add_graph_params

Conversation

@backurs
Copy link
Contributor

@backurs backurs commented Feb 19, 2026

This PR addresses the following issue:

We want to save alpha, l_build, backedge_ratio and vector_dtype somewhere and the best place to do it (in my opinion) is SavedParams.
For that we need to save GraphParams in BfTreeProviderParameters and in BfTreeProvider. This is what this PR does.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds GraphParams struct to persist graph configuration parameters (l_build, alpha, backedge_ratio, vector_dtype) alongside the BfTreeProvider index. The changes enable saving and loading these parameters as part of the index's SavedParams, allowing the DiskANNIndex configuration to be reconstructed on load.

Changes:

  • Introduced GraphParams struct with fields for l_build, alpha, backedge_ratio, and vector_dtype
  • Added optional graph_params field to BfTreeProvider, BfTreeProviderParameters, and SavedParams
  • Updated save/load implementations to persist and restore graph_params
  • Updated all tests and documentation examples to set graph_params: None

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
diskann-providers/src/model/graph/provider/async_/bf_tree/provider.rs Added GraphParams struct, integrated graph_params field into BfTreeProvider/BfTreeProviderParameters/SavedParams, updated save/load logic, updated all doc examples and tests
diskann-providers/src/model/graph/provider/async_/bf_tree/mod.rs Exported GraphParams in public API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


/// Graph configuration parameters persisted alongside the index.
/// These are needed to reconstruct the `DiskANNIndex` config on load.
#[derive(Serialize, Deserialize, Clone, Debug)]
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The GraphParams struct derives Debug while other serialized parameter structs like SavedParams, BfTreeParams, and QuantParams do not. For consistency, consider either removing Debug from GraphParams or adding it to the other parameter structs.

Copilot uses AI. Check for mistakes.
Comment on lines +1834 to +1837
pub struct GraphParams {
pub l_build: usize,
pub alpha: f32,
pub backedge_ratio: f32,
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The GraphParams struct fields lack documentation. Consider adding doc comments to each field to explain what they represent. For example, what is l_build, what does alpha control, what is backedge_ratio used for, and what format should vector_dtype be in?

Suggested change
pub struct GraphParams {
pub l_build: usize,
pub alpha: f32,
pub backedge_ratio: f32,
pub struct GraphParams {
/// Graph build parameter controlling the size of the candidate list
/// used during graph construction (larger values usually improve recall
/// at the cost of higher build time and memory usage).
pub l_build: usize,
/// Tuning factor that controls how aggressively edges are pruned during
/// graph construction, trading off graph sparsity against search quality.
pub alpha: f32,
/// Ratio of backward (reverse) edges to forward edges to retain in the
/// graph, used to improve connectivity and robustness of the index.
pub backedge_ratio: f32,
/// Identifier for the vector element data type stored in the index,
/// for example `"f32"` for 32-bit floating point vectors.

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.00%. Comparing base (e5c83f5) to head (c122b52).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #786      +/-   ##
==========================================
- Coverage   89.00%   89.00%   -0.01%     
==========================================
  Files         428      428              
  Lines       78417    78417              
==========================================
- Hits        69795    69793       -2     
- Misses       8622     8624       +2     
Flag Coverage Δ
miri 89.00% <ø> (-0.01%) ⬇️
unittests 89.00% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pub l_build: usize,
pub alpha: f32,
pub backedge_ratio: f32,
pub vector_dtype: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the data type as in f32/f16 etc.? It's probably better for it to be an enum instead of a raw string.

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.

3 participants

Comments