deepmodeling / deepmodeling/unimol_tools
[Code scan] Respect CPU fallback before moving pretraining models to CUDA
- Dominant language
- Python
- Stars
- 34
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
This issue is a result of a Codex global repository scan.
## Summary
The non-DDP pretraining trainer calls self.model.cuda() unconditionally, then later checks whether CUDA is available and disables fp16. On CPU-only machines the trainer fails during construction before the fallback check can run.
## Code references
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_tools/pretrain/trainer.py#L44-L67
https://github.com/deepmodeling/unimol_tools/blob/4596596aa8f73eb462d5cc5a921d79966d0465da/unimol_tools/pretrain/trainer.py#L164-L174
## Impact
Pretraining cannot run or be smoke-tested on CPU-only environments despite having later logic intended to disable fp16 when CUDA is unavailable.
## Suggested fix
Choose self.device first, disable fp16 before moving modules, and use model.to(self.device) and loss_fn.to(self.device) instead of unconditional .cuda() calls.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with unimol_tools/pretrain/trainer.py at the referenced lines 44-67 and 164-174, tracing device selection and the CPU fallback during trainer construction. Verify the trainer can initialize on a CPU-only machine, disables fp16 before device transfers, and places the model and loss function on the selected device; confirm this with a CPU-only pretraining smoke test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100