Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
4e1636b
docs(write/sequence_mixer): add module and class docstrings
May 25, 2026
89733c3
docs(write/hyena_nd): add module and class docstrings with math context
May 25, 2026
ed7f1d9
docs(review/sequence_mixer): reviewer feedback
May 25, 2026
5f03020
docs(review/hyena_nd): reviewer feedback
May 25, 2026
b950670
docs(integrate/sequence_mixer): apply reviewer feedback
May 25, 2026
c6a2d1f
docs(write/mixed_fftconv): add module and function docstrings
May 25, 2026
68650e7
docs(write/kernels_nd): add module and class docstrings with math con…
May 25, 2026
54eba08
docs(review/mixed_fftconv): reviewer feedback
May 25, 2026
5fe4251
docs(review/kernels_nd): reviewer feedback
May 25, 2026
3117a38
docs(integrate/mixed_fftconv): apply reviewer feedback
May 25, 2026
9edd00e
docs(integrate/kernels_nd): apply reviewer feedback
May 25, 2026
88d5b81
docs(tracker): mark mixed_fftconv, hyena_nd, kernels_nd, sequence_mix…
May 25, 2026
0259fbb
docs(write/patchify): add module and class docstrings
May 25, 2026
4e9ef62
docs(write/residual_block): add module and class docstrings
May 25, 2026
ad08ece
docs(write/film): add module and class docstrings with math context
May 25, 2026
8ab96db
docs(review/residual_block): reviewer feedback
May 25, 2026
b54f66c
docs(review/film): reviewer feedback
May 25, 2026
f996a0f
docs(review/patchify): reviewer feedback
May 25, 2026
e21ab2c
docs(integrate/residual_block): apply reviewer feedback
May 25, 2026
c3072c3
docs(integrate/patchify): apply reviewer feedback
May 25, 2026
2eccb07
docs(write/ckconv_nd): add module and class docstrings with math context
May 25, 2026
6cc9d4b
docs(review/ckconv_nd): reviewer feedback
May 25, 2026
43033cd
docs(integrate/ckconv_nd): apply reviewer feedback
May 25, 2026
a60ac6b
docs(integrate/film): apply reviewer feedback (from worktree)
May 25, 2026
dbe0c72
docs(tracker): mark ckconv_nd, residual_block, patchify, film as done
May 25, 2026
0fb4dea
docs(write/position_encoding): add module and class docstrings with m…
May 25, 2026
d4d36f7
docs(review/position_encoding): reviewer feedback
May 25, 2026
7704ed0
docs(write/attention): add module and class docstrings with math context
May 25, 2026
28130af
docs(integrate/position_encoding): apply reviewer feedback
May 25, 2026
005c2fb
docs(review/attention): reviewer feedback
May 25, 2026
fac9d3a
docs(integrate/attention): apply reviewer feedback
May 25, 2026
f371b4a
docs(integrate/vit5_residual_block+ckconv_multihead_nd): apply review…
May 25, 2026
6d495a7
docs(tracker): mark attention, position_encoding, ckconv_multihead_nd…
May 25, 2026
e6efa18
docs(write/vit5_hyena_adapter): add module and class docstrings
May 25, 2026
b02deb2
docs(write/condition_mixer): add module and class docstrings
May 25, 2026
6014acd
docs(write/mamba_nd): add module and class docstrings with math context
May 25, 2026
32a153b
docs(review/condition_mixer): reviewer feedback
May 25, 2026
c109f4b
docs(integrate/condition_mixer): apply reviewer feedback
May 25, 2026
f2c3b1f
docs(write/vit5_attention): add module and class docstrings
May 25, 2026
3be1131
docs(write/vit5_hyena_adapter): add module and class docstrings
May 25, 2026
27dabe1
docs(write/vit5_attention): add module and class docstrings
May 25, 2026
24dc74f
docs(review/vit5_hyena_adapter): reviewer feedback
May 25, 2026
31ce6c5
docs(review/vit5_attention): reviewer feedback
May 25, 2026
508694a
docs(integrate/vit5_hyena_adapter): apply reviewer feedback
May 25, 2026
bf803a9
docs(write/mamba_nd): add module and class docstrings with math context
May 25, 2026
0279537
docs(review/mamba_nd): reviewer feedback
May 25, 2026
add27d5
docs(integrate/mamba_nd): apply reviewer feedback
May 25, 2026
6610f02
docs(integrate/vit5_attention): apply reviewer feedback
May 25, 2026
24f5d6e
docs: merge vit5_attention worktree (write→review→integrate)
May 25, 2026
bbc888f
docs: merge vit5_hyena_adapter worktree (write→review→integrate)
May 25, 2026
ca08e02
docs: merge mamba_nd worktree (write→review→integrate)
May 25, 2026
421fc8e
docs(tracker): mark vit5_attention, vit5_hyena_adapter, condition_mix…
May 25, 2026
7c9ce22
docs(write+integrate/mlp,grn,layer_scale,masks_nd): add module and cl…
May 26, 2026
1435c4b
docs(tracker): mark mlp, grn, layer_scale, masks_nd as done
May 26, 2026
ed5ee9c
docs(write+integrate/rms_norm,rms_norm_channel_first,drop_path,causal…
May 26, 2026
096fcd7
docs(tracker): mark rms_norm, rms_norm_channel_first, drop_path, caus…
May 26, 2026
70101c9
docs(write+integrate/schedulers,distributed_depthwise_conv_nd,general…
May 26, 2026
ee472eb
docs(tracker): mark schedulers, distributed_depthwise_conv_nd, genera…
May 26, 2026
0920a0b
docs(write+integrate/vit5_classification,a2a_comms,lazy_config,cleanf…
May 26, 2026
60f93fc
docs(write+integrate/experiments): add module docstrings across run, …
May 26, 2026
d2ebc3f
docs(tracker): mark vit5_classification, a2a_comms, lazy_config, metr…
May 26, 2026
a3b5f62
docs(write+integrate/callbacks,ucf101,dali_imagenet_fused): add modul…
May 26, 2026
87f8609
docs(tracker): mark callbacks, ucf101, dali_imagenet_fused as done — …
May 26, 2026
0d0b9e0
docs: add CONVENTIONS.md with docstring style guide and PR enforcemen…
May 26, 2026
e114706
docs: add docstring CI workflow, extend PR template with doc checklis…
May 26, 2026
6dcee72
docs: remove stale review artifacts causing Sphinx warnings
May 26, 2026
2c9ddb9
docs: fix Sphinx cross-ref class names and ViT-5 token layout doc
May 26, 2026
e5f316e
docs(causal_conv1d): fix incorrect Mamba usage note — actual call sit…
May 26, 2026
81a2291
docs(drop_path): clarify drop_prob=1.0 is safe — implementation guard…
May 26, 2026
f378d15
fix(ruff): enforce D100 (missing module docstring) — was silently ign…
May 26, 2026
d182d32
docs: add missing module docstrings to satisfy D100 now that it is en…
May 26, 2026
02cf239
feat(modules): add Swin-style PatchMerging with register-row support
May 25, 2026
259e7f5
feat(networks+examples): hierarchical ViT-5 classifier and v6 configs
May 25, 2026
20e3be7
refactor(v6_hierarchical): move CIFAR-10 configs to cifar10/ subfolde…
May 25, 2026
bda1454
fix(cifar10): add Lightning datamodule required by v6_hierarchical/ci…
May 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ pre-commit run --all-files
## Test plan

<!-- How did you test this? Bulleted checklist preferred. -->

## Documentation checklist

For every new or modified public symbol in `nvsubquadratic/` or `experiments/`:

- [ ] Every new **module** has a module-level docstring explaining what it contains and why.
- [ ] Every new **public class** has a class docstring covering purpose, math/motivation, and key attributes.
- [ ] Every new **public method / function** has `Args:` and `Returns:` blocks with tensor shapes where applicable.
- [ ] Math notation is consistent with the paper (or a comment explains any deviation).
- [ ] Docstrings containing backslashes use `r"""..."""` (required by ruff D301).
- [ ] If a new file was added, a row has been added to [`docs-tracker.md`](../docs-tracker.md) with status `[x]`.

> See [`CONVENTIONS.md`](../CONVENTIONS.md) for the full style guide.
49 changes: 49 additions & 0 deletions .github/workflows/docstring_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docstring coverage

on:
pull_request:

# Cancel in-flight runs for the same PR when a new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docstrings:
name: Check docstrings on changed files
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # need full history to diff against base branch

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install ruff
run: pip install ruff

- name: Collect changed Python files in scope
id: changed
run: |
git diff --name-only origin/${{ github.base_ref }}...HEAD \
| grep -E '^(nvsubquadratic|experiments)/.*\.py$' \
> changed_files.txt || true
echo "Files to check:"
cat changed_files.txt

- name: Run docstring checks on changed files
run: |
if [ ! -s changed_files.txt ]; then
echo "No in-scope Python files changed — skipping."
exit 0
fi
# D100 missing module docstring
# D101 missing class docstring
# D102 missing method docstring
# D103 missing function docstring
# D301 use r""" for docstrings with backslashes
# D417 missing argument descriptions in docstring
xargs ruff check --select D100,D101,D102,D103,D301,D417 < changed_files.txt
128 changes: 128 additions & 0 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Documentation Conventions

## Goal

External collaborators should be able to read any module in `nvsubquadratic/`
or `experiments/` alongside the research paper and understand:

1. **What** the class/function does and **why** it exists.
1. The **math** it implements (notation from the paper where applicable).
1. The **shape contract** of every tensor argument.
1. How it fits into the larger architecture.

______________________________________________________________________

## Docstring style

All public classes, functions, and methods use **Google-style docstrings**.

```python
def forward(self, x: torch.Tensor) -> torch.Tensor:
"""Apply RMS normalisation over the last dimension.

Args:
x: Input tensor of shape ``[*leading, D]``.

Returns:
torch.Tensor: Normalised tensor, same shape and dtype as ``x``.

Raises:
RuntimeError: If ``x.shape[-1]`` does not equal ``self.dim``.
"""
```

### Rules

| What | Where |
| --------------------------------------- | ---------------------------------------------------------- |
| Math / motivation / paper context | **Module docstring** or **class docstring** |
| Parameter descriptions + shapes | `Args:` block on the method |
| Return shape + dtype | `Returns:` block |
| Docstrings containing `\` (backslashes) | Use `r"""..."""` (required by ruff D301) |
| Single-line `__init__` docstrings | Allowed only when the class docstring covers all arguments |

______________________________________________________________________

## PR convention

> **Any PR that adds or modifies a public class or function in `nvsubquadratic/`
> or `experiments/` must update the docstring of every touched symbol.**

This means:

- New file → full module docstring + docstrings on all public classes/functions.
- Existing file touched → update only the affected symbols; do not leave
neighbouring docstrings stale.
- Renamed parameter → rename in the docstring too (never paper over a
misleading name with a docstring explanation).

______________________________________________________________________

## Automated enforcement

### 1. ruff (already active)

The pre-commit hook runs `ruff` with the `D` rule-set enabled. It catches:

- `D100` Missing docstring in public module
- `D101` Missing docstring in public class
- `D102` Missing docstring in public method
- `D103` Missing docstring in public function
- `D301` Use `r"""` if backslashes appear in a docstring

If your commit is rejected by ruff with a `D` error, add or fix the docstring
before pushing.

### 2. CI diff-check (recommended addition)

Add the following job to `.github/workflows/ci.yml` (or your equivalent):

```yaml
- name: Docstring coverage on changed files
run: |
# Collect Python files touched by this PR
git diff --name-only origin/main...HEAD \
| grep -E '^(nvsubquadratic|experiments)/.*\.py$' \
> changed.txt

# Fail if any changed file has missing public docstrings
if [ -s changed.txt ]; then
xargs ruff check --select D100,D101,D102,D103,D417 < changed.txt
fi
```

This restricts the `D` check to **files actually changed in the PR**, so it
never blocks unrelated legacy files.

### 3. CONVENTIONS.md review checklist

Add a pull-request template (`.github/pull_request_template.md`) that
reminds authors:

```markdown
## Documentation checklist

- [ ] Every new public class has a module-level or class-level docstring
explaining *what it does* and *why*.
- [ ] Every new public method/function has Args: and Returns: blocks with
tensor shapes.
- [ ] Math notation is consistent with the paper (or a comment explains any
difference).
- [ ] Docstrings containing backslashes use `r"""..."""`.
```

### 4. Updating `docs-tracker.md`

When a PR introduces a **new file** in scope (`nvsubquadratic/` or
`experiments/`), add a row to the relevant table in `docs-tracker.md` with
status `[x]` and a one-line note. This keeps the tracker current without a
separate documentation PR.

______________________________________________________________________

## What does *not* need a docstring

- Private helpers prefixed with `_` (encouraged but not required).
- `__repr__` / `extra_repr` methods — a brief one-liner is enough.
- Test files under `tests/` — descriptive test names suffice.
- Config files under `experiments/` that contain only a `cfg = ...` assignment.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,17 @@ source .env && PYTHONPATH=. python -m pytest tests/ -m nightly -v -o addopts=""

### Documentation

The API reference is built with Sphinx. Sources live under [`docs/`](docs/) and the rendered site is published to the `gh-pages` branch on every push to `main` via [`.github/workflows/docs.yml`](.github/workflows/docs.yml).
All public classes and functions carry **Google-style docstrings** with math
context, shape annotations, and paper references. See [`CONVENTIONS.md`](CONVENTIONS.md)
for the style guide and PR checklist.

#### Viewing the docs

**Sphinx HTML (full API reference)**

The API reference is built with Sphinx. Sources live under [`docs/`](docs/) and
the rendered site is published to the `gh-pages` branch on every push to `main`
via [`.github/workflows/docs.yml`](.github/workflows/docs.yml).

Build and preview locally:

Expand All @@ -166,7 +176,31 @@ make -C docs html SPHINXBUILD="python -m sphinx"
python -m http.server 8000 --directory docs/_build/html
```

Open <http://localhost:8000> to browse. The autosummary stubs in `docs/generated/` are regenerated on every build (gitignored).
Open <http://localhost:8000> to browse. The autosummary stubs in
`docs/generated/` are regenerated on every build (gitignored).

**Inline — IDE hover / `help()`**

Because all documentation lives directly in the docstrings, you can also:

- Hover over any symbol in VS Code / PyCharm to see the rendered docstring.
- Run `help(SomeClass)` in a Python REPL for an immediate plain-text view.
- Use `python -m pydoc nvsubquadratic.modules.hyena_nd` for a terminal-friendly
per-module dump.

**`pdoc` (quick zero-config HTML)**

For a fast, dependency-light alternative to Sphinx that renders the docstrings
as-is:

```bash
pip install pdoc
pdoc nvsubquadratic --output-dir /tmp/pdoc-out
python -m http.server 8000 --directory /tmp/pdoc-out
```

This does not require a `docs/conf.py` and picks up the Google-style sections
automatically.

### CI

Expand Down
Loading
Loading