Skip to content

Fix NERO crashing when CUDA is available - #660

Merged
Demirrr merged 1 commit into
developfrom
fix/nero-device-mismatch
Oct 23, 2026
Merged

Demirrr merged 1 commit into
developfrom
fix/nero-device-mismatch

Conversation

@Demirrr

@Demirrr Demirrr commented Oct 23, 2026

Copy link
Copy Markdown
Member

Found while testing #658: on a machine with a GPU, 6 of the 7 tests/test_nero_simple.py tests failed on unmodified develop with RuntimeError: Expected all tensors to be on the same device, but got index is on cpu, different from other tensors on cuda:0. CI has no GPU, so it never showed up.

  • The model is moved to self.device for training, but 8 places built the index tensors as torch.LongTensor([[...]]) on the CPU (search, fit, fit_from_iterable, the two embedding getters). They now use a new NERO._index_tensor that creates them on self.device.
  • The public forward moves its inputs to self.device.
  • sort_idxs.detach().numpy() (3 places) would have raised TypeError on a CUDA tensor right after the first fix; now .detach().cpu().numpy().
  • Regression test that runs on CPU-only CI: it gives the learner a meta device and checks that the index tensors follow it. It fails if the CPU is hard-coded again.

Local: test_nero_simple 8 passed with CUDA available and 8 passed with CUDA_VISIBLE_DEVICES=""; ruff clean.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Demirrr
Demirrr merged commit e793d09 into develop Oct 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant