Skip to content

fix(contracts): register 5 missing fused kernels in kernel-fusion-v1.yaml (closes #1858)#1861

Merged
noahgift merged 1 commit into
mainfrom
fix/kernel-fusion-drift-1858
May 22, 2026
Merged

fix(contracts): register 5 missing fused kernels in kernel-fusion-v1.yaml (closes #1858)#1861
noahgift merged 1 commit into
mainfrom
fix/kernel-fusion-drift-1858

Conversation

@noahgift

Copy link
Copy Markdown
Contributor

Summary

Closes #1858 by adding entries for the 5 fused kernels that the `enforcement.kernel_registry_complete` falsifier detected as drift.

The drift was masked until #1857 / #1860 repaired the broken `include_str!` paths — once the QA-002 falsifier could actually compile, it correctly flagged registry incompleteness.

Five entries added

ID Kernel Replaces Call site
FUSION-006 `FusedQKVKernel` Q/K/V GEMVs `crates/aprender-serve/src/cuda/generate.rs:267`
FUSION-007 `FusedGateUpKernel` Gate+Up GEMV + SwiGLU (FP32 path) `crates/aprender-serve/src/cuda/generate.rs:270`
FUSION-008 `FusedGemmBiasGeluKernel` GEMM + Bias + GELU `crates/aprender-gpu/src/memory/resident/ops/composite/linear_bias.rs:232`
FUSION-009 `FusedRmsNormQ4KGemvKernel` RMSNorm + Q4K GEMV `crates/aprender-serve/src/cuda/generate.rs:202`
FUSION-010 `FusedGateUpQ4KGemvKernel` Gate+Up Q4K GEMVs (shared input load) `crates/aprender-serve/src/cuda/generate.rs:273`

All 5 status ACTIVE. FUSION-007 vs FUSION-010 distinction documented inline (FP32-input path vs Q4K-input path).

Verification

```
$ pv validate contracts/kernel-fusion-v1.yaml
Contract is valid.

$ cargo test -p aprender-serve --test fusion_gate_contract_falsify --release
test result: ok. 5 passed; 0 failed ← was 4/5 with QA-002 failing

$ cargo test -p aprender-gpu --features cuda --lib --release falsify_fusion_001_every_fused_kernel_has_yaml_entry
test result: ok. 1 passed; 0 failed ← was failing on FusedQKVKernel
```

Both falsifier tests flip FAILED → PASS.

Test plan

  • `pv validate` clean
  • aprender-serve fusion_gate_contract_falsify: 5/5 PASS
  • aprender-gpu falsify_fusion_001: 1/1 PASS

Closes #1858.

🤖 Generated with Claude Code

…yaml (closes #1858)

The QA-002 falsifier (`enforcement.kernel_registry_complete`) detected
five fused kernels that exist in the codebase but lack `fusion_decisions`
entries. Now registered as FUSION-006..010, all status ACTIVE with
verified call sites.

## Why this matters

Without entries, these kernels are invisible to:
- `pv lint` / contract-coverage audits
- The BLOCKED-requires-benchmark rule (QA-003)
- The Poka-Yoke registry check (kernel_registry_complete)

The drift was previously masked because the falsifier tests couldn't
compile (broken `include_str!` paths repaired in #1857 / #1860).
Repairing those paths surfaced the drift in `fusion_gate_contract_falsify`
(aprender-serve) and `falsify_fusion_001_every_fused_kernel_has_yaml_entry`
(aprender-gpu).

## Five entries added

| ID         | Kernel                            | Replaces                          | Call site |
|------------|-----------------------------------|-----------------------------------|-----------|
| FUSION-006 | FusedQKVKernel                    | Q/K/V GEMVs                       | crates/aprender-serve/src/cuda/generate.rs:267 |
| FUSION-007 | FusedGateUpKernel                 | Gate+Up GEMV + SwiGLU (FP32 path) | crates/aprender-serve/src/cuda/generate.rs:270 |
| FUSION-008 | FusedGemmBiasGeluKernel           | GEMM + Bias + GELU                | crates/aprender-gpu/src/memory/resident/ops/composite/linear_bias.rs:232 |
| FUSION-009 | FusedRmsNormQ4KGemvKernel         | RMSNorm + Q4K GEMV                | crates/aprender-serve/src/cuda/generate.rs:202 |
| FUSION-010 | FusedGateUpQ4KGemvKernel          | Gate+Up Q4K GEMVs (shared input)  | crates/aprender-serve/src/cuda/generate.rs:273 |

Each kernel was confirmed via `grep -rn 'pub struct <Name>\b'` and
each call site verified by inspecting the dispatching file.

FUSION-007 vs FUSION-010 distinction documented inline:
- FUSION-007 = FP32-input gate+up+SwiGLU fused (FusedGateUpKernel)
- FUSION-010 = Q4K-input gate+up sharing input vector load
  (FusedGateUpQ4KGemvKernel); SwiGLU applied separately downstream.

## Verification

```
$ cargo run -p aprender-contracts-cli --bin pv -- validate \
    contracts/kernel-fusion-v1.yaml
Contract is valid.

$ cargo test -p aprender-serve --test fusion_gate_contract_falsify --release
test result: ok. 5 passed; 0 failed     ← was 4/5 with QA-002 failing

$ cargo test -p aprender-gpu --features cuda --lib --release \
    falsify_fusion_001_every_fused_kernel_has_yaml_entry
test result: ok. 1 passed; 0 failed     ← was failing on FusedQKVKernel
```

Closes #1858.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@noahgift noahgift enabled auto-merge (squash) May 22, 2026 05:30
@noahgift noahgift merged commit 0d8d52b into main May 22, 2026
11 checks passed
@noahgift noahgift deleted the fix/kernel-fusion-drift-1858 branch May 22, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contract drift: 5 fused kernels missing from kernel-fusion-v1.yaml

1 participant