Skip to content

incorrect usage of detach/cpu/to #6214

@dvolgyes

Description

@dvolgyes

🐛 Bug

Incorrect use of detach() and cpu() during fixing #4592.

Please reproduce using the BoringModel

You cannot really.

To Reproduce

Use following BoringModel and post here

The fix for #4592 has good intentions but an obvious bug slipped through.

It is easy to understand but hard to test it, so let's rely on common sense:
That is the original code:

            if isinstance(output, Result):
                output.detach()
                if self.move_metrics_to_cpu:
                    output.cpu()

Expected behavior

And that supposed to be the correct code, obviously:

            if isinstance(output, Result):
                output = output.detach()
                if self.move_metrics_to_cpu:
                    output = output.cpu()

Environment

Any.

Additional context

I will make a trivial PR for this, I just wanted to create a ticket to actually track the issue.
In theory, the bug is general pattern, but in practice these two lines were the only ones affected in PL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedOpen to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions