ternary-models: VLMs, Multimodal & Audio
Collection
Ternary-quantized models for architectures GGUF can't handle. tritplane3 scheme. • 16 items • Updated • 2
How to use AsadIsmail/gemma-4-E4B-it-ternary with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-text-to-text", model="AsadIsmail/gemma-4-E4B-it-ternary") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("AsadIsmail/gemma-4-E4B-it-ternary", dtype="auto")How to use AsadIsmail/gemma-4-E4B-it-ternary with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "AsadIsmail/gemma-4-E4B-it-ternary"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AsadIsmail/gemma-4-E4B-it-ternary",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/AsadIsmail/gemma-4-E4B-it-ternary
How to use AsadIsmail/gemma-4-E4B-it-ternary with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "AsadIsmail/gemma-4-E4B-it-ternary" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AsadIsmail/gemma-4-E4B-it-ternary",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "AsadIsmail/gemma-4-E4B-it-ternary" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AsadIsmail/gemma-4-E4B-it-ternary",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use AsadIsmail/gemma-4-E4B-it-ternary with Docker Model Runner:
docker model run hf.co/AsadIsmail/gemma-4-E4B-it-ternary
Ternary-quantized version of google/gemma-4-E4B-it, produced with ternary-quant.
Gemma 4-E4B is Google's multimodal model that processes both images and text. This ternary-quantized version retains multimodal capabilities while reducing model size through a HuggingFace-native, component-aware PTQ workflow.
| Metric | Value |
|---|---|
| Scheme | tritplane3 (3-plane progressive ternary) |
| Components quantized | text_backbone, multimodal_connector (342 linear layers) |
| Vision encoder | Kept in FP16 (preserving image understanding quality) |
| Group size | 32 |
| Calibration iterations | 10 |
| Stored size | 4234 MB (~4.2 GB) |
| FP16 size | ~16 GB |
| Compression ratio | ~3.8x |
from ternary_quant.inference import load_ternary_model
# Load model (auto-detects best device: CUDA > MPS > CPU)
model, processor = load_ternary_model(
"AsadIsmail/gemma-4-E4B-it-ternary",
runtime_mode="metal" # Use "cached" for NVIDIA GPU or CPU
)
# Image understanding
from PIL import Image
image = Image.open("photo.jpg")
inputs = processor(text="Describe this image", images=image, return_tensors="pt")
inputs = {k: v.to(model.device) for k, v in inputs.items()}
outputs = model.generate(**inputs, max_new_tokens=256)
print(processor.decode(outputs[0], skip_special_tokens=True))
| Runtime | Min RAM | Speed | Notes |
|---|---|---|---|
metal (Apple Silicon) |
~8 GB | Good | Native Metal kernels |
cached (any device) |
~12 GB | Fastest | Dequantizes once at load |
triton_memory (NVIDIA) |
~6 GB | Moderate | Packed ternary in VRAM |
pip install ternary-quant
ternary-quant quantize-broad google/gemma-4-E4B-it \
--output ./gemma-4-E4B-it-ternary \
--components text_backbone multimodal_connector \
--scheme tritplane3 \
--dtype float16 \
--eval
See github.com/Asad-Ismail/ternary-models for the full collection of ternary-quantized multimodal models.
@software{ternary_quant,
author = {Ismail, Asad},
title = {ternary-quant: Post-training ternary quantization for HuggingFace generative models},
url = {https://github.com/Asad-Ismail/ternary-quant},
year = {2026}
}