Repository navigation
contract: Hy4-flash's Metal kernels under gates 1 to 5 - #4022
Merged
Merged
Conversation
6 of 8 tasks
ashhart
force-pushed
the
hy4-contract
branch
2 times, most recently
from
November 20, 2026 13:11
f91e082 to
eed268c
Compare
ashhart
marked this pull request as ready for review
November 20, 2026 19:58
ashhart
force-pushed
the
hy4-contract
branch
from
November 20, 2026 20:05
eed268c to
2f60b2f
Compare
Every Metal pipeline Hy4-flash loads registers with the kernel contract, in eight groups (zig/tests/contract/metal_hy4_*.zig, records in zig/src/core/contract/hy4_*_records.zig), each with planted controls. The lane projection's 8-bit reg and inline-sums variants join the affine probe, and their launches record gate 5 at Hy4-flash's served widths. Twelve gate-1 findings on non-finite inputs are recorded as known, with entries of their own and lines in docs/kernel-contract.md.
ashhart
force-pushed
the
hy4-contract
branch
from
November 20, 2026 20:49
2f60b2f to
2de1f60
Compare
ashhart
added a commit
that referenced
this pull request
Nov 22, 2026
Unreleased: the five (#N) placeholders get their PR numbers, the two (#PR) duplicates go, #3192's line goes (#4427 replaced that behaviour on main and its line refs #3192), #3960 is named as the PR that landed #2799, and the penalty under --instruct-sampling card; ?token= Web addresses and pull's digest and size checks). Sixteen PRs merged 20-21 Nov with no line anywhere: a blank lines file replaced each PR's own line at landing. #4321 and #4322 go under Unreleased, the twelve that shipped in 1.3.3 under 1.3.3, and the two 1.3.1 lines that carried no PR number get #3941 and #4022. docs/environment.md: Flash Next checks 37 settings, and TF_GLM_INDEX_SPLIT (registered by #4510) gets its row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Registers Hy4-flash's Metal kernels with the kernel contract. Before: #3941 adds the family with none of its kernels registered. After: every Metal pipeline Hy4-flash loads runs through gates 1 to 5, each group with planted controls, and so do the lane projection variants #3941 adds to core (8-bit reg, inline group sums).
Building the records found one real bug. On Apple chips before the M5, Hy4-flash's row-window library failed to compile when a model loaded:
Rows.loadpairedrows.metalwith the legacy row core, whosetf_rp_rowstakes one template argument fewer. The fix (the wide row core on every chip, plain Metal, the M5's text unchanged) moved into #3941 as 5931932, so main never carries the broken load. This pull request changes only tests, contract records and docs.atc overlap --json: incomplete (limits:myPullRequestsLimit,pullFilesLimit). Against main it counts 135 changed files, most of them Hy4-flash on Metal: native family, serving with DFly2, compressed indexer #3941's. Seven open pull requests would conflict: lanes: hold a stream's draft depth against a noisy round; verify its probe (#3468) #4012, moss image: serve pictures on CUDA (encoder, decoder and host for #1573) #2281, EXL3 Flash Next: draft lane guard for offloaded experts (8/8) #1446, qwen27 metal: serve SenseNova-Loop-9B natively (BF16 and AWQ g128, 512K YaRN, images) #3859, metal nemotron: TF_KV_SHARE keeps prompt states as core pool pages (stacked on #1837) #1850, Flash Next on CUDA: TF_FLASHNEXT_FUSED_SPLIT runs wide split-K decode calls on the fused form #3475 and Qwen3.8-27B on Macs without tensor units: --mtp-drafts drafts with the checkpoint's MTP head, through the lane core's drafter as on CUDA #2464. The shared files areCHANGELOG.md,registry_joins.zig,native/metal.zig,tensorfold.zig,metal_main.zig,docs/kernel-contract.mdand Hy4-flash on Metal: native family, serving with DFly2, compressed indexer #3941's CUDA kernel lists. This pull request's own changes to those files are lines added to lists.Checks on this head
tf-kernel-contract --only "hy4":SUMMARY 76 kernels: 76 pass gates 1-4, 0 fail, 12 known findings; 51 controls: 51 red as planted, 0 missed; 0 limit problemstf-kernel-contract --only "Hy4-flash" --no-limits(the lane variants):SUMMARY 12 kernels: 12 pass gates 1-4, 0 fail, 0 known findingstf-kernel-contract --only "lane projection" --no-limits(every lane entry, after the probe's changes):SUMMARY 22 kernels: 22 pass gates 1-4, 0 fail, 0 known findingstf-kernel-contract --no-gates --offline DIR --only "hy4":PASS limits: 185 selected registered Metal launches against M1-M5, 0 problems, and the M1/M2 compiles have 0 limit problems.zig build test-kernel-contract: the launch map has 1,081 registered launches, 0 missing.test-kernel-contract test-nemotron-prefill-metal-sources test-environment-host test-gemma4-affine-host,-Dhip=true hip-host-test check-native-hip-host,dev-tools,check-native-cuda-host compile-cuda-tests -Dtarget=x86_64-linux-gnu,check-release-paths,-Dfixed-cpu test-gradient-serving test-qwen-serving-hostandtest-hy4-flash-hostall exit 0. The skill gate says SAFE TO PUSH.zig fmt --check build.zig zig,git diff --checkand gitleaks are clean.native/metal.ziglistshy_v4_flash), so its CUDA kernels have no served shapes to register.Receipt
Kernel contract
zig/tests/contract/metal_hy4_*.zig, records inzig/src/core/contract/hy4_*_records.zig):tf_hy4_index_keys,tf_hy4_index_groups,tf_hy4_group_scores,tf_hy4_recall_groups;tf_hy4_rotate,tf_hy4_cache_keys,tf_hy4_gate_values,tf_hy4_absorb_q,tf_hy4_expand_v, andtf_hy4_expand_v_gated(replaces expand then gate);tf_hy4_absorb_nax,tf_hy4_expand_gated_nax,tf_hy4_attend_nax, and the split pair with its combine;tf_hy4_route_select_rowsand_rank,tf_hy4_routed_sum,tf_add_bf16;tf_affine_experts_up/down_4/8, the tensor-unit gathers with Hy4's mapped experts and rounded SiLU, andtf_hy4_qkv_split,tf_hy4_active_experts,tf_hy4_group_pairs;tf_hy4_rows_r2_q4/q8,tf_hy4_argmax, Engram's lookup, gather and apply, andtf_embed_b4/b8_g64at hidden 3,072;docs/kernel-contract.mdlists them under "Known findings".tf_hy4_attend_chunksandtf_hy4_attend_scored: a -Inf score at a chunk's first key gives NaN.tf_hy4_attend_nax: a non-finite value at a masked key its tile reads gives NaN; a row whose every score is NaN gives 0.tf_hy4_route_select_rank: a NaN key ranks 0 and races the best expert for the first pick.tf_hy4_group_scores: a NaN dot scores 0.tf_hy4_engram_apply: a NaN dot is dropped bymax.tf_affine_experts_up_4/8, affine_mm'sam_swigluat q4 and q8) drops a NaN.attention_sink.metalandindexpool.metal: nothing on Metal loads them.rows.metaltemplates: no loader builds them.tf_hy4_expand_v,tf_hy4_gate_values, the split attention pair, the one-launch collapse,tf_hy4_ihc_add,tf_hy4_route_select_rows,tf_add_bf16.Checklist