Topic

Alive2

All digests tagged Alive2

GPU Kernel Formal Verification thumbnail

· 34:39

GPU Kernel Formal Verification

This talk details the critical challenge of establishing trust in high-performance GPU kernels generated by AI. While AI tools like KForge can efficiently generate optimized kernels (e.g., replacing expensive divide operations with exponent/mantissa decomposition), the primary concern shifts from performance generation to correctness. The speaker introduces Tatwa, a tensor algebra equivalence checker, which uses formal verification (Z3 solvers) to reason about the semantic equivalence between a reference kernel (e.g., PyTorch model) and an AI-generated candidate kernel. The talk highlights that while testing is useful, only formal verification can detect subtle bugs, such as missing intermediate clamp operations or semantic discrepancies, by reasoning about the underlying mathematical primitives.

Key takeaways

  1. Limitations of Testing vs. Verification 18:13

    Testing is inherently sampling and can only prove the absence of bugs for tested inputs. Formal verification, however, reasons about the semantics and mathematical structure, allowing it to detect bugs (like missing clamps or incorrect scaling factors) that only manifest for specific, untested inputs.

  2. The Need for Semantic Equivalence Checking 22:10

    The core problem is ensuring that the optimized AI-generated kernel maintains the exact mathematical semantics of the original reference kernel. Tatwa achieves this by decomposing high-level operations (like `clamp` or `softmax`) into basic mathematical primitives for the Z3 solver to reason over.

  3. Bounded Verification Approach 27:10

    Due to computational complexity, the current approach uses bounded verification, limiting the summation or expansion of product terms (e.g., capping the reduction over k to a small value) to keep the problem solvable by solvers like Z3.

Watch on YouTube Full article

Lecture 116: GPU Kernel Formal Verification thumbnail

· 30:35

Lecture 116: GPU Kernel Formal Verification

The talk addresses the critical challenge of establishing trust in high-performance GPU kernels generated by AI systems. While AI-based generators (like KForge) can produce highly efficient kernels, their correctness cannot be guaranteed by traditional testing methods. The speaker introduces formal verification, using a tool called Tatwa, which reasons about the semantic equivalence between a reference program (e.g., PyTorch model) and an optimized candidate (e.g., Triton kernel). The process involves decomposing high-level operations into basic mathematical primitives and expanding tensor operations into scalar terms for analysis by solvers like Z3. The primary limitations discussed include scalability, handling low-level semantics (like hardware intrinsics), and reasoning about thread synchronization.

Key takeaways

  1. Limitations of Testing vs. Verification 3:40

    Testing is inherently sampling and can only confirm correctness for tested inputs. Formal verification, however, aims to prove that the two programs (baseline and candidate) cannot disagree for *any* possible input, addressing the fundamental question of semantic equivalence.

  2. Identifying Semantic Bugs (The Missing Clamp) 9:00

    A key example demonstrated a scenario where an optimized candidate failed to include an intermediate `clamp` operation required by the reference program. This bug was missed by testing/fuzzing but was successfully identified by the verifier because it reasoned about the mathematical semantics, not just the output for sampled inputs.

  3. Formal Verification Workflow 12:00

    The process involves taking the PyTorch/Triton programs, lowering them to mathematical primitives, and then expanding tensor operations (like matrix multiplication) into scalar terms to allow solvers (Z3) to reason about the computation at the element level.

  4. Bounded Verification Approach 19:10

    Due to scalability issues, the approach uses bounded verification, limiting the summation range (e.g., capping a summation over K to a small value) to make the problem solvable by current solvers, acknowledging this as a current limitation.

Watch on YouTube Full article