Scratchpad memory (SPM) is a small, high-speed, software-managed on-chip memory block in hardware accelerators like NPUs and GPUs, designed for explicit, low-latency storage of frequently accessed data. Unlike hardware-managed caches, which use automatic policies to decide what data to keep, SPM requires the programmer or compiler to explicitly control data movement, eliminating the performance unpredictability of cache misses. This makes it a deterministic, high-bandwidth resource for critical data structures, kernels, and intermediate results in compute-intensive workloads.
Glossary
Scratchpad Memory

What is Scratchpad Memory?
A definition of scratchpad memory (SPM), a software-managed on-chip memory used in hardware accelerators like Neural Processing Units (NPUs).
In the memory hierarchy of an NPU, SPM sits closer to the compute units than global DRAM (like HBM) but is distinct from registers. Its software-managed nature allows for optimal data locality exploitation through compiler techniques like tiling and double buffering, where one data block is processed while another is loaded. This explicit control is essential for achieving peak memory bandwidth and predictable low latency, which are fundamental for accelerating AI inference and training on specialized silicon.
Key Characteristics of Scratchpad Memory
Scratchpad memory is a small, high-speed, software-managed on-chip memory used in accelerators like NPUs for explicit, low-latency storage of frequently accessed data, as opposed to hardware-managed caches.
Software-Managed vs. Hardware-Managed
The defining characteristic of scratchpad memory is its software-managed nature. Unlike a traditional hardware cache, which uses automatic algorithms (e.g., LRU) to decide what data to keep, the programmer or compiler must explicitly control all data movement into and out of the scratchpad. This shifts the complexity of optimizing data locality from hardware logic to software, providing deterministic performance at the cost of increased programming effort. The compiler must analyze data access patterns and insert explicit DMA (Direct Memory Access) transfers or load/store instructions to populate the scratchpad.
Deterministic Low Latency
Because scratchpad memory is on-chip SRAM and access is controlled explicitly by software, it offers predictable, low-latency access. There is no concept of a cache miss; if data is in the scratchpad, the access time is constant. This determinism is critical for real-time and latency-sensitive applications common in NPU workloads, such as processing individual layers of a neural network within a strict inference deadline. The absence of tag-checking and replacement logic found in caches further simplifies the memory controller, reducing access energy and cycle time.
Explicit Data Movement & Tiling
Effective use of scratchpad memory relies on the algorithmic technique of tiling (or blocking). Large tensors or matrices are broken into smaller tiles that fit within the scratchpad's limited capacity. A computational kernel loads a tile into the scratchpad, performs all necessary operations on it, writes results back to main memory (e.g., HBM), and then loads the next tile. This pattern maximizes data reuse within the fast on-chip memory, minimizing costly accesses to slower off-chip DRAM. The compiler's ability to automate this tiling and data movement is a key optimization in frameworks like MLIR and TVM.
Architectural Placement & Hierarchy
In a typical NPU memory hierarchy, scratchpad memory sits between processor registers and large, off-chip High Bandwidth Memory (HBM). It is often organized as Shared Memory or Local Data Memory that is accessible by a group of processing cores (e.g., a tensor core array). This placement makes it ideal for storing:
- Activation maps between neural network layers
- Weight tiles for convolutional or linear layers
- Intermediate results from partial computations Its size is a critical hardware design trade-off, typically ranging from hundreds of kilobytes to a few megabytes per core cluster.
Contrast with Hardware Caches
Scratchpad memory and hardware caches represent two different solutions to the memory wall problem.
Scratchpad (SPM):
- Pro: Deterministic latency, no miss penalty, higher energy efficiency, simpler hardware.
- Con: Requires complex compiler analysis and explicit data management.
Hardware Cache:
- Pro: Transparent to software, adapts to dynamic access patterns.
- Con: Non-deterministic performance due to misses, complex tag RAM and logic, coherence overhead in multi-core systems.
Many modern NPUs and GPUs use a hybrid approach, featuring both small L1 caches for instruction/ scalar data and larger software-managed scratchpads (e.g., Shared Memory in CUDA) for bulk tensor data.
Compiler & Runtime Role
Leveraging scratchpad memory is a primary task for NPU compilers (e.g., for Google's TPU, NVIDIA's TensorRT, or Intel's OpenVINO). The compiler's job includes:
- Memory Allocation: Statically assigning regions of the scratchpad to specific tensors or tiles.
- Scheduling DMA Transfers: Overlapping data movement with computation to hide latency.
- Coalescing Accesses: Ensuring memory transactions are efficient for the underlying DRAM and interconnect (e.g., CXL).
- Kernel Fusion: Merging operations to keep intermediate results in the scratchpad, avoiding round trips to main memory. This compiler-driven optimization is a cornerstone of achieving peak FLOPS/Watt on AI accelerators.
How Scratchpad Memory Works in an NPU
Scratchpad memory is a foundational component of neural processing unit (NPU) architecture, designed for explicit, low-latency data management critical to AI workload acceleration.
Scratchpad memory is a small, high-speed, software-managed on-chip memory block within a neural processing unit (NPU) used for the explicit, low-latency storage of frequently accessed data, such as activation tensors and weight tiles. Unlike hardware-managed caches that operate transparently, the scratchpad requires the compiler or programmer to explicitly orchestrate data movement, enabling deterministic performance and eliminating unpredictable cache miss penalties. This explicit control is essential for maximizing data reuse and minimizing costly accesses to slower High Bandwidth Memory (HBM) or system DRAM.
The compiler statically analyzes the neural network computational graph to schedule precise load and store operations between global memory and the scratchpad, a process known as tiling or blocking. This software-defined approach allows for optimal spatial locality and temporal locality exploitation within a kernel's execution. By managing the scratchpad explicitly, NPUs achieve higher memory bandwidth utilization and lower effective memory latency for core matrix operations, which is the primary bottleneck in accelerating deep learning inference and training workloads.
Scratchpad Memory vs. Hardware Cache
A technical comparison of two fundamental on-chip memory architectures used in Neural Processing Units (NPUs) and other accelerators, highlighting their distinct management models, performance characteristics, and design trade-offs.
| Feature / Characteristic | Scratchpad Memory (SPM) | Hardware-Managed Cache |
|---|---|---|
Management Model | Explicitly managed by software (compiler/programmer) | Implicitly managed by hardware controller |
Allocation & Placement | Deterministic; data location and lifetime are explicitly defined in code | Heuristic-based; uses replacement policies (e.g., LRU) and prefetchers |
Access Latency | Predictable, constant low latency (single-cycle access typical) | Variable latency; depends on hit/miss status and coherence state |
Access Guarantees | Guaranteed on-chip access if correctly programmed | No guarantee; data may be evicted, leading to off-chip misses |
Hardware Overhead | Lower (simple SRAM arrays, address decoders, no tags/state logic) | Higher (tag arrays, state bits, replacement logic, coherence directories) |
Bandwidth Utilization | Optimal when programmed correctly; enables precise data orchestration | Can suffer from bandwidth waste due to prefetch inaccuracies or conflict misses |
Coherence Handling | Software's responsibility; requires explicit synchronization (e.g., barriers) | Hardware-enforced (e.g., MESI protocol); automatic for shared data |
Best Use Case | Streaming, regular access patterns; kernels with known data lifetimes | Irregular, data-dependent access patterns; general-purpose workloads |
Compiler Complexity | Higher; requires sophisticated analysis for data placement & movement | Lower; hardware abstracts complexity from the compiler |
Power Efficiency | Higher for predictable workloads (no tag checks, minimal control logic) | Lower for predictable workloads (overhead of tag checks and miss handling) |
Primary Use Cases in AI Acceleration
Scratchpad memory (SPM) is a small, high-speed, software-managed on-chip memory used in accelerators like NPUs for explicit, low-latency storage of frequently accessed data, as opposed to hardware-managed caches. Its primary use cases center on predictable, high-performance data orchestration for compute-intensive AI workloads.
Frequently Asked Questions
Scratchpad memory is a critical, software-managed component in hardware accelerators like Neural Processing Units (NPUs). This FAQ addresses common technical questions about its purpose, operation, and advantages over traditional caches.
Scratchpad memory is a small, high-speed, software-managed on-chip memory explicitly controlled by the programmer or compiler to store frequently accessed data for low-latency access, as opposed to a hardware-managed cache. In the context of Neural Processing Unit (NPU) acceleration, it is a key component of the memory hierarchy, sitting closer to the compute units than global DRAM (like High Bandwidth Memory (HBM)) to minimize the memory wall problem. Its management is a core aspect of Memory Hierarchy Management for maximizing data throughput and computational efficiency.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Scratchpad memory is a key component within the memory hierarchy of NPUs and other accelerators. Understanding its relationship to these adjacent concepts is critical for systems engineers and hardware architects designing high-performance compute systems.
Cache Memory
Cache memory is a small, high-speed hardware-managed memory that transparently stores copies of frequently accessed data from main memory. Unlike a scratchpad, its management (what data is stored and when it is evicted) is handled automatically by hardware logic based on access patterns.
- Key Difference: Caches use hardware-managed policies (e.g., LRU) for data placement and replacement, while scratchpads rely on explicit software directives.
- Trade-off: Caches simplify programming but introduce unpredictability (cache misses) and hardware overhead (tag storage, coherence logic). Scratchpads offer deterministic, low-latency access at the cost of requiring explicit data movement in software.
High Bandwidth Memory (HBM)
High Bandwidth Memory (HBM) is a 3D-stacked DRAM technology that provides extremely high data transfer rates in a compact physical footprint. It typically serves as the high-capacity, off-chip global memory for accelerators like NPUs and GPUs.
- Relationship to Scratchpad: The scratchpad (SRAM) is the small, on-chip, ultra-fast memory. HBM is the large, off-chip, high-bandwidth pool. Efficient NPU programming involves strategically staging data from HBM into the scratchpad for computation, minimizing costly off-chip accesses.
- Performance Impact: The bandwidth of the HBM interface (often hundreds of GB/s to over 1 TB/s) is a critical bottleneck. Scratchpad usage directly reduces pressure on this interface.
Direct Memory Access (DMA)
Direct Memory Access (DMA) is a hardware mechanism that allows peripherals or accelerators to transfer data directly between memory regions (e.g., from system RAM to accelerator memory) without continuous CPU intervention.
- Critical for Scratchpads: DMA engines are essential for efficiently prefetching data from slow, high-latency global memory (like HBM) into the software-managed scratchpad before a compute kernel executes. This allows computation and data transfer to overlap.
- Use Case: A compiler or programmer schedules a DMA transfer to load the next tile of a matrix into the scratchpad while the NPU cores are still computing on the current tile.
Memory Latency
Memory latency is the time delay between a request for data and its availability. It is a primary performance limiter, known as the "memory wall."
- Scratchpad's Role: Scratchpad memory exists specifically to mitigate latency. Access times are typically on the order of tens of cycles, compared to hundreds of cycles for off-chip HBM or DDR memory.
- Determinism: Because software explicitly controls scratchpad contents, latency is predictable and consistent, unlike caches where a cache miss introduces highly variable and severe penalties.
Spatial & Temporal Locality
Spatial locality (using nearby data) and temporal locality (re-using the same data) are fundamental program behavior principles that guide memory hierarchy design.
- Scratchpad Exploitation: Effective use of a scratchpad requires the programmer or compiler to explicitly identify and exploit these localities. Data with high temporal locality (e.g., weights reused across many operations) is a prime candidate for scratchpad residency.
- Contrast with Cache: Caches implicitly try to exploit locality based on past access patterns. Scratchpads require explicit algorithmic design (e.g., tiling/blocking) to structure computations to maximize locality within the limited on-chip memory.
Unified Memory
Unified memory (e.g., CUDA Unified Memory, AMD's ROCm HIP) is a programming model that presents a single, coherent address space shared by the CPU and an accelerator (GPU/NPU). The system hardware and software automatically manage data movement.
- Philosophical Opposite: Unified memory aims for programming simplicity by hiding the memory hierarchy. Scratchpad programming embraces complexity for control, requiring the programmer to explicitly manage data placement.
- Performance Consideration: While unified memory simplifies code, it often relies on page fault-driven migration, which can introduce latency spikes. For peak performance on NPUs, explicit scratchpad management with DMA is usually required.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us