Comments (3)
interesting. @datastream recommend submitting this issue/fix to llama2.c too
from llama2.go.
fixed. thanks @datastream 👍🏻
from llama2.go.
investigation notes
key_cache len: p->n_layers * p->seq_len * p->dim
if steps is too large
steps == seq_len
at the end of main loop
pos == steps - 1
(pos == seq_len - 1)
at the end of loop in transformer
t == pos (thus, t == seq_len - 1)
float* k = s->key_cache + loff + t * dim + h * head_size;
l == num_layers-1
loff == l * p->seq_len * dim
h == num_heads - 1
then loop up to head size + head_size.
---
thus k = (num_layers-1) * seq_len * dim + (seq_len-1) * dim + (num_heads-1) * head_size + (head_size - 1)
k = num_layers * seq_len * dim - seq_len * dim + seq_len * dim - dim + num_heads * head_size - head_size + head_size - 1
k = num_layers * seq_len * dim - dim + num_heads * head_size - 1
k = num_layers * seq_len * dim - dim + num_heads * dim / num_heads - 1
k = num_layers * seq_len * dim - 1
max_k index = num_layers * seq_len * dim - 1
dim = 768
num_heads = 12
head_size = dim / num_heads
---
thus official run.c code is correct and does not breach array size.
from llama2.go.
Related Issues (8)
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 llama2.go.