Direct answer: A Cayley-graph solver ports from CUDA GPUs to TPUs when it is rewritten as framework-level operations. The mathematics travels for free. The speed travels only if you stay above the hardware until profiling proves otherwise.

A Cayley graph is a picture of an algebraic group: elements become nodes, and a small set of chosen generators becomes the edges. Problems on that graph reduce to sparse linear algebra, a clean test case for one question: what survives a move to a different chip?

The trending query From CUDA and Jax to TorchTPU: Lessons from a Cayley Graph Solver climbed the Hacker News front page in late November 2026, which is why it earns a closer read here. Code tuned for one accelerator family rarely lands on another at full speed. The durable idea underneath the spike: performance portability is earned by abstraction level.

Same math, different machines

CUDA is NVIDIA's programming model for its GPUs, and a hand-tuned CUDA kernel carries that hardware's assumptions inside it: banked memory, wide math units, thread exchange patterns. A TPU lays memory out differently and builds its matrix units for dense tiles. A moved kernel usually still runs. It often crawls.

Accelerators differ in three axes: memory layout, math units, and communication patterns. Layout decides how far a value travels between uses. Math units decide whether a dot product is one wide instruction or a scalar loop. Communication decides what a multi-chip run pays to move data. Retune for one machine and the tuning on another quietly expires.

Group + generatorsSparse matrix opsmostly zerosFramework programJAX or PyTorchPer-chip kernelsGPU or TPU

Port the algorithm first

The productive order is algorithm, then framework, then chip. Express the solver in the operations of a framework such as JAX or PyTorch and let each backend lower those operations onto its own strengths. JAX compiles its operations per device, so one program text becomes GPU kernels on one machine and TPU instructions on another.

A Cayley-graph solver takes well to this treatment. Linear algebra over a group structure reduces to sparse matrix operations, and those exist in every framework's vocabulary. Writing the solver as matrix multiplies and index bookkeeping keeps the door open to every backend; a hand-written kernel closes it to every chip except the original target.

missedyour Brain mapquiz yourselfmasteredWatch your weak spots turn green.

Drop in your PDF - it doesn't leave your device.
Every miss becomes a red node on your map.
Free plan: 21 nodes, no card, no countdown.

Open Brain - free

Sparse work is where backends split

Sparse matrices hold mostly zeros and store each nonzero value with its coordinates; every accelerator handles that bookkeeping differently. A GPU gathers and scatters values through wide memory transactions. A TPU prefers dense tiles, so a sparse operation may be padded into dense blocks, paying for wasted multiplies to keep data movement simple. The same operation takes different paths per chip.

This is why sparse workloads are the honest test of a port. Dense matrix multiply is close to solved on every modern accelerator, while sparse formats, load balancing, and irregular access are where implementations drift apart. A group-structure solver lives in that zone, so it teaches more on the target chip than any dense benchmark.

AxisGPU (CUDA)TPU
Memory layoutBanked, wide transactionsDense tiles
Math unitsScalar and matrix coresSystolic matrix multiply
CommunicationDevice-to-device copiesChip interconnects
Sparse handlingScatter and gatherPadding into dense blocks

Stay one layer up, drop down on evidence

Stay at the highest level that expresses the computation, and descend only where numbers demand it. Profiling shows where cycles go: a hotspot in allocation reads differently from one in synchronization, and each points at a different fix. Without measurement, kernel rewrites optimize the wrong thing.

For this solver, the framework level carried the mathematics across chip families, and the rest was measurement on each target. The lesson is that performance portability is earned at the level of abstraction: stay one layer above the hardware until profiling proves a hotspot needs custom code.

Key takeaways

  • A Cayley graph turns a group into nodes and generator edges, so algebra becomes sparse linear algebra.
  • Accelerators differ in memory layout, math units, and communication patterns, so tuned kernels rarely transfer at full speed.
  • Express the solver in framework operations and let each backend lower them to its strengths.
  • Sparse workloads diverge most across backends, making them the honest test of a port.
  • Stay one layer above the hardware until profiling shows a hotspot that needs custom code.

Quick answers

What is a Cayley graph?
A drawing of an algebraic group: elements become nodes, chosen generators become edges.

Why does tuned CUDA code crawl on a TPU?
It embeds GPU assumptions about memory, math units, and communication that a TPU does not share.

Where should a port start?
At the algorithm: express the computation as framework operations each backend can lower to its strengths.

Why is sparse work the hard case?
Sparse formats and irregular access hit different paths per chip; dense multiply is optimized everywhere.

When is a custom kernel worth writing?
Only after profiling shows a measured hotspot the framework's operations cannot close.

One thing to do tonight

Pick one function that hides a hand-optimized path and rewrite its core as plain framework operations. Run it on a second device and write down the gap. That number is your portability score.