qualcomm/qai-appbuilder/qai-runner-skill
Claude Code and agent skill by qualcomm/qai-appbuilder
- community
Checking that the SKILL.md file is still in the repository.
AIPC, AI Porting Conversion. Tools and workflows for QAIRT/AIPC project setup, model conversion, inspection, operator patching, quantization, context-binary generation, and inference on Qualcomm platforms. Use this skill when creating or initializing an AIPC project, exporting AI models to ONNX, converting ONNX models to QNN or SNPE/DLC, converting models to FP16/FP32, patching unsupported operators, generating context binaries, or implementing inference for QNN/SNPE DLC.
Install
npx vskill@latest install qualcomm/qai-appbuilder/qai-runner-skillSKILL.md
The same SKILL.md was published earlier as qualcomm/qai-appbuilder/qai-runner-skill.
AIPC Toolkit
Trigger Phrases
Always activate this skill when the user mentions:
Conversion
- "convert model to qnn" / "qnn conversion" / "convert to qnn"
- "convert model to dlc" / "snpe conversion" / "convert to dlc"
- "convert onnx to qnn" / "convert onnx to snpe"
- "generate context binary" / "context bin" / "qnn context binary"
- "run qnn inference" / "snpe inference" / "qairt inference"
Operator Patching
- "operator not supported" / "unsupported operator"
- "patch operator" / "operator patch"
- "converter failed" / "conversion failed"
- "dry run failed" / "unsupported ops found"
Diagnostics
- "check htp" / "htp ready" / "htp check"
- "qai diagnose" / "environment check"
- "detect target soc" / "qairt devinfo" / "detect device info"
- "fastrpc memory map" / "err 1002" / "smmu" / "context binary too large"
- "split model" / "model split" / "split unet" / "context binary size"
Project Setup
- "create aipc project" / "init aipc project" / "setup aipc project"
- "qai init" / "qai setup"
- "multi-component" / "pipeline export" / "stable diffusion export" / "diffusers export"
- "export unet" / "export vae" / "export text encoder" / "sub-model export"
When to Use
Use this skill for Qualcomm QAIRT/QNN/SNPE model bring-up:
- Export model to ONNX
- Inspect ONNX I/O
- Convert to QNN or SNPE/DLC
- Quantize model
- Generate context binaries
- Run inference and validation
- Create QAIRT/AIPC project
Required Guardrails
- Run skill scripts from their original skill path unless explicitly noted
- Do not swap out QAIRT toolchains ad-hoc
QAIRT_SDK_ROOTmust be set- `QAIRT_TMP_DIR` — set when `/tmp` is full:
qnn-onnx-convertercopies external-data ONNX
weights to a temp directory before processing. On servers where /tmp is a small tmpfs, this fails with Failed to copy external data to the disk at: /tmp/... permission or space issue. Set QAIRT_TMP_DIR to a path with at least 2× the model's weight file size free: ``bash export QAIRT_TMP_DIR=/path/with/enough/space # e.g. /workspace/qairt_tmp ` Check before any converter call: df -h /tmp — if Use% is 100%, set QAIRT_TMP_DIR`.
- LONG-RUNNING JOBS — CRASH RESILIENCE (MANDATORY): Any operation expected to take >2 minutes
(conversion, context binary generation, inference) MUST be launched as a detached systemd service so it survives agent session crashes: ``bash systemd-run --user --unit=aipc-<task> --description="<desc>" bash /path/to/script.sh ``
- Write all output to a persistent log file (not stdout):
exec >> /path/to/job.log 2>&1 - Use idempotent skip-if-done guards:
if [ ! -f output.so ]; then ...; fi - Poll progress:
systemctl --user status aipc-<task>.service --no-pager+tail -20 log - NEVER use `nohup ... &` or `tmux` — both are killed when the agent session ends.
- HOST OOM FOR LARGE MODELS: Check
free -hand model size before conversion.
If available RAM < 2× model size, run qnn-onnx-converter and qnn-model-lib-generator on the remote target device instead. For an explicitly authorized deployment-feasibility test, the controller may set AIPC_DISABLE_MEMORY_GATE=1; in that case continue on the selected host, record the measured RAM/disk limits, and stop immediately on the first resource or converter failure. This override disables only the preflight routing gate; it does not permit ignoring an actual OOM, disk-full, or failed-command result. ``bash # rsync ONNX + external data to remote rsync -av onnx_models/ user@remote:work/onnx_models/ # run conversion remotely (x86 converter works on ARM Linux too) ssh user@remote "cd work && python qai_convert_fp.py --onnx onnx_models/model.onnx \ --host-arch x86_64-linux-clang --target-arch aarch64-ubuntu-gcc9.4 ..." # rsync .so / .bin / .cpp back rsync -av user@remote:work/qairt_output/ qairt_output/ ` Check: df -h /tmp and free -h` before any conversion; if RAM < 2× model size, use remote path.
- PYTHON VERSION ON ARM LINUX (QAIRT 2.44+): Ubuntu 24.04 ARM Linux requires Python 3.12.
The default aienv.sh venv may activate Python 3.10, which is incompatible and causes: NotImplementedError: On Linux aarch64, Python 3.12 is required. Got: 3.10 Always verify before running any converter or wrapper: ``bash python3 --version # must be 3.12+ $QAIRT_SDK_ROOT/bin/check-python-dependency --dry-run ` If Python 3.10 is active, create a 3.12 venv once. **Prefer uv** (faster, no pip needed): `bash curl -LsSf https://astral.sh/uv/install.sh | sh # install uv if not present uv venv ~/pyqairt312 --python 3.12 uv pip install --python ~/pyqairt312 \ diffusers transformers onnxruntime onnx Pillow numpy source ~/pyqairt312/bin/activate $QAIRT_SDK_ROOT/bin/check-python-dependency # installs QAIRT-specific deps ` Fallback (no uv): python3.12 -m venv ~/pyqairt312 --system-site-packages Use ~/pyqairt312/bin/python3` for all subsequent converter and inference calls.
- On Windows, do not rely on Python arch detection — use OS-native arch commands
- On ARM64 Windows,
platform.machine()returnsAMD64under x86_64 emulation.
Prefer the minimal QAIRT device probe script for SoC detection. Avoid CIM/WMI when possible. Model library target must match the Python process arch, not the CPU arch:
- x86_64 emulated Python →
windows-x86_64model DLL - ARM64 native Python →
windows-aarch64model DLL - ARM64X/CHPE hybrid QNN runtime DLLs (
arm64x-windows-msvc) bridge x86_64→native HTP - Cross-platform shell commands:
- Python scripts via
subprocess.run()— no shell quoting issues - Inference execution policy (MANDATORY):
- Run inference via
scripts/qaiwrapper only. - MANDATORY: You MUST use the
onnxwrapper.pyprovided within theaipc-toolkitskill (scripts/onnxwrapper.py). - PROHIBITED: NEVER use or fallback to the
onnxwrapper.pybundled with the QAIRT SDK orqai_appbuilderpackage (e.g., fromsite-packages/qai_appbuilder/onnxwrapper.py). The skill version contains critical patches for AIPC workflows. - Before any final inference run, perform wrapper artifact preflight:
- print which QNN artifact will be selected for
{ONNX_FILE} - remove or quarantine stale matched artifacts (platform-dependent:
<model>.onnx.dll.binon Windows,<model>.onnx.so.binon Linux) before deploying a new one - in context-binary mode, prefer ONNX-matching deployment filename:
<model>.onnx.dll.binon Windows,<model>.onnx.so.binon Linux - the wrapper discovers context binaries by appending platform-specific suffixes to the ONNX path; see
onnxwrapper.py:_find_qnn_model_file()for the full candidate list - If remote target execution is configured (for example
REMOTE_DEVICE_INFOis set in project config),
you MUST skip local host inference runs.
- In this mode, acceptance and validation MUST be executed on the remote target only.
- Local host inference is not allowed as an acceptance substitute.
- `qai_appbuilder` version mismatch: If
python qaisegfaults (exit 139) when loading
a context binary, the installed qai_appbuilder version is incompatible with the QAIRT SDK. Preferred fix — build from source against the exact QAIRT SDK version: ``bash git clone https://github.com/qualcomm/qai-appbuilder.git --recursive cd qai-appbuilder uv pip install --python <venv> wheel setuptools pybind11 build export QNN_SDK_ROOT=/path/to/qairt/<version> export QAI_TOOLCHAINS=aarch64-oe-linux-gcc11.2 # Linux ARM; see BUILD.md for other platforms python -m build -w uv pip install --python <venv> --force-reinstall dist/qai_appbuilder-*.whl ` The built wheel version matches the QAIRT SDK exactly (e.g. 2.47.0), resolving the segfault. See references/inference.md §qai-appbuilder-build for full steps and platform notes. **Fallback** (build not feasible): use qnn-net-run CLI directly (see references/inference.md` §qnn-net-run-fallback). Record in Issue Log.
- Do NOT call
snpe-net-run,qnn-net-run, or raw backend CLIs directly for final inference/validation. - Linux ARM runtime-libs pinning (MANDATORY for remote acceptance):
- Do not rely on implicit wrapper auto-resolution when multiple target toolchain lib folders exist.
- Explicitly set
QAI_QNN_LIBS_DIRto the intended runtime directory for deployment and prepend it toLD_LIBRARY_PATH. - Example:
``bash export QAI_QNN_LIBS_DIR="$QAIRT_SDK_ROOT/lib/aarch64-oe-linux-gcc11.2" export LD_LIBRARY_PATH="$QAI_QNN_LIBS_DIR:$LD_LIBRARY_PATH" export ADSP_LIBRARY_PATH="$QAIRT_SDK_ROOT/lib/hexagon-v${DSP_ARCH}/unsigned" ``
- If not pinned, mixed runtime loading may produce:
Failed to load skel, error: 4000Transport layer setup failed: 14001Failed to parse platform config: 14001Unsupported SoC model .../Invalid dsp arch ...- Avoid PowerShell inline pipelines and variables (
$_,$env:,!) in command arguments passed via-Command(e.g.,Where-Object { $_.LastWriteTime }gets expanded to{ .LastWriteTime }by the outer shell, breaking syntax). Always write PowerShell pipelines to a temporary.ps1file and execute it using the-Fileparameter, or use Python globbing/filesystem functions instead. - Console Encoding Guardrail: Local Windows shells can use non-UTF-8 encodings (such as
cp950orcp437), which frequently triggerUnicodeEncodeErrororUnicodeDecodeErrorwhen processing console outputs with special characters. Always enforce UTF-8 encoding/decoding where possible, and useerrors='replace'orerrors='ignore'in Python subprocess handling. - Escalation: If conversion still fails after export/patch/retry, do not silently replace model architecture. Record error + logs + ONNX snapshot → escalate with full bundle. For B3/B4/B7 criteria → open
references/operator_patching.md. - Dynamic-input ONNX: If ONNX has dynamic inputs, pass explicit shapes during conversion. See
references/qnn_conversion.md(QNN:--input-dim) orreferences/snpe_conversion.md(SNPE:--source-model-input-shape).
⚠️ CRITICAL: Context Binary & Model Library Architecture (DO NOT SKIP)
Context binary (.dll.bin / .so.bin):
- ARM Windows: PREFERRED for fixed-SoC deployment —
.dll(with ARM64X/CHPE runtime) also works. - ARM Linux: OPTIONAL —
.soworks directly. - The binary is SoC-specific and platform-independent — same
.binworks whether host is x86 or ARM64.
Model library (.dll / .so):
- Must match the host process architecture, not the target CPU.
- On ARM64 Windows, the QAIRT Python venv runs under x86_64 emulation → qnn-model-lib-generator tool compile with
-t windows-x86_64. - Compiling for
windows-aarch64produces a DLL that the x86_64 emulated Python cannot load.
Context binary generation runs on the HOST (x86), not on the target device.
- The host uses
qnn-context-binary-generatorwithsoc_id/dsp_archconfig to compile a binary for the target SoC. --modelinput must be a model library matching the host toolchain arch:windows-x86_64on Windows,x86_64-linux-clangon Linux.- The resulting
.binis then deployed to the target for inference. - Do not add target cross-compilation steps unless the user explicitly asks for target model-library build.
soc_idanddsp_archare mandatory — identify them from the target device before generation.- Do not use
/sys/devices/soc0/soc_id— that is the Linux kernel ID, not the QAIRTsoc_id. - For how to read
soc_id/dsp_archfrom the target and full generation commands → openreferences/host_context_binary_gen.md.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtools/skills/qai-runner-skill/SKILL.md
Popularity
- Repository stars
- 175
- Repository forks
- 31
- 7-day trend score
- 26
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/qualcomm/qai-appbuilder/qai-runner-skill)