Code Monkey home page Code Monkey logo

llama2.zig's People

Contributors

clebert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

llama2.zig's Issues

Running with -t 0 error

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.

Vector widths in matmul code and data dependencies

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);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.