EvanOLeary/laguna-xs2-dense-k8-cuda-sft-int8
019
Laguna-XS.2 → Dense (K=8) · CUDA-SFT · torchao Int8 weight-only
Quantized variant of `EvanOLeary/laguna-xs2-dense-k8-cuda-sft`. Pure-PyTorch int8 weight-only quantization via torchao. Bf16 activations / compute, int8 storage. Quantization is lossless on greedy decode for the ReLU smoke prompt (byte-identical to bf16).
Size & quality
ReLU CUDA kernel smoke test (greedy decode, 400 maxnewtokens)
Quantization is functionally lossless on this prompt — int8 output is byte-identical to bf16 (1046 chars, 303 tokens, both greedy).
Prompt: "Write a CUDA kernel that computes ReLU (max(x, 0)) on a float array in-place. Include the kernel and a host-side launcher."
The model produced a complete torch::extension-style CUDA kernel with templated relu_kernel, AT_DISPATCH_FLOATING_TYPES dispatch, a relu_forward host launcher, and a PYBIND11_MODULE entrypoint suitable for torch.utils.cpp_extension.load_inline.
How to load
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "EvanOLeary/laguna-xs2-dense-k8-cuda-sft-int8"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True,
dtype=torch.bfloat16, device_map="cuda")
# torchao quant is baked into the saved weights — no further setup needed.
msgs = [{"role":"user","content":"Write a CUDA kernel for elementwise sigmoid on a float array."}]
text = tok.apply_chat_template(msgs, add_generation_prompt=True, tokenize=False)
ids = tok(text, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
out = model.generate(ids, max_new_tokens=400, do_sample=False, pad_token_id=tok.pad_token_id)
print(tok.decode(out[0][ids.shape[-1]:], skip_special_tokens=True))Provenance & roadmap
Quantization details
- Library: torchao 0.17.0
Int8WeightOnlyConfig - Scheme: symmetric per-channel int8 weight quantization, bf16 activations & computation
- Calibration: none (PTQ on weights only)
- Quantize time: 0.4 s after model load
- Verification: bf16 vs int8 produce byte-identical 1046-char output on the ReLU prompt (greedy decode)
- Inference cost: dequantize-on-the-fly to bf16 per matmul → ~1.34× slower wall-clock than bf16 on A100 (14.8 → 9.8 tok/s).
torch.compileshould close this gap.
