Quilt as a distributed cell engine. Chapel is the language Cray built for the exascale era — a language that wants you to think about locales the way C wants you to think about pointers. When you express the Quilt cell model in Chapel, the cells stop being nodes in a graph and become locales on a machine. The reactive engine walks locales, not cells.
Why • Philosophy • What works • Workarounds • Deeper understanding
Most reactive engines assume one machine, one process, one address space. The "graph" of cells is in memory. The "walker" follows pointers. The "change" is a write to memory. Everything happens in one place.
Chapel was built for the opposite assumption. Chapel was designed by Cray for the machines that don't fit in one place — machines with thousands of nodes, each node with dozens of cores, each core with its own memory. The language was built to express where a computation happens, not just what it computes.
When you express Quilt in Chapel, the cells don't just have values. They have homes. A cell lives on a locale. When its value changes, the change is communicated to the locales that hold the dependents. The reactive engine is not a graph walk — it is a locale-to-locale message-passing system.
This repo is the polyformalism port of Quilt to Chapel. The same model, expressed in the language that thinks the most important question about a computation is where it runs.
The Quilt model is language-independent. A cell is a typed unit of state. A formula is a function over dependencies. A listener is a callback. A sheet is a graph. The polyformalism question is: what does the model look like when the language's central feature is distribution?
The Chapel version emphasizes:
- Cells have homes. Every cell is on a locale. The locale is part of the cell's identity.
- Formulas run where their dependencies are. If both
incomeandexpensesare on locale 0, thesavingsformula runs on locale 0. If they're on different locales, the formula has to fetch. - The reactive engine is a task-parallel walk over locales. When a cell changes, the engine spawns a task on each locale that has a dependent. The tasks run in parallel.
- Distributed arrays are the sheet. A Quilt sheet is a
DistArrayof cells, distributed across locales by aBlockdistribution (cells in contiguous blocks) or aCyclicdistribution (cells round-robin). - The cell model is inherently parallel, and Chapel makes that explicit. In TypeScript, the reactive engine is a single-threaded walk. In Chapel, it is a parallel walk, by design.
The polyformalism insight: in Chapel, the cell model is not a graph you walk — it is a machine you run on. The graph of cells is the topology of the locale graph. The reactive engine is the runtime. The polyformalism insight: cells want to be parallel; Chapel says it out loud.
A cell in Chapel is a var (a distributed variable) on a locale. The compiler and runtime know where it lives.
class ValueCell {
type valueType;
var path: string;
var value: valueType;
}
config const numLocales = 4;
// Distribute cells across locales
const Cells = new DistArray(numLocales, ValueCell);
// Block distribution: cell i lives on locale i % numLocalesThe DistArray is the sheet. The cells are spread across the machine. The compiler emits code that runs on the right locale for each cell access.
Polyformalism insight: the "where" of a cell is an accidental feature in most languages and a first-class feature in Chapel. Making "where" explicit is the polyformalism move: it forces the cell model to confront the machine.
A formula in Chapel is a function that runs on a specific locale. The on clause says: this computation happens here.
proc computeSavings(income: real, expenses: real): real {
return income - expenses;
}
// Run the formula on locale 0
var result: real;
on Locales(0) {
result = computeSavings(sheet.income.localRead(), sheet.expenses.localRead());
}The on clause is explicit. The compiler checks: does income live on locale 0? If not, it inserts a remote read. The polyformalism insight: the cell model's dependency walk is a distributed memory walk, and Chapel is the language that makes the walk explicit.
When a cell changes, the reactive engine uses Chapel's task parallelism to evaluate the dependents in parallel.
proc updateSheet(sheet: DistArray, changed: string) {
coforall loc in Locales do on loc {
// Each locale evaluates its dependent formulas in parallel
for cell in sheet.localSlice() {
if cell.path == changed then cell.value = newValue(cell);
if dependsOn(cell, changed) then cell.value = evaluate(cell, sheet);
}
}
}The coforall is a parallel loop. Each locale runs its own block. The reactive engine is a parallel walk by design.
Polyformalism insight: in TypeScript, the reactive engine is sequential. In Chapel, it is parallel, and you can choose the parallelism granularity. The cell model doesn't have to be sequential; the language choice makes the parallelism visible.
Chapel's domain maps are the way you say "this index lives on that locale." The cell graph is a domain, and the cell-to-locale mapping is a domain map.
const CellDomain = {1..numCells};
const CellMap = new Block(CellDomain); // Block distribution
const Cells: [CellDomain] Cell = new array(CellDomain, Cell, CellMap);The Block distribution says: cells 1..N/4 are on locale 0, cells N/4..2N/4 are on locale 1, etc. The reactive engine knows which cells are on which locale, and it walks the locale graph, not the cell graph.
Polyformalism insight: the domain map is the cell-to-locale mapping. The cell graph is the domain. The reactive engine is the domain map walker. The polyformalism insight: the cell model is a domain, the machine is a locale map, the reactive engine is the walker.
When a formula depends on cells on different locales, the result is a "sync" — a value that may not be available yet. Chapel's sync variables express this naturally.
var savingsSync: sync real;
on Locales(0) {
// income is on locale 0
var localIncome = sheet.income.localRead();
on Locales(1) {
// expenses is on locale 1
var localExpenses = sheet.expenses.localRead();
savingsSync = localIncome - localExpenses;
}
}
// Wait for the sync to be filled
var savings = savingsSync.readFE(); // blocking readThe sync variable is the polyformalism insight: a cell that hasn't been computed yet is a sync. The reactive engine is a sync resolution system.
Chapel has features that no other language has: var, const, config const, on, coforall, forall, sync, single. Each one is a tool for thinking about distribution. Together, they make the language feel like nothing else.
Workaround: Read the Chapel tutorial. Embrace the syntax. The polyformalism insight: the syntax is the philosophy. A language for distributed computing will have distributed syntax.
Insight gained: languages shape the model. A language without on makes the cell model a single-machine thing. A language with on makes it a multi-machine thing. The model didn't change; the language did.
Chapel compiles to C, then C compiles. For a large Quilt sheet with thousands of cells, the compile time can be significant. Chapel is fast at runtime; it is slow at compile time.
Workaround: Use --fast to skip some optimizations. Use chpl --no-checks for development. The polyformalism insight: distributed code has distributed compile costs.
Insight gained: the cost of a language that knows about locales is a compiler that has to think about locales. The cell model doesn't get to be free.
Chapel is a small language. The package manager (Cray has a registry) is small. The libraries are mostly HPC-flavored: PETSc, Trilinos, etc. The cell model doesn't have a "Pandas for Chapel" or "NumPy for Chapel."
Workaround: Use Chapel's C interop. The Quilt cell engine in Chapel can call out to @quilt/c for the inner loop. The polyformalism insight: Chapel is the orchestrator; C is the worker.
Insight gained: the polyformalism stack is a stack for a reason. Each language has a role. Chapel's role is distributed orchestration. The C layer handles the rest.
The sync variable is a powerful abstraction, but it can lead to deadlocks if you're not careful. A formula that depends on two syncs can deadlock if both syncs are waiting for the same locale.
Workaround: Use single variables (one-shot) or use atomic operations. The polyformalism insight: the cell model is a graph of dependencies, and graphs can have cycles, and cycles can deadlock.
Insight gained: distributed reactive engines can deadlock. The cell model is not deadlock-free by default. The polyformalism insight: the language forces you to think about liveness.
After implementing Quilt in Chapel, the following insights emerge:
-
Cells want to be on locales. The "where" of a cell is a first-class concern. In single-machine languages, it's hidden. In Chapel, it's explicit. The polyformalism insight: the cell model is distributed; the language choice is whether you admit it.
-
Formulas are migrations. When a formula runs on a locale, the data it needs must come to that locale. The reactive engine is a data migration system. The polyformalism insight: the cell model's reactive walk is a dataflow, and dataflow is a migration.
-
The reactive engine is a parallel walk. The
coforallis the engine. Each locale evaluates its cells in parallel. The cell model is parallel by default. The polyformalism insight: the cell model is not a sequential algorithm with parallel optimization; it is a parallel algorithm with sequential fallback. -
The domain map is the dependency map. A
Blockdistribution puts contiguous cells on the same locale, which means dependent cells (which are often contiguous) are on the same locale, which means fewer cross-locale reads. The polyformalism insight: the cell graph topology should match the locale graph topology; this is the art of Quilt in Chapel. -
Sync is the reactive primitive. A
syncvariable is a cell that hasn't been computed yet. Asinglevariable is a one-shot cell. The polyformalism insight: the reactive engine is a sync resolution system, and Chapel'ssyncis the language-level expression of that. -
The polyformalism is about distribution. Other languages reveal different facets of the cell model. Chapel reveals the distributed facet. The polyformalism insight: the cell model is a distributed system; Chapel is the language that says so.
🖥️ Supercomputer simulation — A climate scientist runs a simulation on 10,000 nodes. The Quilt sheet holds the simulation state: temperature, pressure, humidity. Each cell is on a locale. Formulas run where the data is. The reactive engine coordinates the simulation. The polyformalism insight: climate science is a reactive cell model, and the cell model is a climate model.
📡 Sensor network — A factory has 1,000 sensors. Each sensor is a ValueCell on a locale. The control system has formulas that depend on multiple sensors. The Quilt sheet is the control system. Formulas run on the locales that have the data. The polyformalism insight: the cell model is the natural fit for IoT, and Chapel is the natural language for IoT.
🌐 Federated agent system — An agent team has agents on different machines. Each agent's state is a Quilt sheet. The sheets are federated: cells reference cells on other locales. The reactive engine coordinates the agents. The polyformalism insight: federation is distribution, and distribution is Chapel's home turf.
🧬 Genome-wide association study — A genomics researcher has data on 1,000,000 SNPs. Each SNP is a cell. Each statistical test is a formula. The tests run on the locales that have the data. The Quilt sheet is the study. The polyformalism insight: GWAS is a reactive cell model with 10^6 cells.
quilt-chapel is the distributed layer of the Quilt polyformalism stack. The full set of 12 languages:
| Language | What it reveals | What needs workarounds |
|---|---|---|
| TypeScript (canonical) | Reactive evaluation is natural | Hides the state machine structure |
| Tutor (1970) | Multi-user cells are the default | No closures, no async, no nested data |
| Pydantic-AI (Python) | Type safety is the runtime contract | Async overhead, slow interpreter |
| Mojo | Cells are types, not values | Young language, moving target |
| Julia | The reactive engine is a type system | No first-class sheets, compile latency |
| Chapel (this) | Cells are inherently parallel, locales are the runtime | Verbose syntax, small ecosystem |
| COBOL | Hierarchical cells map to divisions | No closures |
| C | The mathematical core | No reactivity, just procedure calls |
| C++ | Type-erased cell kinds | Templates explode |
| C# | The enterprise-friendly version | Heavy runtime |
| Metal | GPU-evaluated cells | Host-device split |
| Swift | Actors = cell isolation | Verbose for simple sheets |
The Chapel version is for the distributed system — the case where the cells don't fit on one machine. The cell model is the same; the deployment is different.
If you've ever wanted a reactive engine that runs on a supercomputer. If you've ever wanted the cells to have homes, and the formulas to migrate. If you've ever wanted the language to force you to think about where a computation runs.
This is for you.
Chapel is the language that says: the cell model is not a single-machine algorithm. It is a distributed system. The language that says so lets you build the right thing — slowly, painfully, with on clauses and coforall loops — but correctly.
Apache 2.0. See LICENSE.
Cells want to be on locales. Formulas want to migrate. Chapel says yes.
