AKG CLI
⚠️ Deprecated: The CLI module (
akg_cli) is no longer actively maintained and will not receive future updates.
AKG CLI (akg_cli) is the command-line interface for AI Kernel Generator. This document focuses on the two most common flows:
- Start a Worker Service:
akg_cli worker --start - Generate an operator:
akg_cli op ...
How to get help:
akg_cli --help
akg_cli op --help
akg_cli worker --help
0. Installation
First, install akg_cli by running the following command in the aikg directory:
pip install -e .
1. Start a Worker Service
A Worker Service provides the backend runtime for kernel generation. Start it before running akg_cli op.
# Ascend 910B2
akg_cli worker --start --backend ascend --arch ascend910b2 --devices 0 --host 127.0.0.1 --port 9001
# CUDA A100: --backend cuda --arch a100
# akg_cli worker --start --backend cuda --arch a100 --devices 0 --host 127.0.0.1 --port 9001
Notes:
--backendsupportscudaorascend. If omitted, defaults toWORKER_BACKENDorcuda.--archdefaults toWORKER_ARCHora100.--devicesis a comma-separated list of local device IDs (e.g.,0or0,1,2). It must be non-empty, contain no duplicates, and have no negative numbers.--hostdefaults to0.0.0.0,--portdefaults to9001. For IPv6-only machines, use--host ::(dual-stack/IPv6 bind).
Stop the service when needed:
akg_cli worker --stop --port 9001
2. Generate an Operator
Use akg_cli op to start operator generation. The target config must be provided explicitly from CLI.
# Ascend 910B2
akg_cli op --framework torch --backend ascend --arch ascend910b2 --dsl triton_ascend --worker-url 127.0.0.1:9001
# CUDA A100: --backend cuda --arch a100 --dsl triton_cuda
# akg_cli op --framework torch --backend cuda --arch a100 --dsl triton_cuda --worker-url 127.0.0.1:9001
Optional parameters:
--intent "..."to provide requirements directly (skip interactive prompt).--worker-urlaccepts multiple worker addresses separated by commas. The CLI also accepts both--worker-urland--worker_url.- Choose exactly one of the following:
- Use
--worker-url/--worker_urlwhen you want to run with remote Worker Service(s). - Use
--deviceswhen you want to run on local devices. --devicesand--worker-url/--worker_urlare mutually exclusive.
- Use
--output-pathsets the base directory forsaved_verifications(default: current working directory whereakg_cliis started).--stream/--no-streamto enable/disable streaming output (default:--stream).--rag/--no-ragto enable/disable RAG (default:--no-rag).--yes/-yto auto-confirm all prompts.
Tip: for a mostly non-interactive run, use --intent "..." --yes (best-effort; the CLI may still ask for input in some cases).
Examples:
# Ascend 910B2 with intent
akg_cli op --framework torch --backend ascend --arch ascend910b2 --dsl triton_ascend --worker-url 127.0.0.1:9001 --intent "implement fused softmax kernel for input [batch, head, seq, dim]"
# CUDA A100 with intent
# akg_cli op --framework torch --backend cuda --arch a100 --dsl triton_cuda --worker-url 127.0.0.1:9001 --intent "implement fused softmax kernel for input [batch, head, seq, dim]"
Multiple workers example:
# Ascend 910B2 with multiple workers
akg_cli op --framework mindspore --backend ascend --arch ascend910b2 --dsl triton_ascend --worker-url 127.0.0.1:9001,127.0.0.1:9002
Local devices example (no worker URL needed):
# Ascend 910B2 with local devices
akg_cli op --framework torch --backend ascend --arch ascend910b2 --dsl triton_ascend --devices 0
# CUDA A100 with local devices
# akg_cli op --framework torch --backend cuda --arch a100 --dsl triton_cuda --devices 0
IPv6-only example (note the brackets):
akg_cli worker --start --host :: --port 9001
akg_cli op --framework torch --backend ascend --arch ascend910b2 --dsl triton_ascend --worker-url [::1]:9001
3. Interactive CLI Basics
akg_cli op runs an interactive prompt loop. You can iterate with multiple rounds of input and generation in the same session.
Input:
Enter: submit the current input.Ctrl+J: insert a newline (multi-line input is supported).
Exit / cancel:
- When idle, press
Ctrl+Cto exit. - While generating, press
Ctrl+Cto cancel the current round. You can then continue with the next round, or pressCtrl+Cagain to exit.
Panel:
F2: show/hide the information panel.- The panel is used to show the current task status, output/save path, and recent top implementation summaries.
History:
- Use the Up/Down arrows to browse input history.
- History is saved to
~/.akg_cli_history.