Inferensys

Glossary

Tile Size Selection

Tile size selection is the process of choosing the dimensions of data blocks (tiles) used in loop tiling transformations to optimize for cache locality and parallelism in NPU kernels.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
NPU PERFORMANCE OPTIMIZATION

What is Tile Size Selection?

Tile size selection is a critical compiler optimization for neural processing units (NPUs) that determines the dimensions of data blocks processed in on-chip memory.

Tile size selection is the process of choosing the dimensions of data blocks (tiles) used in loop tiling transformations to optimize for cache locality and parallelism in NPU kernels. The selected tile dimensions directly control how data is partitioned and staged through the NPU's memory hierarchy, balancing the reuse of data in fast scratchpad memory or caches against the overhead of data movement and synchronization. An optimal tile size maximizes data reuse within a compute unit while fitting within limited on-chip memory resources.

This parameter is a primary target for auto-tuning frameworks, which systematically search the configuration space of possible tile dimensions to find the setup that yields peak compute throughput and minimizes memory bandwidth pressure. The selection is hardware-specific, depending on the NPU's cache sizes, memory bus width, and parallel execution capabilities. Poor tile size selection can leave the NPU memory-bound or underutilized, while optimal selection ensures computational units are fed data efficiently, directly impacting kernel execution latency and overall system performance.

PERFORMANCE OPTIMIZATION

Key Objectives of Tile Size Selection

Tile size selection is a critical compiler optimization that partitions loop iterations into smaller blocks to maximize data reuse and parallel execution. The primary objectives are to orchestrate data movement and computation for peak hardware efficiency.

01

Maximize Cache Locality

The foremost goal is to ensure the data accessed within a tile fits within the target cache level (e.g., L1, shared memory). This minimizes expensive accesses to slower, higher-level memory (e.g., global memory, DRAM).

  • Temporal Locality: Data loaded into the cache is reused multiple times by computations within the tile before being evicted.
  • Spatial Locality: The tile dimensions are chosen so that consecutive memory accesses are to adjacent addresses, enabling efficient memory coalescing.
  • Objective: Select a tile size where the working set (input, output, and intermediate data) does not exceed the cache capacity, preventing capacity misses.
02

Optimize Parallel Execution

Tile dimensions directly map to the parallel execution resources of an NPU, such as its cores, warps, or vector units. The size must align with hardware constraints to achieve full occupancy.

  • Workgroup Mapping: The tile is often assigned to a thread block or workgroup. The tile size (e.g., 128x128 elements) must be divisible by the workgroup size (e.g., 256 threads) to ensure balanced load distribution.
  • Reducing Synchronization: Larger tiles can reduce the frequency of global synchronization points between parallel units, but may increase register pressure.
  • Objective: Choose tile dimensions that saturate the NPU's parallel compute units without causing resource contention or thread divergence.
03

Balance Compute and Memory Bound

Tile size is a primary lever to shift a kernel from being memory-bound to compute-bound. The ideal size increases the arithmetic intensity (operations per byte of data moved) within the tile.

  • Memory-Bound Scenario: Small tiles result in high overhead from frequent data movement, leaving compute units idle.
  • Compute-Bound Scenario: Larger tiles increase the number of operations performed on data while it resides in fast cache, better utilizing the ALUs.
  • Objective: Find the tile size that maximizes the ratio of compute operations to memory transactions, moving the workload closer to the hardware's peak compute throughput.
04

Minimize Memory Traffic

Effective tiling reduces the total volume of data transferred between memory hierarchy levels. This directly lowers execution time and power consumption.

  • Redundant Load Elimination: By reusing data within a tile, the same memory address is not fetched multiple times from slow memory.
  • Granularity Optimization: Tile dimensions are chosen to match the NPU's burst transaction size or cache line length, ensuring full utilization of each memory transfer.
  • Objective: Select tile dimensions that minimize the total bytes read/written to global memory per computation, thereby reducing pressure on memory bandwidth.
05

Define a Searchable Configuration Space

Tile size parameters (e.g., TILE_M, TILE_N, TILE_K for matrix multiplication) form the core dimensions of the configuration space explored by an auto-tuner.

  • Discrete Parameters: Tile sizes are typically powers of two or multiples of hardware-specific dimensions (e.g., vector width), creating a finite but large search space.
  • Performance Modeling: The relationship between tile size and performance (latency, throughput) is complex and non-linear, making empirical auto-tuning or Bayesian optimization necessary.
  • Objective: Establish a logical, constrained parameter space that a kernel tuner can efficiently navigate to find the globally optimal configuration for a given NPU and kernel.
06

Manage On-Chip Memory Resources

Tile data must be staged in fast, but limited, on-chip memories like scratchpad SRAM or registers. Tile size selection is a direct trade-off between these resources.

  • Register File Pressure: Larger tiles or more complex operations per element may require more registers per thread, potentially reducing occupancy if the register file is exhausted.
  • Shared Memory Allocation: Tiles are often staged in software-managed cache (shared memory). The tile size must fit within the allocated shared memory budget per thread block.
  • Objective: Choose tile dimensions that optimally partition the available on-chip memory between registers and shared memory to avoid pipeline stalls due to resource limits.
OPTIMIZATION TRADEOFFS

Factors Influencing Tile Size Selection

Key hardware and algorithmic factors that determine the optimal tile dimensions for loop tiling in NPU kernels.

Factor / MetricSmall Tile SizeMedium Tile SizeLarge Tile Size

Cache Hit Rate (L1/L2)

High (fits entirely in cache)

Moderate (partial reuse)

Low (may exceed cache capacity)

Memory Bandwidth Pressure

Low (frequent reuse of loaded data)

Moderate

High (less reuse per load)

Parallelism (Occupancy)

High (many small tiles can be scheduled)

Balanced

Low (fewer, larger concurrent tiles)

Register Pressure per Thread

Low

Moderate

High (more data per thread)

Synchronization Overhead

High (more frequent barrier calls)

Moderate

Low

Data Transfer Overlap Potential

High (small transfers hide latency)

Moderate

Low (large transfers cause stalls)

Suitability for Problem

Irregular access patterns, small working sets

General-purpose, balanced workloads

Regular, compute-heavy kernels with large data reuse

TILE SIZE SELECTION

Frequently Asked Questions

Tile size selection is a critical loop transformation for optimizing data locality and parallelism on Neural Processing Units (NPUs). These questions address the core concepts, trade-offs, and methodologies involved in this key performance tuning process.

Tile size selection is the process of determining the optimal dimensions for sub-blocks of data (tiles) when applying loop tiling (or loop blocking) to a computational kernel, specifically to maximize performance on a Neural Processing Unit (NPU). The goal is to transform a large iteration space into smaller blocks that fit within the NPU's memory hierarchy—such as shared memory or local caches—to reduce expensive accesses to slower global memory. By carefully choosing the tile's height and width, you can dramatically improve cache locality, enable more efficient memory coalescing, and expose higher levels of parallelism for the NPU's execution units. This is a fundamental hardware-aware model optimization that directly impacts compute throughput and whether a kernel is compute bound or memory bound.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.