InfiniCore
InfiniCore 是一个跨平台统一编程工具集,为不同芯片平台的功能(包括计算、运行时、通信等)提供统一 C 语言接口。目前支持的硬件和后端包括:
- CPU;
- CUDA
- 英伟达 GPU;
- 摩尔线程 GPU;
- 天数智芯 GPU;
- 沐曦 GPU;
- 曙光 DCU;
- 华为昇腾 NPU;
- 寒武纪 MLU;
- 昆仑芯 XPU;
API 定义以及使用方式详见 InfiniCore文档。
配置和使用
一键安装
在 script/ 目录中提供了 install.py 安装脚本。使用方式如下:
cd InfiniCore
python scripts/install.py [XMAKE_CONFIG_FLAGS]
参数 XMAKE_CONFIG_FLAGS 是 xmake 构建配置,可配置下列可选项:
| 选项 | 功能 | 默认值 |
|---|---|---|
--omp=[y|n] |
是否使用 OpenMP | y |
--cpu=[y|n] |
是否编译 CPU 接口实现 | y |
--nv-gpu=[y|n] |
是否编译英伟达 GPU 接口实现 | n |
--ascend-npu=[y|n] |
是否编译昇腾 NPU 接口实现 | n |
--cambricon-mlu=[y|n] |
是否编译寒武纪 MLU 接口实现 | n |
--metax-gpu=[y|n] |
是否编译沐曦 GPU 接口实现 | n |
--moore-gpu=[y|n] |
是否编译摩尔线程 GPU 接口实现 | n |
--iluvatar-gpu=[y|n] |
是否编译沐曦 GPU 接口实现 | n |
--sugon-dcu=[y|n] |
是否编译曙光 DCU 接口实现 | n |
--kunlun-xpu=[y|n] |
是否编译昆仑 XPU 接口实现 | n |
--ninetoothed=[y|n] |
是否编译九齿实现 | n |
--ccl=[y|n] |
是否编译 InfiniCCL 通信库接口实现 | n |
手动安装
-
生成九齿算子(可选)
参见使用九齿章节。
-
项目配置
windows系统上,建议使用
xmake v2.8.9编译项目。-
查看当前配置
xmake f -v
-
配置 CPU(默认配置)
xmake f -cv
-
配置加速卡
# 英伟达 # 可以指定 CUDA 路径, 一般环境变量为 `CUDA_HOME` 或者 `CUDA_ROOT` # window系统:--cuda="%CUDA_HOME%" # linux系统:--cuda=$CUDA_HOME xmake f --nv-gpu=true --cuda=$CUDA_HOME -cv # 寒武纪 xmake f --cambricon-mlu=true -cv # 华为昇腾 xmake f --ascend-npu=true -cv
-
-
编译安装
默认安装路径为
$HOME/.infini。xmake build && xmake install
-
设置环境变量
按输出提示设置
INFINI_ROOT和LD_LIBRARY_PATH环境变量。
运行测试
运行Python算子测试
python test/infiniop/[operator].py [--cpu | --nvidia | --cambricon | --ascend]
一键运行所有Python算子测试
python scripts/python_test.py [--cpu | --nvidia | --cambricon | --ascend]
算子测试框架
详见 test/infiniop-test 目录
通信库(InfiniCCL)测试
编译(需要先安装InfiniCCL):
xmake build infiniccl-test
在英伟达平台运行测试(会自动使用所有可见的卡):
infiniccl-test --nvidia
使用九齿
九齿是一门基于 Triton 但提供更高层抽象的领域特定语言(DSL)。使用九齿可以降低算子的开发门槛,并且提高开发效率。
InfiniCore 目前已经可以接入使用九齿实现的算子,但是这部分实现的编译是默认关闭的。如果选择编译库中的九齿实现,需要使用 --ninetoothed=y,并在运行一键安装脚本前完成以下准备工作:
- 安装九齿与九齿算子库:
git clone https://github.com/InfiniTensor/ntops.git
cd ntops
pip install -e .
注:安装 ntops 时,ninetoothed 会被当成依赖也一并安装进来。
- 在
InfiniCore文件夹下运行以下命令 AOT 编译库中的九齿算子:
PYTHONPATH=${PYTHONPATH}:src python scripts/build_ntops.py
注:如果对九齿相关文件有修改,需要重新构建 InfiniCore 时,也需要同时运行以上命令进行重新生成。
如何开源贡献
Metadata
Release files for InfiniCore 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| infinicore-0.1.0.tar.gz | 264.2 kB | Without provenance | Details for infinicore-0.1.0.tar.gz |
Release files / infinicore-0.1.0.tar.gz
| Download URL | infinicore-0.1.0.tar.gz |
|---|---|
| Size | 264.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f11f9ab33ad3a2dd943daf4c1d987162e86e1239abb1a178791bf8a9a2ece560
|
|
BLAKE2b-256 checksum How to use checksums |
8e904d40571bbeaed5d3db8c9defba0362c7c6d9056d8358c0d16b5692352a14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for InfiniCore 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.