Skip to content

docs: add sparse tensor naming and shape conventions#90

Merged
theo-barfoot merged 3 commits into
mainfrom
docs/tb-naming
Jul 14, 2026
Merged

docs: add sparse tensor naming and shape conventions#90
theo-barfoot merged 3 commits into
mainfrom
docs/tb-naming

Conversation

@theo-barfoot

@theo-barfoot theo-barfoot commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a repository-wide guide for naming sparse tensors, matrix shapes, batch
dimensions, sparse and dense dimensions, layouts, and specified entries.

The guide establishes the following core convention:

  • an unbatched sparse matrix has shape (n_rows, n_cols);
  • a batched sparse matrix has shape (batch_size, n_rows, n_cols);
  • terms such as “2D”, “3D”, “rank 2”, and “rank 3” describe tensor rank only
    and should not be used to imply batching or spatial meaning.

It also documents:

  • the distinction between tensor rank, batch dimensions, sparse dimensions,
    and dense value dimensions;
  • differences between COO and compressed sparse layout batching;
  • nse, nnz, explicit zeros, and structural zeros;
  • standard shape notation for multiplication and linear solves;
  • reduction-axis terminology;
  • coalesced and uncoalesced COO tensors;
  • terminology for views, copies, reshaping, and dense materialisation.

Motivation

Recent work exposed some ambiguity between terms such as “3D sparse tensor” and
“batched sparse matrix”. A tensor with shape (batch_size, n_rows, n_cols) is
rank 3, but the leading dimension represents a batch of matrices rather than
a third matrix or spatial dimension.

This guide makes the logical object and its shape explicit, aligns terminology
with existing conventions in the repository, and follows PyTorch sparse tensor
terminology where applicable.

Documentation changes

  • adds docs/source/naming.rst;
  • links the guide from the main documentation index;
  • links the guide from the contributing documentation.

Scope

Documentation only. This PR does not change runtime behaviour or public APIs.

devcontainer

Also changed the devcontainer.json to remove the CPU pinning that is only useful for my personal machine and would be likely to fail for anyone with less than 24 CPU cores/threads.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a repository-wide documentation guide that standardizes how sparse tensor/matrix shapes, batching, layouts, and “specified entries” terminology are described across the project, and links it from the main docs and contributing guide.

Changes:

  • Add a new naming.rst guide defining shape/batching/layout terminology and recommended wording.
  • Link the guide into the Sphinx docs index and the contributing documentation.
  • Adjust devcontainer runtime arguments (removes CPU pinning).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/source/naming.rst New comprehensive naming/shape/layout conventions guide for sparse tensors and batching.
docs/source/index.rst Adds the new guide to the documentation toctree.
docs/source/contributing.rst Points contributors to the naming/shape conventions guide.
.devcontainer/devcontainer.json Removes --cpuset-cpus from container run arguments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .devcontainer/devcontainer.json
@theo-barfoot
theo-barfoot merged commit f19d7b4 into main Jul 14, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants