Skip to content

vector: select pinned KaHIP placement for structured embeddings - #4029

Merged
snissn merged 19 commits into
mainfrom
codex/issue-4024-placement
Jul 31, 2026
Merged

vector: select pinned KaHIP placement for structured embeddings#4029
snissn merged 19 commits into
mainfrom
codex/issue-4024-placement

Conversation

@snissn

@snissn snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Closes #4024

Scope

Adds the smallest offline-only KaHIP 3.25 adapter through the existing exact-request external JSON seam. The selector is limited to graph primary materialization in partition and M3 build stages; no overlap policy, routing, or online dependency changes.

Evidence

Retained 100k structured embedding-mixture graph 5a095727ed0f82815643daddb47bd11a08c9630ede6f9b1d7e7ec427dc8e9937:

backend p4 primary oracle directed cut max load/cap
reference greedy 0.8303 1,122,051 6521/6563
KaHIP Python 3.25 ECO, OMP=1 1.0 0 6283/6563

KaHIP artifact: /mnt/fast4tb/gomap-4024-placement/out-kahip-head-4f4a293/vector_partition_022359b1aedf_ffd419418529_3dba078aad70.json, SHA-256 022359b1aedfa738cde7f2e82e01263c855eb72075b1f2a927d3a5753d6fde9c. Build: 79.289s. Report SHA-256 d11be251f48a054a272fb5eea9bbc741295662ff68ff13647f730f26fa258caa. p1/p2/p4/p8/p16 are all 1.0; truth is diagnostic only. kahip==3.25, MIT, pinned RECORD SHA-256 7ff011253147286fcebc9185573662bf31dbcfbab1944f9b4940032f49ea5217; source wheel SHA-256 e6ea76524e9fc01b27e6f5c5f00b7eec71c94cbd1e84678ce2a14d64dfc9eda4. The bundled CLI is deliberately unused.

Validation

  • TREEDB_KAHIP_PYTHON=/mnt/fast4tb/gomap-4024-kahip-3.25/bin/python go test ./cmd/treedb_vector_partition_bench -run 'TestKaHIP' -count=1
  • go test ./TreeDB/internal/vectorpartition ./TreeDB/vectorpartition

Existing external JSON seam coverage supplies cancellation, deadline, malformed-output, and input/output-cap failure checks. The prior macOS Root failure was unrelated: TreeDB/db TestOrderedRootSpanNativeValueLogLeavesCheckpointReopenAndGC failed with ValueLogGC: treedb: recoverable root set changed; this PR does not touch TreeDB/db, and sibling Root shards passed.

Risks

Offline-only experimental structured-embedding placement. Invocation requires explicit pinned Python and adapter-script paths. The 16M directed-edge envelope is V1 canonical (1M vectors x degree 16), not the broader builder reservation. High-entropy qualification is separate #4030.

Summary by CodeRabbit

  • New Features

    • Added optional offline KaHIP 3.25 partitioning for supported graph-materialization workflows.
    • Added deterministic partitioning with validated assignments, capacity limits, metadata, and edge-cut metrics.
    • Added bounded execution, input/output validation, integrity checks, and single-threaded processing.
  • Documentation

    • Documented the pinned KaHIP configuration, provenance, resource limits, validation rules, and offline evaluation scope.
  • Tests

    • Added coverage for supported configurations, output sizing, adapter integration, and artifact integrity validation.

Copilot AI review requested due to automatic review settings July 31, 2026 18:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@snissn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d3909aaf-dafd-47c0-b360-1fa6077353e9

📥 Commits

Reviewing files that changed from the base of the PR and between 3f585c4 and 8ef8b39.

📒 Files selected for processing (1)
  • .gitattributes
📝 Walkthrough

Walkthrough

The benchmark adds a bounded offline KaHIP 3.25 adapter for graph partition stages. The adapter validates inputs and outputs, runs deterministic ECO partitioning, and returns partition metadata and metrics. Tests and the specification cover configuration, integrity, and comparison results.

Changes

Offline KaHIP partitioning

Layer / File(s) Summary
KaHIP adapter validation and partition output
scripts/treedb_kahip_partition.py
The adapter verifies the pinned package, validates graph limits and edges, symmetrizes the graph, runs ECO partitioning, validates capacities, and writes assignments with metrics.
Benchmark selector and adapter invocation
cmd/treedb_vector_partition_bench/main.go
The benchmark adds KaHIP configuration and command-line options, restricts supported stages, builds bounded requests, invokes the adapter, and validates the returned artifact.
KaHIP coverage and comparison evidence
cmd/treedb_vector_partition_bench/main_test.go, TreeDB/docs/spec/vector-partition-m2.md
Tests cover configuration, output sizing, graph-envelope preflight, adapter round trips, identity, and payload integrity. The specification records the pinned configuration and offline results.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Benchmark as treedb_vector_partition_bench
  participant Adapter as treedb_kahip_partition.py
  participant KaHIP
  Benchmark->>Benchmark: Build bounded graph request
  Benchmark->>Adapter: Invoke with timeout and JSON limits
  Adapter->>KaHIP: Run seeded ECO partitioning
  KaHIP-->>Adapter: Return partition assignment
  Adapter-->>Benchmark: Return assignment, metadata, and metrics
  Benchmark->>Benchmark: Validate and persist artifact
