Onboard Arch Precheck
Gate to prevent running wrong-arch onboard tests on a dev box. CI already
handles this (each onboard runner is labeled with its arch and only gets
matching jobs). Local hardware work bypasses that protection — this skill
restores it.
Why this exists (DO NOT STRIP — non-obvious failure-mode context)
This repo supports two onboard arches:
a2a3— Ascend 910 family (Ascend910B*= Atlas A2 silicon;
Ascend910_93* = Atlas A3 silicon; both build via dav-c220 and share
src/a2a3/)
a5— different silicon (Ascend950*family, builds viadav-c310,
src/a5/)
A given dev box has ONE of them. **Running tests built for the wrong arch
produces error cascades that look like genuine refactor bugs but aren't.**
Typical signatures:
| Error code | Surface | Meaning when arch-mismatched |
| ---------- | ------- | ---------------------------- |
| 507018 (ACL_ERROR_RT_AICPU_EXCEPTION) | aclrtSynchronizeStreamWithTimeout | AICPU kernel built against the wrong silicon contract faults at runtime; host sees a timeout / aicpu exception. |
| 507899 | rtStreamCreate / rtMalloc | Driver rejects an operation because the resource model doesn't match the silicon. |
Critical: BOTH codes can also be GENUINE bugs (real flaky tests,
real refactor regressions, real AICPU OS issues — see issue #822 for a
historical example). This is precisely what makes the misdiagnosis costly.
People chase a phantom regression for hours when the actual cause was
running the wrong --platform. This skill is cheap insurance against that.
When to invoke
Invoke check.sh BEFORE running ANY of these commands:
pytest ... --platform a2a3 ...(onboard)pytest ... --platform a5 ...(onboard)- The pytest command inside a
task-submitallocation using either onboard platform python test_*.py -p a2a3 .../-p a5 ...(standalone scene-test runner)- Any wrapper script that calls the above
Skip the check entirely when the platform string is a sim variant:
--platform a2a3sim--platform a5sim-p a2a3sim/-p a5sim
Sim variants build and run on host CPU only — they cannot mismatch
silicon by definition. Wasting the precheck on them adds latency.
How to use
# Single check; exit non-zero with a clear message on mismatch.
.claude/skills/onboard-arch-precheck/check.sh a2a3
# Embedded in a workflow:
.claude/skills/onboard-arch-precheck/check.sh "$ARCH" || exit 1
pytest ... --platform "$ARCH" ...
# Shared hosts: query and test within the same device allocation.
task-submit --device auto --device-num 1 --env ARCH --run \
'.claude/skills/onboard-arch-precheck/check.sh "$ARCH" && \
pytest ... --platform "$ARCH" --device "$TASK_DEVICE"'
check.sh exits:
0— silicon matches the requested arch, or the arch is a sim variant (pass through)2— silicon mismatch, with an explanation of the detected arch and the 507018 / 507899 failure modes printed to stderr1— unable to detect silicon (npu-smi missing, unrecognized chip, etc.)
Detection method
Same authoritative source as tools/cann-examples/query/ — the CANN
platform_config/<SoC>.ini Short_SoC_version field — but read via
shell so the precheck does not depend on the query binary being built
and never has to bind an ACL device (which would risk contending with
in-flight task-submit device locks).
Pipeline:
- Query for
Chip Nameand, when reported,NPU Name(~600 ms, no ACL
init or binding). A5 queries the first device in TASK_DEVICE (default 0
outside an allocation) via npu-smi info -t board -i <device>; its driver
rejects -c. A2/A3 query card 0 (npu-smi info -t board -i 0 -c 0,
then without -c 0 if that fails): npu-smi -i takes the NPU/card ID
while TASK_DEVICE is the task-submit logic ID, and the two differ on
A2/A3 multi-chip hosts, so card 0 — which always exists and suffices for
arch detection — is queried instead. Outside an allocation, the script
retains the task-submit --run "…" privilege retry where host policy
permits it. Shared hosts must use the allocated-job example above.
A call already inside a task allocation (TASKQUEUE_INSIDE is set) never
submits another task: it tries that platform's queries directly and retains failures.
Retries depend on exit status; only a successful query is parsed. If all
attempts fail, report their commands, exit statuses and output, then exit 1.
A successful but unusable board report is retained in detection errors.
- When
NPU Nameis absent or empty, acceptChip Nameonly as a full SoC
token matching an exact installed CANN INI filename after adding the
Ascend prefix if absent (e.g. 910B2C → Ascend910B2C.ini). The same
Short_SoC_version validation below still applies. Otherwise construct
the CANN SoC name per family:
Ascend910+B*NPU →Ascend910B3(or B1/B2/B4)Ascend910+ numeric NPU →Ascend910_9392(Atlas A3 SKUs)Ascend950+ NPU → look forAscend950DT_<NPU>orAscend950PR_<NPU>;
otherwise try Ascend950_<NPU>
Ascend950DT/Ascend950PR+ NPU →<Chip Name>_<NPU>directly
(e.g. Ascend950DT_9581), without adding another DT/PR suffix
- Read
Short_SoC_version=from
${ASCEND_HOME_PATH}/{aarch64,x86_64}-linux/data/platform_config/<SoC>.ini.
- Map
Short_SoC_version→ repo arch (must stay in sync with
docs/hardware/chip-architecture.md and query.cpp::arch_from_short_soc):
| Short_SoC_version | Repo arch |
| ------------------- | --------- |
| Ascend910B | a2a3 |
| Ascend910_93 | a2a3 |
| Ascend950 | a5 |
The skill never hardcodes "this box is a2a3" — every check
re-derives the answer from npu-smi + the CANN ini files. The result
is cached at ${TMPDIR:-/tmp}/onboard-arch-precheck-<uid>.cache (format
arch|soc|short_soc) with a 1-hour TTL so repeat invocations stay fast
(~5 ms). Mismatch errors include the specific SoC + Short_SoC_version
so you know exactly what silicon was detected (e.g.
Detected silicon: a2a3 (SoC=Ascend910_9392, Short_SoC_version=Ascend910_93)).
What this does NOT cover
- Multi-arch hosts: not a real configuration in this org's fleet. If
one ever exists, the cache will need to be keyed by npu-smi info -i N
per-device. A5 inspects the first granted device (device 0 outside an
allocation); A2/A3 inspect card 0.
- Sim builds: intentionally pass through — they're silicon-agnostic by
construction (src/{arch}/platform/sim/).
- vNPU / virtualization: irrelevant here — vNPU slicing happens within
one silicon family; the Ascend910 vs Ascend950 discrimination is
unaffected.
- CANN version drift: this is a HARDWARE-side check. If CANN is
installed for the wrong silicon, separate ASCEND_HOME_PATH /
ASCEND_DRIVER_PATH errors will trip during the actual build / run,
not here.
Related
- running-onboard.md — sister
rule that says all hardware work goes through task-submit. The
precheck and test run within the same device allocation on shared hosts.
the authoritative table for Short_SoC_version → repo arch. The
npu-smi Chip Name can contain a family name or a full SoC. Both paths
require an exact installed CANN INI and validate its Short_SoC_version
before admitting the requested architecture.