Generate the routing gRPC field mapping from a single source of truth

未关闭
#1,730 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@ramakrishnap-nv 已经在做这个了。

开始于 2026年8月14日。

评估

这个 Issue 还没有评估数据。

描述

improvement

Follow-up to review feedback from @rg20 on #1597 (mapper, to_device, round-trip test).

Problem

Adding one field to cpu_routing_problem_t today means editing five places by hand:

  1. the struct — cpp/include/cuopt/routing/cpu_routing_problem.hpp
  2. the wire format — cpp/src/grpc/routing/cuopt_routing.proto
  3. host → proto — map_routing_problem_to_proto
  4. proto → host — map_proto_to_routing_problem
  5. host → device — cpu_routing_problem_t::to_device

Nothing enforces that all five stay in sync. Not the compiler, not a test.

The failure mode is worse than the usual boilerplate complaint. A forgotten field
does not crash — the value silently never crosses the wire, and the remote solve
returns a plausible answer for a different problem than the one submitted.
That is expensive to detect and easy to miss in review.

Scale: cpu_routing_problem_t currently has 41 std::vector members, 6
std::map members, and 5 nested struct types. Roughly 80% of that is one
regular pattern repeated 41 times.

Suggested direction

Both review threads share a single root cause — the field list is written out
five times — so it is worth fixing once rather than twice.

Single source of truth for the routing field list, expanded into the proto,
both mapper directions, to_device, and a round-trip test. Either:

  • a routing section in cpp/src/grpc/codegen/field_registry.yaml, reusing
    generate_conversions.py (which already emits 27 .inc files and supports
    repeated_messages), or
  • an X-macro field-list header, which is less machinery and also covers
    to_device, which is outside the gRPC codegen's remit.

Caveat worth designing around: routing is less regular than LP. The 6 maps carry
real semantics — order_service_times is keyed by vehicle id with -1 meaning
"all vehicles", vehicle_breaks maps to a vector of structs. Expect ~80%
generated plus a tail of hand-written special cases, not a pure win.

Cheaper first step

A round-trip property test — populate every field with distinct values, go
host → proto → host, compare — catches the same class of bug for a fraction of
the effort and does not restructure anything. Worth doing first, and worth
keeping even after codegen lands.

Prior art in-tree: python/cuopt/cuopt/tests/routing/test_routing_grpc_serialization.py
already fails loudly when a new cuopt.routing._deferred._SETTERS entry is
unmapped. That guards the Python DataModel → cpu_routing_problem_t direction;
this issue is about the remaining C++ hops.

Not blocking #1597

#1597 is approved with these threads open, so this is design follow-up rather
than a merge blocker.

主要语言
Cuda
星标
1.1k
派生
255
平均合并
1 天 22 小时
30 天内合并 PR
102

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/cuopt 的其他 Issue

查看 NVIDIA/cuopt 的全部 Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。