Giter VIP home page Giter VIP logo

torchfix's People

Contributors

amyreese avatar clee2000 avatar francescaaa avatar gesuwen avatar izaitsevfb avatar kit1980 avatar malfet avatar pmeier avatar seemethere avatar soulitzer avatar zainrizvi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

torchfix's Issues

[New Rule Request] Torchfix should issue a warning when a torch.nn.Module stores its layers in a python list instead of a torch.nn.ModuleList

Inside a model definition, the torch.nn.Module objects inside a Python list do not get their parameters registered. Hence such parameters do not get trained by the optimizer, even though they are in the call graph formed by forward(). This should be flagged by torchfix -- currently no warning is given for this issue.

Example:

class FeedForward(torch.nn.Module):
    def __init__(self, n_features, n_classes, n_hidden, width):
        super().__init__()

        # Ideally, torchfix should issue a warning on below code
        # The parameters of the hidden layers do not get registered if they are in a list, and are not optimized!
        self.hidden_layers = [torch.nn.Linear(n_features if i ==0 else width,  width, bias=True) for i in range(n_hidden)]

        # Correct version of the above code -- use ModuleList([]) instead of python list []
        self.hidden_layers = torch.nn.ModuleList([torch.nn.Linear(n_features if i ==0 else width,  width, bias=True) for i in range(n_hidden)])

        # Dummy call to torch.solve() to throw a torchfix warning (to demonstrate that torchfix is working correctly)
        torch.solve()

Torchfix output:

$ torchfix --select=ALL ./supervised/nn/feed_forward_nn.py 
supervised/nn/feed_forward_nn.py:20:9: TOR001 Use of removed function torch.solve: https://github.com/pytorch-labs/torchfix#torchsolve
Finished checking 1 files.

Avoid running TOR003 by default

Today, use_reentrant defaults to True, but TOR003 sets use_reentrant=False which may subtly differ in behavior in certain cases. We should either make TOR003 set use_reentrant=True, or not run it by default.

cc @kit1980

Apply TOR901 only to files in test dir

See pytorch/pytorch#125050 for details.

This will require passing file path as an input to the rules.
In general it doesn't make too much sense, but for PyTorch-internal rule like TOR901 where we know the path in the CI this will allow to remove long enumerations of files to ignore from .flake8

Feature needed: configuration for which PyTorch version to target

Currently TorchFix tries to follow latest PyTorch main for things like deprecated APIs.
This is not ideal for people who want to use a specific release, for example.

So every rule should be annotated for which PyTorch (and also TorchVision and other libraries where applicable) version it applies, and there should be a configuration parameter for TorchFix to pass the version.

Feature needed: TorchFix should understand statically types types

TorchFix should understand statically types of the objects. This feature will enable more rules and more precise targeting for the existing rules. The implementation will require adoption of Pyre and LibCST’s TypeInferenceProvider. The feature will likely be optional as running Pyre may be a barrier for some users.

As an example, currently TorchFix will understand that this qr is a deprecated function here:

import torch
torch.tensor([[1.0], [2.0]])
torch.qr(a)

But not when using method notation - a.qr() - because TorchFix doesn't understand statically that a is a PyTorch tensor, maybe it's some unrelated object that just happens to have a method named qr.

Rule for deprecated `torch.backends.cuda.sdp_kernel()`

/home/runner/work/_tool/Python/3.11.9/x64/lib/python3.11/site-packages/torch/backends/cuda/init.py:342: FutureWarning: torch.backends.cuda.sdp_kernel() is deprecated. In the future, this context manager will be removed. Please see, torch.nn.attention.sdpa_kernel() for the new context manager, with updated signature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.