字号·· | 护眼
theregister

Maxwell让次优代码在运行时焕发新生Maxwell gives sub-optimal code a runtime glow-up

点「原文对照」整页切到原文,或双击某段只看那段的原文。

仅使用LLM编写代码可能还不够,因为它们还能在程序运行时对代码进行调整。总部位于以色列特拉维夫、成立于2023年的初创公司DoubleAI周一推出了Maxwell,这是一种代码执行模型(CEM),能够在程序执行过程中评估、优化并重写二进制代码。Maxwell以“麦克斯韦妖”命名,这一概念由物理学家和数学家詹姆斯·克拉克·麦克斯韦于1867年提出,作为熵的思想实验的一部分。

It may not be enough to just use LLMs to write your code when you can also use them to adjust it while your program runs. DoubleAI, a Tel Aviv, Israel-based startup founded in 2023, on Monday introduced Maxwell, a code execution model (CEM) that evaluates, optimizes, and rewrites binary code during execution. Named for Maxwell's Demon, a creature imagined by physicist and mathematician James Clerk Maxwell in 1867 as part of a thought experiment on entropy, the Maxwell CEM preprocesses algorithms and machine instructions to maximize performance on available hardware.

Maxwell CEM会预处理算法和机器指令,以在可用硬件上实现最大性能。Maxwell的概念类似于即时编译器(JIT),但提供了更大的灵活性,并能形式化地验证替换代码的等价性。源代码不会被修改。“Maxwell和JIT编译器都在程序运行时工作,并且都会生成新的机器代码,”DoubleAI联合创始人、理论计算机科学博士Gal Beniamini在一封发给《The》的邮件中表示。

Maxwell is similar in concept to a just-in-time compiler, but provides more flexibility and formally verifies the equivalence of replacement code. Source code isn't touched. "Both Maxwell and a JIT compiler work while the program runs and both produce new machine code," said doubleAI co-founder Gal Beniamini, who holds a PhD in theoretical computer science, in an email to The.

“区别在于,编译器无法进行高层次的推理。例如,它无法更改算法。而Maxwell可以,并且确实如此。”“JIT编译器如此局限的原因之一在于,尽管它们可以依赖数据,但它们所做的更改必须是‘按构造’的确定性和正确的,因为JIT编译器是‘无思考’的经典算法。”“Maxwell将前沿AI的表达能力带入了‘JIT’环境。此外,Maxwell依赖形式化验证来编写实际的、严格的证明,以展示其优化是可靠的。这使得其允许的优化范围远远超过了任何算法或编译器所能达到的范围。”

"The difference is that a compiler can't do high-level reasoning. It can't, for example, change the algorithm. Maxwell can and does. "One of the reasons why JIT compilers are so narrow is that, even though they can be data-dependent, the changes they make must be deterministic and correct 'by construction,' since JIT compilers are 'unthinking' classical algorithms. "Maxwell brings the expressive power of frontier AI into the 'JIT' setting. In addition, Maxwell relies on formal verification to write actual, hard proofs that show that its optimizations are sound. This expands the scope of its allowed optimisation far beyond that of any algorithm or compiler."

Beniamini以排序为例进行说明。他表示,编译器会让通用排序算法尽可能快地运行,但不会用另一种算法替换它。Beniamini指出,编译器在程序运行前就做出决策,并且在选择上必须保持狭窄和保守。

Beniamini pointed to sorting as an example. The compiler, he said, will make a general-purpose sorting algorithm run as fast as it can, but it won't swap it out for a different algorithm. Compilers, said Beniamini, make decisions before the program runs and have to be narrow and conservative in their choices.

Maxwell,他说,能够处理更多信息,不仅仅是一次性操作,而且在更高层次上运行。“它能够看到程序所运行的确切硬件,以及流经它的数据的实际形状和类型(这些信息仅在运行时可用!),”贝尼亚米尼解释道。“它还能看到环境的状态,同一程序中还有什么在运行,以及哪些实际瓶颈表现出来,以及在什么条件下表现出来。这使得它能够以编译器永远无法实现的方式进行专门化。”

Maxwell, he said, works with more information, isn't just a one-pass operation, and operates at a higher level. "It sees the exact hardware the program has landed on, and the actual shapes and types of the data flowing through it (information that is only available during runtime!)," Beniamini explained. "It also sees the state of the environment, what else is running in the same program, and which actual bottlenecks express themselves, and under which conditions. This allows it to specialize in ways a compiler never can."

