transformers-mblt 0.0.0__tar.gz

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.
Files changed (115) hide show
  1. transformers_mblt-0.0.0/LICENSE +28 -0
  2. transformers_mblt-0.0.0/MANIFEST.in +5 -0
  3. transformers_mblt-0.0.0/PKG-INFO +212 -0
  4. transformers_mblt-0.0.0/README.md +168 -0
  5. transformers_mblt-0.0.0/pyproject.toml +110 -0
  6. transformers_mblt-0.0.0/setup.cfg +4 -0
  7. transformers_mblt-0.0.0/transformers_mblt/__init__.py +32 -0
  8. transformers_mblt-0.0.0/transformers_mblt/_npu.py +43 -0
  9. transformers_mblt-0.0.0/transformers_mblt/_registry.py +92 -0
  10. transformers_mblt-0.0.0/transformers_mblt/cli/__init__.py +3 -0
  11. transformers_mblt-0.0.0/transformers_mblt/cli/__main__.py +4 -0
  12. transformers_mblt-0.0.0/transformers_mblt/cli/chat.py +38 -0
  13. transformers_mblt-0.0.0/transformers_mblt/cli/list.py +56 -0
  14. transformers_mblt-0.0.0/transformers_mblt/cli/main.py +51 -0
  15. transformers_mblt-0.0.0/transformers_mblt/cli/tps.py +5275 -0
  16. transformers_mblt-0.0.0/transformers_mblt/cli/tps_table.py +1086 -0
  17. transformers_mblt-0.0.0/transformers_mblt/cli/transformers_compat.py +272 -0
  18. transformers_mblt-0.0.0/transformers_mblt/models/__init__.py +0 -0
  19. transformers_mblt-0.0.0/transformers_mblt/models/aya_vision/__init__.py +20 -0
  20. transformers_mblt-0.0.0/transformers_mblt/models/aya_vision/configuration_aya_vision.py +40 -0
  21. transformers_mblt-0.0.0/transformers_mblt/models/aya_vision/modeling_aya_vision.py +204 -0
  22. transformers_mblt-0.0.0/transformers_mblt/models/aya_vision/proxy_aya_vision.py +27 -0
  23. transformers_mblt-0.0.0/transformers_mblt/models/bert/__init__.py +20 -0
  24. transformers_mblt-0.0.0/transformers_mblt/models/bert/configuration_bert.py +23 -0
  25. transformers_mblt-0.0.0/transformers_mblt/models/bert/modeling_bert.py +200 -0
  26. transformers_mblt-0.0.0/transformers_mblt/models/bert/proxy_bert.py +27 -0
  27. transformers_mblt-0.0.0/transformers_mblt/models/blip/__init__.py +20 -0
  28. transformers_mblt-0.0.0/transformers_mblt/models/blip/configuration_blip.py +76 -0
  29. transformers_mblt-0.0.0/transformers_mblt/models/blip/modeling_blip.py +166 -0
  30. transformers_mblt-0.0.0/transformers_mblt/models/blip/modeling_blip_text.py +218 -0
  31. transformers_mblt-0.0.0/transformers_mblt/models/blip/proxy_blip.py +27 -0
  32. transformers_mblt-0.0.0/transformers_mblt/models/cohere2/__init__.py +20 -0
  33. transformers_mblt-0.0.0/transformers_mblt/models/cohere2/configuration_cohere2.py +42 -0
  34. transformers_mblt-0.0.0/transformers_mblt/models/cohere2/modeling_cohere2.py +102 -0
  35. transformers_mblt-0.0.0/transformers_mblt/models/cohere2/proxy_cohere2.py +27 -0
  36. transformers_mblt-0.0.0/transformers_mblt/models/exaone/__init__.py +20 -0
  37. transformers_mblt-0.0.0/transformers_mblt/models/exaone/configuration_exaone.py +15 -0
  38. transformers_mblt-0.0.0/transformers_mblt/models/exaone/modeling_exaone.py +126 -0
  39. transformers_mblt-0.0.0/transformers_mblt/models/exaone/original/__init__.py +15 -0
  40. transformers_mblt-0.0.0/transformers_mblt/models/exaone/original/configuration_exaone.py +182 -0
  41. transformers_mblt-0.0.0/transformers_mblt/models/exaone/proxy_exaone.py +27 -0
  42. transformers_mblt-0.0.0/transformers_mblt/models/exaone4/__init__.py +20 -0
  43. transformers_mblt-0.0.0/transformers_mblt/models/exaone4/configuration_exaone4.py +15 -0
  44. transformers_mblt-0.0.0/transformers_mblt/models/exaone4/modeling_exaone4.py +87 -0
  45. transformers_mblt-0.0.0/transformers_mblt/models/exaone4/proxy_exaone4.py +27 -0
  46. transformers_mblt-0.0.0/transformers_mblt/models/llama/__init__.py +20 -0
  47. transformers_mblt-0.0.0/transformers_mblt/models/llama/configuration_llama.py +69 -0
  48. transformers_mblt-0.0.0/transformers_mblt/models/llama/modeling_llama.py +89 -0
  49. transformers_mblt-0.0.0/transformers_mblt/models/llama/proxy_llama.py +27 -0
  50. transformers_mblt-0.0.0/transformers_mblt/models/llama_eagle3/__init__.py +29 -0
  51. transformers_mblt-0.0.0/transformers_mblt/models/llama_eagle3/configuration_llama_eagle3.py +39 -0
  52. transformers_mblt-0.0.0/transformers_mblt/models/llama_eagle3/modeling_llama_eagle3.py +119 -0
  53. transformers_mblt-0.0.0/transformers_mblt/models/llama_eagle3/proxy_llama_eagle3.py +28 -0
  54. transformers_mblt-0.0.0/transformers_mblt/models/qwen2/__init__.py +20 -0
  55. transformers_mblt-0.0.0/transformers_mblt/models/qwen2/configuration_qwen2.py +15 -0
  56. transformers_mblt-0.0.0/transformers_mblt/models/qwen2/modeling_qwen2.py +87 -0
  57. transformers_mblt-0.0.0/transformers_mblt/models/qwen2/proxy_qwen2.py +27 -0
  58. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_eagle3/__init__.py +29 -0
  59. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_eagle3/configuration_qwen2_eagle3.py +40 -0
  60. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_eagle3/modeling_qwen2_eagle3.py +124 -0
  61. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_eagle3/proxy_qwen2_eagle3.py +28 -0
  62. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_vl/__init__.py +20 -0
  63. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_vl/configuration_qwen2_vl.py +50 -0
  64. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_vl/modeling_qwen2_vl.py +680 -0
  65. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_vl/processing_qwen2_vl.py +121 -0
  66. transformers_mblt-0.0.0/transformers_mblt/models/qwen2_vl/proxy_qwen2_vl.py +33 -0
  67. transformers_mblt-0.0.0/transformers_mblt/models/qwen3/__init__.py +20 -0
  68. transformers_mblt-0.0.0/transformers_mblt/models/qwen3/configuration_qwen3.py +15 -0
  69. transformers_mblt-0.0.0/transformers_mblt/models/qwen3/modeling_qwen3.py +86 -0
  70. transformers_mblt-0.0.0/transformers_mblt/models/qwen3/proxy_qwen3.py +27 -0
  71. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_asr/__init__.py +51 -0
  72. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_asr/_errors.py +31 -0
  73. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_asr/configuration_qwen3_asr.py +341 -0
  74. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_asr/modeling_qwen3_asr.py +814 -0
  75. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_asr/processing_qwen3_asr.py +17 -0
  76. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_asr/proxy_qwen3_asr.py +62 -0
  77. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_eagle3/__init__.py +29 -0
  78. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_eagle3/configuration_qwen3_eagle3.py +40 -0
  79. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_eagle3/modeling_qwen3_eagle3.py +119 -0
  80. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_eagle3/proxy_qwen3_eagle3.py +28 -0
  81. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_vl/__init__.py +25 -0
  82. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_vl/configuration_qwen3_vl.py +96 -0
  83. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_vl/modeling_qwen3_vl.py +2109 -0
  84. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_vl/processing_qwen3_vl.py +1192 -0
  85. transformers_mblt-0.0.0/transformers_mblt/models/qwen3_vl/proxy_qwen3_vl.py +60 -0
  86. transformers_mblt-0.0.0/transformers_mblt/models/siglip/__init__.py +20 -0
  87. transformers_mblt-0.0.0/transformers_mblt/models/siglip/configuration_siglip.py +14 -0
  88. transformers_mblt-0.0.0/transformers_mblt/models/siglip/modeling_siglip.py +32 -0
  89. transformers_mblt-0.0.0/transformers_mblt/models/whisper/__init__.py +30 -0
  90. transformers_mblt-0.0.0/transformers_mblt/models/whisper/configuration_whisper.py +15 -0
  91. transformers_mblt-0.0.0/transformers_mblt/models/whisper/modeling_whisper.py +819 -0
  92. transformers_mblt-0.0.0/transformers_mblt/models/whisper/processing_whisper.py +73 -0
  93. transformers_mblt-0.0.0/transformers_mblt/models/whisper/proxy_whisper.py +40 -0
  94. transformers_mblt-0.0.0/transformers_mblt/py.typed +0 -0
  95. transformers_mblt-0.0.0/transformers_mblt/utils/__init__.py +3 -0
  96. transformers_mblt-0.0.0/transformers_mblt/utils/api.py +175 -0
  97. transformers_mblt-0.0.0/transformers_mblt/utils/base_utils.py +68 -0
  98. transformers_mblt-0.0.0/transformers_mblt/utils/benchmark_cli_common.py +709 -0
  99. transformers_mblt-0.0.0/transformers_mblt/utils/benchmark_utils.py +2677 -0
  100. transformers_mblt-0.0.0/transformers_mblt/utils/cache_utils.py +1050 -0
  101. transformers_mblt-0.0.0/transformers_mblt/utils/configuration_utils.py +1305 -0
  102. transformers_mblt-0.0.0/transformers_mblt/utils/core_mode.py +78 -0
  103. transformers_mblt-0.0.0/transformers_mblt/utils/eagle3/__init__.py +1 -0
  104. transformers_mblt-0.0.0/transformers_mblt/utils/eagle3/decoding.py +20 -0
  105. transformers_mblt-0.0.0/transformers_mblt/utils/eagle3/eagle3_utils.py +1184 -0
  106. transformers_mblt-0.0.0/transformers_mblt/utils/eagle3/tree_decoding.py +671 -0
  107. transformers_mblt-0.0.0/transformers_mblt/utils/generation_utils.py +1258 -0
  108. transformers_mblt-0.0.0/transformers_mblt/utils/modeling_utils.py +1754 -0
  109. transformers_mblt-0.0.0/transformers_mblt/utils/multi_slot_dispatch.py +534 -0
  110. transformers_mblt-0.0.0/transformers_mblt.egg-info/PKG-INFO +212 -0
  111. transformers_mblt-0.0.0/transformers_mblt.egg-info/SOURCES.txt +113 -0
  112. transformers_mblt-0.0.0/transformers_mblt.egg-info/dependency_links.txt +1 -0
  113. transformers_mblt-0.0.0/transformers_mblt.egg-info/entry_points.txt +2 -0
  114. transformers_mblt-0.0.0/transformers_mblt.egg-info/requires.txt +19 -0
  115. transformers_mblt-0.0.0/transformers_mblt.egg-info/top_level.txt +1 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Mobilint, Inc.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,5 @@
