Planning: Generalized N-D IndexWavefront & stencil recurrences

Aperta
#116 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
compilers

Direzione di ricerca

Start by reading the existing IndexWavefront IR node and the par.wavefront implementation, then trace the CPU and GPU backends that execute it. The issue proposes several substantial pieces of work, including N-D scheduling, rolling buffers, loop recognition, and reverse-mode AD; agree on a focused first milestone with maintainers. Done means implementing and validating an agreed milestone while preserving the existing 2D API.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Motivation

IndexWavefront (par.wavefront, par.batched_wavefront, par.soft_align) currently supports 2D causal recurrences with the fixed 3-neighbor stencil {(i-1, j), (i, j-1), (i-1, j-1)}, traversing anti-diagonals i + j = d in O(M) rolling memory.

Mathematically, the exact same hyperplane schedule generalizes cleanly to arbitrary rank d >= 2 and general causal stencil offsets:

  1. N-D anti-diagonal hyperplanes (3D, 4D, ...):
    • For a d-dimensional grid of shape (N_0, N_1, ..., N_{d-1}), cells on the hyperplane i_0 + i_1 + ... + i_{d-1} = t are mutually independent whenever every dependence offset delta = (delta_0, ..., delta_{d-1}) >= 0 has sum(delta) > 0.
    • All cells on hyperplane t execute in parallel across CPU threads or GPU blocks, while memory collapses from O(N_0 * N_1 * ... * N_{d-1}) to O(w * prod_{k>0} N_k) rolling slices (where w = max(sum(delta))).
  2. Generalized causal recurrence stencils:
    • Support arbitrary static offset tuples (e.g. 2D 2-step recurrences (i-2, j), (i, j-2), 3D 7-point Gauss-Seidel / SOR PDE sweeps, 3D multiple-sequence alignment, 4D Viterbi / RNA-co-folding DP, and tiled hyperplane blocks).
    • For non-unit dependence cones, find a valid schedule normal h with h . delta > 0 for all offsets delta (unimodular skewing).
  3. Automatic recognition of nested DP for loops:
    • Recognize canonical nested loops like for i: for j: for k: dp[i, j, k] = f(dp[i-1, j, k], dp[i, j-1, k], dp[i, j, k-1]) and lower them directly to IndexWavefront with rolling-slice buffer contraction when the full table is dead after the loop.

Proposed Roadmap

  • Generalize IndexWavefront IR node from (m, n, i, j, top, left, diag) to (shape: tuple[Expr, ...], coords: tuple[Var, ...], offsets: tuple[tuple[int, ...], ...]) with static offset validation (all(d >= 0) and any(d > 0)).
  • Extend par.wavefront to accept 2D, 3D, 4D+ shapes and an optional offsets= parameter (defaulting to the standard 2D top/left/diag API for full backwards compatibility).
  • Implement rolling hyperplane ring buffers and tiled hyperplane blocking for CPU and GPU backends.
  • Add Law 2 checkpointed reverse-mode AD (O(sqrt(T))) for smooth N-D wavefront recurrences.
Lingua principale
Python
Stelle
236
Fork
11
Merge medio
3h 46m
PR unite (30g)
64

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di iskandr/parakeet

Tutte le issue di iskandr/parakeet

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.