Live data from Hacker News

Run Llama locally with only PyTorch on CPU

github.com

21–30 of 35 posts

Re: Run Llama locally with only PyTorch on CPU

#21

If your goal is > I want to peel back the layers of the onion and other gluey-mess to gain insight into these models. Then this is great. If your goal is > Run and explore Llama models locally with minimal dependencies on CPU then I recommend https://github.com/Mozilla-Ocho/llamafile which ships as a single file with no dependencies and runs on CPU with great performance. Like, such great performance that I've mostly…

How great is the performance? Tokens/s?

Re: Run Llama locally with only PyTorch on CPU

#22
post #12
post #11

Earlier quoted context omitted.

Can it use GPU if available, say on Apple silicon Macs

> GPU on MacOS ARM64 is supported by compiling a small module using the Xcode Command Line Tools, which need to be installed. This is a one time cost that happens the first time you run your llamafile.

I wonder if it's possible for llamafile to distribute without the need for Xcode Command Line Tools, but perhaps it's necessary for the single cross-platform binary.

Loved llamafile and used it to build the first version of https://recurse.chat/, but live compilation using XCode Command Line Tool is a no-go for Mac App Store builds (runs in Mac App Sandbox). llama.cpp doesn't need compiling on user's machine fwiw.

Re: Run Llama locally with only PyTorch on CPU

#23
post #7

Earlier quoted context omitted.

Ollama is great if you're really in love with the idea of having your multi gigabyte models (likely the majority of your disk space) stored in obfuscated UUID filenames. Ollama also still hasn't addressed the license violations I reported to them back in March. https://github.com/ollama/ollama/issues/3185

I think this is also a problem in a lot of tools, that is never talked about. Even myself I’ve not thought about this so deeply, even though I am also very concerned about honoring other people’s work and that licenses are followed. I have some command line tools for example that I’ve written in Rust that depend on various libraries. But because I distribute my software in source form mostly, I haven’t really paid at…

It's really something that should be abstracted by the linker. Codebases like zlib for example will just put a `const char notice[] = "Copyright Adler et al";` in one of their files so the license issue with zlib is solved simply by using zlib. However modern linkers have gotten so good that -fdata-sections -Wl,--gc-sections will strip that away and probably LTO too. In Cosmopolitan Libc I used to use the GNU assembler `.ident` directive in an asm() tag at the tops of .c files to automate license compliance. But some changes to ld.bfd ended up breaking that. Now I have to use these custom defines like https://github.com/jart/cosmopolitan/blob/706cb6631021bbe7b1... and https://github.com/jart/cosmopolitan/blob/706cb6631021bbe7b1... and https://github.com/jart/cosmopolitan/blob/706cb6631021bbe7b1... to get the job done. It really should be a language feature so that library authors can make it as simple as possible for users to comply with their license. I just don't think I've ever seen anyone think about it this way except for maybe Google's JavaScript minifiers, which is where I got the idea.

Re: Run Llama locally with only PyTorch on CPU

#24
post #21

If your goal is > I want to peel back the layers of the onion and other gluey-mess to gain insight into these models. Then this is great. If your goal is > Run and explore Llama models locally with minimal dependencies on CPU then I recommend https://github.com/Mozilla-Ocho/llamafile which ships as a single file with no dependencies and runs on CPU with great performance. Like, such great performance that I've mostly…

How great is the performance? Tokens/s?

Random sample query ("What shape should a kumquat be?") against a 7B model quantised to 4b running on an i7-9750H (so a good CPU, but also a good laptop CPU from 2019) gives:

  148 tokens predicted, 159 ms per token, 6.27 tokens per second

Re: Run Llama locally with only PyTorch on CPU

#25
post #21

Earlier quoted context omitted.

How great is the performance? Tokens/s?

Random sample query ("What shape should a kumquat be?") against a 7B model quantised to 4b running on an i7-9750H (so a good CPU, but also a good laptop CPU from 2019) gives: 148 tokens predicted, 159 ms per token, 6.27 tokens per second

Thanks, that helps.

Re: Run Llama locally with only PyTorch on CPU

#26

If your goal is > I want to peel back the layers of the onion and other gluey-mess to gain insight into these models. Then this is great. If your goal is > Run and explore Llama models locally with minimal dependencies on CPU then I recommend https://github.com/Mozilla-Ocho/llamafile which ships as a single file with no dependencies and runs on CPU with great performance. Like, such great performance that I've mostly…

Thanks for posting this!

Very happy to have helped:)

Re: Run Llama locally with only PyTorch on CPU

#27

If your goal is > I want to peel back the layers of the onion and other gluey-mess to gain insight into these models. Then this is great. If your goal is > Run and explore Llama models locally with minimal dependencies on CPU then I recommend https://github.com/Mozilla-Ocho/llamafile which ships as a single file with no dependencies and runs on CPU with great performance. Like, such great performance that I've mostly…

Thanks for the suggestion. I've added a link to llamafile in the repo's README. Though, my focus was on exploring the model itself.

Re: Run Llama locally with only PyTorch on CPU

#30
post #7
post #4

Earlier quoted context omitted.

Ollama (also wrapping llama.cpp) has GPU support, unless you're really in love with the idea of bundling weights into the inference executable probably a better choice for most people.

Ollama is great if you're really in love with the idea of having your multi gigabyte models (likely the majority of your disk space) stored in obfuscated UUID filenames. Ollama also still hasn't addressed the license violations I reported to them back in March. https://github.com/ollama/ollama/issues/3185

Llamafile is great if you don't want to run any meaningful models because it's limited to 4GB.
Post reply on HN