SuperAPI AI Directory

external-cannbot-ops-aiss-tiling-solver

General & other

View repository

Updated 10-15 17:19

About this skill

AISS-TilingSolver

Guide users to use the AISS-TilingSolver CLI tool to automatically solve for the optimal tiling parameters for Ascend C operators.

Core principle: guide users to use the TilingSolver CLI tool. Do not manually calculate tiling yourself, and do not give generic GPU tiling advice. The only task is to help users correctly invoke the tool and interpret its output.

Obtain the tool

# aarch64
curl -LO https://gitcode.com/HIT1920/TilingSolver/releases/download/latest/tiling_solver_aarch64
curl -LO https://gitcode.com/HIT1920/TilingSolver/releases/download/latest/platform_info_aarch64
mv tiling_solver_aarch64 tiling_solver
mv platform_info_aarch64 platform_info
x86_64

curl -LO https://gitcode.com/HIT1920/TilingSolver/releases/download/latest/tiling_solver_x86_64 curl -LO https://gitcode.com/HIT1920/TilingSolver/releases/download/latest/platform_info_x86_64 mv tiling_solver_x86_64 tiling_solver mv platform_info_x86_64 platform_info

chmod +x tiling_solver platform_info


- `tiling_solver` — tiling 参数求解器(aarch64 / x86_64)
- `platform_info` — 硬件平台信息采集工具(aarch64 / x86_64)
- `platform_info` — 硬件平台信息采集工具

环境要求:aarch64 或 x86_64 架构,glibc ≥ 2.38。

## 完整使用流程

### 第一步:采集硬件平台参数

```bash
./platform_info

The output includes information such as the number of cores, cache capacities at each level, and bandwidth.

Step 2: Construct the input JSON

Fill the hardware parameters collected in Step 1 into the JSON as custom platform parameters. Also fill in the operator shape and data type.

Step 3: Run the solver

./tiling_solver input.json

The output is JSON, containing the optimal tiling parameters.

Operator type

MatMul (matrix multiplication)

{
  "type": "matmul",
  "M": 1024,
  "N": 640,
  "K": 256,
  "a_dtype": "float16",
  "b_dtype": "float16",
  "c_dtype": "float32",
  "has_bias": false,
  "aic_core_num": 20,
  "aiv_core_num": 40,
  "L0A_SIZE": 65536,
  "L0B_SIZE": 65536,
  "L0C_SIZE": 131072,
  "L1_SIZE": 524032,
  "UB_SIZE": 196352,
  "L2_SIZE": 176160768,
  "HBM_SIZE": 34359738368,
  "BT_SIZE": 1024,
  "FP_SIZE": 2048,
  "L0A_ALIGN": 512,
  "L0B_ALIGN": 512,
  "L0C_ALIGN": 64,
  "UB_ALIGN": 32,
  "FRACTAL_DIM": 16,
  "DATABLOCK_SIZE": 32,
  "L2_BW": 110,
  "HBM_BW": 32,
  "L1_TO_L0_BW": 64,
  "FIXPIPE_BW": 64,
  "GM_TRANSFER_GRANULARITY": 512,
  "MIN_TRANSFER_FOR_PEAK_BW": 16384,
  "CUBE_OPS_PER_CYCLE": 4096,
  "optimize": true,
  "timeout_ms": 10000
}

Required fields:type, M, N, K. Others have default values. Hardware parameters are obtained from platform_info and then filled in.

Output fields:base_m, base_n, base_k(inner loop block size),single_core_m, single_core_n(M/N range per core),step_ka, step_kb(K-direction L1 buffer step),depth_a1, depth_b1(L1 buffer depth),db_l0a, db_l0b, db_l0c(L0 double buffering, 1 or 2),iterate_order(0=M first, 1=N first),solve_time_ms, status。

Vector (element-wise operator, such as Add / LeakyReLU)

{
  "type": "vector",
  "total_length": 16384,
  "dtype": "float16",
  "num_inputs": 2,
  "num_outputs": 1,
  "temp_buf_dtypes": ["float32"],
  "UB_SIZE": 196352,
  "aiv_core_num": 40,
  "optimize": true
}

Required fields:type, total_length. Others have default values. It is also recommended to obtain hardware parameters from platform_info .

Output fields:block_dim(number of AI Core cores),tile_num(number of tiles per core),buf_num(number of buffers),tile_length(number of elements per tile),solve_time_ms, status。

Optional parameters

Parameter Type Default value Description
optimize bool true Whether to use the cost model to search for the optimal solution
timeout_ms int 10000 Z3 solving timeout (milliseconds)

Supported data types:float16, float32, bfloat16, int8, int16, int32, int64, uint8, uint16, uint32, uint64, bool. Aliases are also supported: fp16, fp32, bf16, i8, i16, i32, i64, u8, u16, u32, u64, half, float, double。

Result interpretation

  • status: "ok" — solving succeeded, and the parameters can be directly applied to the operator implementation
  • status: "unsat" — the constraints are unsatisfiable; the current shape/dtype has no feasible solution on this hardware
  • status: "timeout" — Z3 solving timed out; try increasing timeout_ms or disabling optimize
  • status: "error" — invalid input parameters or an internal exception

Troubleshooting

  • "cannot execute binary file" — downloaded a binary for the wrong architecture; confirm the platform with uname -m (aarch64 / x86_64), and download the corresponding version
  • "GLIBC_2.38 not found" — the glibc version is too old; upgrade the system or use a container
  • Returns unsat — try reducing the dimensions to confirm whether a feasible solution exists, then gradually scale up
  • Returns timeout — increase timeout_ms(for example, 30000), or set "optimize": false to obtain a feasible solution

Assist the user

  1. If the operator type and dimensions are not provided, proactively ask
  2. Recommend that the user first run platform_info to obtain hardware parameters
  3. Integrate the platform_info output into the tiling JSON
  4. Construct the complete JSON file and run tiling_solver
  5. Interpret the output and explain the impact of each field on operator performance
  6. When an error occurs, diagnose based on status and provide repair suggestions