Skip to main content

Termux-BitNet (v2.0.0 Sovereign Ternary)

Production-Grade Universal 1.58-Bit (i2_s) On-Device LLM Inference Engine with ARM64 NEON DotProd SIMD & Native Vulkan GPU Acceleration.

PyPI Version npm Version GitHub Release Documentation Portal License Core Acceleration Supported Models Tested Hardware


🏛️ Executive Engineering Disclosure: The v2.0.0 Sovereign Ternary Breakthrough

termux-bitnet v2.0.0 represents a generational architectural leap from a single-model experimental wrapper into a universal, multi-model 1.58-bit on-device inference runtime.

This release mathematically resolves the notorious ternary numerical collapse ("word salad") that has plagued the global BitNet community, introduces a zero-overhead dynamic activation dispatcher, and breaks mobile memory boundaries by executing 7.45B parameter models on 6GB RAM smartphones without OOM crashes.

📚 Official Academic & Upstream Credibility


⚡ Empirical Real-Device Hardware Fleet Scorecard (Ground Truth)

All benchmarks were empirically measured on genuine Samsung Galaxy hardware under unrooted Android Termux Bionic libc environments across 4 canonical 1.58-bit model families:

Target Model Parameter / Size Architecture / Activation Device & SoC Prompt Eval Token Generation Empirical Verification Status
Falcon-E-1B 1.0B (635 MB) SwiGLU (SiLU) Galaxy A53 (Exynos 1280) 1,986 ms 9.69 tok/s REAL-TIME (Human Reading Speed)
BitNet-2B 2.0B (1.13 GB) Squared ReLU + Sub-Norm Galaxy S25 (Snapdragon 8 Elite) 1,269 ms 3.95 tok/s PASS (100% Coherent Output)
BitNet-2B 2.0B (1.13 GB) Squared ReLU + Sub-Norm Galaxy A53 (Exynos 1280) 1,382 ms 5.91 tok/s PASS (100% Coherent Output)
BitNet-2B 2.0B (1.13 GB) Squared ReLU + Sub-Norm Galaxy A35 (Exynos 1380) 5,386 ms 1.57 tok/s PASS (100% Coherent Output)
BitNet-Embed 268M (367 MB) 1.58-bit Vector Search Galaxy A53 (Exynos 1280) 126 ms 30.68 tok/s PASS (Zero-Copy Mmap)
Falcon3-7B 7.45B (3.05 GB) SwiGLU (SiLU) Galaxy A53 (6GB RAM / E1280) 7,170 ms 2.00 tok/s PASS (6GB RAM OOM Defense)
Falcon3-7B 7.45B (3.05 GB) SwiGLU (SiLU) Galaxy A35 (6GB RAM / E1380) 16,386 ms 0.57 tok/s PASS (6GB RAM OOM Defense)

🔬 Key Technical Breakthroughs in v2.0.0

1. Mathematical Elimination of Ternary Numerical Collapse

Upstream forks historically mapped raw bitfields using (b & 1) - (b >> 1). In Microsoft's official specification, weights are offset by +1 ($w_{\text{stored}} = w_{\text{ternary}} + 1$). The legacy mapping turned the 49.6% inactive zero neurons into +1, causing exponential activation norm explosion across 30 layers. termux-bitnet v2.0.0 enforces canonical dequantization: $$w_{\text{ternary}} = (b & 3) - 1 \implies 00 \to -1,; 01 \to 0,; 10 \to +1$$ Coupled with the extraction and accumulation of 32-byte GGUF tensor trailer weight scales ($S_W = \text{mean}(|W|)$), output logits remain perfectly calibrated.

2. Zero-Overhead Dynamic Activation Dispatcher

Standard runtimes hardcode either SiLU or Squared ReLU. termux-bitnet v2.0.0 inspects the presence of lay.ffn_sub_norm to seamlessly auto-dispatch:

  • Microsoft BitNet 2B: Squared ReLU ($\text{relu}(x)^2$) + Sub-LayerNorm.
  • Falcon-E-1B & Falcon3-7B: Standard SwiGLU ($\text{SiLU}(x) \cdot \text{up}$) without Sub-LayerNorm.

