Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

[teeny] Phase B3: pushpull pull/push/count/grad take teeny carriers — tensor-native impl boundary #63

Description

@balbasty

Agent:claude-fastfields-to-teeny

Part of the tensor-native-boundaries umbrella (fastfields-lib#57), Phase B. One coordinated PR-set with the cpu-lib half (fastfields-cpu-lib "Phase B3" issue); this issue covers the impl repo (pushpull.h). Convention: TEENY-MIGRATION.md §9 — R2 spellings at.ndim / at.size(at.ndim - 1).

Tier-1 status confirmed (no kernel work here):kernels/pushpull/teeny.h's vox:: entry points are already tensor-native — vox::pull<D,O,B,reduce_t,offset_t>(VOut out, const VIn inp, const reduce_t loc[D], int extrapolate, bound_t rt) and siblings take teeny cell views; the loc[D] coordinate stays a plain array by design (§9.1: a vector of values, not a tensor operand — R2 does not apply to it). This issue is the impl-entry re-skin only.

Current signatures (exact; 4 entry points)

template <int D, int O, bound_t B, typenamereduce_t, typenamescalar_t, typenameoffset_t>
voidpull(offset_t nbatch, int extrapolate, bound_t bound,
scalar_t * out, constscalar_t * inp, constscalar_t * grid,
constoffset_t * size_out, constoffset_t * size_inp, constoffset_t * size_grid,
constoffset_t * stride_out, constoffset_t * stride_inp, constoffset_t * stride_grid)

(push identical; count drops the inp triple; grad adds bool ABS to the template and wraps out at nbatch + D + 2.) Each body opens with three tny::as_anyrank(..., rank, tny::copy_meta) calls over arrays the caller just exploded — pushpull already passes per-tensor size/stride arrays (no shared-size hazard), so this module is the cleanest mechanical case: the carriers replace 6–9 raw array arguments per entry with 2–3 self-describing ones.

Target

template <int D, int O, bound_t B, typenamereduce_t, classAO, classAI, classAG>
voidpull(AO ao, constAI ai, constAG ag, int extrapolate, bound_t bound)
// offset_t = decltype(ao.size(0)); nbatch = ao.ndim - D - 1 (R2)// nsp (spatial voxels per batch cell) = product of ag.size(nbatch + d), d in [0, D)
  • nbatch and all six/nine size_*/stride_* arrays disappear (R2/R3); _grid_spatial reads the grid carrier instead of size_grid.
  • extrapolate/bound stay: runtime kernel parameters, not geometry. D/O/B/ABS/reduce_t stay template parameters (R1 — dispatch direction unchanged).
  • Read-only operands (ai, ag; push's ai) are const-element carriers (R4). push/count's scatter target ao stays non-const (atomic accumulate).
  • The cur_b batch-cell caching (peel the (*spln, C) volume once per batch cell, not per voxel — a mixed-radix decode saved nsp−1 times per cell) and the flat voxel-parallel scatter via anyAtomicAdd are unchanged, line for line. Only the three-line as_anyrank prologue moves out.
  • grad's out carrier arrives at rank nbatch + D + 2 (the extra (C, D) axis) — its nbatch derivation is ao.ndim - D - 2; say so in a comment, since it is the one entry whose two carriers disagree in rank.

Scope

pushpull.h only, all 4 entry points. NOT kernels/pushpull/teeny.h (tier-1, already native), NOT kernels/gather.h, NOT the legacy pushpull/1d.h interpreter (Phase E), NOT cuda-impl (its own Phase B issue). Old signatures deleted, not deprecated — cpu-lib converts in the same PR-set.

Gate (Phase A's, restated)

  1. Untouched kernel-layer instantiations (vox::pull/push/count/grad, _make_axis, gather_sep, _pull_rec/_push_rec/_grad_rec) byte-identical at -O2 wherever they exist as standalone symbols in cpu-lib's pushpull.o, both compilers.
  2. Re-skinned driver loops: no new instructions inside the per-voxel loop — in particular the cur_b cache must still elide the per-voxel peel_front_at<-(D+1)>; a diff that shows the batch-cell peel back inside the loop is a failed gate, not jitter.
  3. Oracle: test_pushpull326 checks (clang make test baseline, 2026-08-04), identical counts clang++ AND g++, true make clean between; whole suite green, unchanged counts; asan/ubsan on touched paths.
  4. g++ nuance (Phase A finding): untouched-neighbor whole-TU inlining jitter acceptable; the g++ bar is kernels + driver loops + oracles.

Judgment call to document in the PR

The out/grid (pull/grad) — or inp/grid (push) — spatial-extent equality that CHECK_SAME_SPATIAL pins lib-side is what the shared flat voxel index relies on. The impl currently trusts it; with carriers a one-line debug assert per entry (ao.ndim == ag.ndim + the D spatial extents) is nearly free — decide and document, don't silently widen scope.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions