Comments (4)
Does it work if you use vmap instead, by any chance
from pytorch.
I'm sorry but I don't know how to use vmap instead;
I tried to vmap the autograd call, but, as stated by https://pytorch.org/tutorials/intermediate/jacobians_hessians.html << We canβt directly apply vmap to torch.autograd.grad; instead, PyTorch provides a torch.func.vjp>>
But apparently torch.func.vjp
is designed to build the Jacobian but it runs the forward too.
Whereas my function is non deterministic, so I don't want to (re)run the forward to compute this autograd.grad.
Also, I tried both Cpu and Cuda,
BatchNorm and InstanceNorm work,
Only GroupNorm fails
from pytorch.
Is it possible to avoid running forward the first time? vjp returns both the forward output and the gradients.
from pytorch.
But apparently torch.func.vjp is designed to build the Jacobian but it runs the forward too.
Whereas my function is non deterministic, so I don't want to (re)run the forward to compute this autograd.grad.
You can use torch.func.vjp to run the forward once. It gives you a callable that can be used to run the backward. The idea is to vmap over said callable (this avoids re-running the forward).
from pytorch.
Related Issues (20)
- [ONNX] Create a new compiler in torchbench to start measuring torch-onnx
- Support for torch.Generator with JIT HOT 1
- DISABLED test_dummy_mha_with_nt_cuda (__main__.TestNestedTensorSubclassCUDA) HOT 1
- forward_ad ignores checkpoints
- `sort()` can use the 0D tensor of a `complex` type value against error message
- The unexpected behavior of `sort()` HOT 1
- (Refactor) Change default nonlinearity and bound calculation in kaiming_uniform_ & kaiming_normal_ and change kaiming_uniform call in reset_parameters in conv.py & linear.py to avoid sqrt(5) confusion (and maybe change numerical bound val in kaiming_uniform_ and numerical std val in kaiming_normal?)
- Incorrect index from torch.mode
- `python3 setup.py bdist_wheel` tries to write to /usr/local/... during build HOT 2
- PyTorch C++ API binary compiled with xmake crashes HOT 4
- [ExecutionTraceObserver] Tracer gets stuck using Pytorch 2.2 versions for some models using torch.compile
- [ONNX][low pri] Move old (non-public) implementation into legacy/ and schedule for deprecation
- `argsort()` can use the 0D tensor of a complex type value against error message HOT 1
- Upgrade dependencies MKL and Intel OpenMP to 2024.2.0 HOT 6
- The unexpected behavior of `argsort()`
- `msort()` can use the 0D tensor of a complex type value against error message HOT 1
- [TP+FSDP2] model weights become fully shard again after calling model.unshard() followed by dcp get_model_state_dict HOT 1
- `int` type for `dims` of `tile()` without `dims=` works with a tensor against the doc HOT 1
- `repeat_interleave()` without `repeats` argument and `input` keyword works HOT 1
- [export/dynamo] torch._check fails at compile time when the condition evaluates to False HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch.