mirror of
https://github.com/NandhaKishorM/laya.git
synced 2026-09-28 07:52:57 +08:00
Follow-up to #9 (@sirgio03), whose diagnosis of issue #6 was right: a silent CPU fallback is a real trap and deserves an actionable message. Two corrections to how it detects that case. The condition inferred a fallback from the environment -- cpu and (torch.cuda.is_available() or torch.version.cuda is not None) -- which is true whenever torch was built against CUDA, including when the caller deliberately passed device="cpu". Our own demo Space loads that way and would have printed a six-line notice telling the user to reinstall PyTorch on every boot. Track whether the fallback happened instead. It also dropped the one line that reported the underlying exception, replacing a real reason with a guess about CUDA architecture. That guess is right for a Blackwell card and misleading for an OOM or a driver mismatch; the message now carries both the reason and the advice. Also avoids adding an unconditional torch.cuda.is_available() call to every Agent construction -- touching CUDA early is what broke ZeroGPU in the demo Space, so it is not worth doing for a warning we can emit without it. tests/test_criteria.py: 5 regression tests (29 -> 34). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>