A Typed Tensor Language for Shared-State Federated Computation

Theofilos Mailis, Theodore Papamarkou, Andreas Ktenidis, Kalliopi-Christina Despotidou, Konstantinos Filippopolitis, Yannis Foufoulas, Thanasis-Michail Karampatsis, Evdokia Mailli, Yannis IoannidisNeurIPS 2026

TL;DR

Federated algorithms—from simple statistical means to complex second-order machine learning optimizers—are usually designed as bespoke protocols, obscuring the fact that they share the exact same underlying mathematical skeleton. This paper introduces a formal, typed tensor language that makes data locality and aggregation explicit right in the type system. By proving that any valid program in this language automatically factors into local encoding, fixed-size merging, and server-side decoding, it guarantees your distributed computation behaves identically to running on a single centralized dataset.

What Problem Does This Paper Address?

Imagine data scattered across thousands of devices (clients) that cannot be pooled onto a central server. The standard playbook in federated computation is to have clients compute local summaries, aggregate them on a server, and post-process the result.

Despite sharing this common rhythm, federated computations are typically specified algorithm by algorithm—a federated covariance matrix, a FedSGD step, and a Newton update are all written as separate protocols. Furthermore, while existing frameworks track where data lives (placement), they don't formally track how tensors are sliced across clients at the mathematical level. Without strict rules, it is easy to write tensor expressions that accidentally treat distributed records as if they were sitting together in global memory. The authors ask a foundational question: Which distributed tensor computations can be strictly expressed as local math, followed by a fixed-size shared summary, followed by server-only post-processing?

Methods

Instead of building just another system interface, the authors design a formal typed tensor language built around two distinct tensor "sorts":

  1. Shared tensors ($\text{Sh}$): Globally available values identical across all clients (like model weights).
  2. Federated tensors ($\text{Fed}_r$): Client-partitioned data where the type explicitly tracks the record axis $r$—the specific dimension along which records are split across clients.

The magic is in the type rules. Operations on federated tensors stay strictly client-local unless you explicitly eliminate the record axis via two designated boundary operations: axis-wise aggregation (like summing across records) or a specific federated-federated matrix contraction (computing $X^\top X$ as $\sum_c {X^{(c)}}^\top X^{(c)}$).

Figure 1: Shared-state factorization of a federated computation. Each client applies a local encoder to its local tensor, the encoded summaries are merged into a finite-dimensional shared state, and a shared-only decoder produces the final output.

Every valid program naturally induces a shared-state factorization (see Figure 1):

  • Local encoders ($\phi$): Clients independently crunch their local slices.
  • Commutative monoid merge ($\oplus$): Client summaries combine (where order doesn't matter) into a shared tensor whose dimensions depend only on the program, never on the number of clients or samples.
  • Shared-only decoder ($\psi$): Pure post-processing on the merged state.

To verify correctness, the authors introduce a virtual global tensor—an imaginary tensor formed by concatenating all client slices—proving their distributed semantics match centralized evaluation. They extend this round-by-round to iterative learning by pairing losses with per-record gradient expressions and adding server-side linear algebra primitives.

Datasets

Not discussed in the paper. (This is a theoretical and programming-languages paper focused on formal semantics and expressibility proofs rather than empirical benchmarks.)

Key Insights and Ideas

  • Locality and exposure are visible in the types: You don't have to guess when data leaves a client. Shared state is created if and only if a primitive eliminates the federated record axis. (Note: the authors call this exposure discipline—it tracks information flow structurally, though it is not a cryptographic or differential privacy guarantee on its own.)
  • Iteration doesn't require a new communication principle: Extending one-round analytics to multi-round machine learning (like server-side Adam or Momentum) just means threading shared state from round to round. Every single step remains the exact same encode-merge-decode pattern.
  • Centralized convergence comes for free: Because typed federated programs are mathematically guaranteed to match evaluation on the virtual global tensor, any centralized optimizer convergence proof automatically transfers to the federated version without needing new heterogeneity proofs.

Key Results

Because the contribution is theoretical, the "results" are structural guarantees and complexity bounds:

  • Exact Expressibility Equivalence (Theorems 1–3): Every valid one-round (and iterative) typed program admits a shared-state factorization, and conversely, every typed-realizable factorization can be written as a program in this language.
  • Linear-Time Extraction: Given a valid program derivation $\mathcal{D}$, its encode-merge-decode factorization can be automatically extracted in $O(|\mathcal{D}|)$ time and $O(|\mathcal{D}|)$ space.
  • Broad Algorithmic Coverage & Message Sizing: First-order methods (FedSGD, server-side Momentum, Adam) require a shared message dimension of $D = p$ (for $p$ parameters) and $O(p)$ server memory. Adding shared linear algebra covers second-order curvature methods—like damped Newton, Gauss-Newton, and IRLS—with dense message size $D = p + p^2$. (The authors also note a companion Python package, FeTA, detailed in the appendix.)

Limitations and Future Work

  • No persistent private client state: Algorithms where clients maintain private control variates across rounds (like SCAFFOLD or FedDyn) are outside the language's scope.
  • Multi-step FedAvg breaks global consistency: Standard FedAvg (taking multiple local gradient steps before averaging) depends on how data is partitioned across clients; it only fits via a relaxed extension that sacrifices virtual-global equivalence.
  • Bounded-state constraints: Exact medians, quantiles (which lack fixed-size mergeable summaries), and kernel methods whose state grows with sample counts cannot be represented.
  • No built-in autodiff or privacy: Per-sample gradient expressions must currently be supplied alongside the loss rather than derived via automatic differentiation, and building formal differential privacy/cryptographic layers atop these factorizations is left for future work.

Summary updated

Abstract

Shared-state federated computations combine client-local tensor computation, mergeable aggregation into shared state, and shared-only post-processing. We introduce a typed tensor language for this class of computations. Its two tensor sorts separate client-partitioned data from globally available values, and typing tracks the partitioned axis. A virtual global tensor serves as a semantic reference for centralized evaluation. We show that typed one-round programs factor through shared tensors whose shapes depend on the program but are independent of client and sample counts. The converse applies to typed-realizable factorizations: each encoder component is represented by an allowed aggregation or contraction with its valid merge, and the decoder is shared-only. The construction extends round by round to programs whose persistent state is shared. For a loss supplied with a client-local per-sample gradient expression, summation represents the empirical gradient. This gives typed programs for server-side first-order updates and, with shared linear algebra, curvature-block updates. The language covers federated analytics and FedSGD. General multi-local-step FedAvg and persistent private client state are outside its scope.
BibTeX
@inproceedings{mailis2026typed,
  author = {Theofilos Mailis and Theodore Papamarkou and Andreas Ktenidis and Kalliopi-Christina Despotidou and Konstantinos Filippopolitis and Yannis Foufoulas and Thanasis-Michail Karampatsis and Evdokia Mailli and Yannis Ioannidis},
  title = {{A Typed Tensor Language for Shared-State Federated Computation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=jfzDfme1bL},
}
Figure