add-pallas-kernel

Implement, benchmark, and autotune TPU/GPU kernels with JAX Pallas.

1.2k|146|Updated Mar 22, 2024
One-click install
npx skills add https://github.com/marin-community/marin --skill add-pallas-kernel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-pallas-kernel
Source: https://github.com/marin-community/marin/tree/main/.agents/skills/add-pallas-kernel
Command: npx skills add https://github.com/marin-community/marin --skill add-pallas-kernel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the need to implement, modify, benchmark, or autotune high-performance kernels on TPUs and GPUs using JAX's Pallas experimental features, ensuring numerical safety and performance.

Core Features & Use Cases

  • Kernel Implementation: Develop both vanilla JAX and Pallas kernel implementations with consistent APIs.
  • Correctness & Performance Validation: Includes harnesses for value/gradient parity, numerics, and steady-state timing.
  • Autotuning: Automates the search for optimal block/tile sizes for specific hardware and shape regimes.
  • Use Case: When developing a new neural network layer that requires custom, high-performance computation on accelerators, this Skill provides the framework to build, test, and optimize the underlying kernel.

Quick Start

Implement a Pallas kernel for matrix multiplication with autotuned block sizes for TPU v5e.

Frequently Asked Questions about add-pallas-kernel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize custom kernels for TPU and GPU using JAX?

You can optimize TPU and GPU kernels using JAX's experimental Pallas library, which enables implementing, benchmarking, and autotuning high-performance computations. It enforces numerical safety and produces reference implementations with tuned tables for runtime selection.

What is the best way to autotune block sizes for Pallas kernels?

Autotuning Pallas kernels automates the search for optimal block and tile sizes for specific hardware and shape regimes. This generates tuned tables used for runtime selection, ensuring optimal performance across varying tensor shapes.

How do I validate correctness and performance when writing Pallas kernels?

Correctness and performance validation uses harnesses for value and gradient parity, numerics, and steady-state timing. This ensures your Pallas kernel matches the vanilla JAX implementation while achieving targeted acceleration performance.

Can I use Pallas to implement a new neural network layer that requires high-performance computation on accelerators?

Yes, Pallas is designed for developing new neural network layers requiring custom high-performance computation on accelerators. It provides the framework to build, test, and optimize the underlying kernel with consistent APIs.

Does this approach provide both vanilla JAX and Pallas kernel implementations?

Yes, the approach develops both vanilla JAX and Pallas kernel implementations with consistent APIs. This allows direct performance benchmarking and correctness comparisons between standard JAX operations and custom Pallas kernels.