Comments (6)
Hi @befelix , thank you for reporting, there is a circular import problem that we need to address.
step-by-step what happens in python -W "error" -c 'import einops; import torch._dynamo'
- einops is imported
- torch._dynamo is imported, it detects that einops is imported, and calls https://github.com/pytorch/pytorch/blob/88a71594933b2464d9d8b6b3533c5a945a4ac2ff/torch/_dynamo/decorators.py#L322
- ... which imports
from einops._torch_specific ...
- einops._torch_specific tries to register ops by using
allow_in_graph
, that is needs to import first from torch._dynamo. That's where we run in circular imports
from einops.
Seems this torch PR was trying to address the problem, but that didn't quite work:
https://github.com/pytorch/pytorch/pull/111835/files
Fix wouldn't work it seems: einops needs allow_in_graph
being importable, meaning that hook can only be called after _dynamo
was imported. Currently hook is called during the import.
from einops.
Should we delete the special einops handling from torch._dynamo
?
from einops.
it is preferrable to defer that logic to 'on first compile' (or when torch._dynamo is fully imported)
Otherwise, we better just delete that handling code - it wouldn't work as intended
from einops.
Can you check if this fixes it: pytorch/pytorch#124084
from einops.
Thank you @jansel for merging that. I can confirm nightly torch==2.4.0.dev20240420+cpu does not have this issue.
Before fix comes live users need to use manual registration of functions:
https://github.com/arogozhnikov/einops/wiki/Using-torch.compile-with-einops
from einops.
Related Issues (20)
- *** AttributeError: 'Rearrange' object has no attribute 'recipe'[BUG] HOT 1
- [BUG] batchsize of dataloading
- [BUG] error when import einops HOT 1
- [BUG] Einops repeat throws device error during torchscripting HOT 1
- [Feature suggestion] apple mlx support
- [Feature suggestion] Allow performing a view instead of a reshape HOT 3
- [BUG] einops.repeat returns value with type Never HOT 3
- Add support for keras3 HOT 2
- [Feature suggestion] fixup/support anonymous axes in `parse_shape` HOT 2
- [BUG] `einsum` with `ii->i` raises an unknow axis error. HOT 1
- [Feature suggestion] package downloaded from conda-forge seems missing some functions HOT 1
- Passing a float in `repeat` as a dimension size prevents correct usage afterwards HOT 2
- What am I doing wrong with repeat command? HOT 1
- Tests failing on FreeBSD HOT 3
- Alias ellipsis to a star for rearrange HOT 3
- [BUG] SyntaxError in Python 3.11 HOT 2
- [BUG] Basic code from documentation does not work HOT 1
- [Feature suggestion] Optionally return the inferred dimensions
- module 'einops' has no attribute 'layers' HOT 1
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 einops.