supertensor: shape-aware tensor figure toolkit

Extracted from the tensor-formula-viz skill and rebuilt around the idea that
the geometry rules should be enforced by construction rather than restated as
prose an agent has to remember.

- assets/supertensor.sty: faces, stacks, index faces, shared caption lanes,
  meaning box, signature. Macros take a declared axis and a declared role, so
  equal shapes get equal edges, a x a is square, a transpose swaps the face,
  and contracted axes share an edge length -- without any manual alignment.
- scripts/preflight.sh: decide the TikZ/CJK path before drawing.
- scripts/build.sh: compile and fail on silent corruption (missing CJK glyphs,
  overfull boxes, undeclared roles), then export pdf/svg/png/thumb.
- scripts/test.sh: build every figure as a regression test for the package.
- examples/: three golden figures (TP-FFN, causal MHA, MoE top-k gather) plus
  an anti-pattern gallery of figures that compile cleanly and still lie.
- SKILL.md + references/: lean entry point, details loaded on demand.
This commit is contained in:
dela
2026-08-05 12:17:33 +08:00
commit 7a22bef9e3
20 changed files with 1661 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
# Pre-delivery checklist
A clean `build.sh` proves only that TeX was happy. Nothing below is checked by the compiler.
Work through it against the rendered PNG. Any mandatory violation means redraw, not patch.
## 1. Math (before looking at the picture)
- [ ] Every shape recomputed independently from the source formula or code.
- [ ] Block multiplication, broadcasting, reductions and sharding algebra verified.
- [ ] Axis identities that the figure asserts actually hold in the numbers drawn
(`d = h·d_h`, `Σ_e n_e = T·k`, shards summing to the parent).
## 2. Semantics ledger
- [ ] Every discrete or overloaded symbol has one type, domain and range.
- [ ] Score, index and mask are three distinct objects in three distinct grammars.
- [ ] Producer-to-consumer chain closed: scores → indices → gather/mask → values.
- [ ] Shared selectors drawn once, with the reuse axis marked.
## 3. Geometry ledger
- [ ] Equal shapes have identical faces everywhere.
- [ ] `a×a` is square; every transpose physically swaps the face.
- [ ] Both occurrences of each contracted axis have the same edge length.
- [ ] Shards tile their parent exactly; concat reverses split; elisions use an ellipsis.
## 4. Full-size visual audit
Open the PNG at 100 %.
- [ ] No forbidden intersection, tangency, clipping or occlusion — including stack offset
sheets, brackets, arrow labels and the meaning box.
- [ ] Every connector's white label underlay covers only its own connector.
- [ ] No connector crosses a box that is not its endpoint.
- [ ] Symbols and shapes sit on two flat lanes per row; stage headings share a left rail.
- [ ] Top zone compact (≤2 formula lines, no shape underbraces).
- [ ] Bottom box: one column, ≤3 rows, no overflow, no shrunken type.
- [ ] Signature outside the box, one line, names what the figure actually shows, not clipped
and not visually dominant.
- [ ] Structural support exact: known zeros unfilled, masks and diagonals exactly right.
## 5. Thumbnail audit
Open `*-thumb.png` (360 px).
- [ ] ≤4 active hue families per row plus gray; each role keeps one hue across stages.
- [ ] Base colors still muted, not saturated.
- [ ] Three visibly separated lightness levels where values vary; nothing is uniform pastel.
- [ ] Borders neutral, not tensor-colored.
- [ ] Dense texture reads as noise, not as stripes, checkerboard or a symmetric motif.
- [ ] The main structural claim of the figure is still legible at this size.
## 6. Delivery
- [ ] PNG preview shown.
- [ ] Short mechanism explanation in prose.
- [ ] `.tex` source and vector artifact (PDF/SVG) linked.
- [ ] Any degraded path stated explicitly — no CJK font, no `pdftocairo`, fallback renderer,
inferred shapes or conventions.