Loading

Possibly related PRs

Suggested reviewers: copilot

Poem

A rabbit checks each graph edge twice,
Then sends it through KaHIP’s device.
Bounded requests flow,
Partitions align,
Deterministic hops suffice.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: selecting a pinned KaHIP placement for structured embeddings.
Linked Issues check ✅ Passed The changes satisfy [#4024] by adding bounded, deterministic, offline-only pinned KaHIP placement with validation and focused tests.
Out of Scope Changes check ✅ Passed The documentation, integration, adapter, and tests directly support the offline structured-placement objectives in [#4024].
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-4024-placement

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/treedb_kahip_partition.py`:
- Line 11: In scripts/treedb_kahip_partition.py, remove Ruff E701/E702 compound
statements by placing each statement on its own line, including the
open/json.load statement and the additional flagged ranges. Preserve the
existing execution order and behavior while formatting all affected blocks as
separate statements.
- Around line 9-10: Enforce the documented KaHIP wheel identity, not only
version 3.25: in scripts/treedb_kahip_partition.py lines 9-10, validate the
installed distribution identity and include it in artifact metadata; in
cmd/treedb_vector_partition_bench/main_test.go lines 1531-1559, require the
documented Python interpreter and identity and add rejection coverage for
another KaHIP 3.25 installation; in TreeDB/docs/spec/vector-partition-m2.md
lines 78-84, restrict execution to that wheel or document all accepted
identities.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: cd6cdc6d-874e-47cc-9679-72a47d5b19da

📥 Commits

Reviewing files that changed from the base of the PR and between ffd4194 and 06154a7.

📒 Files selected for processing (4)
  • TreeDB/docs/spec/vector-partition-m2.md
  • cmd/treedb_vector_partition_bench/main.go
  • cmd/treedb_vector_partition_bench/main_test.go
  • scripts/treedb_kahip_partition.py

Comment thread scripts/treedb_kahip_partition.py Outdated
Comment thread scripts/treedb_kahip_partition.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06154a7762

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/treedb_vector_partition_bench/main.go Outdated
Comment thread cmd/treedb_vector_partition_bench/main.go Outdated
@snissn
snissn marked this pull request as draft July 31, 2026 18:29
@snissn snissn changed the title vector: select pinned offline KaHIP placement vector: add pinned offline KaHIP placement candidate Jul 31, 2026
@snissn snissn changed the title vector: add pinned offline KaHIP placement candidate vector: select pinned KaHIP placement for structured embeddings Jul 31, 2026
@snissn
snissn marked this pull request as ready for review July 31, 2026 19:11
@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai review

Copilot AI review requested due to automatic review settings July 31, 2026 19:11

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

@snissn: I will review the changes in #4029.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI review requested due to automatic review settings July 31, 2026 19:13

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

@snissn I will review the changes in #4029.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40d23c6819

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/treedb_vector_partition_bench/main.go
Comment thread scripts/treedb_kahip_partition.py Outdated
@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Copilot AI review requested due to automatic review settings July 31, 2026 19:24

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

@snissn I will review the changes in #4029.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

1 similar comment
@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f585c4ad7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/treedb_vector_partition_bench/main.go
Copilot AI review requested due to automatic review settings July 31, 2026 22:00

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

1 similar comment
@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

2 similar comments
@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

3 similar comments
@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@snissn

snissn commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

Final merge evidence

Exact head: 8ef8b396c6f1468737638e2c50f2853d632e491d

  • CI: 34/34 checks pass; no pending, failed, skipped, or cancelled checks
  • Review: exact-head Codex reported no major issues: vector: select pinned KaHIP placement for structured embeddings #4029 (comment)
  • Threads: 0 unresolved across 18 total review threads
  • Local validation: focused KaHIP selector/adapter checks, full cmd/treedb_vector_partition_bench tests, Git attribute/digest checks, and git diff --check pass
  • Structured 100k retained evidence: reference p4 recall 0.8303; selected p1/p2/p4/p8/p16 recall 1.0000; cut 0; max load/cap 6283/6563; artifact SHA-256 022359b1aedfa738cde7f2e82e01263c855eb72075b1f2a927d3a5753d6fde9c
  • Claim boundary: no universal or high-entropy p4 claim; trusted local offline runtime remains outside V1 attestation

Merge gate satisfied without waiver.

@snissn
snissn merged commit 9137f2a into main Jul 31, 2026
37 of 38 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 8ef8b396c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

Select balanced graph placement for structured embeddings

2 participants