1
+ # Tests, benchmarks, and debug scripts are development-only. setuptools already builds only the
2
+ # `transformers_mblt*` packages; prune them from the sdist to pin that intent.
3
+ prune tests
4
+ prune benchmark
5
+ prune scripts
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: transformers-mblt
3
+ Version: 0.0.0
4
+ Summary: Mobilint NPU integrations for Hugging Face Transformers: LLMs, VLMs, ASR, and speculative decoding
5
+ Author-email: "Mobilint Inc." <tech-support@mobilint.com>
6
+ License: BSD-3-Clause
7
+ Project-URL: Home, https://www.mobilint.com/
8
+ Project-URL: Repository, https://github.com/mobilint/transformers-mblt
9
+ Keywords: transformers,NPU,LLM,VLM,pre-quantized models,inference,mobilint,mblt,aries,regulus
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: BSD License
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: <3.13,>=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: mblt-npu-python>=0.1.0
26
+ Requires-Dist: mobilint-qb-runtime>=1.4.0
27
+ Requires-Dist: transformers[serving]<5.18.0,>=4.54.0
28
+ Requires-Dist: torch>=2.4.1
29
+ Requires-Dist: torchvision
30
+ Requires-Dist: torchcodec
31
+ Requires-Dist: numpy>=1.26.0
32
+ Requires-Dist: huggingface-hub
33
+ Requires-Dist: datasets<=3.6.0,>=3.2.0
34
+ Requires-Dist: sentencepiece
35
+ Requires-Dist: pillow>=11.1.0
36
+ Requires-Dist: opencv-python>=4.11.0.86
37
+ Requires-Dist: packaging
38
+ Requires-Dist: tqdm
39
+ Requires-Dist: matplotlib
40
+ Requires-Dist: mblt-tracker>=1.0.1
41
+ Provides-Extra: qwen-asr
42
+ Requires-Dist: qwen-asr; extra == "qwen-asr"
43
+ Dynamic: license-file
44
+
45
+ # transformers-mblt
46
+
47
+ <!-- markdownlint-disable MD033 -->
48
+ <div align="center">
49
+ <p>
50
+ <a href="https://www.mobilint.com/" target="_blank">
51
+ <img src="https://raw.githubusercontent.com/mobilint/.github/main/assets/Mobilint_Logo_Primary.png" alt="Mobilint Logo" width="60%">
52
+ </a>
53
+ </p>
54
+ </div>
55
+ <!-- markdownlint-enable MD033 -->
56
+
57
+ Run Mobilint pre-quantized generative AI models on Mobilint NPUs through Hugging Face
58
+ [Transformers](https://github.com/huggingface/transformers). `transformers-mblt` supplies the
59
+ Mobilint configuration, model, cache, processor, and generation classes behind the standard
60
+ `transformers` Auto classes and `pipeline(...)`. It covers LLMs, VLMs, speech recognition,
61
+ image captioning, masked language models, and EAGLE-3 speculative decoding.
62
+
63
+ Models run on Mobilint [ARIES](https://www.mobilint.com/aries) and
64
+ [REGULUS](https://www.mobilint.com/regulus) boards. Supported target-device identifiers are
65
+ `aries-rb`, `regulus-ra`, `regulus-rb`, `regulus-ra-usb`, and `regulus-rb-usb`.
66
+
67
+ Version `0.0.0` is the first standalone release. It was extracted from `mblt-model-zoo` 2.10.0.
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ pip install transformers-mblt
73
+ ```
74
+
75
+ The following are installed as required dependencies:
76
+
77
+ - `transformers[serving]>=4.54.0,<5.18.0`
78
+ - `mblt-npu-python`, the shared Mobilint NPU backend
79
+ - `mobilint-qb-runtime`
80
+
81
+ NPU execution requires a supported Mobilint NPU driver and device. Qwen3-ASR additionally needs the
82
+ upstream `qwen-asr` package:
83
+
84
+ ```bash
85
+ pip install "transformers-mblt[qwen-asr]"
86
+ ```
87
+
88
+ ## Quick start
89
+
90
+ Mobilint models are published on the [Mobilint Hugging Face organization](https://huggingface.co/mobilint).
91
+ Call `transformers_mblt.register()` once, and the standard `transformers` Auto classes and `pipeline(...)` load them
92
+ from the installed package without running Hub remote code:
93
+
94
+ ```python
95
+ import transformers_mblt
96
+ from transformers import AutoTokenizer, TextStreamer, pipeline
97
+
98
+ transformers_mblt.register()
99
+
100
+ model_id = "mobilint/Llama-3.2-1B-Instruct"
101
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
102
+ pipe = pipeline(
103
+ "text-generation",
104
+ model=model_id,
105
+ tokenizer=tokenizer,
106
+ streamer=TextStreamer(tokenizer=tokenizer, skip_prompt=False),
107
+ model_kwargs={"core_mode": "single"},
108
+ )
109
+ messages = [{"role": "user", "content": "What is an NPU?"}]
110
+ pipe(messages, max_new_tokens=128)
111
+ pipe.model.dispose()
112
+ ```
113
+
114
+ ### Loading through Hub remote code
115
+
116
+ Each `mobilint/*` repository also ships `proxy_*.py` remote code, loaded with `trust_remote_code=True`. The proxies
117
+ import `transformers_mblt` first and fall back to `mblt_model_zoo.hf_transformers`, so this path works with either
118
+ package installed.
119
+
120
+ NPU placement is controlled with keyword arguments. The main ones are `mxq_path`, `dev_no`,
121
+ `core_mode`, `target_cores`, `target_clusters`, `target_device`, `revision`, `embedding_weight`,
122
+ and `npu_prefill_chunk_size`. Multi-backend models accept the same arguments with `vision_`,
123
+ `text_`, `encoder_`, `decoder_`, `base_`, or `draft_` prefixes. The
124
+ [API reference](transformers_mblt/README.md#keyword-parameters) describes each argument.
125
+
126
+ Use `list_tasks()` and `list_models()` to discover the supported tasks and published models:
127
+
128
+ ```python
129
+ from transformers_mblt import list_models, list_tasks
130
+
131
+ print(list_tasks())
132
+ print(list_models("text-generation"))
133
+ ```
134
+
135
+ ## Supported architectures
136
+
137
+ | Task | Architectures |
138
+ | --- | --- |
139
+ | `text-generation` | Llama, Qwen2, Qwen3, EXAONE 3.5, EXAONE 4.0, Cohere2, EAGLE-3 (Llama, Qwen2, Qwen3) |
140
+ | `image-text-to-text` | Qwen2-VL, Qwen3-VL, Aya Vision (SigLIP + Cohere2) |
141
+ | `automatic-speech-recognition` | Whisper, Qwen3-ASR |
142
+ | `image-to-text` | BLIP |
143
+ | `fill-mask` | BERT |
144
+
145
+ ## Command line
146
+
147
+ The `transformers-mblt` command provides these subcommands:
148
+
149
+ - `list` shows the published models for each task.
150
+ - `tps` measures tokens per second.
151
+ - Upstream Transformers commands such as `chat`, `serve`, `run`, `download`, `env`, and `version`
152
+ are passed through with the Mobilint models registered.
153
+
154
+ ```bash
155
+ transformers-mblt list --task text-generation
156
+ transformers-mblt chat mobilint/Llama-3.2-1B-Instruct --trust-remote-code
157
+
158
+ transformers-mblt tps measure --model mobilint/Llama-3.2-1B-Instruct --prefill 512 --decode 128 --repeat 10
159
+ transformers-mblt tps sweep --model mobilint/Llama-3.2-1B-Instruct \
160
+ --prefill-range 128:512:128 --cache-lengths 1024,2048,4096 --decode-window 128 --json tps.json
161
+ ```
162
+
163
+ `python -m transformers_mblt.cli` is equivalent to `transformers-mblt`. Run
164
+ `transformers-mblt tps measure --help` for the EAGLE-3, VLM, and per-backend core-mode options.
165
+
166
+ ## Using with mblt-model-zoo
167
+
168
+ This package replaces `mblt_model_zoo.hf_transformers`, and `mblt-model-zoo` is moving to depend on it. The
169
+ modules have the same contents, and only the import prefix differs:
170
+
171
+ | mblt-model-zoo | transformers-mblt |
172
+ | --- | --- |
173
+ | `mblt_model_zoo.hf_transformers.models.<arch>` | `transformers_mblt.models.<arch>` |
174
+ | `mblt_model_zoo.hf_transformers.utils` | `transformers_mblt.utils` |
175
+ | `mblt-model-zoo tps ...` / `mblt-model-zoo chat ...` | `transformers-mblt tps ...` / `transformers-mblt chat ...` |
176
+
177
+ Hub proxy modules first import `transformers_mblt`. If that package is missing, they fall back to
178
+ `mblt_model_zoo.hf_transformers`, so the same Hub repositories work with either package.
179
+
180
+ ## Development
181
+
182
+ Use [uv](https://docs.astral.sh/uv/) to manage the development environment:
183
+
184
+ ```bash
185
+ git clone https://github.com/mobilint/transformers-mblt.git
186
+ cd transformers-mblt
187
+ uv venv --python 3.12
188
+ source .venv/bin/activate
189
+ uv pip install -e . --group dev
190
+ pre-commit install
191
+ ```
192
+
193
+ `scripts/test_transformers_matrix.py` uses uv to rebuild the environment for each supported
194
+ `transformers` release line and run the test phases against it.
195
+
196
+ ## Documentation and tests
197
+
198
+ - The [API reference](transformers_mblt/README.md) covers model loading, NPU keyword parameters,
199
+ the Qwen3-VL release contract, the EAGLE-3 policies, and the TPS CLI.
200
+ - The [test guide](tests/TEST.md) explains the quick, full-matrix, and core-mode sweep test runs.
201
+ - The [benchmark guide](benchmark/transformers/README.md) covers the text-generation, VLM, and ASR
202
+ benchmark scripts.
203
+
204
+ ## Support and issues
205
+
206
+ For installation, model, or runtime support, visit the [Mobilint forum](https://discuss.mobilint.com/)
207
+ or contact [tech-support@mobilint.com](mailto:tech-support@mobilint.com). Report reproducible
208
+ package issues in the [transformers-mblt issue tracker](https://github.com/mobilint/transformers-mblt/issues).
209
+
210
+ ## License
211
+
212
+ Distributed under the [BSD 3-Clause License](LICENSE).
@@ -0,0 +1,168 @@
1
+ # transformers-mblt
2
+
3
+ <!-- markdownlint-disable MD033 -->
4
+ <div align="center">
5
+ <p>
6
+ <a href="https://www.mobilint.com/" target="_blank">
7
+ <img src="https://raw.githubusercontent.com/mobilint/.github/main/assets/Mobilint_Logo_Primary.png" alt="Mobilint Logo" width="60%">
8
+ </a>
9
+ </p>
10
+ </div>
11
+ <!-- markdownlint-enable MD033 -->
12
+
13
+ Run Mobilint pre-quantized generative AI models on Mobilint NPUs through Hugging Face
14
+ [Transformers](https://github.com/huggingface/transformers). `transformers-mblt` supplies the
15
+ Mobilint configuration, model, cache, processor, and generation classes behind the standard
16
+ `transformers` Auto classes and `pipeline(...)`. It covers LLMs, VLMs, speech recognition,
17
+ image captioning, masked language models, and EAGLE-3 speculative decoding.
18
+
19
+ Models run on Mobilint [ARIES](https://www.mobilint.com/aries) and
20
+ [REGULUS](https://www.mobilint.com/regulus) boards. Supported target-device identifiers are
21
+ `aries-rb`, `regulus-ra`, `regulus-rb`, `regulus-ra-usb`, and `regulus-rb-usb`.
22
+
23
+ Version `0.0.0` is the first standalone release. It was extracted from `mblt-model-zoo` 2.10.0.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install transformers-mblt
29
+ ```
30
+
31
+ The following are installed as required dependencies:
32
+
33
+ - `transformers[serving]>=4.54.0,<5.18.0`
34
+ - `mblt-npu-python`, the shared Mobilint NPU backend
35
+ - `mobilint-qb-runtime`
36
+
37
+ NPU execution requires a supported Mobilint NPU driver and device. Qwen3-ASR additionally needs the
38
+ upstream `qwen-asr` package:
39
+
40
+ ```bash
41
+ pip install "transformers-mblt[qwen-asr]"
42
+ ```
43
+
44
+ ## Quick start
45
+
46
+ Mobilint models are published on the [Mobilint Hugging Face organization](https://huggingface.co/mobilint).
47
+ Call `transformers_mblt.register()` once, and the standard `transformers` Auto classes and `pipeline(...)` load them
48
+ from the installed package without running Hub remote code:
49
+
50
+ ```python
51
+ import transformers_mblt
52
+ from transformers import AutoTokenizer, TextStreamer, pipeline
53
+
54
+ transformers_mblt.register()
55
+
56
+ model_id = "mobilint/Llama-3.2-1B-Instruct"
57
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
58
+ pipe = pipeline(
59
+ "text-generation",
60
+ model=model_id,
61
+ tokenizer=tokenizer,
62
+ streamer=TextStreamer(tokenizer=tokenizer, skip_prompt=False),
63
+ model_kwargs={"core_mode": "single"},
64
+ )
65
+ messages = [{"role": "user", "content": "What is an NPU?"}]
66
+ pipe(messages, max_new_tokens=128)
67
+ pipe.model.dispose()
68
+ ```
69
+
70
+ ### Loading through Hub remote code
71
+
72
+ Each `mobilint/*` repository also ships `proxy_*.py` remote code, loaded with `trust_remote_code=True`. The proxies
73
+ import `transformers_mblt` first and fall back to `mblt_model_zoo.hf_transformers`, so this path works with either
74
+ package installed.
75
+
76
+ NPU placement is controlled with keyword arguments. The main ones are `mxq_path`, `dev_no`,
77
+ `core_mode`, `target_cores`, `target_clusters`, `target_device`, `revision`, `embedding_weight`,
78
+ and `npu_prefill_chunk_size`. Multi-backend models accept the same arguments with `vision_`,
79
+ `text_`, `encoder_`, `decoder_`, `base_`, or `draft_` prefixes. The
80
+ [API reference](transformers_mblt/README.md#keyword-parameters) describes each argument.
81
+
82
+ Use `list_tasks()` and `list_models()` to discover the supported tasks and published models:
83
+
84
+ ```python
85
+ from transformers_mblt import list_models, list_tasks
86
+
87
+ print(list_tasks())
88
+ print(list_models("text-generation"))
89
+ ```
90
+
91
+ ## Supported architectures
92
+
93
+ | Task | Architectures |
94
+ | --- | --- |
95
+ | `text-generation` | Llama, Qwen2, Qwen3, EXAONE 3.5, EXAONE 4.0, Cohere2, EAGLE-3 (Llama, Qwen2, Qwen3) |
96
+ | `image-text-to-text` | Qwen2-VL, Qwen3-VL, Aya Vision (SigLIP + Cohere2) |
97
+ | `automatic-speech-recognition` | Whisper, Qwen3-ASR |
98
+ | `image-to-text` | BLIP |
99
+ | `fill-mask` | BERT |
100
+
101
+ ## Command line
102
+
103
+ The `transformers-mblt` command provides these subcommands:
104
+
105
+ - `list` shows the published models for each task.
106
+ - `tps` measures tokens per second.
107
+ - Upstream Transformers commands such as `chat`, `serve`, `run`, `download`, `env`, and `version`
108
+ are passed through with the Mobilint models registered.
109
+
110
+ ```bash
111
+ transformers-mblt list --task text-generation
112
+ transformers-mblt chat mobilint/Llama-3.2-1B-Instruct --trust-remote-code
113
+
114
+ transformers-mblt tps measure --model mobilint/Llama-3.2-1B-Instruct --prefill 512 --decode 128 --repeat 10
115
+ transformers-mblt tps sweep --model mobilint/Llama-3.2-1B-Instruct \
116
+ --prefill-range 128:512:128 --cache-lengths 1024,2048,4096 --decode-window 128 --json tps.json
117
+ ```
118
+
119
+ `python -m transformers_mblt.cli` is equivalent to `transformers-mblt`. Run
120
+ `transformers-mblt tps measure --help` for the EAGLE-3, VLM, and per-backend core-mode options.
121
+
122
+ ## Using with mblt-model-zoo
123
+
124
+ This package replaces `mblt_model_zoo.hf_transformers`, and `mblt-model-zoo` is moving to depend on it. The
125
+ modules have the same contents, and only the import prefix differs:
126
+
127
+ | mblt-model-zoo | transformers-mblt |
128
+ | --- | --- |
129
+ | `mblt_model_zoo.hf_transformers.models.<arch>` | `transformers_mblt.models.<arch>` |
130
+ | `mblt_model_zoo.hf_transformers.utils` | `transformers_mblt.utils` |
131
+ | `mblt-model-zoo tps ...` / `mblt-model-zoo chat ...` | `transformers-mblt tps ...` / `transformers-mblt chat ...` |
132
+
133
+ Hub proxy modules first import `transformers_mblt`. If that package is missing, they fall back to
134
+ `mblt_model_zoo.hf_transformers`, so the same Hub repositories work with either package.
135
+
136
+ ## Development
137
+
138
+ Use [uv](https://docs.astral.sh/uv/) to manage the development environment:
139
+
140
+ ```bash
141
+ git clone https://github.com/mobilint/transformers-mblt.git
142
+ cd transformers-mblt
143
+ uv venv --python 3.12
144
+ source .venv/bin/activate
145
+ uv pip install -e . --group dev
146
+ pre-commit install
147
+ ```
148
+
149
+ `scripts/test_transformers_matrix.py` uses uv to rebuild the environment for each supported
150
+ `transformers` release line and run the test phases against it.
151
+
152
+ ## Documentation and tests
153
+
154
+ - The [API reference](transformers_mblt/README.md) covers model loading, NPU keyword parameters,
155
+ the Qwen3-VL release contract, the EAGLE-3 policies, and the TPS CLI.
156
+ - The [test guide](tests/TEST.md) explains the quick, full-matrix, and core-mode sweep test runs.
157
+ - The [benchmark guide](benchmark/transformers/README.md) covers the text-generation, VLM, and ASR
158
+ benchmark scripts.
159
+
160
+ ## Support and issues
161
+
162
+ For installation, model, or runtime support, visit the [Mobilint forum](https://discuss.mobilint.com/)
163
+ or contact [tech-support@mobilint.com](mailto:tech-support@mobilint.com). Report reproducible
164
+ package issues in the [transformers-mblt issue tracker](https://github.com/mobilint/transformers-mblt/issues).
165
+
166
+ ## License
167
+
168
+ Distributed under the [BSD 3-Clause License](LICENSE).
@@ -0,0 +1,110 @@
1
+ [build-system]
2
+ requires = ["setuptools>=70.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "transformers-mblt"
7
+ dynamic = ["version"]
8
+ description = "Mobilint NPU integrations for Hugging Face Transformers: LLMs, VLMs, ASR, and speculative decoding"
9
+ readme = "README.md"
10
+ authors = [{ name = "Mobilint Inc.", email = "tech-support@mobilint.com" }]
11
+ license = { text = "BSD-3-Clause" }
12
+ requires-python = ">=3.10,<3.13"
13
+ keywords = ["transformers", "NPU", "LLM", "VLM", "pre-quantized models", "inference", "mobilint", "mblt", "aries", "regulus"]
14
+ dependencies = [
15
+ "mblt-npu-python>=0.1.0",
16
+ "mobilint-qb-runtime>=1.4.0",
17
+ "transformers[serving]>=4.54.0,<5.18.0",
18
+ "torch>=2.4.1",
19
+ "torchvision",
20
+ "torchcodec",
21
+ "numpy>=1.26.0",
22
+ "huggingface-hub",
23
+ "datasets>=3.2.0,<=3.6.0",
24
+ "sentencepiece",
25
+ "pillow>=11.1.0",
26
+ "opencv-python>=4.11.0.86",
27
+ "packaging",
28
+ "tqdm",
29
+ "matplotlib",
30
+ "mblt-tracker>=1.0.1",
31
+ ]
32
+ classifiers = [
33
+ "Development Status :: 4 - Beta",
34
+ "Environment :: Console",
35
+ "Intended Audience :: Developers",
36
+ "Intended Audience :: Science/Research",
37
+ "License :: OSI Approved :: BSD License",
38
+ "Operating System :: POSIX :: Linux",
39
+ "Programming Language :: Python :: 3",
40
+ "Programming Language :: Python :: 3.10",
41
+ "Programming Language :: Python :: 3.11",
42
+ "Programming Language :: Python :: 3.12",
43
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
44
+ "Topic :: Software Development :: Libraries :: Python Modules",
45
+ ]
46
+
47
+ [project.urls]
48
+ Home = "https://www.mobilint.com/"
49
+ Repository = "https://github.com/mobilint/transformers-mblt"
50
+
51
+ [project.scripts]
52
+ transformers-mblt = "transformers_mblt.cli:main"
53
+
54
+ [project.optional-dependencies]
55
+ qwen-asr = [
56
+ "qwen-asr",
57
+ ]
58
+
59
+ [tool.setuptools]
60
+ packages = { find = { where = ["."], include = ["transformers_mblt", "transformers_mblt.*"] } }
61
+
62
+ [tool.setuptools.dynamic]
63
+ version = { attr = "transformers_mblt.__version__" }
64
+
65
+ [tool.setuptools.package-data]
66
+ "transformers_mblt" = ["py.typed"]
67
+
68
+ [dependency-groups]
69
+ dev = [
70
+ "pre-commit>=4.3.0",
71
+ "pytest>=8.4.2",
72
+ "jiwer>=3.0.0",
73
+ "librosa>=0.11.0, <=0.11.0",
74
+ "numba>=0.60.0, <=0.60.0",
75
+ "hf_xet",
76
+ "build",
77
+ "ruff",
78
+ "soundfile",
79
+ "rich",
80
+ ]
81
+
82
+ [tool.pytest.ini_options]
83
+ markers = [
84
+ "full_matrix: additional transformer model/core matrix cases enabled by --full-matrix.",
85
+ "requires_network: test downloads models, datasets, or other remote artifacts.",
86
+ "requires_npu: test requires a configured Mobilint NPU runtime and device.",
87
+ "upstream_contract: pins invariants of upstream HF transformers classes that our wrappers depend on; deselect with '-m \"not upstream_contract\"' in fast CI.",
88
+ ]
89
+ filterwarnings = [
90
+ "ignore:Keep-all or multi-position `logits_to_keep` on a last-only MXQ:UserWarning",
91
+ ]
92
+
93
+ [tool.ruff]
94
+ line-length = 120
95
+ target-version = "py310"
96
+ # The model and utility modules were extracted verbatim from mblt-model-zoo, where they were also excluded.
97
+ exclude = [
98
+ "transformers_mblt/models",
99
+ "transformers_mblt/utils",
100
+ ]
101
+
102
+ [tool.ruff.lint]
103
+ select = ["E", "F", "I"]
104
+ ignore = ["PLC0414"]
105
+
106
+ [tool.ruff.format]
107
+ quote-style = "double"
108
+ indent-style = "space"
109
+ skip-magic-trailing-comma = false
110
+ line-ending = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,32 @@
1
+ """Mobilint NPU integrations for Hugging Face Transformers.
2
+
3
+ Import :mod:`transformers_mblt` and call :func:`register` to make the ``mobilint-*`` model types resolvable by the
4
+ ``transformers`` Auto classes, or load ``mobilint/*`` Hub models with ``trust_remote_code=True``.
5
+ """
6
+
7
+ from typing import TYPE_CHECKING
8
+
9
+ __version__ = "0.0.0"
10
+
11
+ if TYPE_CHECKING:
12
+ from . import models, utils
13
+ from ._registry import register
14
+ from .utils.api import list_models, list_tasks
15
+
16
+ __all__ = ["__version__", "list_models", "list_tasks", "models", "register", "utils"]
17
+
18
+
19
+ def __getattr__(name: str):
20
+ import importlib
21
+
22
+ if name in {"list_models", "list_tasks"}:
23
+ return getattr(importlib.import_module(".utils.api", __name__), name)
24
+ if name == "register":
25
+ return importlib.import_module("._registry", __name__).register
26
+ if name in {"models", "utils"}:
27
+ return importlib.import_module(f".{name}", __name__)
28
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
29
+
30
+
31
+ def __dir__() -> list[str]:
32
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1,43 @@
1
+ """NPU backend exports used by the Transformers integration.
2
+
3
+ The backend implementation is maintained by ``mblt-npu-python`` (:mod:`mblt_npu`). This module adds the
4
+ multi-slot ``dispatcher`` property that the Transformers models rely on, without coupling the NPU wheel to
5
+ ``transformers``.
6
+ """
7
+
8
+ from mblt_npu import (
9
+ BACKEND_CLASSES,
10
+ DEFAULT_TARGET_DEVICE,
11
+ MobilintAriesBackend,
12
+ MobilintBackendAllocError,
13
+ MobilintNPUBackend,
14
+ MobilintRegulusBackend,
15
+ backend_class_for,
16
+ )
17
+
18
+
19
+ def _get_transformers_dispatcher(backend: MobilintNPUBackend):
20
+ """Return the backend's lazily created :class:`MultiSlotDispatcher`."""
21
+ # Attribute name is shared with mblt-model-zoo so a backend keeps one dispatcher when both packages are installed.
22
+ dispatcher = getattr(backend, "_mblt_model_zoo_dispatcher", None)
23
+ if dispatcher is None:
24
+ from .utils.multi_slot_dispatch import MultiSlotDispatcher
25
+
26
+ dispatcher = MultiSlotDispatcher(backend)
27
+ backend._mblt_model_zoo_dispatcher = dispatcher
28
+ return dispatcher
29
+
30
+
31
+ # Guarded so installing alongside mblt-model-zoo (which installs the same property) never overrides an existing one.
32
+ if not hasattr(MobilintNPUBackend, "dispatcher"):
33
+ MobilintNPUBackend.dispatcher = property(_get_transformers_dispatcher)
34
+
35
+ __all__ = [
36
+ "BACKEND_CLASSES",
37
+ "DEFAULT_TARGET_DEVICE",
38
+ "MobilintBackendAllocError",
39
+ "MobilintAriesBackend",
40
+ "MobilintNPUBackend",
41
+ "MobilintRegulusBackend",
42
+ "backend_class_for",
43
+ ]