Skip to content

Commit 41d4f24

Browse files
Clarify in docs that the deferred layer records setter calls
Per review discussion: keep the "deferred" name but make the docstrings state plainly that the mechanism is call recording -- the class records the problem and defers building the device model, it does not build anything itself. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
1 parent f7a9846 commit 41d4f24

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

python/cuopt/cuopt/routing/_deferred.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
"""Store-then-build (deferred build) layer for the routing DataModel.
5-
6-
The public DataModel records its setter calls on the host and builds the device
7-
(Cython) model only transiently -- at solve, or when a getter is queried -- by
8-
replaying the recorded calls. Design points:
4+
"""Deferred-build layer for the routing DataModel: record setter calls, build on demand.
5+
6+
The public DataModel **records** each setter call on the host instead of applying
7+
it to the GPU immediately. The class does not build anything itself -- it stores
8+
the problem and defers construction of the device (Cython) model until it is
9+
actually needed (at solve, or when a getter is queried), at which point it builds
10+
transiently by replaying the recorded calls onto the wrapper. "Deferred" refers
11+
to that deferred build; the mechanism is call recording. Design points:
912
1013
* **Host-resident IR.** Host inputs (numpy/pandas) are copied to a numpy array
1114
the DataModel owns at record time, so the recorded calls form a serializable,

python/cuopt/cuopt/routing/vehicle_routing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class DataModel(_DeferredDataModel):
5151
host (numpy/pandas) inputs are copied to the device for the local
5252
solve. Python lists and tuples are not supported.
5353
54-
- Inputs are recorded and the device model is built lazily, so
55-
solver-side (C++) validation and dtype-cast warnings surface when the
56-
model is built -- at ``Solve`` -- rather than at the individual setter
54+
- Inputs are recorded and the device model is built on demand (deferred
55+
to ``Solve``), so solver-side (C++) validation and dtype-cast warnings
56+
surface when the model is built rather than at the individual setter
5757
call. Structural checks (matrix shape, array sizes, value ranges) are
5858
still validated eagerly at the setter.
5959

0 commit comments

Comments
 (0)