Views
No views yet
fn attention_f16(q: Tensor<f32, [D]>,
key_cache: Tensor<f16, [L, SeqLen, KvDim]>,
value_cache: Tensor<f16, [L, SeqLen, KvDim]>,
layer: i32, pos: i32, H: i32, scale: f32) -> Tensor<f32, [D]>
with tile=[8, 64], parallel=[h, t] {
var att: Tensor<f32, [H, SeqLen]> = zeros([H, SeqLen])
# Compute attention scores
att[h, t] = if t > pos { -inf } else {
sum(i) q[h * Dh + i] * (key_cache[layer, t, h * Dh + i] as f32) * scale
}
var weights: Tensor<f32, [H, SeqLen]> = softmax(att)
# ... weighted sum over values
}| Model | Parameters | Format | Description |
|---|---|---|---|
llama2_7b_f16.safetensors | 7B | FP16 | Llama2-7B |
qwen2.5_coder_0.5b_bf16.safetensors | 0.5B | BF16 | Qwen2.5-Coder-0.5B-Instruct |
1# Clone TensaLang
2git clone https://github.com/BenChaliah/Tensa-Lang.git
3cd Tensa-Lang && ./build.sh
4
5# Download models
6huggingface-cli download BenChaliah/TensaLang-models --local-dir ./models
7
8# Or download a specific model
9huggingface-cli download BenChaliah/TensaLang-models llama2_7b_f16.safetensors --local-dir ./Llama2-assets1./bin/tensalang-run examples/llama2_manual_tiling_fp16.tl \
2 --model Llama2-assets/llama2_7b_f16.safetensors \
3 --tokenizer Llama2-assets/tokenizer.json \
4 --prompt "Once upon a time" \
5 --target cuda \
6 --steps 128 \
7 --fused-attention 2 \
8 --cuda-arch sm_891./bin/tensalang-run examples/qwen25_coder_bf16.tl \
2 --model Qwen25-assets/qwen2.5_coder_0.5b_bf16.safetensors \
3 --tokenizer Qwen25-assets/tokenizer.json \
4 --prompt "def quicksort(arr):" \
5 --target cuda \
6 --steps 64 \
7 --cuda-arch sm_89