wai-quantum: the tensor-engine member's kernel compiles for a device #302

Merged
dcharlot merged 1 commit from wai/tensor-engine-device-compile into main 2026-10-17 16:52:17 -04:00
Owner

What

The tensor-engine member's helper compiled its kernel for the simulator only. On a device, every test of the member failed at the first request with failed to resolve name 'nl.ndarray'.

  • Cause. The kernel was defined inside main(), with the kernel toolchain imported there. The simulator runs the kernel as Python, so the names resolved. Compiling for a device traces the kernel's source and resolves its names in the kernel's module, where they were absent.
  • Fix. The kernel now sits at module level. main() still imports the toolchain after the target is chosen (the toolchain reads the target at import), but binds it as module globals.
  • Second fix, found on the way. Compiling for a device runs the toolchain's compiler from PATH. The interpreter the member is given (WAI_QUANTUM_TENSOR_ENGINE_PYTHON) need not be on PATH, and in that case the compiler is launched as None. For a device target, the helper now puts its interpreter's directory first on PATH.

Checked

  • Off the device, with the toolchain's own compiler at the pinned version, in a clean container:
    • before the fix, the error reproduces exactly;
    • after it, the kernel compiles for the device target, and the request stops only where execution needs the device's runtime.
  • The simulator path answers a request as before.
  • The repository checks pass: comparative prose, vanity metrics, public names, lockfiles, workflow concurrency, tests in CI, orphan sources.

The run on the device itself follows this PR.

🤖 Generated with Claude Code

## What The tensor-engine member's helper compiled its kernel for the simulator only. On a device, every test of the member failed at the first request with `failed to resolve name 'nl.ndarray'`. - **Cause.** The kernel was defined inside `main()`, with the kernel toolchain imported there. The simulator runs the kernel as Python, so the names resolved. Compiling for a device traces the kernel's source and resolves its names in the kernel's module, where they were absent. - **Fix.** The kernel now sits at module level. `main()` still imports the toolchain after the target is chosen (the toolchain reads the target at import), but binds it as module globals. - **Second fix, found on the way.** Compiling for a device runs the toolchain's compiler from `PATH`. The interpreter the member is given (`WAI_QUANTUM_TENSOR_ENGINE_PYTHON`) need not be on `PATH`, and in that case the compiler is launched as `None`. For a device target, the helper now puts its interpreter's directory first on `PATH`. ## Checked - Off the device, with the toolchain's own compiler at the pinned version, in a clean container: - before the fix, the error reproduces exactly; - after it, the kernel compiles for the device target, and the request stops only where execution needs the device's runtime. - The simulator path answers a request as before. - The repository checks pass: comparative prose, vanity metrics, public names, lockfiles, workflow concurrency, tests in CI, orphan sources. The run on the device itself follows this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wai-quantum: the tensor-engine member's kernel compiles for a device
All checks were successful
wai-quantum matrix-extension member / member · matrix extension, emulated (aarch64 Linux) (pull_request) Successful in 19s
wai-quantum neural-processor member / member · neural processor (macos) (pull_request) Successful in 6m22s
wai-quantum OpenCL member / member · OpenCL GPU (macos) (pull_request) Successful in 35s
wai-quantum matrix-extension member / member · matrix extension absent (macos) (pull_request) Successful in 10s
wai-quantum portable tensor program / tensor program · Metal and the arm64 CPU (macos) (pull_request) Successful in 15s
wai-quantum CPU vector units / member · vector unit absent (macos) (pull_request) Successful in 16s
wai-quantum WebGPU member / member · Metal (macos) (pull_request) Successful in 5m41s
wai-quantum tensor-engine member / member · tensor engine, the kernel toolchain's simulator (linux) (pull_request) Successful in 7m45s
wai-quantum portable tensor program / tensor program · CPU, mutants, GPU builds (pull_request) Successful in 30s
wai-quantum CPU vector units / member · vector unit, rvv 1024-bit (riscv64, emulated) (pull_request) Successful in 16s
wai-quantum CPU vector units / member · vector unit, sve 128-bit (aarch64, emulated) (pull_request) Successful in 25s
wai-quantum WebGPU member / member · browser WebGPU (macos) (pull_request) Successful in 2m4s
wai-quantum CPU vector units / member · vector unit, rvv 128-bit (riscv64, emulated) (pull_request) Successful in 12s
wai-quantum CPU vector units / member · vector unit, sve 2048-bit (aarch64, emulated) (pull_request) Successful in 9s
wai-quantum CPU vector units / member · vector unit, avx2 (x86_64 silicon) (pull_request) Successful in 12s
wai-quantum signal processor / processor and member · signal processor, emulated (pull_request) Successful in 12m57s
wai-quantum CPU vector units / member · vector unit, sve 512-bit (aarch64, emulated) (pull_request) Successful in 11s
wai-quantum WebGPU member / member · software Vulkan (linux) (pull_request) Successful in 2m7s
wai-quantum WebGPU member / shader checks · browser build · wasip2 inertness · MSRV (pull_request) Successful in 3m21s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 3m25s
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Successful in 17s
WAI conformance / delivery telemetry · CMCD and CMSD against an independent library (pull_request) Successful in 14s
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Successful in 35s
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Successful in 1m13s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 5m30s
wai-quantum HIP member / member · HIP absent (linux-arm64) (pull_request) Successful in 44s
wai-quantum npu-cores member / member · npu-cores absent (linux-arm64) (pull_request) Successful in 45s
wai-quantum tensor-engine member / member · tensor engine absent (linux-arm64) (pull_request) Successful in 27s
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Successful in 16m53s
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Successful in 20m7s
adc86f0175
The helper defined its kernel inside main() and imported the kernel
toolchain there. The simulator runs the kernel as Python and found the
names; compiling for a device traces the kernel's source and resolves its
names in the kernel's module, so it found none ("failed to resolve name
'nl.ndarray'") and every device test failed at the first request. The
kernel now sits at module level; main() binds the toolchain as module
globals after the target is chosen.

Compiling for a device also runs the toolchain's compiler from PATH, and
the interpreter the member is given need not be on it, so the helper puts
that interpreter's directory first on PATH for a device target.

Checked off the device with the toolchain's compiler: the kernel compiles
for the device target; the simulator path is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!302
No description provided.