www: bend section on lumbda.com

New section between Portal and EML universality proof. Brief
explanation of the bend primitive + a worked code example showing:

  - tiny inputs stay local (cost below threshold)
  - heavy inputs ship to a GPU worker (cost above threshold)
  - one tier-portable (bend …) macro, with bend-call as the asm form

Mentions the measured 1.5–10× wins against host hashlib on the
SHAKE256 fan-out workload, calls out the ~100 MB break-even
threshold so visitors know when bend pays off.

Cites the cuda-fanout README + integration design for callers who
want the wire contract and per-tier hosting story.

License: AGPLv3, matching the rest of the site.
This commit is contained in:
russell@unturf.com 2026-06-05 08:16:56 -04:00
parent 6b03516ecb
commit 9410816bdc
No known key found for this signature in database

View file

@ -59,6 +59,25 @@ make test-all</code></pre>
</ul>
</section>
<section id="bend">
<h2>bend: dispatch to a GPU without rewriting your code</h2>
<p>Wrap any registered GPU-able form in <code>(bend …)</code> and lumbda decides per call whether to run it locally or ship it to a CUDA worker over our wire protocol. The decision uses a cost estimator on the argument shape, not the operation name. Tiny inputs stay local; heavy inputs bend to a worker that holds a warm CUDA context across requests.</p>
<pre><code>;; bend works on every tier — Python, C, asm — through the same
;; tcp-* + portal primitives lumbda already ships.
(load "examples/cuda-fanout/wire.lsp")
(load "examples/cuda-fanout/bend.lsp")
(load "examples/cuda-fanout/bend-macros.lsp") ; Python/C only — asm uses bend-call
;; Tiny — cost below threshold, evaluates locally
(bend (cuda-shake-fanout '("00" "01" "deadbeef") 32))
;; Heavy — cost above threshold, ships to a GPU worker on 127.0.0.1:9091
(bend (cuda-shake-fanout one-million-inputs 32))</code></pre>
<p>On a single RTX 3090 with a warm daemon, fan-out matched <code>hashlib.shake_256</code> byte-for-byte and won by 1.5&ndash;10&times; across the workloads we measured. Below the break-even (~100 MB of bulk hash work) host CPU stays faster — the cost estimator picks correctly.</p>
<p>The CUDA toolchain stays isolated to the leaf binary the worker spawns. No tier links libcudart; no tier requires nvcc at build time. Asm tier hosts workers through hand-written <code>pipe2 + fork + execve</code> syscalls — no libc anywhere on the chain.</p>
<p>See <a href="https://git.unturf.com/engineering/unturf/lumbda/-/blob/master/examples/cuda-fanout/README.md">examples/cuda-fanout/</a> for the wire contract, daemon protocol, bench data, and per-tier integration sketch.</p>
</section>
<section id="proof">
<h2>EML universality proof</h2>
<p>A single operator <code>eml(x, y) = exp(x) &minus; ln(y)</code> with a constant 1 generates all elementary functions: <code>exp</code>, <code>ln</code>, arithmetic, negation, complex-plane access, trigonometry. Verified numerically in Python, verified in Lumbda's own bytecode, proven formally in Lean 4 with zero <code>sorry</code>. Lumbda's native symbolic-rewrite checker runs five theorems in 46 ms cold or 7 ms cached &mdash; roughly 16&times; faster than Lean's cold rebuild on identical hardware.</p>