mirror of
https://github.com/hanzoai/ml.git
synced 2026-11-20 22:24:53 +00:00
Three-way per file through the rename: base 39355c6c91, theirs the upstream
merge of main with 35d7ae7c (via 7ef6a694d), ours origin/main.
Lands the barrier thread pool, runtime CPU feature dispatch, aarch64 and x86
repacked quantized kernels (indexed_gemv, gemv_fused_shared_lhs), quantized
embedding on CPU/Metal/CUDA, paged flash-attn kernels, cutile fused MoE, the
in-place op aliasing API, parking_lot storage locks, Metal buffer builders and
debug labels, safetensors 0.8, hf-hub 1.0, tokenizers 0.23.
Ours keeps ROCm, Vulkan, wgpu, the IQ/MXFP4/NVFP4/TQ dtypes, and the i-quant
weight/activation block split in matmul. Our backends ride InplaceOpN and the
quantized embedding; Metal get_rows gains the IQ kernels. ug leaves, as upstream.
Co-authored-by: Hanzo Dev <[email protected]>
hanzo-ml-llava
LLaVA (Large Language-and-Vision Assistant) is an end-to-end trained large multimodal model. This example is from hanzo-ml-llava
The code is based on https://github.com/haotian-liu/LLaVA, Hence the llava-hf version of config may perform differently.
model zoo
Right now this has been tested on liuhaotian/llava-v1.6-vicuna-7b and
llava-hf/llava-v1.6-vicuna-7b-hf. Memory usage might have room for optimization.
Tokenizer Setup
The llava-hf models contain a tokenizer.json file so can be used directly with
the -hf command line flag.
For the original llava models, you can use the following code to generate the tokenizer.json file.
conda create -n llava python=3.10
pip install transformers protobuf
conda activate llava
python -c "from transformers import AutoTokenizer;tokenizer=AutoTokenizer.from_pretrained('liuhaotian/llava-v1.6-vicuna-7b');tokenizer.save_pretrained('tokenizer')"
Then the tokenizer.json file should be in tokenizer/tokenizer.json (which is the default path).
eval
cargo run --example llava --features cuda -- --image-file "llava_logo.png" --prompt "is this a cat?" --hf # default args, use llava-hf/llava-v1.6-vicuna-7b-hf. image-file is required^_^
cargo run --example llava --features cuda -- --model-path liuhaotian/llava-v1.6-vicuna-7b --image-file "llava_logo.png" --prompt "is this a cat?" # use liuhaotian/llava-v1.6-vicuna-7b, tokenizer setup should be done
Major Limitations
- Currently only support llama-2/vicuna llm. Haven't supoort Mistral yet.
- There are some ops like split, nonzero and where are not supported by hanzo.
- Lack of quantization and LoRA support.