Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Error when using vmap to compute per-sample-gradient #105

@YiteWang

Description

@YiteWang

Hi,
When I used vmap to compute per-sample-gradient for the network with following lines which use part of the features as output:
x = x[:,:,::2,::2]
or
y = self.convs(y[:, :, 1:, 1:])

I have encountered the following error:
RuntimeError: vmap: aten::copy_(self, *extra_args) is not possible because there exists a Tensor 'other' in extra_args that has more elements than 'self'. This happened due to 'other' being vmapped over but 'self' not being vmapped over. Please try to use out-of-place operators instead of aten::copy_. If said operator is being called inside the PyTorch framework, please file a bug report instead.

I am wondering if functorch can support such operations.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions