Skip to content

Commit efa515c

Browse files
committed
docs: update masked tensor section and add references and improve AI disclosure
1 parent 3e13b3a commit efa515c

4 files changed

Lines changed: 73 additions & 16 deletions

File tree

paper/jats/paper.jats

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ a Creative Commons Attribution 4.0 International License (CC BY
159159
<p>PyTorch also provides <monospace>MaskedTensor</monospace>, which
160160
distinguishes specified and unspecified elements and is conceptually
161161
closer to the constrained-subspace interpretation of sparsity.
162-
However, <monospace>MaskedTensor</monospace> remains at prototype
163-
stage with incomplete operator coverage, and storing a full boolean
164-
mask incurs a significant memory overhead, partially negating the
165-
memory benefits of sparse index-based representations for large-scale
166-
problems.</p>
162+
However, PyTorch classifies the API as prototype stage, operator
163+
support is limited, and each <monospace>MaskedTensor</monospace>
164+
stores a separate mask tensor matching the data tensor’s size and
165+
storage format, introducing additional mask-storage overhead
166+
(<xref alt="PyTorch Contributors, 2026b" rid="ref-pytorch_maskedtensor" ref-type="bibr">PyTorch
167+
Contributors, 2026b</xref>,
168+
<xref alt="2026a" rid="ref-pytorch_maskedtensor_sparsity" ref-type="bibr">2026a</xref>).</p>
167169
<p>Other libraries provide efficient sparse kernels but do not
168170
directly solve “sparsity-preserving gradients in PyTorch”: SciPy
169171
(<xref alt="Virtanen et al., 2020" rid="ref-scipy" ref-type="bibr">Virtanen
@@ -410,15 +412,28 @@ SMVN(torch.zeros(n), torch.ones(n), scale_tril=L).rsample().sum().backward()</co
410412
</sec>
411413
<sec id="ai-usage-disclosure">
412414
<title>AI usage disclosure</title>
413-
<p>Generative AI tools were used during development of this software
414-
and manuscript. Various large language models were used to assist with
415-
code generation, refactoring, and test scaffolding for portions of the
416-
codebase, and AI assistance was used to draft and edit parts of the
417-
documentation and this manuscript. The repository was initiated prior
418-
to widespread AI coding assistant adoption, with AI tools incorporated
419-
during later development phases. All AI-assisted outputs were
420-
reviewed, edited, and validated by the human authors, who take
421-
responsibility for the final software and paper.</p>
415+
<p>Generative AI tools were used intermittently during later
416+
development and maintainence of the software and preparation of the
417+
documentation and manuscript. This is a best-effort retrospective
418+
disclosure because exact provider-side model snapshots were not
419+
recorded contemporaneously for every historical interaction. Based on
420+
the authors’ records and recollection, and on commit dates relative to
421+
public model-release dates, OpenAI ChatGPT with GPT-4, GPT-4o, and
422+
GPT-5-series models was used for code suggestions, refactoring,
423+
debugging, test scaffolding, and documentation drafting when those
424+
models were the latest available ChatGPT models. The original
425+
unit-test suite and foundational sparse operators were developed
426+
before the authors began using generative AI. Later maintenance,
427+
tests, and documentation may include AI-assisted contributions, and
428+
OpenAI Codex is also used for release-pipeline management.</p>
429+
<p>All AI-assisted outputs were reviewed, edited, and validated by the
430+
human authors. Software changes were checked using code review,
431+
automated tests, continuous integration, and comparisons with
432+
reference behaviour where applicable, and all pull requests were
433+
reviewed entirely manually by human reviewers. The human authors made
434+
the primary mathematical, architectural, scientific, and editorial
435+
decisions and take responsibility for the final software and
436+
manuscript.</p>
422437
</sec>
423438
<sec id="acknowledgements">
424439
<title>Acknowledgements</title>
@@ -651,6 +666,28 @@ SMVN(torch.zeros(n), torch.ones(n), scale_tril=L).rsample().sum().backward()</co
651666
<uri>https://github.com/pytorch/pytorch/issues/87448</uri>
652667
</element-citation>
653668
</ref>
669+
<ref id="ref-pytorch_maskedtensor">
670+
<element-citation>
671+
<person-group person-group-type="author">
672+
<string-name>PyTorch Contributors</string-name>
673+
</person-group>
674+
<article-title>torch.masked: MaskedTensor documentation</article-title>
675+
<publisher-name>PyTorch documentation</publisher-name>
676+
<year iso-8601-date="2026">2026</year>
677+
<uri>https://docs.pytorch.org/docs/stable/masked.html</uri>
678+
</element-citation>
679+
</ref>
680+
<ref id="ref-pytorch_maskedtensor_sparsity">
681+
<element-citation>
682+
<person-group person-group-type="author">
683+
<string-name>PyTorch Contributors</string-name>
684+
</person-group>
685+
<article-title>MaskedTensor sparsity</article-title>
686+
<publisher-name>PyTorch tutorial</publisher-name>
687+
<year iso-8601-date="2026">2026</year>
688+
<uri>https://docs.pytorch.org/tutorials/unstable/maskedtensor_sparsity.html</uri>
689+
</element-citation>
690+
</ref>
654691
<ref id="ref-flaport2020sparse">
655692
<element-citation>
656693
<person-group person-group-type="author">

paper/paper.bib

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ @misc{pytorch_sparse_issue_87448
118118
url = {https://github.com/pytorch/pytorch/issues/87448}
119119
}
120120

121+
@misc{pytorch_maskedtensor,
122+
title = {{torch.masked}: MaskedTensor documentation},
123+
author = {{PyTorch Contributors}},
124+
year = {2026},
125+
howpublished = {{PyTorch} documentation},
126+
url = {https://docs.pytorch.org/docs/stable/masked.html},
127+
note = {Accessed: 2026-07-01}
128+
}
129+
130+
@misc{pytorch_maskedtensor_sparsity,
131+
title = {{MaskedTensor} sparsity},
132+
author = {{PyTorch Contributors}},
133+
year = {2026},
134+
howpublished = {{PyTorch} tutorial},
135+
url = {https://docs.pytorch.org/tutorials/unstable/maskedtensor_sparsity.html},
136+
note = {Accessed: 2026-07-01}
137+
}
138+
121139
@misc{flaport2020sparse,
122140
title = {Solving sparse linear systems in PyTorch},
123141
author = {Laporte, Floris},

paper/paper.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ However, learning these models with gradient-based optimisation requires backpro
4545

4646
PyTorch [@pytorch] exposes sparse layouts (COO, CSR, and related formats) and implements a growing set of sparse operations. However, PyTorch's design goal is *dense-equivalent semantics* for sparse layouts: a guiding invariant is that applying an operation in sparse form should match applying it in dense form after conversion, including the backward function [@pytorch_sparse_issue_87448]. This makes it difficult to learn parameters that are intended to remain structurally sparse, because gradients may be produced for implicit zeros, or intermediate computations may densify.
4747

48-
PyTorch also provides `MaskedTensor`, which distinguishes specified and unspecified elements and is conceptually closer to the constrained-subspace interpretation of sparsity. However, `MaskedTensor` remains at prototype stage with incomplete operator coverage, and storing a full boolean mask incurs a significant memory overhead, partially negating the memory benefits of sparse index-based representations for large-scale problems.
48+
PyTorch also provides `MaskedTensor`, which distinguishes specified and unspecified elements and is conceptually closer to the constrained-subspace interpretation of sparsity. However, PyTorch classifies the API as prototype stage, operator support is limited, and each `MaskedTensor` stores a separate mask tensor matching the data tensor's size and storage format, introducing additional mask-storage overhead [@pytorch_maskedtensor; @pytorch_maskedtensor_sparsity].
4949

5050
Other libraries provide efficient sparse kernels but do not directly solve "sparsity-preserving gradients in PyTorch": SciPy [@scipy] provides mature sparse linear algebra but no automatic differentiation; CuPy [@cupy] and JAX [@jax] provide sparse solvers in their respective ecosystems but are not drop-in components for PyTorch autograd/training loops. GPyTorch [@gpytorch] targets scalable Gaussian process inference via kernel structure and approximations (e.g., inducing/structured methods) rather than arbitrary user-specified sparse covariance/precision factors. PyTorch Geometric’s torch_sparse [@pytorch_geometric] focuses on graph message-passing primitives rather than sparse covariance/precision modelling and differentiable sparse solves for probabilistic models.
5151

@@ -137,7 +137,9 @@ On the SuiteSparse Rothberg/cfd2 matrix [@davis2011university; @rothberg1997cfd2
137137

138138
# AI usage disclosure
139139

140-
Generative AI tools were used during development of this software and manuscript. Various large language models were used to assist with code generation, refactoring, and test scaffolding for portions of the codebase, and AI assistance was used to draft and edit parts of the documentation and this manuscript. The repository was initiated prior to widespread AI coding assistant adoption, with AI tools incorporated during later development phases. All AI-assisted outputs were reviewed, edited, and validated by the human authors, who take responsibility for the final software and paper.
140+
Generative AI tools were used intermittently during later development and maintainence of the software and preparation of the documentation and manuscript. This is a best-effort retrospective disclosure because exact provider-side model snapshots were not recorded contemporaneously for every historical interaction. Based on the authors' records and recollection, and on commit dates relative to public model-release dates, OpenAI ChatGPT with GPT-4, GPT-4o, and GPT-5-series models was used for code suggestions, refactoring, debugging, test scaffolding, and documentation drafting when those models were the latest available ChatGPT models. The original unit-test suite and foundational sparse operators were developed before the authors began using generative AI. Later maintenance, tests, and documentation may include AI-assisted contributions, and OpenAI Codex is also used for release-pipeline management.
141+
142+
All AI-assisted outputs were reviewed, edited, and validated by the human authors. Software changes were checked using code review, automated tests, continuous integration, and comparisons with reference behaviour where applicable, and all pull requests were reviewed entirely manually by human reviewers. The human authors made the primary mathematical, architectural, scientific, and editorial decisions and take responsibility for the final software and manuscript.
141143

142144
# Acknowledgements
143145

paper/paper.pdf

-1.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)