# Show HN: Warpspec – TLA+ model checking on a GPU, 4,600× faster than TLC

> Source: <https://praveenperera.com/blog/tla-model-checking-4600x-faster-on-a-gpu/>
> Published: 2026-12-02 15:51:19+00:00

**Key takeaway:** Packing each state into a few 64-bit integers made warpspec's generated CPU checker 13× to 73× faster than tla-mc's compiled Rust checker on 24 cores, and restructuring the GPU kernel to compute enabled actions per thread before building and hashing next states raised it from 3.6× to 26.9× over 24 C

I’ve been looking for workloads outside AI where a single desktop GPU makes a real difference, and TLA+ model checking stood out. Checking a distributed protocol spec means exploring millions or billions of reachable states, and most of that work is parallel. I built [warpspec](https://github.com/praveenperera/warpspec) to test whether putting it on a GPU actually works. It compiles a TLA+ spec and its TLC config into a fixed-size, bit-packed `no_std` Rust state machine, then searches the state graph on an NVIDIA GPU or across every core of a CPU. Both run the exact same generated code, print TLC-format counterexample traces on safety or deadlock failures, and on the CPU check temporal liveness and fairness too. It’s Apache-2.0 licensed.

My rule from the start was that speed doesn’t count unless the answers match TLC. For every model both checkers finished, warpspec reports the exact same number of distinct states, generated states, and search depth.

| Model | Distinct states | TLC (24 workers) | Generated CPU (24 threads) | RTX 5090 | 
|---|---|---|---|---|
| EWD998, N = 4 | 248,006,200 | 401.5 s | 5.93 s | 0.121 s | 
| LamportMutex, N = 4, maxClock = 5 | 561,679,480 | 1,824 s | 16.55 s | 0.473 s | 
| PaxosCommit, RM = 3 | 1,357,590,081 | 4 h 40 min | 74.9 s | 3.65 s | 
| KeyValueStore `MCKVSSafetyLarge` | 594,616,815 | not run | not run | 3.93 s | 
| EWD998, N = 4, pending ≤ 5 | 2,127,805,446 | not run | not run | 3.91 s | 

The CPU and GPU columns are search time; TLC’s are its reported totals with its default fingerprint set (switching TLC to its off-heap fingerprint set brings EWD998 N = 4 down to 330.1 s). I didn’t run TLC on the last two rows, and they don’t fit in the CPU checker’s memory on this machine. I explain how their counts were checked [below](#fitting-2-billion-states-in-32-gb).

Two things surprised me while building this. First, the flat state layout does a huge part of the work before a GPU is even involved: packing each state into a few 64-bit integers makes the generated code 13× to 73× faster than `tla-mc`’s compiled Rust checker on the same 24 CPU cores. Second, the obvious GPU kernel was way too slow (only 3.6× over 24 CPU cores on LamportMutex) until I changed its structure. Now each thread first works out which actions can fire, then builds those next states one at a time and passes every one through the same short piece of code that hashes and stores it. That jumped it to 26.9×. Across the 191 exhaustive-search configs in `tlaplus/Examples`, warpspec compiles 152 with no wrong counts or verdicts against TLC, and refuses the other 39 at compile time.

## Table of Contents

## Where model checkers spend their time

At a high level, TLC runs breadth-first search. It computes the starting states, then walks through the state graph one level at a time. For each state, it runs `Next` to find every possible next state, checks the invariants on each new one, and stores a 64-bit hash (fingerprint) in a set of states already seen. It stops when a level produces nothing new.

The graph search itself is cheap. Almost all the time goes into evaluating the spec. TLC interprets TLA+ over dynamically typed values, where any variable can hold a nested mix of sets, records, functions, and sequences. That flexibility lets TLC check almost any spec you write without asking for types. On EWD998 with N = 4, a Java Flight Recorder profile of TLC on 24 workers showed 76% of samples in computing next states and 22% in hashing and checking the seen-states set. The state queue was 0.4%.

[tla-mc](https://github.com/ddalton/tla-mc) compiles TLA+ to Rust, which gets rid of the interpreter. It’s much faster than TLC: 76.7 s against 401.5 s on EWD998 N = 4, and 36.3 s against 101 s on PaxosCommit with four acceptors. [everystate](https://github.com/mattzcarey/everystate), a Rust TLA+ checker that runs directly with no compile step (and ships on npm with no Java needed), beats TLC too: 280.2 s against 401.5 s on EWD998 N = 4, and 88.3 s against 101 s on PaxosCommit with four acceptors. Both still keep a dynamic value representation so they can run general TLA+, and that sets their speed ceiling.

I profiled tla-mc and warpspec on PaxosCommit with RM = 2 (the `tlaplus/Examples` config, 1,321,761 distinct states) on a single thread. tla-mc took 26.9 s, everystate 0.4.6 took 25.8 s, and warpspec’s generated CPU code took about 0.5 s. Under callgrind, tla-mc ran 424.0 billion instructions to the generated code’s 4.82 billion, about 27,800 instructions per next state versus 284.

Here’s where tla-mc’s instructions went (inclusive, so the rows overlap):

| Work | Share | What tla-mc does | What warpspec’s code does | 
|---|---|---|---|
| Hashing next states | 31.9% | Walks the whole value tree, including every record in the message set, about 5,460 instructions per call | Hashes three 64-bit integers | 
| Set membership | 18.8% | Linear scan comparing values across the message set | Tests one bit | 
| Checking `PCTypeOK` | 15.0% | Walks nested functions and records | Checks bit-packed fields | 
| Building new values | about 18% | Allocates records, merges sets, and updates copies | Sets bits in a copy of the state | 
| Storing states | about 14% | Encodes and decodes dynamic values for the state store | Copies three integers | 

Memory allocation is 8.3% of the total and sits mostly inside the value-building work. There’s no single slow function you could patch away. PaxosCommit’s `msgs` variable is a set of records that grows as the protocol runs, so hashing, membership checks, and copying all get slower as it grows. A bitset does each of those in a few CPU instructions.

warpspec gives up checking every TLA+ spec so each state fits in a fixed number of 64-bit integers.

## Packing a spec into fixed integers

The generator, `tla-gpu-gen`, takes a TLA+ spec and a TLC config and writes one Rust file. It reuses tla-mc’s lexer, parser, and module loader; everything after the syntax tree is new.

First, it evaluates every constant from the config file ahead of time. With `RM = {r1, r2, r3}` and `Ballot = {0, 1}`, a set like PaxosCommit’s `Message` turns into a fixed, finite list of records the generator can number.

Next, it needs a fixed type for every variable. It pulls that from a `TypeOK` invariant (the `v \in S` lines most TLC users already write). If there isn’t one, it starts from the values in `Init` and expands them with whatever `Next` assigns until they stop growing. PaxosCommit’s type invariant looks like this:

``` php
PCTypeOK ==
  /\ rmState \in [RM -> {"working", "prepared", "committed", "aborted"}]
  /\ aState  \in [RM -> [Acceptor -> [mbal : Ballot,
                                      bal  : Ballot \cup {-1},
                                      val  : {"prepared", "aborted", "none"}]]]
  /\ msgs \in SUBSET Message
```

Each type turns into a fixed-width field:

- **Integers** are shifted to start at zero and packed into just enough bits for their range in`TypeOK` ,`Init` , or a`CONSTRAINT` . If one end has no bound, warpspec reserves 5 bits by default (`--int-bits` ) and checks every write at runtime. Anything out of range stops the run with`encoding overflow` instead of wrapping silently.
- **Model values and strings** from a finite set become enums.
- **Records and fixed-key functions** flatten into one field per key.
- **Finite sets** become bitsets with one bit per possible member.
- **Sequences** need a length bound like`Len(s) <= k` and turn into a length field plus`k` packed slots.

The generator packs those fields, largest first, into an array of 64-bit integers (`u64` words). For PaxosCommit with two resource managers, `Message` has 144 possible records, so `msgs` is a 144-bit bitset and the entire state fits in three 64-bit words. The generator writes the layout as a comment at the top of each generated file:

```
Layout, 3 words:
- word 0 bit  0: msgs (set bits 0..64): 64 bits
- word 1 bit  0: msgs (set bits 64..128): 64 bits
- word 2 bit  0: msgs (set bits 128..144): 16 bits
- word 2 bit 16: rmState[r1]: 2 bits
- word 2 bit 18: rmState[r2]: 2 bits
- word 2 bit 20: aState[r1][a1].bal: 2 bits
- word 2 bit 22: aState[r1][a1].val: 2 bits
...
- word 2 bit 49: aState[r2][a3].mbal: 1 bits
```

With three resource managers, `Message` has 215 members and the state is five words, 40 bytes total. Adding a known message to `msgs` is one bitwise OR, and checking whether it’s already there is one bitwise AND.

EWD998 with three nodes fits in 35 bits of a single 64-bit integer. Its counters have no lower bound in the spec, so the generator reserves room down to -28 and checks for overflow on every update:

```
- word 0 bit  0: counter[0]: 5 bits
- word 0 bit  5: counter[1]: 5 bits
- word 0 bit 10: counter[2]: 5 bits
- word 0 bit 15: token.q: 5 bits
- word 0 bit 20: pending[0]: 2 bits
...
- word 0 bit 34: token.color: 1 bits
```

LamportMutex was the trickiest benchmark state to pack. Its `network` variable is a nested map of FIFO channels, one per pair of nodes, each holding `[type, clock]` records. With `BoundedNetwork` capping each channel at three messages, each channel packs into 17 bits, and the whole N = 4 state fits in six words, 48 bytes. When I laid it out by hand earlier, I needed eight words.

Once the layout is fixed, the generator evaluates each action ahead of time with only the current state left as a runtime input. Anything constant disappears, and what’s left compiles down to plain Rust bit math over the state array. It also tracks the min and max possible value of each integer as it goes, so any comparison whose answer is already known gets dropped too. Here is part of EWD998’s `PassToken(1)` builder:

``` js
1 => 'b: {
    let v48: u64 = (s[0] >> 15) & 0x1f;
    let v49: i64 = (v48 as i64) + -22;
    let v54: u64 = (s[0] >> 5) & 0x1f;
    let v55: i64 = (v54 as i64) + -28;
    let v58: i64 = v49.wrapping_add(v55);
    // ...
    if !((v58 <= 9)) { break 'b (1 << 2) | CONSTRAINED; }
    if !((v51 >= 0) && (v51 <= 2) && (v58 >= -22)) { break 'b (1 << 2) | OVERFLOW; }
    t[0] = (t[0] & !0xf8000) | (((v58 - -22) as u64) << 15);
    // ...
}
```

The builders never allocate, and every function is `#[inline(always)]`. Each state is just a `Copy` array, `[u64; W]`. That same generated file compiles for both the CPU driver and the GPU kernel crate.

Matching TLC’s generated-state count turned out to be trickier than matching distinct states. When a TLA+ action branches on `\/`, `\E`, `x' \in S`, `IF`, or `CASE`, TLC counts a next state once for every branch that produces it, even if two branches produce the exact same state. My first PaxosCommit model matched TLC’s distinct states and depth, but generated 16,375,079 states against TLC’s 16,959,159. TLC even forks on an `\E` nested inside an `\A` in an action. When a branch only checks a condition and doesn’t assign any next-state (`x'`) variables, the generator now turns it into a check plus a branch count, and emits that next state once per matching branch so the totals match TLC.

## The same code on the CPU

The CPU driver runs that same generated file on `std` threads, using the same flat hash table design as the GPU. On the same 24 cores, against tla-mc’s compiled checker (check time only):

| Model | tla-mc compiled | Generated CPU | Ratio | 
|---|---|---|---|
| EWD998, N = 4 | 76.7 s | 5.93 s | 13× | 
| LamportMutex, N = 4, maxClock = 5 | 402.9 s | 16.55 s | 24× | 
| PaxosCommit, RM = 2, 4 acceptors | 36.3 s | 0.717 s | 51× | 
| PaxosCommit, RM = 3 | 5,460 s | 74.9 s | 73× | 

The gap is smallest on EWD998, which has no sets in its state, and largest on PaxosCommit, where `msgs` dominates.

tla-mc agrees with TLC on distinct states and depth for all of these. Its generated-state count is lower on PaxosCommit and EWD998 because it doesn’t count the extra branches TLC forks on. That’s just a counting difference and doesn’t change which states get explored.

I also timed [everystate](https://github.com/mattzcarey/everystate) 0.4.6 (`-workers 24`, wall time) on this same 24-core machine. It matched TLC’s exact distinct, generated, and depth counts on every run with no compile step:

| Model | Distinct states | everystate (24w) | warpspec CPU (24t) | warpspec RTX 5090 | 
|---|---|---|---|---|
| EWD998, N = 4 | 248,006,200 | 280.2 s (11.8 GiB) | 5.93 s (47×) | 0.121 s (2,316×) | 
| PaxosCommit, RM = 2, 4 acceptors | 21,180,165 | 88.3 s (22.9 GiB) | 0.717 s (123×) | 0.018 s (4,900×) | 
| LamportMutex, N = 4, maxClock = 4 | 37,706,250 | 46.6 s (4.4 GiB) | 0.858 s (54×) | 0.0345 s (1,350×) | 

Because everystate keeps its multi-worker fingerprints and shared values in memory (40 to 65 bytes per distinct state, plus shared values, which hit 22.9 GiB on 21.2M-state PaxosCommit and crossed 30 GiB partway through 562M-state LamportMutex), the larger runs don’t fit comfortably in this machine’s 56 GB of RAM. On models that do fit, compiling down to flat integers puts warpspec 47× to 123× ahead on the same 24 CPU cores and 1,350× to 4,900× ahead on the RTX 5090 (the LamportMutex maxClock = 4 warpspec times above are from the hand-written model in the next section; the generated layout is smaller and faster).

## Why the obvious GPU kernel was slow

I wrote the first GPU kernels before the generator existed, against hand-written models of EWD998 and LamportMutex. The whole point was to see whether a GPU would stay far enough ahead of the exact same compiled code running on 24 CPU cores. The kernels are written in Rust and compiled to PTX (NVIDIA’s GPU assembly) with [cuda-oxide](https://github.com/NVIDIA/cuda-rust) from `NVIDIA/cuda-rust`.

Each GPU thread takes one state from the current frontier and expands it. For every next state it finds, it computes the fingerprint, tries to insert it into a hash table with a 64-bit compare-and-swap, and if the state is new, checks the invariants and appends it to the next frontier.

On EWD998 at N = 4, the GPU was 48× faster than the hand-compiled CPU code on 24 threads. My hand-written N = 4 EWD998 state fit in 61 bits of a single integer, though, so it could act as its own hash key with no hashing and no multi-word memory reads. Before building a full compiler, I set a kill bar on LamportMutex, with its 64-byte state and channels of records: if the GPU couldn’t beat 24 CPU cores by at least 10×, I’d stop.

The first LamportMutex kernel ran the hash, table-insert, and append code directly inside each of the 28 action branches. That’s the natural way to write it for a CPU. On N = 4, maxClock = 4, the GPU was only 3.8× faster than the CPU. Profiling with Nsight Compute (ncu) made the problem obvious: duplicating that insert code across all 28 actions blew out the GPU’s instruction cache. Warps spent about 95% of their time stalled waiting to fetch instructions, fewer than 4 of the 32 threads in a warp were active on average, and memory bandwidth sat under 2%.

The fix was to split each step in two and funnel every next state through one shared output path. First, each thread checks which actions can fire and packs the results into a bitmask. Then it loops over the set bits, builds each next state in registers, and passes it to a single piece of code that hashes and stores it. That’s the shape the generator writes:

``` php
pub fn successors<S: Sink>(s: &State, p: &Params, sink: &mut S) -> u32 {
    let m = enabled(s);
    let mut n = 0u32;
    let mut w = 0;
    while w < MASK_WORDS {
        let mut b = m[w];
        while b != 0 {
            let k = (w as u32) * 64 + b.trailing_zeros();
            b &= b - 1;
            let mut t = *s;
            let r = build(s, &mut t, k);
            let c = r & 3;
            if c != DISABLED {
                // one emit site; a slot whose fork TLC counts j times emits j times
                let mut j = r >> 2;
                while j > 0 {
                    j -= 1;
                    n += 1;
                    sink.generated();
                    if c == BUILT {
                        sink.emit(&t);
                    } else if c == OVERFLOW {
                        sink.overflow();
                    }
                }
            }
        }
        w += 1;
    }
    n
}
```

One wide BFS level dropped from 14.52 ms to 2.04 ms. On the hand-written LamportMutex model:

| Configuration | 24 CPU threads | GPU, insert per action | GPU, single output path | 
|---|---|---|---|
| N = 4, maxClock = 4 (37.7M states) | 0.858 s | 0.227 s (3.8×) | 0.0345 s (24.9×) | 
| N = 4, maxClock = 5 (561.7M states) | 15.31 s | 4.21 s (3.6×) | 0.568 s (26.9×) | 

At maxClock = 5, that kernel is 709× faster than tla-mc’s compiled checker and 3,210× faster than TLC. On the CPU, the exact same change actually made the code 3% slower, so this is a GPU-specific layout the compiler has to emit on purpose. The generator writes both versions, and `--inline` runs the per-action one for comparison.

The generated LamportMutex model beat my hand-written one too: 0.473 s against 0.572 s, mostly because its 48-byte state is smaller than the 64-byte layout I wrote by hand. The generated EWD998 model is within 4% of the hand-written one.

How much this layout matters depends on the GPU. On PaxosCommit RM = 3, the per-action version is 22% slower on the RTX 5090 (4.45 s against 3.65 s). On an NVIDIA L40S, it took 40.23 s against 4.80 s for the single-output version.

## Why Rust and cuda-oxide

Every part of warpspec is Rust: the generator, the generated models, the CPU driver, and the GPU kernels. The biggest win is that each model exists once.

The generator outputs Rust source and lets `rustc` and LLVM handle type checking, inlining, and register allocation. I didn’t have to write separate backends for x86 and PTX.

Each generated model is plain `no_std` Rust that never allocates, and both the host crate and the kernel crate include it with `#[path]`. The model doesn’t know or care where its next states go. It hands each one to a small trait:

```
pub trait Sink {
    fn generated(&mut self);
    fn emit(&mut self, s: &State);
    fn overflow(&mut self);
}
```

The CPU driver implements `Sink` with its own hash table and a `Vec` for the next frontier. The GPU kernel crate implements it with cuda-oxide’s `DeviceAtomicU64` compare-and-swap into the GPU table and an atomic counter into the frontier buffer. Rust compiles `successors` separately for each sink, so the GPU build has no virtual calls or function pointers. The builders, the hash, and the insert all inline into one kernel. The compact visited set in `model/cset.rs` is shared the same way, so both drivers run one implementation of it.

That made the CPU checker useful for a lot more than benchmarks. I tracked down count mismatches against TLC, ran callgrind profiles, and ran the 191-config sweep on the CPU with normal Rust tooling. Since the GPU runs the exact same builders, if it ever disagrees with the CPU, I know the bug is in the GPU driver or its hash table.

I’d already used cuda-oxide to replace cuDNN and cuBLAS in [speakrs](https://praveenperera.com/blog/writing-gpu-kernels-in-rust-speakrs-60x-faster-than-pyannote/#the-driver-only-build), so I knew it could handle real kernels. I reused the same setup here: kernels written as ordinary Rust, PTX built offline and committed to the repo, and a host binary that needs only stable Rust and the NVIDIA driver.

[cuda-oxide](https://github.com/NVIDIA/cuda-rust) is what makes sharing the model file possible on the GPU. It’s a `rustc` codegen backend from NVIDIA’s `cuda-rust` project that compiles ordinary Rust to PTX. A kernel is a Rust function marked `#[kernel]` that reads its index from `thread::index_1d()`. A `macro_rules!` in the kernel crate stamps out the seed, expand, filter, and insert kernels for each generated model, so putting a new model on the GPU is one line in that macro. The host loads the PTX and launches the kernels with [cudarc](https://github.com/chelsea0x3b/cudarc). Without cuda-oxide, the generator would have to output every model twice, once as Rust and once as CUDA C++, and I’d have to keep two copies of every state layout and builder in sync.

There are a few rough edges. cuda-oxide needs its own pinned Rust toolchain, though only the kernel crate uses it and the host just embeds the PTX it produces. The build also rejects any PTX that contains a `call` instruction, so any helper function that fails to inline shows up as a build error instead of quietly tanking performance. That check caught the first models with `SYMMETRY`: the generator had marked the symmetry helper `#[inline(never)]`, and the KeyValueStore kernels wouldn’t build until it inlined.

The PTX for the RTX 50 series is committed to the repo, so building and running the GPU host only needs stable Rust and an NVIDIA driver, no CUDA toolkit. Building PTX for another GPU generation is one script run per architecture, which is how I built the L40S kernels, so shipping kernels for common GPUs follows the same setup speakrs uses.

## Fitting 2 billion states in 32 GB

The GPU checker keeps both the seen-states table and the current and next frontiers in GPU memory, so VRAM is the hard limit.

The default table is a flat array of 8-byte slots. When a state packs into fewer than 64 bits (bit 63 is 0), warpspec XORs it with a fixed seed whose top bit is 1 before running `splitmix64`’s reversible mixer, so the output is a bijection that can never equal `0` (the empty-slot marker). Because the mixer is reversible, two different states can never collide. Larger states store a 64-bit fingerprint, just like TLC, so a hash collision could theoretically hide a state. PaxosCommit RM = 3 used a 1.8-billion-slot table (14.4 GB, 75% full at the end) plus two 150-million-state frontier buffers of 40-byte states (12 GB), or 26.4 GB of the RTX 5090’s 32 GB.

For larger runs, there’s a compact table made of 64-byte buckets. Part of each fingerprint picks the bucket, and the bucket stores the remaining bits plus 4 bits of bookkeeping for collisions — 41 bits per entry in the 2.13-billion-state run (40 bits at 2^28 buckets or more). At 90% full, that comes out to 5.93 bytes per state, or 12.6 GB for the visited table (~23.4 GB total with the level table and frontier buffers). Each BFS level expands all next states first, then filters and inserts them in a separate pass, so inserts don’t need locks.

That’s how the `EWD998, pending ≤ 5` row fits: 2,127,805,446 distinct states and 23.8 billion generated in 3.91 s on one RTX 5090. I didn’t run TLC on that config; its counts match my hand-written GPU model of the same spec. With tighter bounds (1,566,720,292 states), it matches TLC exactly, and TLC took 51 minutes 23 seconds.

The KeyValueStore row uses TLC’s `SYMMETRY` option. When a spec has interchangeable participants, swapping their IDs produces an equivalent state. warpspec generates all valid permutations of those IDs, just like TLC, and hashes only the smallest equivalent version, so symmetric states collapse into one. `MCKVSSafetyLarge` is symmetric over three transaction IDs (up to six equivalent versions per state), and its whole state fits in one 64-bit integer. It finished with 594,616,815 distinct states, 13,385,471,536 generated, and depth 30 in 3.93 s.

`tlaplus/Examples` records a passing 7 hour 16 minute TLC run of `MCKVSSafetyLarge` without state counts, so these counts were verified by repeated GPU runs that agree, including on a different GPU generation. The same spec matches TLC exactly on `MCKVSSafetySmall` and `MCKVSSafetyMedium`, which uses the same symmetry over two transaction IDs.

## Traces and liveness

Fast state counts don’t help much if you can’t see *why* a spec failed. Adding counterexample traces without slowing down the GPU was straightforward once I split the two jobs apart. During the main search, neither the CPU nor the GPU records parent pointers at all, so the hot path stays untouched (rebuilding the PTX after adding traces produced a byte-identical binary). Only if an invariant fails or the checker hits a deadlock does the host replay a bounded CPU breadth-first search down to that exact depth, keeping parent pointers for the replay, and decode the packed integers back into TLC-format TLA+ values and action names to print a shortest trace. Every trace-decoding helper sits behind `#[cfg(not(target_arch = "nvptx64"))]`, so the GPU build never sees it. Across 16 failing trace specs checked against TLC, all 16 agree (15 exact state-for-state matches and 1 alternate shortest path of the same length on `MissionariesAndCannibals`).

On the CPU, warpspec also checks temporal liveness and fairness (`WF`, `SF`, `[]`, `<>`, `~>`, `ENABLED`, and `[][A]_v` action properties). It runs safety first, then searches the state graph for fair accepting cycles and reports the violated property along with the lasso’s stem and cycle lengths. The GPU driver stays safety-only for now, so passing `--skip-liveness` lets you run a liveness spec’s safety check on the GPU.

## Testing against tlaplus/Examples

I picked the benchmark specs myself, so they don’t say much about how much real-world TLA+ the generator handles. To test coverage honestly, I ran it against every exhaustive-search config in the official [tlaplus/Examples](https://github.com/tlaplus/Examples) manifests, 191 in total, with `CommunityModules` (`SequencesExt`, `FiniteSetsExt`, `BagsExt`, `Functions`, `Folds`, and others), `TLCExt`, and `Randomization` bundled directly into the generator.

warpspec compiles 152 of the 191 configs (145 with liveness checking enabled and 7 with `--skip-liveness`) and refuses the other 39 at compile time, with zero wrong counts or verdicts against TLC v1.8.0:

| Outcome | Configs | 
|---|---|
| Same distinct, generated, and depth as TLC | 134 | 
| Stops on the invariant TLC reports violated | 13 | 
| Stops on the action property TLC reports violated ( `SpecificationRefinement/bad` ) | 1 | 
| Stops at run time with `encoding overflow` (`EWD998Chan` ) | 1 | 
| Not compared on CPU ( `MCKVSSafetyLarge` CPU timeout; 2 with no TLC oracle) | 3 | 
| **Generated** | **152** | 
| Refused at generation | 39 | 

All 72 regression fixtures (covering safety, liveness, bundled modules, and traces) agree with TLC too. `EWD998Chan` stops cleanly with `encoding overflow` because its channels mix two different record shapes, instead of returning a wrong answer.

When a manifest’s depth came from a multi-worker TLC run, I reran TLC with a single worker. With multiple workers, TLC can discover a state at a deeper level than strict BFS order would give it, so EWD840’s manifest says depth 10 where single-worker TLC says 9. Single-worker TLC agreed with warpspec in every case.

PaxosCommit was my held-out test. I built the generator without looking at it, then pointed it at the spec to see what broke. It shook out a few real gaps, like recursive functions defined inside a `LET` and the `\E`-inside-`\A` branch-counting rule above, but nothing in the spec had to be rejected. Its RM = 3 run became the 1.36-billion-state benchmark.

The sweep also caught subtle bugs that smaller models missed. One change gave `AllocatorImplementation` the right distinct count, 17,701, but 56,566 generated states at depth 25 where TLC reports 64,414 at depth 16. Transitions were quietly getting lost while every other test passed. I backed it out and refused the model until a proper fix matched TLC exactly.

I also verified the GPU path on an NVIDIA L40S with PTX built for that card. All 104 `tlaplus/Examples` configs under 250 KB of generated Rust, 35 regression specs under that size, and all 21 benchmark configs (with both kernel shapes) matched the CPU and TLC results, and `compute-sanitizer` memcheck came back clean on all 20 runs it covers.

## Limitations

Here are the limits that matter if you want to try warpspec on your own spec:

- **GPU is safety-only (liveness runs on CPU).** On the CPU, warpspec checks safety, deadlocks, action properties,`WF` /`SF` fairness, and temporal liveness (reporting the violated property and its lasso’s stem and cycle lengths, not decoded states yet; liveness under`SYMMETRY` is refused). The GPU driver checks safety only (pass`--skip-liveness` to check safety on the GPU for specs with liveness properties), and very large state graphs can outgrow RAM during the CPU liveness pass.
- **Memory.** The seen-states table and frontier must fit in GPU memory, or in RAM for the CPU checker. There is no spill to host memory or disk yet.
- **Parser and type limits.** warpspec uses tla-mc’s parser instead of TLA+’s official SANY front end, and every variable needs a type from a`TypeOK` -style invariant or from`Init` . Specs tla-mc can’t parse are refused, and parameterized`INSTANCE` only works for modules without variables. All three are on the roadmap[below](#whats-next) .
- **Recompiling on edits.** Changing a spec or its`.cfg` constants means regenerating and recompiling Rust (plus rebuilding PTX to run a new model on the GPU).`warpspec check` caches compiled runners under`~/.cache/warpspec` : the first run builds dependencies once (~6 s on a 24-core machine), after that a new spec compiles in a couple of seconds (1.5 s for PaxosCommit RM = 3), and an unchanged spec starts right away. So end-to-end runs are still way faster than TLC on most specs; the compile step only gets in the way on tiny specs TLC finishes in a second or two, or while iterating if you’re rebuilding GPU PTX every time.
- **Fingerprint collisions.** Multi-word states use 64-bit fingerprints, as TLC does, and warpspec doesn’t print collision probabilities.

The 39 refused configs in `tlaplus/Examples` show where the generator still draws the line. Most are variables whose type or function domain can’t be pinned down at compile time, `VIEW`, infinite sets (` Seq(S)`, `Int`), TLC-specific extensions like `POSTCONDITION`, or recursion on runtime values, not specs whose states can’t pack flat.

Every one of those stops generation with an error naming the unsupported construct (or hits the 120 s generator timeout). If warpspec isn’t sure it can match TLC, it refuses the spec instead of guessing. The same rule holds at runtime: a value outside its bit range, a full hash table, or a full frontier stops the run, and nothing is silently dropped.

Generating model-specific GPU code isn’t a new idea. GPUexplore 3.0 (Wijs and Osama, SPIN 2023) generates CUDA code per model from SLCO, which describes sets of finite-state machines over variables. It writes one next-state function per state machine, stores states in a compressed tree database on the GPU, and checks deadlocks on BEEM models against Spin and LTSmin. TLA+ is harder to split up that way: it has sets, functions, sequences, quantifiers, `CHOOSE`, and recursion, with no process boundaries to divide the work along, and users who expect TLC’s exact counts. I haven’t found another GPU model checker for TLA+.

TLC is still the reference. It accepts the full TLA+ language without needing a fixed state shape, handles `VIEW`, spills to disk, and checks liveness on larger graphs, and the numbers here only mean anything because they match TLC. [everystate](https://github.com/mattzcarey/everystate) gives you a fast, zero-Java drop-in checker with `VIEW`, random simulation, and WebAssembly support and no compile step, which makes it great for everyday checks. [Apalache](https://apalache-mc.org/) takes a different route, encoding bounded runs for an SMT solver, which some teams reach for when TLC runs out of time on big models. warpspec is for the case where you want TLC’s exhaustive check on a model too big to run often, and the spec’s state has a fixed shape.

## Trying it

The CPU checker works on Linux (x86_64 and arm64) and macOS (Apple silicon), no GPU needed. Each check compiles the spec to native code under the hood, so you’ll need a Rust toolchain (1.89 or newer) and a C compiler.

Run it directly with `npx`, install it globally with `npm`, or use the standalone installer:

```
npx warpspec check Spec.tla
# or install globally:
npm install -g warpspec
# or with the standalone installer (puts warpspec and tla-gpu-gen in ~/.local/bin):
curl -LSfs https://github.com/praveenperera/warpspec/releases/latest/download/install.sh | sh
```

`warpspec check` picks up the `.cfg` file beside your spec automatically, bundles `CommunityModules`, `TLCExt`, and `Randomization`, compiles and caches the runner in `~/.cache/warpspec`, and prints TLC-style output with TLC 1.8.0’s exit codes (pass `--json` for machine-readable output for scripts and coding agents, or install the bundled agent skill from `skills/warpspec/SKILL.md`):

```
warpspec check specs/lamport_mutex/MCLamportMutex.tla
Model checking completed. No error has been found.
2729079 states generated, 724274 distinct states found, 0 states left on queue.
The depth of the complete state graph search is 61.
```

By default, `warpspec check` uses the GPU if you have an NVIDIA card (driver for CUDA 12.8 or newer) and `cuda-oxide` installed (`cargo xtask build install-oxide`), and falls back to all CPU cores otherwise. You can also pass `--gpu` or `--cpu` explicitly, or run the prebuilt benchmark models straight from a checkout (the committed PTX targets RTX 50-series / `sm_120`; rebuild PTX for other GPUs):

```
git clone https://github.com/praveenperera/warpspec && cd warpspec
cargo run --release --manifest-path host/Cargo.toml -- gen-cpu-bfs --model ewd998_n3 --threads 8
cargo run --release --manifest-path host/Cargo.toml --features gpu -- gen-gpu-bfs --model ewd998_n3
```

[docs/architecture.md](https://github.com/praveenperera/warpspec/blob/master/docs/architecture.md) covers the generator, traces, liveness, building PTX, and the repository layout. [docs/benchmarks.md](https://github.com/praveenperera/warpspec/blob/master/docs/benchmarks.md) has the generated-state counts, depths, how each number was measured, and the commands to reproduce them.

## What’s next

Now that the core engine, CLI, counterexample traces, and CPU liveness checks are in place, here’s what I’m working on next:

- **Better TLA+ frontend and coverage.** Replacing`tla-mc` ’s parser, either through SANY or a full-parity Rust parser tested directly against SANY so warpspec stays zero-Java by default. Alongside that, inferring variable types and integer bounds automatically so specs don’t need a`TypeOK` invariant, plus stateful parameterized`INSTANCE` (modules with variables) and`VIEW` .
- **Spilling past 32 GB of VRAM.** Random writes over PCIe are far too slow for a hash table, so scaling to 5 or 10 billion states on one workstation GPU needs a batched spill tier to host RAM and NVMe.
- **GPU liveness checking.** Moving fairness and temporal liveness checking from the CPU onto the GPU so big models don’t have to fall back to safety-only on the GPU.
- **Remote GPU backend.** Offloading GPU checks to a hosted GPU runner so you can run billion-state GPU checks from a laptop without an NVIDIA card.
- **Differential testing with FuzzTLA.** Plugging warpspec into FuzzTLA alongside TLC and Apalache as a third independent checker.
