Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Retiarii] Inconsistent usage of .to(device) and to_device() in one-shot NAS Trainers #3957

Closed
thomasschmied opened this issue Jul 19, 2021 · 2 comments
Assignees
Labels
external contributor NAS 2.0 issues and pull requests for Retiarii user raised

Comments

@thomasschmied
Copy link
Contributor

Describe the issue:

Hello!

While running one-shot NAS experiments on custom datasets, I encountered some inconsistencies in the usage of .to(device) and to_device().

EnasTrainer, on the one hand, uses the to_device() function from nni.retiarii.oneshot.pytorch.utils to transfer the tensor to the specified device. DartsTrainer and ProxylessTrainer, on the other hand, use the standard torch .to() function.

Using .to() is problematic, as the torch.utils.data.DataLoader instances might return batches that are not of type torch.Tensor and hence have no .to() method. The to_device function handles these cases.

Would it be possible to use to_device() across all Trainer classes?

Environment:

  • NNI version: 2.3
  • Python version: 3.8.8
  • PyTorch version: 1.9.0

Thank you,
Thomas

@ultmaster
Copy link
Contributor

As I said in #3956, we will probably handle the device issue with a more general framework like PyTorch-lightning. Before this refactor, we encourage you to change all .to() to to_device() in a PR. Thanks in advance.

@scarlett2018
Copy link
Member

closing the issue as the PR had been merged, thanks @thomasschmied for the support and contributions!

@scarlett2018 scarlett2018 added NAS 2.0 issues and pull requests for Retiarii and removed retiarii-v2.0 labels Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external contributor NAS 2.0 issues and pull requests for Retiarii user raised
Projects
None yet
Development

No branches or pull requests

3 participants