Buffer/Compute/Flush: Higher-Categorical Feedback and Higher Monads for Differentiable Compilation
This synopsis accompanies the full 40-page manuscript and the version 1.0.0 reproducibility package.
Main idea
Signals are buffered, code operates on the buffered data and retained state, and results are flushed to storage, exposed to an observer, or reused in another computational buffer. Repetition gives a feedback system rather than merely deferred evaluation.
For world state $Q$, input $I$, and output $O$, a cycle has the effectful type \[ \gamma:Q\times I\longrightarrow M(Q\times O). \] Ingress, computation, and routing compose in the Kleisli category of the chosen runtime monad. The world includes hidden state, buffer policy, code, storage state when used, parameter versions, and runtime capabilities.
General code--data interaction is evaluation \[ \operatorname{ev}^M:\operatorname{Code}(A,B)\times A\longrightarrow MB. \] Literal convolution is recovered for explicitly linear time-invariant causal kernel actions. It is not imposed on nonlinear or stateful code.
Higher-monadic semantics
A higher monad is an associative algebra object in endofunctors, with coherent unit and multiplication. The manuscript gives the concrete unary-command construction \[ \begin{aligned} K^*&=\coprod_{n\geq0}K^n,\\ \mathbb{T}_K X&=K^*\times X,\\ \mu(u,(v,x))&=(u\mathbin{+\!\!+}v,x). \end{aligned} \] Words list commands in outermost-to-innermost syntax order. Given an action of each generator on $A$, the execution algebra is \[ \alpha([k_1,\ldots,k_n],a)=k_1(\cdots k_n(a)). \] Thus the chronological buffer--compute--flush cycle has the syntax word [flush,compute,buffer]. This explicit construction covers a sequential fragment. A fuller typed lambda syntax requires a binding-aware free-monad construction and its stated existence hypotheses.
Monad multiplication substitutes and flattens program structure. A $T$-algebra $TA \to A$ evaluates in a selected carrier; an effectful interpretation $T \to M$ realizes a selected runtime. Routing, asynchronous device dispatch, awaiting completion, and durable commit have separate interfaces.
Higher equivalences carry specified observation-preservation witnesses. Noninvertible operational refinements require a directed higher setting. Indexed or graded structure can retain phase, time, parameter version, and resource information. Guarded feedback is distinguished from arbitrary instantaneous fixed points.
The contextual extension uses higher sheaves under explicit descent assumptions. Smooth interpretation, tangent structure, base-change compatibility, and global executable realization are additional obligations, not automatic properties of every higher topos.
Differentiable source and compiler
The executable language has fixed scalar/vector/matrix tensor types, Euclidean products, source lambdas, application, let binding, smooth tensor primitives, labelled rebuffering, JVP, and scalar reverse-gradient forms. Known higher-order source functions specialize to a first-order tensor SSA graph. Derivative programs are generated explicitly, without framework autograd.
The admitted derivative forms are \[ \begin{aligned} \mathsf{jvp}(f,a,v)&=(f(a),Df(a)[v]),\\ \langle\mathsf{grad}(f,a),v\rangle&=Df(a)[v]. \end{aligned} \] Fresh formal aliases separate a differentiation argument from captured equal-valued inputs. Rebuffer identity nodes preserve both primal dependence and gradient transport. Stop-gradient flushing would define a different differentiated program.
A backend interface runs the same plan on NumPy CPU or optional PyTorch CUDA tensors. CUDA dispatch is separated from synchronization. The artifact emits an operation-level tensor plan, not custom native CUDA kernels.
Nontrivial neural executable
The workload is a higher-order lambda term implementing a twelve-cycle nonlinear recurrent network: \[ \begin{aligned} H_{t+1}&=\mathsf{rebuffer}_{t+1}\bigl(\\ &\quad\tanh\bigl(X_tW_x\\ &\qquad+H_tW_h+\mathbf{1}b_h^{\mathsf{T}}\bigr)\bigr). \end{aligned} \] Batch size is 48, input width 5, hidden width 24, and output width 3. Five shared parameter blocks contain 795 scalar parameters. A terminal mean-squared objective is trained against a controlled teacher recurrence. Full finite-horizon backpropagation crosses every rebuffer route.
A separate outer buffer/compute/flush loop snapshots one parameter version, computes its gradient, and publishes the next version. The reference update uses 180 steps with learning rate 0.12 and seed 314159.
Evidence and limits
The recorded environment is Python 3.12.14 with NumPy 2.3.5, CPU float64. Initial training loss was 0.05656894568461964 and final loss was 0.00250650651739431, approximately 95.569% lower.
The training plan has 463 nodes, 106 matrix multiplications, and 24 rebuffer markers: twelve state routes in each of two forward recurrences emitted by the transparent compiler.
Nine integration checks passed. An additional CUDA parity check was skipped because PyTorch was absent. The compiled JVP was 0.007683039195305381, the reverse-gradient pairing was 0.0076830391953053795, and the central difference at step 1e-5 was 0.0076830391951276935.
These are checks on a substantial executable fragment, not a general compiler proof or a claim about held-out generalization. CUDA source support is included but GPU execution and performance were not verified. General higher-categorical preservation statements are conditional obligations; extended proofs and elementary finite illustrations are omitted.
The package includes full editable LaTeX, Python implementation, tests, a generated plan, precise evidence files, and reproduction commands.
References
1. Eugenio Moggi, Notions of computation and monads (1991). https://www.cs.cmu.edu/~crary/819-f09/Moggi91.pdf 2. Jacob Lurie, Higher Algebra (2017), Section 4.7. https://www.math.ias.edu/~lurie/papers/HA.pdf 3. Jacob Lurie, Higher Topos Theory (2009). https://www.math.ias.edu/~lurie/papers/HTT.pdf 4. Gordon Plotkin and John Power, Algebraic operations and generic effects (2003). https://homepages.inf.ed.ac.uk/gdp/publications/alg_ops_gen_effects.pdf 5. Andre Joyal, Ross Street, Dominic Verity, Traced monoidal categories (1996). https://doi.org/10.1017/S0305004100074338 6. Lars Birkedal et al., First steps in synthetic guarded domain theory (2012). https://arxiv.org/abs/1208.3596 7. Thomas Ehrhard and Laurent Regnier, The differential lambda-calculus (2003). https://doi.org/10.1016/S0304-3975(03)00392-X 8. Mathieu Huot, Sam Staton, Matthijs Vakar, Correctness of automatic differentiation via diffeologies and categorical gluing (2020). https://arxiv.org/abs/2001.02209 9. Matthijs Vakar, Reverse AD at higher types (2021). https://arxiv.org/abs/2007.05283 10. Robin Cockett et al., Reverse derivative categories (2020). https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.CSL.2020.18 11. NVIDIA, CUDA Programming Guide: Asynchronous Execution. https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/asynchronous-execution.html 12. PyTorch, CUDA semantics. https://docs.pytorch.org/docs/main/notes/cuda.html
Authorship
Prepared with AI assistance at the commissioning researcher's direction. The anonymous review byline asserts no institutional affiliation. Human responsibility and review remain necessary for a submitted version. No independent review or acceptance is claimed.