The COO (Coordinate Format) is a sparse tensor storage scheme that explicitly stores a list of (row, column, value) tuples for every non-zero element. It is defined by three parallel arrays: row_indices, col_indices, and values. This simple, flexible format is easy to construct and modify, making it a common intermediate representation for sparse operations. However, its memory overhead for storing explicit indices can be high, and its performance for operations like Sparse Matrix Multiplication (SpMM) is often suboptimal compared to compressed formats like CSR (Compressed Sparse Row).
Glossary
COO Format (Coordinate Format)

What is COO Format (Coordinate Format)?
COO (Coordinate Format) is a fundamental sparse tensor storage scheme that explicitly lists the coordinates and values of every non-zero element.
For efficient sparse inference, COO's primary limitation is irregular memory access. Executing a SpMM kernel requires inefficient gather-scatter operations across the dense input matrix, leading to load imbalance and poor cache utilization. While COO is useful for incremental construction or highly irregular sparsity, production sparse inference engines typically convert it to a compressed format like CSR or a blocked sparse data layout for execution. This conversion minimizes sparse kernel overhead and better leverages hardware, such as Sparse Tensor Cores that require structured patterns like N:M sparsity.
Key Characteristics of COO Format
The Coordinate (COO) format is a foundational sparse tensor storage scheme that explicitly lists the indices and values of every non-zero element. Its simplicity makes it a versatile building block, but its memory efficiency depends heavily on the operation and sparsity pattern.
Core Data Structure
The COO format stores a sparse tensor using three parallel arrays (or lists of tuples) of equal length:
- Coordinates Array(s): One array per dimension (e.g.,
rows,cols) containing the integer indices of each non-zero element. - Values Array: A contiguous array containing the data value (e.g.,
float32) of each corresponding non-zero element. For a 2D matrix withnnznon-zeros, storage requiresO(3 * nnz)memory:nnzrow indices,nnzcolumn indices, andnnzvalues. This explicit indexing makes construction and random element access straightforward.
Simplicity & Flexibility
COO's primary advantage is its conceptual and implementation simplicity. It imposes no structural constraints, making it ideal for:
- Dynamic Construction: Easily incrementally assemble a sparse tensor by appending
(index, value)tuples. - Irregular Sparsity: Efficiently represents completely unstructured sparsity patterns where non-zeros are randomly distributed.
- High-Dimensional Tensors: Naturally extends to N-dimensional data by simply adding more coordinate arrays. This flexibility makes COO a common intermediate format in sparse linear algebra libraries, used for constructing matrices before conversion to more operation-optimized formats like CSR or CSC.
Memory & Performance Overheads
The explicit storage of all coordinates leads to significant memory overhead compared to compressed formats. For a matrix, COO uses 2 * nnz integers for indices, while CSR uses nnz + (num_rows + 1) integers.
Performance bottlenecks arise from:
- Random Access for Operations: Matrix-vector multiplication (
SpMV) requires indirect, non-sequential gathers from the dense vector, causing poor cache utilization. - Duplicate Entries: The format allows multiple entries for the same coordinate, requiring a summation pass to coalesce duplicates, which adds preprocessing cost.
- No Fast Row Traversal: Unlike CSR, iterating over all non-zeros in a specific row requires scanning the entire
rowsarray, anO(nnz)operation.
Typical Use Cases
COO is best suited for scenarios where its construction benefits outweigh its operational inefficiencies:
- Sparse Tensor I/O & Serialization: A simple, portable format for saving/loading sparse data (e.g., in MLX, SciPy's
.npzfiles). - Graph Construction: Representing adjacency matrices for graph algorithms where edges are added incrementally.
- Sparse Matrix Assembly in finite element analysis, where element stiffness matrices are summed into a global matrix.
- Conversion Hub: Often used as a canonical format to convert between other sparse formats (e.g., CSR ↔ CSC) due to its symmetric treatment of dimensions.
Comparison to CSR Format
COO and Compressed Sparse Row (CSR) are the two most common sparse matrix formats. Their key differences are:
- Index Storage: COO stores explicit
(row, col)per element. CSR compresses row pointers, storing onlycolindices per element and arow_ptrarray of sizenum_rows + 1. - Row-Based Operations: CSR provides
O(1)access to the start of a row's data, making SpMV and row-slicing highly efficient. COO does not. - Construction: Building CSR directly is complex; it's often built via COO.
- Memory: For typical matrices, CSR uses less memory than COO. COO becomes competitive only when
nnzis very small ornum_rowsis very large.
Variants & Optimizations
Several optimized variants of COO address its shortcomings:
- Sorted COO: The coordinate arrays are sorted lexicographically (e.g., by row, then column). This enables faster conversion to CSR/CSC and improves cache locality for some operations.
- Blocked COO (BCOO): Groups non-zero values into small, dense blocks (e.g., 2x2). Stores block coordinates and a dense block values array. This reduces index storage overhead and improves arithmetic intensity for structured sparsity.
- Compressed COO: Uses run-length encoding on one dimension (like CSR) but keeps full indices for the other, offering a middle-ground between COO and CSR. These variants illustrate the trade-off space between flexibility, memory footprint, and operational speed inherent to sparse storage.
COO vs. Other Sparse Formats
A feature and performance comparison of the COO (Coordinate) format against other common sparse tensor storage formats, highlighting trade-offs in memory, access patterns, and computational efficiency.
| Feature / Metric | COO (Coordinate) | CSR (Compressed Sparse Row) | CSC (Compressed Sparse Column) | Blocked Sparse (e.g., BSR) |
|---|---|---|---|---|
Primary Storage Structure | List of (row, col, value) tuples | Three arrays: row pointers, column indices, values | Three arrays: column pointers, row indices, values | Array of dense sub-blocks + block indices |
Construction & Modification | Easy, O(1) insertion | Complex, requires sorting/compression | Complex, requires sorting/compression | Moderate, requires block alignment |
Random Element Access (by coordinate) | Slow, O(nnz) linear search | Moderate, O(log(nnz_row)) binary search | Moderate, O(log(nnz_col)) binary search | Slow, requires block lookup + intra-block offset |
Row Slice Iteration | Slow, requires scanning all entries | Fast, O(1) row start lookup | Very slow, requires full scan | Fast for aligned rows, variable otherwise |
Column Slice Iteration | Slow, requires scanning all entries | Very slow, requires full scan | Fast, O(1) column start lookup | Fast for aligned columns, variable otherwise |
Memory Overhead (Index Storage) | High, 2 ints per nnz | Moderate, ~1 int per nnz + row array | Moderate, ~1 int per nnz + col array | Low, indices per block, not per nnz |
Ideal Sparsity Pattern | Arbitrary, unstructured | Row-heavy operations, SpMV | Column-heavy operations, SpMV^T | Regular, clustered non-zeros |
Sparse Matrix-Vector Multiply (SpMV) Performance | Poor, irregular access | Good, streaming access to x vector | Poor for y = Ax, good for y = A^Tx | Excellent with vectorized block ops |
Sparse Matrix-Matrix Multiply (SpMM) Performance | Poor | Good | Good for specific orientations | Excellent with high block utilization |
Hardware Kernel Support | Limited, generic only | Widespread (BLAS, cuSPARSE) | Widespread (BLAS, cuSPARSE) | Specialized, requires block-aware kernels |
Typical Use Case | Incremental construction, dynamic graphs, simplicity | Scientific computing, linear solvers (most common) | Graph algorithms (transpose ops), certain decompositions | Computer vision, dense sub-structures (e.g., from structured pruning) |
How COO Format Works in Sparse Model Inference
The COO (Coordinate) Format is a foundational sparse tensor storage scheme that directly encodes the positions and values of non-zero elements, providing a simple but memory-intensive representation crucial for certain sparse model operations.
COO (Coordinate) Format is a sparse tensor storage scheme that explicitly stores a list of (row index, column index, value) tuples for every non-zero element in a matrix or higher-dimensional tensor. This direct coordinate representation offers maximum flexibility for representing irregular, unstructured sparsity patterns generated by techniques like magnitude-based pruning. Its simplicity makes it easy to construct and modify, but the explicit storage of two integer indices per value introduces significant memory overhead for metadata, especially as tensor dimensionality increases.
During sparse model inference, COO is often used as an intermediate or input format before conversion to more compute-efficient layouts like CSR (Compressed Sparse Row). Its primary advantage is efficient random insertion and deletion of non-zeros, which is useful during dynamic sparsity patterns or model assembly. However, for core operations like SpMM (Sparse Matrix-Matrix Multiplication), the format's irregular memory access can lead to load imbalance and poor cache utilization compared to compressed formats, making it less ideal for direct execution on parallel hardware like GPUs without significant kernel optimization.
Frequently Asked Questions
The Coordinate (COO) format is a fundamental sparse tensor storage scheme. This FAQ addresses its core mechanics, trade-offs, and role in sparse neural network inference.
The Coordinate (COO) format is a sparse tensor storage scheme that explicitly stores a list of tuples, each containing the indices and value of a non-zero element. For a 2D sparse matrix, each non-zero is represented as a (row_index, column_index, value) triplet. These triplets are typically stored in three parallel arrays (or a single array of structs). The format does not compress index data, making it simple to construct and modify but often less memory-efficient for computation than formats like Compressed Sparse Row (CSR).
How it works:
- Data Arrays:
row_indices[],col_indices[],data[]. - Storage: The
i-th non-zero element has its row index inrow_indices[i], column index incol_indices[i], and value indata[i]. - Access: To iterate all non-zeros, you loop from
0tonnz-1(number of non-zeros). Random access by(row, col)is inefficient, requiring a linear scan.
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
Key concepts and formats essential for understanding and implementing efficient sparse tensor computations.
CSR Format (Compressed Sparse Row)
A compressed sparse matrix format that stores three arrays:
- Row Pointers (RP): An array of length
rows + 1whereRP[i]indicates the start index of rowiin the column and value arrays. - Column Indices (CI): An array storing the column index for each non-zero element.
- Values (VAL): An array storing the non-zero values.
Key Difference from COO: CSR compresses the row index information, eliminating the explicit row array. This makes row-wise access and operations like SpMM (Sparse Matrix-Dense Matrix Multiplication) highly efficient, as iterating through all non-zeros in a row is a contiguous memory operation. However, modifying the sparsity structure (adding/removing non-zeros) is more expensive than in COO.
Sparse Matrix Multiplication (SpMM)
The fundamental computational kernel for multiplying a sparse matrix by a dense matrix. It is the core operation in sparse linear layers of neural networks. Efficient SpMM requires:
- Zero-Skipping: Skipping multiplications where the sparse matrix value is zero.
- Efficient Gather-Scatter: The dense matrix rows must be gathered according to the sparse matrix's column indices, multiplied, and the results scattered (accumulated) into the output matrix according to the row indices.
Performance Factors: The efficiency of SpMM is heavily dependent on the sparse data layout (COO, CSR, etc.), the distribution of non-zeros, and the underlying hardware's ability to handle irregular memory access patterns and load imbalance.
Gather-Scatter Operations
Parallel computing primitives critical for sparse computation on accelerators like GPUs.
- Gather: Reads data from a set of non-contiguous memory addresses (specified by an index array) into a contiguous vector for processing. In SpMM, this gathers the relevant rows of the dense input matrix.
- Scatter: Writes data from a contiguous vector to a set of non-contiguous memory addresses. In SpMM, this scatters and accumulates partial results into the correct positions of the dense output matrix.
These operations are memory-bandwidth intensive and can cause load imbalance if not carefully managed, as different threads may handle varying numbers of non-zeros.
Sparse Tensor Core
A specialized hardware unit in modern NVIDIA GPUs (e.g., Ampere, Ada Lovelace, Hopper architectures) designed to accelerate sparse matrix operations. It leverages a specific N:M Sparsity Pattern (e.g., 2:4), where in every block of 4 weights, 2 must be zero.
How it Works: The hardware reads a dense 4-value vector and a 4-bit mask. It prunes the 2 zero values on-the-fly and executes a dense matrix operation with the 2 non-zero values, effectively doubling the theoretical FLOPs throughput for eligible operations. This highlights the move from software-only sparse kernels to hardware-aware compression where the sparsity pattern is co-designed with the silicon.
Unstructured Pruning
A model compression technique that removes individual weights from a neural network based on a saliency criterion (e.g., magnitude-based pruning), resulting in irregular, fine-grained sparsity.
Relation to COO: The resulting weight tensors are perfect candidates for storage in the COO format, as the non-zero elements have no regular pattern. However, executing such models requires a sparse inference engine with kernels optimized for irregular access. The sparse efficiency gap is often more pronounced for unstructured sparsity compared to structured pruning due to higher sparse kernel overhead from metadata processing and irregular memory accesses.
Sparse Kernel Overhead
The additional computational cost incurred when executing sparse operations versus their dense counterparts. This overhead can diminish the theoretical speedup gained from zero-skipping. Sources include:
- Metadata Processing: Reading and decoding index arrays (row, col in COO; row pointers in CSR).
- Irregular Memory Access: Non-contiguous gather-scatter operations cause poor cache utilization and high memory latency.
- Conditional Branching & Load Imbalance: Threads may follow different execution paths based on sparsity, leading to warp divergence on GPUs.
Optimizing a sparse inference engine involves minimizing this overhead through techniques like sparse operator fusion and choosing the optimal sparse data layout for the target operation.

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