跳到主内容
@wquguru
精选88r/LocalLLaMA(Reddit)技巧与观点

laya.cpp:基于ggml与自定义CUDA内核的Laya推理优化实现

laya.cpp: Optimized laya near-instant decision making

原文
发到 X
推荐理由

给本地部署Laya模型的同学提供了极佳的推理加速方案,C++实现配合自定义CUDA内核性能提升明显,且无需Python依赖,适合对延迟敏感的生产环境参考。

After seeing u/Nandakishor_ml’s post introducing Laya, I wanted to see how fast it could run in a standalone C++ implementation.

在看到 u/Nandakishor_ml 发布的介绍 Laya 的帖子后,我想看看它在独立的 C++ 实现中能跑得多快。

Credit to u/Nandakishor_ml for the architecture, training and open-source release. My contribution is the inference implementation: laya.cpp, built on ggml with custom CUDA kernels.

架构、训练和开源发布归功于 u/Nandakishor_ml。我的贡献是推理实现:laya.cpp,基于 ggml 并带有自定义 CUDA 内核构建。

It supports all three checkpoints—English, multilingual and typed-decisions—with native tokenization, model execution and output formatting. There’s also an HTTP server with a JEV-compatible endpoint. No Python or PyTorch is required for inference.

它支持所有三个检查点——英语、多语言和类型决策——具备原生分词、模型执行和输出格式化功能。此外还有一个带有 JEV 兼容端点的 HTTP 服务器。推理过程不需要 Python 或 PyTorch。

Some English-model results on an RTX PRO 6000 Blackwell, capped at 450 W:

在 RTX PRO 6000 Blackwell 上运行部分英语模型的结果,功耗限制为 450 W:

BatchPython BF16C++ BF16Python FP32C++ FP32
1149366148342
2268586202421
4460761233437
8663810232386
BatchPython BF16C++ BF16Python FP32C++ FP32
1149366148342
2268586202421
4460761233437
8663810232386

These are questions per second over a fixed 250-question corpus containing choices, scores and booleans. Each precision has paired Python/C++ timings with alternating execution order. Loading and JSON transport are excluded. The README has the full three-model results.

这是针对包含选项、分数和布尔值的固定 250 题语料库每秒处理的题目数。每种精度都有配对的 Python/C++ 计时数据,执行顺序交替进行。加载时间和 JSON 传输时间已排除在外。README 中有完整的三模型结果。

Most of the optimization came from removing unnecessary conversions and copies, fusing operations while preserving rounding, and improving attention memory access.

大部分优化来自于移除不必要的转换和拷贝,在保留舍入精度的同时融合操作,以及改进注意力机制的内存访问。

The code is MIT-licensed. BF16 currently needs the documented CUDA 13.0/cuBLAS 13.1.0 build profile.

代码采用 MIT 许可证。BF16 目前需要文档中指定的 CUDA 13.0/cuBLAS 13.1.0 构建配置。

Implemented using Codex Astra.

使用 Codex Astra 实现。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件