clebert / llama2.zig Goto Github PK
View Code? Open in Web Editor NEWInference Llama 2 in pure Zig
License: MIT License
Inference Llama 2 in pure Zig
License: MIT License
Running with just checkpoint and -t 0 procudes
❯ zig-out/bin/llama2 stories15M.bin -t 0
Error: To control the diversity of samples use either the temperat
ure or the top-p value, but not both.
Usage: llama2 <checkpoint_path> [options]
Options:
-t <float> temperature = 1
-p <float> top_p = 0.9; 0 == off
-s <int> random_seed = milli_timestamp
-n <int> n_steps = 256; 0 == max_seq_len
-i <string> input_prompt = ""
Example: llama2 model.bin -i "Once upon a time"
Also I dont think there is anything wrong with using temperature and top p together.
I think the vector widths you are using are too large. 32x4 is 128 bytes or 1024 bits which is much larger than the width of any vector type that is on cpus today.
std.simd.suggestVectorSize(f32)
will return the current cpus maximum vector size for a given type. I think seeing an improvement by making it larger means something else is going on that is not related.
Also there is performance to be had from reworking your summing by using a vector of sums. Currently the CPU struggles to optimize because of a data dependency as each sum needs to depend on the previous lanes value. If you instead keep N sums and then reduce them at the end you should see a speedup.
var value: @Vector(v_len, f32) = @splat(0.0);
... loop
value += a * b;
...
xoutptr.* = @reduce(.Add, value);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.