Skip to content

Breaking compatibility with custom datatypes implementing .to #2314

@digitalillusions

Description

@digitalillusions

🚀 Feature

Bring back compatibility for custom datatypes in collections implementing .to for transferring data.

Motivation

I am using Pytorch Lightning together with Pytorch Geometric. Pytorch Geometric implements several custom datatypes and dataloaders which is really useful for geometric deep learning. Everything worked well with pytorch lightning 0.7.6, as the custom datatypes implement a .to method for transferring the data to different devices.
However, with the recent 0.8.1 update, this is no longer possible and I had to scour the documentation to be able to implement a fix using transfer_batch_to_device(batch, device). This is in my opinion not very pretty, as my batch looks like this

{"data": pytorch geometric batch object, "id": tensor, ...}

i.e. it is just a dictionary of types that all implement the .to method.

Pitch

  • Make it possible for classes implementing the .to method to be transferred automatically
  • If part of the batch could not be transferred automatically output a warning letting the user know, that a custom transfer function for the batch might be required, or to implement the .to method for custom datatypes in the batch
  • Add a note to the introduction guide about custom datatypes and handling for custom datatypes

Alternatives

If this change was intentional and the behavior of trying to call the .to method is not desired, I think there should definitely be some more documentation about this, in a more obvious place.

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions