TL;DR
Tenon is a unified programming framework for Processing-In-Memory (PIM) that decouples workload logic from hardware-specific details. By modeling PIM targets as nested grids and using a novel layout algebra, it automatically optimizes data placement to minimize expensive data movement, achieving significant speedups across diverse commercial and academic PIM architectures.
What Problem Does This Paper Address?
Processing-In-Memory (PIM) is a promising solution for memory-bound workloads like Large Language Model (LLM) inference because it places compute units directly inside or next to memory. However, the PIM landscape is currently a "Wild West" of fragmented programming stacks. Every vendor—from Samsung to UPMEM—uses different instruction sets, memory hierarchies, and programming models.
The biggest challenge is data layout. In PIM, compute units are physically tied to specific memory partitions. If the data isn't in the right place, the unit can't process it without a slow, explicit transfer (often involving the host CPU). Existing compilers are mostly device-specific and lack a unified way to represent and optimize this tight coupling between data location and computation.
Methods
Tenon introduces a "write-once, retarget-anywhere" approach for PIM by separating the compilation process into three distinct parts:
- Workload: A high-level description of the computation (e.g., a matrix-vector multiply).
- Target: A model of the hardware as nested grids of compute and storage units connected by legal data paths.
- Cost: An analytical performance model that prices operations and data transfers.
The core innovation is the generalization of $\mathbb{F}_2$ linear layout algebra (originally used in GPU compilers) to PIM. Tenon represents data layouts as binary matrices, allowing it to mathematically reason about complex patterns like bank interleaving and operand replication. It uses a bounded search algorithm to automatically find the "minimum-movement" layout for a given workload and hardware target.
Datasets
The authors evaluated Tenon across a diverse set of PIM backends:
- Commercial Hardware/Simulators: Samsung HBM-PIM, SK Hynix AiM, UPMEM, GSI Gemini-I, and GSI Gemini-II.
- Academic Architecture: AttAcc, a state-of-the-art HBM3-based PIM design.
- Benchmarks: A suite of kernels including GEMV, matrix multiplication, histograms, and k-means, as well as end-to-end GPT-13B decoding.
Key Insights and Ideas
- Layout is Legality: In PIM, data layout isn't just a performance hint; it's a constraint. Tenon treats "ownership" (which unit owns which data) as a first-class citizen, ensuring that generated code is physically executable on the target.
- Algebraic Portability: By using $\mathbb{F}_2$ matrices, Tenon can describe vastly different hardware—from bit-serial SRAM processors to RISC-core DRAM—using the same mathematical framework.
- Virtual Architecture Exploration: Because the cost model is decoupled, Tenon can act as a "virtual backend." Architects can tweak hardware parameters (like buffer sizes) in the target description and immediately see the predicted performance impact on real workloads without building a full simulator.
Key Results
Tenon demonstrates that a unified framework can match or beat expert-tuned, device-specific code:
- Commercial Speedups: Across five commercial backends, Tenon achieved geometric-mean speedups of up to 1.20x, with individual kernels seeing gains up to 3.65x over vendor and expert baselines.
- LLM Performance: For end-to-end GPT-13B decoding on the AttAcc architecture, Tenon-compiled workloads were 1.2–1.3% faster than those from DCC, a state-of-the-art PIM-specific compiler.
- Productivity: Tenon reduced the lines of code needed to describe workloads by 66% compared to DCC and compiled 2.2x faster on the same hardware.
Limitations and Future Work
- Analytical Model Validation: While fast, Tenon's analytical cost models can miss low-level hardware effects (like row-buffer conflicts) and require careful calibration against real hardware.
- Power-of-Two Constraints: The current layout algebra is optimized for dimensions that are powers of two. Irregular shapes require padding, which can introduce some overhead.
- Numerical Precision: Automatically reordering operations for better layout can change the order of floating-point additions, potentially affecting numerical results. Tenon currently requires explicit user permission for such reassociations.
- General Compiler Features: The prototype lacks some standard compiler features like general register allocation and "spilling" (moving data to memory when registers are full), which are left for future work.
Summary updated