Repository navigation
borealis: add packed vec4 compute alternates for certified copy, im2col, fadd, and 4D pad kernels - #687
Conversation
|
Thanks. I read the matchers and the dispatch selectors at 4300093. Most of this is safe in the sense that a miss falls back to the original shader. My main concern is how narrow some of the matching is.
Assisted-by: LLM (Claude:Opus 5.5) |
4300093 to
d74cf83
Compare
|
Addressed all review points in Round 2 (
Verified clean with Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Clean-room Apple M5 Pro ( 1. M5 Pro Bug Found in R2 (
|
|
Pushed R3 (
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
d74cf83 to
7f319bd
Compare
Clean-room M5 Pro (
|
| Check | Result |
|---|---|
meson test --suite asahi (-Db_ndebug=true) |
156/156 OK, 0 fail (hk_identity_copy4 OK 0.01s, hk_pack OK 1.14s) |
gb-gaussian (checked, 2 repeats/case) |
12/12 PASS (bit-exact vs CPU reference) |
Vulkan CTS 1.4.7.1 (/tmp/cts-mega12.txt) |
522/678 pass / 0 fail / 0 warn / 156 unsupported |
Geekbench 6.7.1 Vulkan spills (sp>0) & dmesg |
0 spills / 0 new dmesg lines / 0 GPU faults |
Interleaved A/B/C -> C/B/A Geekbench 6.7.1 Vulkan (busy/iter median ms, HK_FRAME_ANATOMY_TS=all)
| Workload | Base f3016978f09e (A1 / A2 / avg) |
#687 R3 7f319bd7a50f (B1 / B2 / avg) |
Delta | Speedup |
|---|---|---|---|---|
| Background Blur | 7.402 / 7.419 (7.410) |
7.279 / 7.295 (7.287) |
-1.67% | 1.017x |
| Face Detection | 10.980 / 10.942 (10.961) |
10.452 / 10.451 (10.451) |
-4.65% | 1.049x |
| Horizon Detection | 6.142 / 6.156 (6.149) |
6.164 / 6.181 (6.172) |
+0.38% | 0.996x |
| Edge Detection | 4.939 / 4.980 (4.960) |
4.939 / 4.933 (4.936) |
-0.47% | 1.005x |
| Gaussian Blur | 6.978 / 6.991 (6.984) |
6.992 / 6.981 (6.986) |
+0.03% | 1.000x |
| Feature Matching | 15.964 / 15.683 (15.823) |
15.695 / 15.991 (15.843) |
+0.12% | 0.999x |
| Stereo Matching* | 7.079 / 7.400 (7.239) |
7.394 / 7.402 (7.398) |
+2.19%* | 0.979x* |
| Particle Physics | 24.663 / 24.629 (24.646) |
24.623 / 24.639 (24.631) |
-0.06% | 1.001x |
| 8-WL Geomean | — | — | -0.54% | 1.0054x |
*Stereo Matching exhibits its standard bimodal ~7.08 / ~7.40 ms scheduling mode across Base (7.079 / 7.400) and #688 R3 (7.086 / 7.395).
M5 Pro (AGX3C) signoff: GREEN (-4.65% Face Detection, -1.67% Background Blur, 156/156 release unit tests, 12/12 gb-gaussian, 0 CTS fails, 0 spills, 0 GPU faults).
Assisted-by: LLM (Antigravity:Gemini 4 Neon)
7f319bd to
0f86446
Compare
|
Rebased onto |
satchlj
left a comment
There was a problem hiding this comment.
Verdict at 0f864464e973
APPROVE — The certified packed-vec4 compute alternate matchers, NIR rewriters, runtime eligibility/alignment/alias certification, and binary cache serialization are sound, and both the full asahi test suite and live Apple M5 Max Borealis Vulkan compute CTS pass with zero GPU faults.
Blockers
None.
Checked
- Code audit (
hk_nir_copy_identity4.c,hk_cmd_dispatch.c,hk_descriptor_set.c,hk_buffer.c,hk_cmd_buffer.c,hk_shader.c,agx_compile.c):- Descriptor backing tracking (
storage_backings) is allocated onagx_chip_native_or_m5(), maintained/cleared acrosshk_UpdateDescriptorSets,hk_UpdateDescriptorSetWithTemplate(viawrite_buffer_desc/write_buffer_desc_array), andhk_copy_descriptor_sets, and freed inhk_descriptor_set_destroy. - Buffer eligibility (
hk_buffer.c:591) excludesmem->replay_vaandAGX_BO_SHARED | AGX_BO_SHAREABLE | AGX_BO_HOST_PTR. - Push-constant tracking (
identity_copy4_push_mask) covers the 64-byteHK_COMPUTE_OPT_PUSH_BYTESwindow outside meta ops, resets onhk_reset_cmd_bufferandhk_cmd_invalidate_compute_state, and preserves state around meta ops. - Dispatch certification (
hk_cmd_dispatch.c:2955-3321) enforcesagx_chip_native_or_m5(),!cmd->in_meta, primary command buffer, direct CDM mode, zero base group, no invocation stat query (conditional rendering already converts to indirect), exact local workgroup size, positive/mod-4 bounds with overflow and unsigned wraparound guards (__builtin_mul_overflow,INT32_MAX,0x3fffffff), 16-byte VA+offset alignment and backing-size checks (rejecting descriptor buffers and push descriptors and matchingdesc->root.sets[set]), and BO+VA disjointness (allow_inplaceonly for exact same handle+BO offset+VA onLINEAR_COPY/LINEAR_FADD, never onLINEAR_OFFSET/PAD4/IM2COL). - Shader lifecycle and binary cache (
hk_shader.c): cleans upidentity_copy4andim2col_vec4on both error and destroy paths, skipsshader_binary_cachewhenhas_identity_copy4is set, bumps the shader binary version (45 -> 46), and validates bounds and local-size invariants during explicit field-by-field deserialization.
- Descriptor backing tracking (
- Unit & drm-shim tests:
hk_identity_copy4andhk_execution_allowance(2/2PASS) and fullmeson test --suite asahi(non-layout:259/259PASS,0fail). - Live hardware verification (Apple M5 Max
G17C B1, Linux 7.3, Borealis,MESA_SHADER_CACHE_DISABLE=1):407/420Vulkan CTS compute/SSBO cases PASS (0fail,13not supported),0GPU faults indmesg. - Untested scope: Live end-to-end execution of real-world ML/compute workloads that trigger the certified packed-
vec4copy/im2col/fadd/4D-pad dispatch fast path at runtime (covered here by unit tests intest-hk-identity-copy4.crather than an external ML benchmark),asahi_layout_tests, and non-M5 (AGX2/AGX3B/AGX3D) hardware.
Evidence
- Targeted unit tests (
build-b19):asahi - mesa:hk_execution_allowance:OK(0.00s)asahi - mesa:hk_identity_copy4:OK(0.01s)
- Full
meson test --suite asahi(excludingasahi_layout_tests):259/259 OK,0 Fail. - Live Vulkan CTS on Apple M5 Max (
G17C B1), Linux 7.3, Borealis (MESA_SHADER_CACHE_DISABLE=1):dEQP-VK.compute.pipeline.basic.*:80/81PASS (0fail,1not supported)dEQP-VK.compute.pipeline.indirect_dispatch.gen_in_compute.*:24/36PASS (0fail,12not supported)dEQP-VK.ssbo.layout.single_basic_type.std430.*:303/303PASS (0fail)- Kernel
dmesg:0GPU faults.
0f86446 to
0b79f9e
Compare
|
Rebased cleanly onto
Ready for the exact-head M4 |
0b79f9e to
9574085
Compare
|
Rebased cleanly onto
|
…ol, fadd, and 4D pad kernels Signed-off-by: Diljit Singh <hey@djdev.me>
9574085 to
ba75e6a
Compare
|
Rebased cleanly onto current |
|
Exact-head M4 (
|
Verdict at
|
Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
Add general NIR pattern matchers and packed
vec4compute shader alternates in Borealis (hk) for four certified compute kernel families on native AGX3 GPUs (agx_chip_native_agx3()):vec4copy / offset-copy / elementwisefadd(hk_nir_copy_identity4.c):1x1stride-1im2col, andfaddkernels at NIR level (hk_nir_copy_identity4()).128x1x1vec4alternate transferring 4 coalescedvec4s (64 B) per lane with a workgroup-uniform interior fast path and safe tail path.hk_select_identity_copy4()) validates push-constant shapes, 16-byte alignment, backing-buffer bounds, and interval disjointness/in-place safety before selecting the alternate.vec4generalim2col(hk_nir_im2col_vec4()):im2colkernels with channel count divisible by 4 and builds a32x4x1vec4alternate selected when runtime push constants and backing buffers satisfy 16-byte alignment and non-overlap.vec44D tensor pad (build_pad4d_vec4()):N,H,W,C) and builds a64x2x12D-gridvec4alternate with anout_n == 1uniform fast path avoidingudiv/umodon the outer dimension.hk_buffer/hk_descriptor_setfor exact runtime aliasing/bounds checks.hk_shader.c, bypassinghk_shader_binary_cachewhen alternates are attached so alternate blobs are never silently dropped.src/asahi/vulkan/tests/test-hk-identity-copy4.c.Verification
DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD:PR head is cleanFEDORA-CIon exact head430009309aa79f9a8b8aa42dd42e35ecfe0291e6:157/0PASS (Ok 157 Fail 0, includinghk_identity_copy4)G17P B1) verification (combined Wave 2G1e747f6cb01, kernel7.3.0-41.fc44.aurora.aarch64,PMU=30 00 -> 30 00,kfaults=0,avc=0):PAD4(50d93768):2.688 -> 2.197 ms(-18.3%)im2col_vec4(5a400c45):2.069 -> 1.333 ms(-35.6%)27,740 Pass / 0 Fail / 0 Recov