First matrix product takes 2–3× longer to compile with GPUArrays 12.3.0: `mul!` compiles every branch's kernel launches

未关闭
#866 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
julia
领域
performance

调研方向

Start with the mul! paths in GPUArrays 12.3.0 described in the report, especially generic_matmatmul!, tiled_matmatmul!, and the storage-level methods from #852; compare them with the matvec kernels from #855. Reproduce the first-call timings with the supplied JLArrays example and --trace-compile-timing. Done means identifying and addressing the unnecessary host compilation while preserving the reported matrix product behavior and validating the fresh-process timings.

由索引模型根据 Issue 内容生成。

描述

I saw this on the TTFX graph, this might be intended but thought I would open an issue in case it is not.


🤖

The first A * b on a JLArray went from about 0.7 s to 2.0 s between GPUArrays 12.2.0 and 12.3.0.

using JLArrays
A = jl(rand(3, 3)); b = jl(rand(3))
@time A * b

First call in a fresh process with the JIT object cache cleared, in ms:

A*b A*B A'*b Symmetric(A)*b A*A'
12.2.0 708 677 708 722 694
12.3.0 1997 1226 1969 2141 1246

The kernel itself compiles in about 0.2 s as before. The rest is host code: --trace-compile-timing attributes about 1.4 s to *(::JLArray{Float64, 2}, ::JLArray{Float64, 1}), up from about 60 ms.

Compiling that one method now specializes the kernel compile-and-launch code for kernels the call never runs:

  • LinearAlgebra.@stable_muladdmul in generic_matmatmul! and tiled_matmatmul! expands to a branch per MulAddMul type, so everything below it is compiled four times.
  • The storage-level mul! methods from #852 reach, statically, _rmul_or_fill! (fill and scale kernels), the reshape fallback into the matrix mul!, and blas_syrk!/blas_herk! with copytri! (four kernels).
  • The matvec kernels from #855 loop over a StepRange, whose construction can throw. That sends the kernel through GPUCompiler's exception-site code, which is not precompiled (about 100 ms).
主要语言
Julia
星标
462
派生
109
平均合并
4 天 11 小时
30 天内合并 PR
26

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaGPU/GPUArrays.jl 的其他 Issue

查看 JuliaGPU/GPUArrays.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。