Skip to content

Fix autograd engine checks #65016

@ezyang

Description

@ezyang

When you accumulate gradient into a tensor with a custom tensor subclass that doesn't match the base tensor (e.g., think sparse gradients), we will fail you:

RuntimeError: Function AddBackward0 returned an invalid gradient at index 0 - expected type TensorOptions(dtype=float, device=meta, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt)) but got TensorOptions(dtype=float, device=cpu, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt))

This issue is to relax the checks.

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @albanD @gqchen @pearu @nikitaved @soulitzer @lezcano @Varal7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions