Skip to content

fix(routing): preserve row-major layout when resizing capacity routes#1621

Open
mlubin wants to merge 1 commit into
NVIDIA:mainfrom
mlubin:fix/capacity-route-resize-stride
Open

fix(routing): preserve row-major layout when resizing capacity routes#1621
mlubin wants to merge 1 commit into
NVIDIA:mainfrom
mlubin:fix/capacity-route-resize-stride

Conversation

@mlubin

@mlubin mlubin commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes capacity_route_t::resize to be correct when there's more than one capacity dimension.

Adds a test that previously fails more reliably than the existing flaky failures and fixes #1618.

@mlubin
mlubin requested review from a team as code owners July 24, 2026 18:34
@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@mlubin
mlubin requested review from akifcorduk and removed request for Kh4ster July 24, 2026 18:34
@mlubin mlubin added bug Something isn't working non-breaking Introduces a non-breaking change labels Jul 24, 2026
@mlubin

mlubin commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7ffa08c

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c0de55d8-3f70-45ce-96cc-499f1f5dbc24

📥 Commits

Reviewing files that changed from the base of the PR and between 7ffa08c and 51893be.

📒 Files selected for processing (3)
  • cpp/src/routing/route/capacity_route.cuh
  • cpp/tests/routing/CMakeLists.txt
  • cpp/tests/routing/unit_tests/capacity_route_resize.cu
🚧 Files skipped from review as they are similar to previous changes (3)
  • cpp/tests/routing/CMakeLists.txt
  • cpp/src/routing/route/capacity_route.cuh
  • cpp/tests/routing/unit_tests/capacity_route_resize.cu

📝 Walkthrough

Walkthrough

The change makes capacity-route storage resizing preserve row-major data across stride changes and adds a CUDA unit test covering repeated growth of routes with weight and volume capacities.

Changes

Capacity route resize

Layer / File(s) Summary
Preserve strided capacity data
cpp/src/routing/route/capacity_route.cuh
capacity_route_t::resize reallocates capacity vectors using the new stride and copies overlapping dimension rows with cudaMemcpy2DAsync.
Validate multi-dimensional route growth
cpp/tests/routing/CMakeLists.txt, cpp/tests/routing/unit_tests/capacity_route_resize.cu
Adds and registers a test that repeatedly grows routes with weight and volume capacities, then validates resulting vehicle loads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: hlinsen, ramakrishnap-nv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preserving capacity route layout during resize.
Description check ✅ Passed The description is directly related to the resize fix and the added regression test.
Linked Issues check ✅ Passed The changes address the reported multi-dimensional resize corruption and add regression coverage as requested in #1618.
Out of Scope Changes check ✅ Passed The CMake update and new unit test are in scope for the resize bug fix and regression coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

🤖 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 `@cpp/tests/routing/unit_tests/capacity_route_resize.cu`:
- Around line 17-86: Update multi_dim_grow_preserves_second_dimension to use
distinct, binding weight and volume demand/capacity values so both constraints
can detect corruption, and adjust the expected load calculations accordingly.
Before validating capacities, assert that every order is assigned exactly once
in the returned host_route. Replace the current tautological cap checks with
assertions against each dimension’s actual configured capacity.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f0b3ed3d-1bee-4f16-b5cb-992fa0bb7918

📥 Commits

Reviewing files that changed from the base of the PR and between 0d93a5a and 7ffa08c.

📒 Files selected for processing (3)
  • cpp/src/routing/route/capacity_route.cuh
  • cpp/tests/routing/CMakeLists.txt
  • cpp/tests/routing/unit_tests/capacity_route_resize.cu

Comment thread cpp/tests/routing/unit_tests/capacity_route_resize.cu
Comment thread cpp/src/routing/route/capacity_route.cuh Outdated
capacity_route_t stores its per-node arrays row-major with one row per
capacity dimension and stride == max_nodes_per_route. resize() grew the
flat buffers with device_uvector::resize, which only preserves the linear
prefix, so after a mid-solve route growth every capacity dimension beyond
the first ended up read at the wrong stride.

On problems with >=2 capacity dimensions this corrupted demand data
whenever a route outgrew its allocation, yielding wrong infeasibility
costs: a flaky "Cost should improve!" / "Cost mismatch" SIGABRT in
assert-enabled builds, and silent constraint-accounting errors in
release builds.

Re-place each dimension's row at its new offset with a strided copy, and
add a regression test that drives a multi-dimension route past its base
allocation during a solve (see issue NVIDIA#1618).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Miles Lubin <mlubin@nvidia.com>
@mlubin
mlubin force-pushed the fix/capacity-route-resize-stride branch from 7ffa08c to 51893be Compare July 24, 2026 18:50
@mlubin

mlubin commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 51893be

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

CI Test Summary

✅ All 31 test job(s) passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Multi-dimension capacity data corrupted when routes are resized mid-search (flaky Cost should improve! / Cost mismatch SIGABRT in ROUTING_TEST)

2 participants