jmorganca 48de4b56c8 cleanup 8 tháng trước cách đây
..
example 8ef58a6695 fix `example` 9 tháng trước cách đây
ggml-cuda 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
patches 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
runner 48de4b56c8 cleanup 8 tháng trước cách đây
.gitignore 5152a430f5 Prefix all build artifacts with an OS/ARCH dir 9 tháng trước cách đây
Makefile 46c5f5fd9e Runtime selection of new or old runners 9 tháng trước cách đây
README.md 8931724a7a add note in readme 9 tháng trước cách đây
base64.hpp 87833dd606 sync 9 tháng trước cách đây
build-info.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
clip.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
clip.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
common.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
common.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-aarch64.c 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-aarch64.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-alloc.c 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-alloc.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-backend-impl.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-backend.c 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-backend.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-common.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-cuda.cu 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-cuda.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-impl.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-metal-darwin_arm64.m 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-metal.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-metal.metal 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-quants.c 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml-quants.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml.c 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
ggml.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
grammar-parser.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
grammar-parser.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
json-schema-to-grammar.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
json-schema-to-grammar.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
json.hpp 87833dd606 sync 9 tháng trước cách đây
llama-grammar.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama-grammar.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama-impl.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama-sampling.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama-sampling.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama-vocab.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama-vocab.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama.go cd776e49ad llama: wip vision support for `runner` 8 tháng trước cách đây
llama.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama_darwin.c 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llama_darwin.go 7ad4c5334e clean up metal code 9 tháng trước cách đây
llama_test.go b767f6554c wip meta 9 tháng trước cách đây
llava.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
llava.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
log.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
sampling.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
sampling.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
sampling_ext.cpp 834aac8450 llama: sync 9 tháng trước cách đây
sampling_ext.h 834aac8450 llama: sync 9 tháng trước cách đây
sgemm.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
sgemm.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
stb_image.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
sync.sh 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
unicode-data.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
unicode-data.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
unicode.cpp 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây
unicode.h 41bf8d9932 Update sync with latest llama.cpp layout, and run against b3485 9 tháng trước cách đây

README.md

llama

Note: this package is not used in Ollama yet. For now, see the llm package.

This package integrates the llama.cpp library as a Go package and makes it easy to build it with tags for different CPU and GPU processors.

Supported:

  • CPU
  • avx, avx2
  • macOS Metal
  • Windows CUDA
  • Windows ROCm
  • Linux CUDA
  • Linux ROCm
  • Llava

Extra build steps are required for CUDA and ROCm on Windows since nvcc and hipcc both require using msvc as the host compiler. For these shared libraries are created:

  • ggml_cuda.dll on Windows or ggml_cuda.so on Linux
  • ggml_hipblas.dll on Windows or ggml_hipblas.so on Linux

Note: it's important that memory is allocated and freed by the same compiler (e.g. entirely by code compiled with msvc or mingw). Issues from this should be rare, but there are some places where pointers are returned by the CUDA or HIP runtimes and freed elsewhere, causing a a crash. In a future change the same runtime should be used in both cases to avoid crashes.

Building

go build .

AVX

go build -tags avx .

AVX2

# go doesn't recognize `-mfma` as a valid compiler flag
# see https://github.com/golang/go/issues/17895
go env -w "CGO_CFLAGS_ALLOW=-mfma|-mf16c"
go env -w "CGO_CXXFLAGS_ALLOW=-mfma|-mf16c"
go build -tags=avx,avx2 .

Linux

CUDA

Install the CUDA toolkit v11.3.1:

make ggml_cuda.so
go build -tags avx,cuda .

ROCm

Install the CUDA toolkit v11.3.1:

make ggml_hipblas.so
go build -tags avx,rocm .

Windows

Download w64devkit for a simple MinGW development environment.

CUDA

Install the CUDA toolkit v11.3.1 then build the cuda code:

make ggml_cuda.dll
go build -tags avx,cuda .

ROCm

Install ROCm 5.7.1.

make ggml_hipblas.dll
go build -tags avx,rocm .

Building runners

# build all runners for this platform
make -j

Syncing with llama.cpp

To update this package to the latest llama.cpp code, use the sync.sh script:

./sync.sh ../../llama.cpp