Uh oh!
There was an error while loading. Please reload this page.
Routing Phase 3: export the recorded problem to a host representation - #1583
Conversation
Add to_host_problem(dm): walks the store-then-build IR (DataModel._calls) and produces host (numpy) arrays keyed by the gRPC RoutingProblem field names, exporting any device (cuDF/cupy) inputs to host at this point (the mixed-IR "export on serialize"). Proto-agnostic -- a dict of host arrays -- so it does not depend on generated gRPC stubs and is the client-side foundation for serializing a routing problem over gRPC. Covers the full setter surface, including uniform and per-vehicle break dimensions. Verified end-to-end: host+device (numpy/cuDF) inputs export to a fully host problem with correct row-major matrices, grouped per-vehicle breaks, and no device references left; full routing suite passes (56). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Replace the per-setter if/elif chain in to_host_problem with a dispatch table: setters that rename fields, take several args, or build nested structures get an explicit handler in _HANDLERS; the common set_<field>(array) -> field <field> setters are derived automatically and need no entry. An unmapped add_* setter raises, and test_every_setter_is_exportable checks every recorded setter is exportable, so a new setter fails loudly instead of being silently dropped. Behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
ramakrishnap-nv
commented
Jul 17, 2026
@CodeRabbit review |
✅ Action performedReview finished.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughChangesRouting serialization
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@python/cuopt/cuopt/routing/_serialize.py`:
- Around line 180-184: Update the public function to_host_problem with explicit
parameter and return type annotations, using the project’s existing types for
the routing problem input and host-array mapping. Expand its docstring to
document the dm parameter, returned RoutingProblem-keyed host arrays, and the
KeyError raised when required problem fields are missing.
- Around line 194-205: Update the unregistered set_* fallback in the _serialize
loop to require exactly one argument before exporting args[0]; raise the
existing unmapped-setter error (or equivalent) for multi-argument calls so they
require an explicit _HANDLERS entry. Add a regression test covering a
multi-argument set_* call and verify it is rejected.
In `@python/cuopt/cuopt/tests/routing/test_serialize.py`:
- Around line 61-77: Strengthen the routing serialization assertions in
python/cuopt/cuopt/tests/routing/test_serialize.py lines 61-77 by validating
time-window arrays, both capacity demand/capacity arrays, and matrix dtype plus
metadata alongside values, shapes, and existing fields. Also update lines 94-103
to assert uniform-break earliest/latest and every field of both vehicle breaks,
including both locations arrays; retain the existing device-reference check.
🪄 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: 924e8e2a-f40f-4a0a-9a2c-9a10478710cf
📒 Files selected for processing (2)
python/cuopt/cuopt/routing/_serialize.pypython/cuopt/cuopt/tests/routing/test_serialize.py
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- to_host_problem: add parameter/return type hints and a full docstring (parameters, returns, KeyError behavior). - Guard the 1:1 set_* fallback: a multi-argument set_* with no handler now raises instead of silently dropping its extra arguments; add a regression test for that path. - Strengthen the export tests to assert the complete structures (matrix dtype/vehicle_type, both time-window arrays, capacity demand+capacity, and every field of both vehicle breaks including locations). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
CI Test Summary✅ All 22 test job(s) passed. |
ramakrishnap-nv
commented
Jul 20, 2026
/merge |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Adds
to_host_problem(dm): exports a recorded routing problem (the store-then-build IR from #1556) to host numpy arrays keyed by theRoutingProblemfields, copying any device (cuDF) inputs to host. This is the client-side foundation for serializing a routing problem over gRPC.Validated by a round-trip against the VRP
RoutingProblemproto; full routing suite passes.🤖 Generated with Claude Code