Workgroup size is the number of threads grouped together for cooperative execution and synchronization within a single compute unit on a Neural Processing Unit (NPU) or GPU. This tunable parameter directly controls the granularity of parallelism and is critical for balancing occupancy (hardware utilization) with efficient memory coalescing and minimizing thread divergence. Selecting the optimal size is a primary target for auto-tuning systems.
Glossary
Workgroup Size

What is Workgroup Size?
A fundamental parameter for optimizing parallel execution on hardware accelerators.
The ideal workgroup size is determined by hardware constraints like register file and shared memory capacity, as well as the algorithm's data access patterns. A poorly chosen size can lead to resource contention or leave hardware underutilized, making it a key variable in bottleneck analysis. Performance engineers use kernel profilers to measure metrics like compute throughput and memory bandwidth to guide this selection within the configuration space.
Key Characteristics of Workgroup Size
Workgroup size is a fundamental tunable parameter that determines how threads are grouped for cooperative execution on a Neural Processing Unit. Optimizing it balances parallelism, resource utilization, and synchronization overhead.
Definition and Hardware Mapping
Workgroup size defines the number of threads that are bundled together for cooperative execution on a single Compute Unit (CU) or Streaming Multiprocessor (SM). This grouping is the fundamental unit of scheduling for the hardware's SIMD (Single Instruction, Multiple Data) or SIMT (Single Instruction, Multiple Thread) engine. The hardware executes threads in groups called warps (NVIDIA) or wavefronts (AMD), and the workgroup size must be a multiple of this hardware warp/wavefront size (typically 32 or 64) to avoid underutilization. The compiler and runtime map each workgroup to the hardware's execution resources, managing register allocation and shared memory per workgroup.
Impact on Occupancy and Latency Hiding
Occupancy is the ratio of resident workgroups to the maximum possible on a compute unit. A larger workgroup consumes more registers and shared memory, potentially reducing the number of concurrent workgroups and lowering occupancy. However, sufficient occupancy is critical for latency hiding: when some threads are stalled waiting for memory, the hardware can switch to executing instructions from other ready threads within other resident workgroups. The optimal workgroup size maximizes occupancy while providing enough threads to keep the hardware busy during memory access latencies. Profiling tools report occupancy metrics to guide this tuning.
Relationship to Memory Coalescing
Workgroup size and organization directly influence memory coalescing, a critical optimization for bandwidth. For global memory accesses, consecutive threads within a workgroup should access consecutive memory addresses. This pattern allows the memory controller to combine multiple accesses into a single, wide transaction. A poorly chosen workgroup size or thread indexing scheme can result in non-coalesced access, where each thread's request is issued separately, devastating effective bandwidth. The workgroup dimensions (e.g., (16, 16) for a 2D kernel) should align with the data access patterns of the algorithm to promote coalescing.
Synchronization and Shared Memory Scope
Threads within a workgroup can synchronize efficiently using barrier instructions (e.g., barrier(CLK_LOCAL_MEM_FENCE)). This allows for cooperative algorithms like parallel reductions or tiled matrix multiplication where threads load data into scratchpad memory (a.k.a. shared memory/LDS), synchronize, and then compute. The workgroup size defines the scope and size of this collaborative workspace. The amount of shared memory required per workgroup is a key constraint; exceeding the per-CU limit will prevent the workgroup from launching. Synchronization is only defined within a workgroup; communication between workgroups requires atomic operations on global memory.
Auto-Tuning and Parameter Search
Finding the optimal workgroup size is a prime target for auto-tuning due to complex interactions with hardware. The configuration space includes:
- Total size (e.g., 64, 128, 256, 512).
- Multi-dimensional layout (e.g.,
(8,8),(16,16),(32,4)).
Kernel tuners like CLTune or AutoKernel perform a parameter search, often guided by Bayesian optimization or genetic algorithms, to evaluate performance across this space. A performance model may predict optimal sizes based on kernel characteristics (compute vs. memory bound) and hardware limits (register count, shared memory). The search must respect hardware constraints (max workgroup size, which is often 1024 or higher).
Trade-offs and Design Heuristics
Choosing workgroup size involves balancing competing factors:
- Large Workgroups: Improve latency hiding within the group and can reduce global synchronization overhead. Risk higher register pressure, lowering occupancy.
- Small Workgroups: Increase potential occupancy and may fit more concurrent groups. Risk insufficient parallelism to hide memory latency and increased global scheduling overhead.
Common heuristics: Start with a size that is a multiple of the warp/wavefront size (e.g., 128 or 256). For memory-bound kernels, prioritize sizes that maximize occupancy. For compute-bound kernels, ensure the size provides enough independent instructions to keep all ALUs busy. The final choice is always validated with a kernel profiler measuring execution time and hardware performance counters.
How Workgroup Size Impacts Performance
Workgroup size is a fundamental tunable parameter that directly dictates how computational threads are mapped to the parallel hardware of a Neural Processing Unit (NPU) or GPU, with profound implications for latency, throughput, and resource efficiency.
Workgroup size defines the number of threads grouped for cooperative execution on a single compute unit. An optimal size maximizes hardware occupancy—the utilization of parallel execution units—and enables efficient intra-group synchronization and shared memory access. If too small, it underutilizes the processor, leaving arithmetic logic units (ALUs) idle. If too large, it can cause resource contention for registers or local memory, leading to pipeline stalls and reduced throughput. The ideal value is discovered through auto-tuning against hardware-specific constraints.
Performance is dictated by the interplay between workgroup size and the underlying memory hierarchy. Efficient sizes promote memory coalescing, where consecutive threads access consecutive addresses, maximizing memory bandwidth. Poorly chosen sizes can create memory access patterns that cause cache thrashing and high latency. Therefore, tuning is a critical step in bottleneck analysis, shifting a kernel from being memory-bound to compute-bound. Tools like a kernel profiler measure execution traces and performance counters to guide this optimization.
Workgroup Size Optimization Considerations
Key factors to evaluate when selecting the optimal workgroup size for a computational kernel on an NPU or GPU.
| Optimization Factor | Small Workgroup (e.g., 32-64 threads) | Medium Workgroup (e.g., 128-256 threads) | Large Workgroup (e.g., 512-1024 threads) |
|---|---|---|---|
Occupancy Potential | Low to Medium | High | High (but can be limited by register pressure) |
Thread Divergence Impact | High (significant serialization) | Medium | Low (cost amortized across many threads) |
Memory Coalescing Efficiency | Often Poor | Good | Excellent (enables wide, aligned transactions) |
Synchronization Overhead (barriers) | < 5 ns | 10-20 ns | 30-50 ns |
Register Pressure per Thread | Low | Medium | High (can force register spilling to slower memory) |
Shared Memory Usage per Block | Low | Medium | High (may exceed hardware limits) |
Latency Hiding Capability | Poor (few threads to mask stalls) | Good | Excellent (many threads to interleave) |
Kernel Launch Overhead | High (relative to work) | Medium | Low (amortized over large work) |
Practical Examples and Heuristics
Selecting the optimal workgroup size is a hardware-specific tuning problem. These cards provide concrete heuristics and examples for common NPU and GPU architectures.
Hardware-Specific Heuristics
Optimal workgroup size is dictated by the underlying hardware's execution units and memory architecture.
- NVIDIA GPU (CUDA): Aim for a multiple of 32 (the warp size). Common sizes are 128, 256, or 512 threads per block to maximize occupancy and hide latency.
- AMD GPU (ROCm): Target a multiple of 64 (the wavefront size). Sizes of 64, 128, or 256 are typical.
- Mobile/Edge NPUs (e.g., Qualcomm Hexagon): Often have smaller, fixed-size SIMD lanes (e.g., 128-bit). Workgroups may be smaller, such as 64 or 128, to fit constrained shared memory.
- Apple Silicon (GPU): Uses threadgroups aligned with its SIMD width. Sizes like 128 or 256 are efficient, but performance depends heavily on memory coalescing patterns.
Memory-Bound vs. Compute-Bound Kernels
The nature of the kernel's bottleneck influences the ideal workgroup size.
- Memory-Bound Kernels: Performance is limited by memory bandwidth. Use larger workgroups (e.g., 256-512) to increase the number of concurrent memory requests, improving latency hiding and enabling better memory coalescing.
- Compute-Bound Kernels: Performance is limited by ALU throughput. Use smaller workgroups (e.g., 64-128) that fit more concurrent groups on a core, increasing occupancy and utilization of arithmetic units.
- Rule of Thumb: Profile with a kernel profiler to identify the bottleneck, then adjust workgroup size accordingly.
Shared Memory and Register Pressure
Workgroup size directly impacts the consumption of on-chip, fast memory resources.
- Shared Memory (Local Data Share): Each workgroup allocates a static block of shared memory. Larger workgroups consume more, potentially limiting the number of concurrent groups that can reside on a compute unit.
- Register Pressure: Each thread requires architectural registers. Larger workgroups increase total register demand per group, which can reduce occupancy if registers are exhausted.
- Heuristic: Use the vendor's occupancy calculator or profiler to find the maximum workgroup size before register/spill pressure causes performance degradation.
Divergence and Control Flow
Workgroup size impacts the penalty for thread divergence.
- Within a warp (NVIDIA, 32 threads) or wavefront (AMD, 64 threads), divergent
if/elseor loop paths cause serialized execution. - Smaller workgroups may increase the probability that all threads in a warp follow the same path, reducing divergence.
- Heuristic: For kernels with complex, data-dependent control flow, experiment with workgroup sizes that are exact multiples of the hardware's warp/wavefront size to pack similar threads together.
Auto-Tuning in Practice
Auto-tuning is the definitive method for finding the optimal workgroup size. A typical search involves:
- Define the Configuration Space: Parameterize workgroup size (e.g.,
[32, 64, 128, 256, 512]). - Use a Search Strategy:
- Exhaustive Search: Test all combinations (feasible for 1-2 parameters).
- Bayesian Optimization: Models performance to intelligently sample the space.
- Genetic Algorithms: Evolve populations of configurations.
- Evaluate with a Benchmark: Run the kernel with each configuration, measuring execution time or compute throughput.
- Select the Optimum: Choose the configuration with the best performance metric.
Tools like CLTune, Kernel Tuner, or Ansor automate this process.
Example: Matrix Multiplication Tuning
For a tiled matrix multiplication kernel on an NVIDIA A100 GPU:
- Key Tunable:
BLOCK_SIZE(which defines the workgroup dimensions asBLOCK_SIZE x BLOCK_SIZE). - Typical Search Space:
BLOCK_SIZE∈[8, 16, 32, 64]. - Trade-offs:
BLOCK_SIZE=16: 256 threads/block. Good occupancy, but may not fully utilize shared memory bandwidth.BLOCK_SIZE=32: 1024 threads/block (max). Maximizes parallelism per block but increases register pressure, potentially lowering occupancy.
- Optimal Result: For large matrices,
BLOCK_SIZE=32often wins due to superior memory coalescing within tiles. Auto-tuning validates this againstBLOCK_SIZE=16.
This demonstrates that the theoretical maximum workgroup size is not always optimal.
Frequently Asked Questions
Essential questions and answers about workgroup size, a fundamental tunable parameter for optimizing parallel execution on Neural Processing Units (NPUs) and GPUs.
Workgroup size (also known as thread block size in CUDA or workgroup dimensions in OpenCL) defines the number of threads that are grouped together for cooperative execution and synchronization within a single compute unit on an NPU or GPU. It is a critical launch parameter specified by the programmer that determines how a parallel workload is partitioned across the hardware's execution resources. The optimal size balances occupancy (hardware utilization), efficient use of shared memory, and minimizes overhead from thread divergence and synchronization.
- Key Components: Typically defined as a 1D, 2D, or 3D configuration (e.g.,
(256, 1, 1)). - Hardware Limits: Constrained by the NPU/GPU architecture's maximum threads per compute unit and available registers.
- Performance Impact: Directly influences memory coalescing, cache behavior, and the ability to hide instruction and memory latency.
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
Workgroup size is a fundamental tunable parameter that interacts with other hardware and software characteristics. These related concepts define the landscape for performance optimization on NPUs and GPUs.
Occupancy
The ratio of active warps (on GPUs) or wavefronts (on some NPUs) to the maximum number that can be resident simultaneously on a streaming multiprocessor (SM) or compute unit. It measures the utilization of parallel execution resources.
- High occupancy ensures the hardware can hide instruction and memory latency by switching between many active thread groups.
- Workgroup size directly impacts occupancy, as it determines how many thread groups can be scheduled based on shared resource limits (registers, shared memory).
- Optimal performance is often found at a balance point, not necessarily maximum occupancy, as overly small workgroups increase scheduling overhead, while overly large ones reduce the number of concurrent groups.
Memory Coalescing
An optimization for memory access patterns where consecutive threads in a workgroup access consecutive memory addresses. This enables the memory controller to combine multiple accesses into a single, wide transaction.
- Coalescing is a hardware feature on NPUs/GPUs that dramatically increases effective memory bandwidth.
- Workgroup size and thread indexing must be designed to promote coalesced access. For example, if thread
iaccesses elementA[i]in a contiguous array, accesses are coalesced. - Poorly chosen workgroup sizes or memory access patterns can lead to uncoalesced accesses, where each thread triggers a separate memory transaction, severely bottlenecking performance.
Thread Divergence
A condition where threads within the same warp or wavefront (the smallest unit of parallel execution) follow different control flow paths due to conditional statements (e.g., if/else).
- Divergence causes serialization; the hardware must execute all divergent paths sequentially, disabling threads not on the current path.
- Workgroup organization influences divergence. If divergence correlates with thread ID within a warp, performance plummets. Algorithms should be designed for branch uniformity.
- Performance analysis tools measure branch efficiency to quantify the impact of divergence, which is a key consideration when tuning workgroup size and data partitioning.
Compute Bound vs. Memory Bound
The two primary performance regimes for a kernel, identifying the limiting factor for execution time.
- A kernel is compute-bound when its speed is limited by the arithmetic throughput of the NPU's cores. The ALUs are saturated, and increasing memory bandwidth yields little improvement.
- A kernel is memory-bound when its speed is limited by the memory subsystem's bandwidth or latency. The compute cores spend significant time stalled, waiting for data.
- Workgroup size tuning can shift the bottleneck. Larger workgroups may increase arithmetic intensity (ops/byte) moving towards compute-bound, while smaller groups may exacerbate memory pressure. Profiling tools use metrics like FLOPs/byte to diagnose the bound.
Configuration Space
The multidimensional search domain defined by all tunable parameters for a computational kernel. For NPU/GPU kernels, this space includes:
- Workgroup size (X, Y, Z dimensions)
- Tile sizes for loop blocking
- Loop unrolling factors
- Vectorization width
- Use of shared/local memory
The size of the configuration space grows exponentially with the number of parameters, making exhaustive search infeasible. Auto-tuners like Kernel Tuner or TVM's AutoTVM use heuristic or model-based search (e.g., Bayesian Optimization) to efficiently navigate this space and find a performance-optimal configuration for a specific hardware target.
Performance Model
An analytical or machine-learned representation that predicts the execution time or resource usage of a kernel based on its parameters, input data, and hardware characteristics.
- Analytical models might estimate cycles based on known latencies, bandwidth limits, and operation counts.
- Empirical models are built by profiling many kernel configurations and learning a surrogate function (e.g., a Gaussian Process).
- These models are central to efficient auto-tuning. Instead of exhaustively measuring every configuration, the model predicts performance, guiding the search toward promising regions of the configuration space, including optimal workgroup sizes.

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