由于Maxwell持续运行,它可以在新瓶颈出现时不断改进程序。而且它能够以编译器无法实现的方式进行“推理”。如果模型以在运行时引入错误的方式重写代码,那么Maxwell的方法将不可能实现,因此形式证明能力不是可选的。根据doubleAI的说法,Maxwell使数据管道的速度提高了38倍以上,AI推理内核的速度提高了4.5倍以上。

Since Maxwell operates continuously, it can keep improving programs as new bottlenecks arise. And it can "reason" in a way that compilers cannot. Maxwell's approach wouldn't be possible if the model rewrote code in a way that introduced errors on the fly, so the formal proof capability is not optional. According to doubleAI, Maxwell has made data pipelines more than 38x faster and AI inference kernels more than 4.5x faster.

LTX-2.5是一个能够生成4K视频的开放世界模型,在Maxwell的帮助下,其速度几乎提高了一倍。Maxwell的优化减少了GPU之间的数据交换,并优化了内核选择以去除不必要的令牌填充。Maxwell的优化能力因源代码和硬件而异。“Maxwell在算法性代码以及能够以非平凡方式针对硬件进行定制的代码上表现最佳,”贝尼亚米尼说。

LTX-2.5, an open world model that generates 4K video, managed to do so almost twice as fast with the help of Maxwell. Maxwell's optimizations reduced the data being exchanged between GPUs and optimized the kernel selection to drop unnecessary token padding. Maxwell's optimization capability varies depending on the source code and the hardware. "Maxwell does best on code that is algorithmic, and which can be tailored to hardware in a non-trivial manner," said Beniamini.

“话虽如此,即使代码不是这样的,但如果是用像Python这样的高级语言编写的,由于可用的余量,通常也能享受到广泛的优化。PyTorch图也是如此,即使在Torch的编译器下,它们也往往远离最优状态。”它还能帮助提升代码安全性。贝尼亚米尼说,Maxwell可以通过在形式化过程中证明其不存在来消除诸如内存错误之类的问题。

"That being said, even code that isn't like that, but is written in a high level language like Python, can usually enjoy far reaching optimisations due to the available overhang. The same is true for PyTorch graphs, which (even under Torch's compiler) tend to be extremely far from optimal." It can also help with code security. Beniamini said Maxwell can eliminate issues like memory errors by proving their non-existence as part of the formalization process.

“轶事地说,我们通过使用 Maxwell 在 Python 本身中发现了此类问题 — — 即 Python 并非内存安全的情况,而 Maxwell 证明了这一点,”他说。更好的是,Maxwell 的追踪和分析在 CPU 或 GPU 上几乎不会产生任何开销。“Maxwell 的追踪和分析的最大开销为 2%(当它不进行追踪时,开销自然降至零),而 Maxwell 带来的优化远远超过这一点,”贝尼亚米尼说。

"Anecdotally, we have found such issues in Python itself, through the use of Maxwell – i.e., cases in which Python was not memory safe, and where Maxwell proved that to be the case," he said. And better still, Maxwell's tracing and profiling don't incur much if any overhead on either the CPU or GPU. "The maximal overhead of Maxwell's tracing and profiling is 2 percent (when it isn't tracing, that falls to zero, of course), and the optimisations that Maxwell yields far outweigh that," said Beniamini.

“我们还将 Maxwell 应用于运行时本身,这样我们就能获得远高于 2% 的'平坦'加速效果,全面提升。简而言之:它从不会变慢。”安装过程同样轻量:开发者安装运行时并运行代码,而 Maxwell 模型由 doubleAI 托管。然而,这种安排确实需要一定程度的信任。Amnon Shashua,doubleAI 的联合创始人兼首席执行官,Mobileye 的创始人及离任首席执行官,以及希伯来大学耶路撒冷分校的计算机科学教授,在一份声明中表示,AI 已经改变了软件的编写方式,现在正在改变软件的运行方式。

"We also apply Maxwell to the runtime itself, so that we get back a much larger than 2 percent 'flat' speedup, across the board. So in short: it's never slower." The installation process is similarly light-touch: Devs install the runtime and run their code, with the Maxwell model hosted by doubleAI. This arrangement, however, does require some amount of trust. Amnon Shashua, co-founder and CEO of doubleAI, founder and departing CEO of Mobileye and a professor of computer science at the Hebrew University of Jerusalem, said in a statement that AI has changed how software is written and now is changing how it runs.

“CEMs,尤其是 Maxwell,是代表硬件工作的代理,而不是代表人类用户工作的代码代理,”他说。”换句话说,它们是第一批为机器而非程序员工作的 AI。”®

"CEMs, and Maxwell in particular, are agents on behalf of the hardware as opposed to code agents that are on behalf of the human user," he said. "In other words, they are the first AI that works for the machine, not the programmer." ®

阅读媒体原文 ↗