Repository navigation
contract: an XPU limits backend (gate 5, the .ze_info reader, planted controls) - #2155
Conversation
|
Thanks @tolewis. This is PR 1 as agreed on #2080, and the GRF check is exactly what we asked for: a record can't claim 128 GRF for a zebin built at 256, pinned by a host test and by your planted run. Keeping the steps behind |
3cbd915 to
8ef0f6f
Compare
An XPU launch record holds the symbol, image, work-group size, static SLM bytes, sub-group size and GRF mode, with what ocloc made of it for the BMG-G31 card. Gate 5 checks each launch against the card row, which follows the device's own clinfo read, and refuses a stale record, from the zebin's .ze_info, so it runs with no GPU. The six Qwen3.8-27B glue kernels register first, and six planted controls must stay red, including sub-group 32 at 256 GRF and the sub-group 8 the device does not run. The device runner, gates 1 to 4, comes in a second pull request.
8ef0f6f to
b5898b7
Compare
|
Thank you @tolewis. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
|
Thanks @tolewis! This is in TensorFold 1.2.4, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.4 |
What this changes
XPU kernels can now register with the kernel contract, and gate 5 (launch limits) checks them with no GPU. This PR adds an XPU launch record, a BMG-G31 (Arc Pro B70) device row, a reader for the
.ze_infosection of an ocloc zebin, gate 5 with planted controls, andxpu-kernel-contract-limits. The Level Zero runner with gates 1 to 4 is the second PR.9d6f1d78).atc overlap --json: not run, because the CLI needsghauth that I do not use here. By hand: 40 open pull requests changedocs/kernel-contract.md,zig/src/core/contract.zigorzig/build/xpu.zig. I rangit merge-treeof each one against main and against this head. This head adds no conflicting file to any of them. Every conflict it has is one that the pull request already has with main. This head merges into current main cleanly.As you asked on #2080, the audit checks each record's GRF mode against the zebin. ocloc writes
grf_countfor every kernel: 128 by default, and 256 with-cl-intel-256-GRF-per-thread.xpu_limits.grfBuiltfails a record whose mode is not that value, and also a kernel that has nogrf_count. A record cannot claim 128 for an image built at 256.zig/src/core/contract/xpu_limits.zigfits,stale,grfBuilt,xpuzig/src/core/contract/xpu_records.zigzig/src/core/contract/zebin.zig.ze_infosection of a zebin ELF, and a fixture builder for the testszig/src/core/contract/zeinfo.zigzig/tests/xpu/contract_limits.ziglimits DIRauditzig/tests/xpu/contract_main.zigtf-xpu-kernel-contract [limits DIR]zig/build/xpu_contract.zigtf-xpu-kernel-contract,xpu-kernel-contract-objects,xpu-kernel-contract-limitszig/kernels/xpu/contract_controls.clzig/kernels/xpu/contract_controls_sg8.clzig/src/core/contract.zigzig/build/xpu.zig-Dxpu-contractdocs/kernel-contract.mdThe build wiring is in
zig/build/xpu.zig, notbuild.zig. Zig 0.17 refuses a secondb.optionwith the same name, andxpu.zigalready declaresoclocandxpu-device.The device row follows the card's own read: work-group 1024, work-item sizes 1024/1024/1024, SLM 131072 bytes a work-group, sub-groups 16 and 32, 8 EUs a Xe-core, 8 threads an EU. The limit of 512 work-items at 256 GRF comes from the compile (
eu_thread_count: 4at 256 GRF, 8 at 128) and from Intel's oneAPI GPU optimization guide, "Small Register Mode vs. Large Register Mode".Checks on this head
3cbd915dpython3 tools/zig/lean_check.py, on the base and on this head: 425 and 425, the same lines; 0 new findings.zig build test-kernel-contract: 189 passed, 0 failed, 0 skipped.zig build test: 6964 tests, 6904 passed, 1 failed, 59 skipped. The failure is the listener test that binds the IPv6 loopback, which this machine does not have. It also fails on main on the same machine.zig fmt --check zig/: clean.Receipt
3cbd915don main9d6f1d78, Linux, Zig 0.17.0, ocloc 26.35.39758.10. ocloc runs on an Intel Arc Pro B70 host, as a CPU compile only. No checkpoint is needed.tf-xpu-kernel-contract limits DIRon the Zig host.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a. No kernel, weight or inference path changes.tools/bench_openai.py: n/a, for the same reason.The zebins, from the repository root of this head:
On an Intel GPU host with both tools,
zig build -Dxpu-contract=true xpu-kernel-contract-limits -Docloc=... -Dxpu-device=bmgdoes the same in one step.tf-xpu-kernel-contract limits <dir>, exit 0 (theRECORDlines are left out):The GRF check, planted: I set the
add_rmsnorm_decrecord to 128 GRF, rebuilt, and ran the audit on the same zebins. Exit 1:The two problems are the GRF mode and the stored usage, which no longer matches the image. The host test
a record cannot claim 128 GRF for a zebin built at 256inzeinfo.zigdoes the same on fixture bytes, with no ocloc.ocloc refuses to build the sub-group 8 control for bmg, so that record has
compiled = falseand the audit checks its declaration only:Kernel contract, only when a GPU kernel is new or changed
add_rmsnorm,add_rmsnorm_dec,gated_norm,swiglu,argmaxandembedfrom the Qwen3.8-27B glue image, for gate 5. None replaces a kernel. These kernels do not change.SUMMARYline and exit status: the runner and itsSUMMARYline are PR 2. The limits audit endsPASS xpu-kernel-contract-limits: every registered launch fits bmg-g31, every record current, every control red, exit 0. The records-only run endsPASS xpu-kernel-contract: every registered XPU launch fits bmg-g31, every control red, exit 0.Checklist