Skip to main content

controlmt

Python SDK for ControlMT v2.3 — a compact 139M-parameter Kannada ↔ English translator.

Install

# CPU-only (smaller — ~200 MB torch wheel)
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install controlmt

# GPU (CUDA) — default; pulls ~2 GB CUDA torch wheel
pip install controlmt

The default pip install controlmt works on both CPU and GPU machines — but pulls the GPU-enabled torch wheel (~2 GB). If you don't have a CUDA GPU, install the CPU-only torch wheel first (one extra command, ~200 MB) and the model still runs at full speed via bf16 / int8 dynamic quantization.

Quick start

from controlmt import ControlMT

model = ControlMT.from_hf()                                    # auto everything
print(model.translate("ನಾನು ಕನ್ನಡ ಮಾತನಾಡುತ್ತೇನೆ."))
# → "I speak Kannada."

That's it. The SDK auto-detects:

  • Device — GPU if CUDA is available, else CPU (overridable)
  • Dtype — fp16 on GPU, bf16 on CPU (overridable; bf16 only when supported)
  • Direction — Kannada → English if input is mostly Kannada chars, else reverse

Explicit control

# Force CPU, even on a GPU box
model = ControlMT.from_hf(device="cpu")

# Force GPU; falls back to CPU with a warning if not present
model = ControlMT.from_hf(device="gpu")

# Pick an exact dtype
model = ControlMT.from_hf(device="cpu", dtype="bf16")    # bfloat16
model = ControlMT.from_hf(device="gpu", dtype="fp16")    # float16
model = ControlMT.from_hf(dtype="fp32")                  # full precision

# CPU int8 dynamic quantization (~2× faster than bf16 on CPU)
model = ControlMT.from_hf(device="cpu", quant="int8")

# Specific HF revision (e.g. a pre-quantized branch)
model = ControlMT.from_hf(model_id="anandkaman/controlmt-v2.3-int8", quant="int8")

# Loud: print the auto-pick decisions
model = ControlMT.from_hf(verbose=True)

Inspect the resolved config:

>>> model
<ControlMT model_id='anandkaman/controlmt-v2.3' cuda · float16>
>>> model.config
ResolvedConfig(device='cuda', dtype_str='float16', quant='none', bf16_cpu=True)

Batched translation

By design: you must specify batch_size to opt into batching. Otherwise the SDK runs one sentence at a time — predictable memory, no surprises.

texts = ["ನಾನು ಕನ್ನಡ.", "I speak English.", ...]

# Default: one at a time (safe everywhere)
outs = model.batch_translate(texts)

# Explicit fixed batch size
outs = model.batch_translate(texts, batch_size=8)

# Auto-pick batch size from free VRAM (GPU only)
outs = model.batch_translate(texts, auto_batch=True)
Mode CPU GPU
(no batch_size, no auto_batch) 1 sentence at a time 1 sentence at a time
batch_size=N uses N uses N
auto_batch=True ignored + warning → 1 probes torch.cuda.mem_get_info(), picks N ≤ 64

Other endpoints

# Heuristic direction detection (>30% KN chars → kn2en, else en2kn)
ControlMT.detect_direction("ನಾನು ಕನ್ನಡ.")    # → "kn2en"

# JIT/compile warmup — kills the 5–10s "first request" lag in production
model.warmup()

# Run the 6-pair DEPLOYMENT.md benchmark suite on YOUR hardware
result = model.benchmark()
# {'config': 'cuda · float16', 'num_beams': 2, 'median_latency_s': 0.19, 'rows': [...]}

Architecture note

ControlMT v2.3 is an encoder-decoder seq2seq model (T5/mBART family), not a decoder-only LM. That means:

  • ✅ Works: this SDK, raw Transformers, FastAPI, Docker, HF Inference Endpoints
  • ❌ Doesn't work without significant adapter work: vLLM, Ollama, llama.cpp/GGUF, HF TGI

See DEPLOYMENT.md Section 9 for the full "not supported" table and why.

License

Apache 2.0. Same as the underlying model weights.

Metadata

Release files for controlmt 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for controlmt 0.1.4
File Size Uploaded
controlmt-0.1.4.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for controlmt 0.1.4
File Interpreter ABI Platform
controlmt-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / controlmt-0.1.4.tar.gz

Download URL controlmt-0.1.4.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
141a0c8cab4e9d542ac2c20ca637207b56d457eb67f6c8b944edb5a6c418495f
BLAKE2b-256 checksum
How to use checksums
7c79df7412610a93e38b2ed36151540732c232361e5b6fe0b0cc778f9c6eb12c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / controlmt-0.1.4-py3-none-any.whl

Download URL controlmt-0.1.4-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcd3bdf8e28780d2ffee9d57d02576d51df16ad4d731ee8985cfb1fc70dfa254
BLAKE2b-256 checksum
How to use checksums
25d86902cfa2dd985b9f2cc4cb2b2451f82a6bf88ecb99c331b8dcfd5d7d66eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page