首页 时政热点 科技头条 智能AI 安全攻防 数码硬件 开发者生态 归档 标签 关于

显示 HN:Warpspec – 在 GPU 上进行 TLA+ 模型检查,比 TLC 快 4,600 倍

摘要

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 billi...

the and TLC CPU GPU run states its state not
2026-12-03 1 阅读 约10分钟阅读 praveenperera
分享:
字号:
我一直在寻找 AI 之外的工作负载,其中单个桌面 GPU 可以发挥真正的作用,而 TLA+ 模型检查脱颖而出。检查分布式协议规范意味着探索数百万或数十亿个可达状态,并且大部分工作是并行的。我构建了 warpspec 来测试将其放在 GPU 上是否真的有效。 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.它已获得 Apache-2.0 许可。我从一开始就遵循的原则是,除非答案与 TLC 相匹配,否则速度不算数。对于两个检查器完成的每个模型,warpspec 报告完全相同数量的不同状态、生成状态和搜索深度。 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 CPU 和 GPU 列是搜索时间; 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).我没有在最后两行上运行 TLC,它们不适合这台机器上的 CPU 检查器内存。我将在下面解释如何检查它们的计数。在构建这个时,有两件事让我感到惊讶。 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.其次,明显的 GPU 内核太慢了(LamportMutex 上的 24 个 CPU 内核仅慢了 3.6 倍),直到我改变了它的结构。 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.这使其跃升至 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 Packing a spec into fixed integers The same code on the CPU Why the obvious GPU kernel was slow Why Rust and cuda-oxide Fitting 2 billion states in 32 GB Traces and liveness Testing against tlaplus/Examples Limitations Trying it What’s next Where model checkers spend their time At a high level, TLC runs breadth-first search.它计算起始状态,然后一次遍历状态图一层。 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.当一个关卡没有产生任何新内容时,它就会停止。图搜索本身很便宜。几乎所有的时间都花在了评估规范上。 TLC 通过动态类型值解释 TLA+,其中任何变量都可以保存集合、记录、函数和序列的嵌套组合。这种灵活性使 TLC 可以检查您编写的几乎所有规范,而无需询问类型。 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.状态队列为0.4%。 tla-mc 将 TLA+ 编译为 Rust,从而摆脱了解释器。它比 TLC 快得多:在 EWD998 N = 4 上为 76.7 秒,而在 EWD998 N = 4 上为 401.5 秒;在具有四个接受器的 PaxosCommit 上为 36.3 秒,而在 PaxosCommit 上为 101 秒。 everystate , a Rust TLA+ checker that runs directly with no compile step (and
这篇文章对您有帮助吗?

订阅66必读

每日精选科技资讯,直达你的邮箱