Skip to content

Commit 33cf0a4

Browse files
author
Han Wang
committed
test(pt_expt): keep the DPA4 dense-branch eager reference on CPU
_make_sample_inputs builds tensors on _env.DEVICE, so on a CUDA box the CPU eager model received CUDA tensors (index_select device mismatch). Make explicit CPU copies for the eager reference; the artifact call keeps its separate _env.DEVICE copies, mirroring the graph branch.
1 parent b6c3c37 commit 33cf0a4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

source/tests/pt_expt/model/test_dpa4_export.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,14 @@ def test_dpa4_freeze_to_pt2(tmp_path, lower_kind, expected_input_kind) -> None:
176176
if expected_input_kind == "nlist":
177177
# 4a. Dense-ABI eager reference vs. AOTI artifact parity on
178178
# forward_common_lower.
179+
# _make_sample_inputs creates tensors on _env.DEVICE (CUDA on a GPU
180+
# box); the eager reference model lives on CPU, so make explicit CPU
181+
# copies for it. The artifact call below gets separate _env.DEVICE
182+
# copies via _to_artifact_device.
179183
sample = _make_sample_inputs(model, nframes=1, has_spin=False)
180-
ext_coord, ext_atype, nlist_t, mapping_t, fparam, aparam, charge_spin = sample
184+
ext_coord, ext_atype, nlist_t, mapping_t, fparam, aparam, charge_spin = tuple(
185+
t if t is None else t.to("cpu") for t in sample
186+
)
181187

182188
eager_out = model.forward_common_lower(
183189
ext_coord.detach().requires_grad_(True),

0 commit comments

Comments
 (0)