Skip to main content

Union Tool for inference on Sophgo chips

Project description

UnTool

UnTool是一个用于Sophon芯片推理的Python工具包,支持x86_64和aarch64架构,以及SOC和PCIE两种模式。

安装

pip install untool

使用示例

接口使用

  • 接口1:适用于LLM或多模态LLM,untool.LLMBasePipeline封装,便于修改
import argparse
from untool import LLMBasePipeline, MiniCPMVPipeline

parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model_path', type=str, required=True, help='bmodel文件路径')
parser.add_argument('-t', '--tokenizer_path', type=str, required=True, help='tokenizer文件路径')
parser.add_argument('-d', '--devid', type=int, default=0, help='设备ID')
args = parser.parse_args()

pipeline = LLMBasePipeline(args)  # 常规LLM,如Qwen2.5
# pipeline = MiniCPMVPipeline(args)  # 多模态LLM,如MiniCPMV2.6
pipeline.chat()
  • 接口2:适用于LLM,C++底层封装,推理速度更快,但不便修改
import argparse
from untool import EngineLLM

parser = argparse.ArgumentParser()
parser.add_argument('-m', '--model_path', type=str, required=True, help='bmodel文件路径')
parser.add_argument('-t', '--tokenizer_path', type=str, required=True, help='tokenizer文件路径')
parser.add_argument('-d', '--devid', type=int, default=0, help='设备ID')
args = parser.parse_args()

engine = EngineLLM(args)
engine.chat()
  • 接口3:适用于CV模型等
from untool import EngineOV

model = EngineOV("path/to/model.bmodel", device_id=0)
result = model([input_np_array])[0]

EngineOV接口可以通过self.reset_net_stage(net_idx, stage_idx)切换不同的net和stage。

基于untool开发的项目参考LLM分布式推理AIGC-SDK

其他

详见源代码仓库https://www.modelscope.cn/wlc952/UnTool.git

Project details


Download files

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

Source Distribution

untool-0.2.2.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

untool-0.2.2-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file untool-0.2.2.tar.gz.

File metadata

  • Download URL: untool-0.2.2.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for untool-0.2.2.tar.gz
Algorithm Hash digest
SHA256 282cbfb01f4fea231d4ce72f232fc952fec8bc6adfea5bcfe6dc43287af83cd5
MD5 bbbc6d52003051278de1589563ae78f0
BLAKE2b-256 201811408f5e8a9f4b25e06db49701b92bb4f727bcc0d19f4e69043ee7b8c15a

See more details on using hashes here.

File details

Details for the file untool-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: untool-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for untool-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a088f64bf99ed048a57c2e200ba0004e66228a3e31fb5cc8c55cb9039893864
MD5 d89409e76eda069208c1265817ee1161
BLAKE2b-256 a1d42b36524fdb348192f1ba868febf4ce37cefd10de8920755a180b25eb89db

See more details on using hashes here.

Supported by

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