Skip to main content

termux-bitnet

Production 1.58-bit (i2_s) BitNet On-Device Inference SDK & CLI for Android Termux & ARM64.

PyPI Version PyPI Downloads Python Versions License Core C++ Platform


1. Overview & Architecture

termux-bitnet is a native Python SDK and CLI tool designed for running 1.58-bit quantized Large Language Models (BitNet b1.58) directly on Android Termux, ARM64 mobile processors, and edge devices.

The underlying execution engine is written in native C++17 with optimized ARM64 NEON SIMD and DotProd vector instructions (vdotq_s32), exposed to Python via a high-throughput, zero-overhead C-types FFI layer.

[Python 3.8+ Application / CLI]
       │
       ▼ (BitNetEngine / BitNetConfig)
[termux-bitnet Python SDK (ctypes Zero-Copy FFI)]
       │
       ▼ (Strict C ABI: libtermux_bitnet.so)
[Native C++ BitNet Core] ──► ARM64 NEON + DotProd SIMD Vector Kernels

2. Verified BitNet GGUF Model Registry

termux-bitnet provides one-touch model downloading and caching from verified Hugging Face repositories with HTTP Range resume capability:

Model Alias Hugging Face Repository & File Parameters File Size Target Device
bitnet-2b microsoft/bitnet-b1.58-2B-4T-gguf 2.4B 1.13 GB Flagship Phones (Galaxy S20+, S24, S25, Pixel)
bitnet-large RichardErkhov/1bitLLM_-_bitnet_b1_58-large-gguf 0.7B 404 MB Entry-level / Low-RAM ARM64 Devices
bitnet-3b Green-Sky/bitnet_b1_58-3B-GGUF 3.3B 730 MB High-Capacity Mobile Workstations
bitnet-3b-q4 RichardErkhov/1bitLLM_-_bitnet_b1_58-3B-gguf 3.3B 1.83 GB High-Precision Q4 Quantized Model

3. Quick Start

3.1 Installation

# In Android Termux or ARM64 Linux
pip install termux-bitnet

3.2 CLI Commands

# 1. Hardware Diagnostic (Check NEON & DotProd SIMD Acceleration)
termux-bitnet info

# 2. List Available Verified Models
termux-bitnet models

# 3. Download Model with HTTP Range Resume Support
termux-bitnet download bitnet-2b

# 4. Run On-Device Inference
termux-bitnet run -m ~/.cache/termux-bitnet/models/bitnet-2b-ggml-model-i2_s.gguf   -p "The capital of France is"   -t 8 -c 2048 -n 128 --temp 0.7 --top-p 0.95 --top-k 40 --repeat-penalty 1.15

4. Python SDK Usage

4.1 Real-Time Token Streaming

from termux_bitnet import BitNetEngine, BitNetConfig

# 1. Configure Engine Parameters
config = BitNetConfig(
    model_path="~/.cache/termux-bitnet/models/bitnet-2b-ggml-model-i2_s.gguf",
    n_threads=8,
    temperature=0.7,
    top_p=0.95,
    top_k=40,
    min_p=0.05,
    repeat_penalty=1.15,
)

# 2. Stream Generation with Context Manager
with BitNetEngine(config) as engine:
    print("[Prompt]: Write a Python palindrome check function")
    print("[Response]: ", end="", flush=True)
    for token in engine.generate_stream("Write a Python palindrome check:"):
        print(token, end="", flush=True)
    print()

4.2 Programmatic Model Management

from termux_bitnet import download_model, detect_hardware, print_hardware_summary

# Inspect ARM64 Hardware Capabilities
hw = detect_hardware()
print_hardware_summary(hw)

# Download and Cache Model
model_path = download_model("bitnet-2b")
print(f"Model downloaded to: {model_path}")

5. Full Parameter Matrix (BitNetConfig)

CLI Flag Python (BitNetConfig) Default Description
-m, --model model_path "" Path to GGUF model binary
-p, --prompt prompt "" Input prompt text
-t, --threads n_threads cores Number of CPU worker threads
-c, --ctx-size n_ctx 2048 KV Cache context window size
-b, --batch-size n_batch 512 Prompt evaluation batch size
-n, --n-predict n_predict 128 Maximum tokens to generate
--temp temperature 0.7 Softmax temperature (0.0 = Greedy)
--top-p top_p 0.95 Nucleus Top-P sampling cutoff
--top-k top_k 40 Top-K sampling cutoff
--min-p min_p 0.05 Min-P relative probability cutoff
--repeat-penalty repeat_penalty 1.15 Repetition penalty coefficient
-s, --seed seed 0 Random seed (0 = non-deterministic)
--system-prompt system_prompt "" Optional system prompt prefix
-r, --stop stop_tokens "" Stop sequence tokens

6. License

Apache License 2.0. Copyright (c) 2026 uno-km (AMEVA Foundation).\n

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termux_bitnet-1.0.3.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

termux_bitnet-1.0.3-cp312-cp312-win_amd64.whl (17.5 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file termux_bitnet-1.0.3.tar.gz.

File metadata

  • Download URL: termux_bitnet-1.0.3.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.0

File hashes

Hashes for termux_bitnet-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7cde7229e9c7846f2166c531def85124a76d99a20975d15e408d039a6a358002
MD5 4fc7d06fc431f79f7a792c7fada9d14c
BLAKE2b-256 25dce5e4a560c796706b39c9b5c61cc2eb21f6e66189a8215fbec6b0c1168636

See more details on using hashes here.

File details

Details for the file termux_bitnet-1.0.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for termux_bitnet-1.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2a695208d79a9a32ea871f50ba7ad82131a3412f83c855c59072a3dd4be8f7d3
MD5 e6e87961c6e09fdce314d0e260385b5e
BLAKE2b-256 5213a1f395a7a3ff2becfe4d672e21c388d10947e53cfcce826078c2ad43b970

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.5

2 files

1.0.4

2 files

This release

1.0.3 This release

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page