Skip to content

Commit d31ef64

Browse files
committed
fix: convert boolean PBC to tensor for System constructor
TorchSim's SimState.pbc is a boolean, but metatomic's System constructor expects a Tensor. Convert the boolean to a 3-element boolean tensor.
1 parent bc878e8 commit d31ef64

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

PR-167-REVIEW-RESPONSES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,20 @@ Move the TorchSim model integration upstream from the TorchSim repository into m
2626
| 12 | Add support for output variants | ✅ DONE | Added `variants` parameter and `pick_output()` usage in both initialization and energy check |
2727
| 13 | Extended model outputs API | ⏭️ DEFERRED | Waiting for TorchSim property calculator API to stabilize |
2828

29+
## CI Fixes
30+
31+
### PBC Tensor Conversion (6241b33)
32+
Fixed TorchSim integration tests failing with:
33+
```
34+
RuntimeError: __init__() Expected a value of type 'Tensor' for argument 'pbc' but instead found type 'bool'.
35+
```
36+
37+
**Fix:** Convert `state.pbc` (boolean) to a 3-element boolean tensor before passing to `System()` constructor.
38+
2939
## Final Commit
3040

3141
```
32-
b82a9c0 feat: add metatomic-torchsim package for TorchSim integration (Rohit Goswami)
42+
80e1b9c fix: convert boolean PBC to tensor for System constructor (Rohit Goswami)
3343
```
3444

3545
### Author Attribution:

python/metatomic_torchsim/metatomic_torchsim/_model.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,19 @@ def forward(self, state: "ts.SimState") -> Dict[str, torch.Tensor]:
240240
sys_cell = sys_cell @ strain
241241
strains.append(strain)
242242

243+
# Convert boolean PBC to tensor (System expects Tensor, not bool)
244+
pbc_tensor = torch.tensor(
245+
[state.pbc, state.pbc, state.pbc],
246+
device=self._device,
247+
dtype=torch.bool,
248+
)
249+
243250
systems.append(
244251
System(
245252
positions=sys_positions,
246253
types=sys_types,
247254
cell=sys_cell,
248-
pbc=state.pbc,
255+
pbc=pbc_tensor,
249256
)
250257
)
251258

0 commit comments

Comments
 (0)