Skip to content

Conversation

@devin-ai-integration
Copy link

Add custom allocator support to SimpleBlockedGraph (resolves intel#81)

Summary

This PR resolves issue #81 by adding custom allocator support to SimpleBlockedGraph for dynamic vamana index graph construction. Previously, SimpleBlockedGraph was hardcoded to use HugepageAllocator, preventing users from providing their own allocators.

Changes:

  • Added allocator template parameter to SimpleBlockedGraph with default HugepageAllocator<Idx> (following the pattern already established in SimpleGraph)
  • Added constructor accepting custom allocator: SimpleBlockedGraph(size_t num_nodes, size_t max_degree, const Alloc& allocator)
  • Updated both load() methods to accept optional allocator parameter with default
  • Added operator== for comparing graphs with different allocators
  • Updated three deduction guides in multi.h to explicitly specify HugepageAllocator<uint32_t>

Backward Compatibility:
All existing code continues to work without modification because the allocator template parameter defaults to HugepageAllocator<Idx>. Code using SimpleBlockedGraph<uint32_t> will automatically resolve to SimpleBlockedGraph<uint32_t, HugepageAllocator<uint32_t>>.

Review & Testing Checklist for Human

This PR has moderate risk due to lack of local compilation and runtime testing. Please verify:

  • CI compilation succeeds - Verify all tests build without template instantiation errors or type mismatches
  • Backward compatibility works - Existing code using SimpleBlockedGraph<uint32_t> should compile and work identically to before
  • Deduction guide changes are correct - The three updated deduction guides in multi.h now explicitly specify HugepageAllocator<uint32_t>. Review these carefully to ensure they don't break template argument deduction
  • Optional: Test custom allocator usage - Consider manually testing that users can now instantiate SimpleBlockedGraph<uint32_t, CustomAllocator<uint32_t>> and use it with MutableVamanaIndex
  • Optional: Add test coverage - Consider adding a test case that explicitly uses a custom allocator with SimpleBlockedGraph to verify the feature works end-to-end

Test Plan Recommendation

  1. Run existing test suite to verify backward compatibility
  2. Manually instantiate SimpleBlockedGraph with a custom allocator (e.g., std::allocator<uint32_t>) in a test file
  3. Verify it can be used with MutableVamanaIndex for graph construction

Notes

  • This implementation follows the exact same pattern as SimpleGraph (lines 337-377 in graph.h), which already has custom allocator support
  • The change assumes that data::BlockedData properly supports custom allocators (verified from Python bindings usage, but not verified in the actual implementation)
  • No new tests were added because existing tests will verify backward compatibility, and the pattern is already proven in SimpleGraph

Devin Session: https://app.devin.ai/sessions/d6b3fe1407f141f3b43e774b3e91aa46
Requested by: @milind-cognition

… index (resolves intel#81)

- Add allocator template parameter to SimpleBlockedGraph with default HugepageAllocator
- Add constructor accepting custom allocator
- Update load methods to accept allocator parameter with default
- Add operator== for comparing graphs with different allocators
- Update deduction guides in multi.h to explicitly specify default allocator
- Maintains full backward compatibility via default template parameter

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

Support custom allocator for dynamic vamana index

1 participant