Skip to content

Document when TransformerDFT beats TransformerNUFFT - #498

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/sparse-transformer-guidance
Aug 22, 2026
Merged

Document when TransformerDFT beats TransformerNUFFT#498
Jammy2211 merged 1 commit into
mainfrom
claude/sparse-transformer-guidance

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

The transformer-choice block in scripts/interferometer/start_here.py told readers TransformerNUFFT was "Recommended for any dataset size". Measurement says otherwise below a crossover, so this replaces the claim with the actual rule.

Companion to PyAutoLabs/PyAutoArray#479, which adds the same guidance library-side.

What the guidance now says

The DFT setup costs O(N_vis × N_pix) against the NUFFT's O((N_vis + N_pix) log N) plus a fixed ~2 s overhead — so the product decides which is faster, not the visibility count. Measured on CPU, the crossover sits near N_vis × N_pix ≈ 1e7: the DFT runs at 0.2–0.7× the NUFFT time below it, and the NUFFT is 1.2–1.9× faster above.

At a typical 64×64 mask that's ~5,000 visibilities — but on a 32×32 mask the DFT still wins at 4,000. A visibility-count-only rule would be wrong on half the grids, which is why the prose leads with the product.

Past ~1e8 it stops being a speed question: the DFT's allocation grows with the same product and reaches ~109 GB at a million visibilities, where the NUFFT allocates nothing measurable beyond its working buffers.

Two other things the old wording left out

  • Both transformers work with apply_sparse_operator, agreeing to ~3e-13. The old text implied the DFT was the one for that workflow.
  • The existing 10,000-visibility DatasetException is now mentioned, with its raise_error_dft_visibilities_limit=False opt-out. A reader who hit that error previously had nothing in the tutorial pointing at it or explaining why it exists.

Scripts Changed

  • scripts/interferometer/start_here.py

notebooks/ and markdown/ carry the same prose and are regenerated from scripts/ at release time; the equivalent edits are applied here directly so they are not stale in the interim. Notebook JSON was edited in place rather than round-tripped, so the diff stays surgical.

Test Plan

  • Prose changes only — no executable code paths touched
  • All 355 notebooks still parse as valid JSON
  • No "Recommended for any dataset size" claim remains anywhere in the repo

Generated by Claude Code

The transformer-choice block said TransformerNUFFT was "Recommended for any
dataset size". Measurement says otherwise below a crossover, and the reason is
worth stating because it is not the visibility count on its own.

The DFT setup costs O(N_vis x N_pix) against the NUFFT's
O((N_vis + N_pix) log N) plus a fixed ~2s overhead, so the product is what
decides it. Measured on CPU, the crossover sits near N_vis x N_pix ~ 1e7: the
DFT is 0.2-0.7x the NUFFT time below it and the NUFFT is 1.2-1.9x faster
above. At a typical 64x64 mask that is ~5,000 visibilities, but on a 32x32
mask the DFT still wins at 4,000 — quoting a visibility count alone would be
wrong on half the grids.

Past ~1e8 it stops being a speed question: the DFT's allocation grows with the
same product and reaches ~109 GB at a million visibilities, where the NUFFT
allocates nothing measurable beyond its working buffers. That is why ALMA-scale
work uses the NUFFT, and it is what the existing 10,000-visibility
DatasetException is really protecting against — now mentioned here along with
its opt-out, since a reader hitting that error had nothing pointing at it.

Also states plainly that both transformers are supported in the sparse-operator
workflow and agree to ~3e-13, which the previous wording left ambiguous.

notebooks/ and markdown/ carry the same prose and are regenerated from
scripts/ at release time; edited here directly so they are not stale in the
interim, in place rather than round-tripped so the diffs stay surgical.
@Jammy2211
Jammy2211 merged commit 05cf4e2 into main Aug 22, 2026
7 checks passed
@Jammy2211
Jammy2211 deleted the claude/sparse-transformer-guidance branch August 25, 2026 18:56
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