Views
No views yet
torch.quantization.quantize_dynamic to every nn.Linear at load time.
You don't need to write any quantization code — just load it the standard HF way.| Variant | Latency / pair | RAM | vs CPU bf16 |
|---|---|---|---|
| int8 (this) | 0.28 s | ~140 MB | 1.8× faster |
| CPU bf16 | 0.51 s | 280 MB | (baseline) |
| CPU fp32 | 1.44 s | 560 MB | 2.8× slower |
1from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("anandkaman/controlmt-v2.3-int8", trust_remote_code=True)
4model = AutoModelForSeq2SeqLM.from_pretrained("anandkaman/controlmt-v2.3-int8", trust_remote_code=True)
5
6# Already quantized — just translate
7print(model.translate("ನಾನು ಕನ್ನಡ ಮಾತನಾಡುತ್ತೇನೆ.",
8 tokenizer=tokenizer, direction="kn2en"))
9# → "I speak Kannada."quantize_dynamic call needed; the modeling code does it for you
on from_pretrained.pip install):pip install controlmt1from controlmt import ControlMT
2model = ControlMT.from_hf(model_id="anandkaman/controlmt-v2.3-int8", quant="int8").to('cuda') reverts the int8 ops to fp32 Linear and you lose the speed/memory win. Use the main repo with dtype=torch.float16 for GPU.| Repo | Best for |
|---|---|
| controlmt-v2.3 | General use — fp32 / bf16 / fp16 chosen at load |
| controlmt-v2.3-int8 (you are here) | CPU-only, memory-constrained, fastest CPU |
| controlmt-demo | Live web demo |