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.1.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.1-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for untool-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0736a74420434b69ad74ac8bc5c5d7b0ff19e4eca36f0534ffbe535a24e51358
MD5 a24350a2f938b596db30dbbc158315cf
BLAKE2b-256 cec12c99d37f0574c76d37c8cbd86a2c456120aa14d21435f1ee68361c37c82d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: untool-0.2.1-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.3

File hashes

Hashes for untool-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e54a7ac6664eec2c169418627f0a9925506308431f39514b792830b4e3caaa14
MD5 c2ebac5943b5f6cf10d5749662591d6d
BLAKE2b-256 fba75a5f8265ae832d4e96139a182b377eb2c900f4b73de4590b0326421b3e17

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