3. 6GB RAM Smartphone 7.45B Model Execution

Through Zero-Copy mmap weight streaming and bounded KV cache management, 3.05GB model weights are mapped directly from flash storage without duplicating resident set size (RSS), allowing 7.45B parameter LLMs to complete inference on mainstream 6GB RAM devices without triggering Android Low Memory Killer (LMK).


📦 Installation

1. Python SDK (PyPI)

# Inside Android Termux (prerequisites: clang cmake python openblas)
pkg update && pkg install -y clang cmake python openblas

# Install Termux-BitNet and AMEVA-Runtime
pip install --upgrade termux-bitnet ameva-runtime

2. Node.js CLI (npm)

npm install -g termux-bitnet @ameva/runtime

3. One-Touch Native Installer

curl -sSL https://raw.githubusercontent.com/uno-km/termux-bitnet/main/install.sh | bash

🚀 Quickstart Recipes

1. Python Programmatic Inference

from termux_bitnet import BitNetEngine, BitNetConfig

# Configure for real-time Falcon-E-1B or BitNet-2B
config = BitNetConfig(
    model_path="~/.cache/termux-bitnet/models/falcon-e-1b-instruct-i2_s.gguf",
    device="auto",        # "auto", "cpu", or "gpu"
    n_threads=4,
    temperature=0.7,
    top_p=0.95
)

with BitNetEngine(config) as engine:
    print("[Prompt]: Explain the theory of relativity in one sentence.")
    print("[Response]: ", end="", flush=True)
    for token in engine.generate_stream("Explain the theory of relativity in one sentence:"):
        print(token, end="", flush=True)
    print()
    metrics = engine.get_last_metrics()
    print(f"Speed: {metrics.tokens_per_second:.2f} tok/s")

2. Standalone CLI Usage

# Run 1B real-time conversational model
termux-bitnet run -m models/falcon-e-1b-instruct-i2_s.gguf \
  -p "What is the capital of South Korea?" -t 4

# Run 7.45B model on 6GB RAM device
termux-bitnet run -m models/falcon3-7b-instruct-1.58bit-i2_s.gguf \
  -p "Solve this riddle: I speak without a mouth..." -t 4

📑 Supported Pretrained Models

Model Identifier Parameter Count Disk Footprint Target Use Case Recommended Hardware
falcon-e-1b 1.0B 635 MB Real-Time Mobile Dialogue (9.69 tok/s) Galaxy A53 / A35 / All Devices
bitnet-2b 2.0B 1.13 GB General Reasoning & Q&A Galaxy S25 / A53 / A35
bitnet-embed-270m 268M 367 MB On-Device Vector Search & Local RAG All Devices (30+ tok/s)
falcon3-7b 7.45B 3.05 GB Advanced Coding & Complex Reasoning 6GB+ RAM Devices (A53, A35, S25)

Metadata

Release files for termux-bitnet 2.0.0

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

Source distribution (sdist)

Source distribution for termux-bitnet 2.0.0
File Size Uploaded
termux_bitnet-2.0.0.tar.gz 73.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for termux-bitnet 2.0.0
File Interpreter ABI Platform
termux_bitnet-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 116.8 kB

Release files / termux_bitnet-2.0.0.tar.gz

Download URL termux_bitnet-2.0.0.tar.gz
Size 73.5 kB
Tags Source
SHA-256 checksum
How to use checksums
318bbe1bf689c0f266b6a0f3eacb8ea1fb74da2e02afe7bb4eb4d56254a54db5
BLAKE2b-256 checksum
How to use checksums
1592963cba64d2864cb1d070b9ab73a87149704da335c3d8f674061167a911ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / termux_bitnet-2.0.0-py3-none-any.whl

Download URL termux_bitnet-2.0.0-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7221e0d972c5c29fe4845773a2b842dac7b9a9b49c01d2907c7542a718be46f
BLAKE2b-256 checksum
How to use checksums
7d89ef1746a2fc03f629078856c2ca38683de3a89948c673431272bce41df7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.1

2 release files

This release

2.0.0 This release

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.5

2 release files

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.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