AI Accelerators

1. Custom Kernel Integration

Custom kernels can optimize for new architectures, allow developing new algorithms and can improve hardware perf on existing kernels on specific workloads.

For example, flash-attention is a custom kernel that optimizes the attention mechanism in transformers with:

  1. Operator fusion.
  2. Block tiling: seperate , , into small tiles (blocks), caching tiles in SRAM.
  3. Re-computation: recompute attention matrix and in the backward pass.

FOR CHEAT SHEET, COPY THE ALGORITHM FROM THE SLIDES!!

To actually create the kernel, either:

  1. Write a CUDA Kernel with a Python binding.
  2. Use Triton (DSL for DL) to write a kernel in Python and compile it to CUDA.

2. AI Hardware

GPUs are a mature ecosystem supporting massive parallelism, but are not energy efficient and have instruction decode overhead. A domain specific architecture (DSA) may be better suited for AI, trading generality for efficiency.

2.1 Systolic Arrays

Systolic arrays use a grid of Processing Elements (PEs) that compute and pass data to neighbors in a rhythmic fashion.

For example, a dot product of two vectors and can be computed using a systolic array by feeding elements of and into the array, where each PE computes partial sums and passes them along until the final result is obtained.

invert small screen center

This reduces wiring complexity, improves scalability and can reuse data.

Each PE has registers for input , weight , and intermediate accumulating result . It has one multiplier and one adder.

2.1.1 Streaming Dataflow

Streamflow is a systolic array that uses streaming dataflow to reduce memory bandwidth requirements. There are different strategies for GEMM:

2.1.2 Convolution

We can either:

2.2 Scale up vs Scale out

2.3 Reconfigurable Architecture

Reconfigurable Architecture adapts hardware structure for specific tasks. Can be fine-grained (bit-level / gate-level, longer runtime cost), or coarse-grained (block-level changes, shorter runtime cost). Tradeoffs between flexibility and performance.

2.3.1 FPGA

Field Programmable Gate Array (FPGA): Fine-grained reconfigurable hardware that can be programmed to perform specific tasks. Consists of configurable logic blocks (CLB) containing:

FPGAs have on-chip SRAM and a programmable interconnect linking CLBs, DSPs (Digital Signal Processors - high speed multiply-accumulate units), and I/O blocks.

Allow bit-level control and have a flexible interconnect - allowing programmers to build custom datapaths with irregular parallelism and application-specific pipelines.

However, FPGAs have limited resources and lower clock speeds, so are well suited only for low-latency or edge applications.

2.3.2 CGRA

Coarse-Grained Reconfigurable Architecture (CGRA): Consists of PEs that can be reconfigured at a coarser level than FPGAs. Each PE can perform more complex operations and has its own local memory. CGRAs are well-suited for data-parallel applications and can achieve high performance with lower power consumption compared to traditional processors.

Back to Home