Comments (1)
Hi, we have not observed this instability in practice and the workaround that we used before was an overkill but I left the comment just in case.
The instability I am talking about is the following (excuse the relatively unreadable pseudocode):
Q = ...
K = ...
QK = Q K^T # arbitrarily large but probably no overflow
A = QK / QK.sum(-1) # now we sum a possibly large number of arbitrarily large numbers possible overflow
A = (QK / 100) / (QK / 100).sum(-1) # less chances of overflow
# And the following has no chances of overflow because it ensures that all numbers in QK are less than 1
M = max(Q.norm(), K.norm())
Q /= M
K /= M
QK = Q K^T
A = QK / QK.sum(-1)
I hope it is clearer. If not feel free to reopen the bug report.
Cheers,
Angelos
from fast-transformers.
Related Issues (20)
- how causal mask constructed in training batch model with linear causal attention?
- Runtime error on causal_product_cpu on GCC/G++ 11 HOT 3
- Casual attention is cheating by looking in the future HOT 1
- Installing error on linux HOT 4
- Any decoder example? HOT 1
- Can't officially save Linear Attention model HOT 2
- can offer built code for linus?
- Speed of recurrent model HOT 2
- Cuda version HOT 1
- Example for NLP
- Understanding how to define key, query and value for the cross attention calculation
- Detailed implementation of `clustered_sparse_dot_product`
- Windows installation - building wheel error HOT 27
- Got different result for the same batch HOT 1
- Error about `causal_product_cpu.cpython-38-darwin.so` on Mac HOT 2
- `.causal_product_cuda` missing in pip installed version on linux HOT 4
- Provenance of algorithms
- ImportError HOT 1
- ERROR: Could not build wheels for pytorch-fast-transformers, which is required to install pyproject.toml-based projects HOT 10
- [WinError 2] The system cannot find the file specified: build_ext 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 fast-transformers.