hymt-cpp 1.1.1__cp312-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hymt/__init__.py ADDED
@@ -0,0 +1,17 @@
1
+ from ._hymt import (
2
+ Engine,
3
+ EngineOptions,
4
+ GenerateOptions,
5
+ GenerateStats,
6
+ ModelInfo,
7
+ Session,
8
+ )
9
+
10
+ __all__ = [
11
+ "Engine",
12
+ "EngineOptions",
13
+ "GenerateOptions",
14
+ "GenerateStats",
15
+ "ModelInfo",
16
+ "Session",
17
+ ]
Binary file
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.2
2
+ Name: hymt-cpp
3
+ Version: 1.1.1
4
+ Summary: Lightweight pure C++17 CPU-only GGUF inference engine for Tencent Hunyuan HY-MT translation models
5
+ License: MIT License
6
+
7
+ Copyright (c) 2026 touken
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+
27
+ Requires-Python: >=3.12
28
+ Description-Content-Type: text/markdown
29
+
30
+ # hymt.cpp
31
+
32
+ A lightweight, pure C++17, CPU-only GGUF inference engine for Tencent Hunyuan **HY-MT** translation models (`Hy-MT2-1.8B` / `Hy-MT3-1.8B` / `Hy-MT3-7B`, `hunyuan-dense` architecture), with [Google Highway](https://github.com/google/highway) as its sole third-party dependency. No `llama.cpp` required; portable across x64 (SSE4/AVX2/AVX-512), ARM64 (NEON/SVE), and RISC-V (RVV).
33
+
34
+ ## Features
35
+
36
+ - **Single Dependency**: Only depends on `third_party/highway` for multi-target SIMD dynamic dispatch, 64-byte aligned allocation, and `hwy::ThreadPool`.
37
+ - **Zero-Copy Loading**: Cross-platform read-only `mmap` (Win32 `MapViewOfFile` / POSIX `mmap`) directly maps GGUF v3 vocabularies and weights.
38
+ - **Regex-Free Tokenizer**: Hand-written UTF-8 Unicode pre-tokenizer state machine + GPT-2 byte-level BPE with built-in Hy-MT translation and chat templates.
39
+ - **High-Throughput Portable SIMD Kernels**:
40
+ - Native `Q2_0C`, `Q4_K`, `Q6_K`, `Q8_0`, `F16`, and `F32` support, with L1-tiled 128-token batched prefill, fused 4-head GQA attention, fused `QKV`/`Gate+Up` scheduling, and zero-allocation decode (`Engine` / `Session` split).
41
+
42
+ | Kernel Path | Highway Primitive (Instruction) | Highway Targets | Typical CPUs |
43
+ | --- | --- | --- | --- |
44
+ | **`Dot32`** | `SumOfMulQuadAccumulate` (`sdot` / `vpdpbusd`) | `NEON_BF16`, `SVE/SVE2`, `AVX3_DL`, `AVX3_ZEN4`, `AVX3_SPR` | Apple M1–M5, ARMv9 Android, AMD Zen 4/5, Intel Xeon (Ice Lake+) |
45
+ | **`Pairwise16`** | `SatWidenMulPairwiseAdd` (`vpmaddubsw`) | `SSE4`, `AVX2`, `AVX3` | Intel Core 6th–14th Gen (AVX2), AMD Zen 1–3 |
46
+
47
+ ## Project Layout
48
+
49
+ ```text
50
+ hymt.cpp/
51
+ ├── CMakeLists.txt
52
+ ├── third_party/highway/ # Google Highway (sole third-party dependency)
53
+ ├── include/hymt/engine.h # Public C++17 API
54
+ ├── src/
55
+ │ ├── gguf/ # Cross-platform mmap + read-only GGUF v3 parser
56
+ │ ├── tokenizer/ # Regex-free Unicode pre-tokenizer + BPE + Hy-MT templates
57
+ │ ├── kernels/ # Isolated Highway SIMD kernel translation units
58
+ │ ├── model/ # Weight views, F16/F32 KV cache, scratchpad, forward pass, sampler
59
+ │ └── engine.cpp # Engine / Session facade
60
+ └── apps/
61
+ ├── hymt_cli.cpp # CLI translator and benchmark tool
62
+ └── hymt_server.cpp # Zero-dependency HTTP/1.1 + JSON + SSE server & built-in Web UI
63
+ ```
64
+
65
+ ## Build
66
+
67
+ ```bash
68
+ # Fetch Highway if not already present
69
+ git clone --depth 1 https://github.com/google/highway.git third_party/highway
70
+
71
+ # Configure & build both CLI and Server (Clang + Ninja example; omit compiler flags on Linux/macOS if desired)
72
+ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
73
+ cmake --build build --target hymt_cli hymt_server -j
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ Run `--help` on either binary for full command-line options (model path, threads, context length, sampling parameters, host/port, etc.):
79
+
80
+ ```bash
81
+ # CLI translation
82
+ ./build/hymt_cli -m models/Hy-MT2-1.8B-2Bit.gguf -t "Hello world!" -l Chinese
83
+ ./build/hymt_cli --help
84
+
85
+ # HTTP server (built-in streaming Web UI at http://127.0.0.1:8080/ + REST/SSE/OpenAI-compatible API)
86
+ ./build/hymt_server -m models/Hy-MT2-1.8B-2Bit.gguf --host 127.0.0.1 --port 8080
87
+ ./build/hymt_server --help
88
+ ```
89
+
90
+ `hymt_server` exposes `GET /` (streaming Web UI), `GET /health`, `GET /v1/models`, `POST /v1/translate`, and `POST /v1/chat/completions`.
91
+
92
+ ## Docker
93
+
94
+ Multi-arch (`linux/amd64` and `linux/arm64`) images come bundled with `Hy-MT2-1.8B-2Bit.gguf` and start `hymt_server` on port `8080`:
95
+
96
+ ```bash
97
+ docker run -d --name hymt -p 8080:8080 ghcr.io/touken928/hymt.cpp:latest
98
+ ```
99
+
100
+ Then open `http://localhost:8080/` for the Web UI or call `/v1/translate` and `/v1/chat/completions`. You can also build locally with `docker build -t hymt-server .` or override server flags (e.g. `-j 8` or mounting another GGUF model).
101
+
102
+ ## C++ API Example
103
+
104
+ ```cpp
105
+ #include "hymt/engine.h"
106
+ #include <iostream>
107
+
108
+ int main() {
109
+ std::string err;
110
+ auto engine = hymt::Engine::Load("models/Hy-MT2-1.8B-2Bit.gguf", {}, &err);
111
+ if (!engine) {
112
+ std::cerr << err << "\n";
113
+ return 1;
114
+ }
115
+
116
+ auto session = engine->CreateSession();
117
+ hymt::GenerateStats stats;
118
+ std::string out = session->Translate("Hello world!", "Chinese", {}, nullptr, &stats);
119
+ std::cout << out << "\n";
120
+ }
121
+ ```
122
+
123
+ ## Python
124
+
125
+ Prebuilt `abi3` wheels (Python 3.12+, zero runtime dependencies) are available for Linux (`x86_64` / `aarch64`), Windows (`AMD64` / `ARM64`), and macOS (`arm64`):
126
+
127
+ ```bash
128
+ pip install hymt-cpp
129
+ ```
130
+
131
+ ```python
132
+ import hymt
133
+
134
+ engine = hymt.Engine.load("models/Hy-MT2-1.8B-2Bit.gguf")
135
+ session = engine.create_session()
136
+
137
+ # Translate (releases GIL during inference)
138
+ print(session.translate("Hello world!", target_lang="Chinese"))
139
+
140
+ # Streaming + performance stats
141
+ out, stats = session.translate(
142
+ "Hello world!",
143
+ target_lang="Chinese",
144
+ stream_cb=lambda piece: (print(piece, end="", flush=True), True)[1],
145
+ return_stats=True,
146
+ )
147
+ print(f"\n{stats.prefill_tok_per_sec:.1f} / {stats.decode_tok_per_sec:.1f} tok/s")
148
+ ```
149
+
150
+ ## Benchmarks
151
+
152
+ Measured on **AMD Ryzen 7 PRO 5755G** (Zen 3 8C/16T, AVX2 without VNNI, zero-copy `mmap`, `~560`-token prefill / `128`-token decode):
153
+
154
+ | Model File | Quantization | Prefill (8T / 12T) | Decode (8T / 12T) |
155
+ | --- | --- | --- | --- |
156
+ | [`Hy-MT2-1.8B-2Bit.gguf`](https://huggingface.co/tencent/Hy-MT2-1.8B-2Bit-GGUF) (595 MB) | `Q2_0C` + `Q6_K` | **325–336 / 375–393 tok/s** | **50.5–50.8 / 52.8–53.2 tok/s** |
157
+ | [`Hy-MT3-1.8B-Q4_K_M.gguf`](https://huggingface.co/tencent/Hy-MT3-1.8B-GGUF) (1.34 GB) | `Q8_0` + `Q4_K` + `Q6_K` | **200–201 / 237–238 tok/s** | **24.5–24.7 / 25.9 tok/s** |
158
+ | [`Hy-MT3-7B-Q4_K_M.gguf`](https://huggingface.co/tencent/Hy-MT3-7B-GGUF) (5.15 GB) | `Q8_0` + `Q4_K` + `Q6_K` | **44.0–49.7 / 58.6–60.5 tok/s** | **6.7–6.9 / 7.0 tok/s** |
159
+
160
+ ## License
161
+
162
+ Licensed under the [MIT License](LICENSE).
@@ -0,0 +1,6 @@
1
+ hymt/__init__.py,sha256=gBZX8OpRavkmj7oq90ktKnM8A9eHRe_X5Awkc71Dm1Q,265
2
+ hymt/_hymt.cp312-win_amd64.pyd,sha256=im94Rvr45vXMRST_bBSrmjLorrWq-23bLaqJM_thyG0,1103872
3
+ hymt_cpp-1.1.1.dist-info/METADATA,sha256=ApmNLKQ14Lu7m8pmPdRu18C5-SSSRgcMh2vVnIVdVJc,7468
4
+ hymt_cpp-1.1.1.dist-info/WHEEL,sha256=8_VRiNQbKO5y5eAOf8e1j64w5TmsZcQyvXjqQfIKHN4,104
5
+ hymt_cpp-1.1.1.dist-info/licenses/LICENSE,sha256=cpk44R_ED9uYgTI5s3E4mrbKHipQzptybVRwdYhNeUk,1084
6
+ hymt_cpp-1.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 1.1.2
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-abi3-win_amd64
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 touken
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.