Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Request: detecting unnecessary torch.no_grad #97

Description

@jamesbraza

It would be nice for TorchFix to flag when no_grad is used both as a decorator and a context manager in the same function:

import torch

@torch.no_grad
def some_func():
    with torch.no_grad():  # Redundant to decorator
        ...

Same thing applies for torch.inference_mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions