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

Aperta
#866 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
julia
Ambito
performance

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).
Lingua principale
Julia
Stelle
462
Fork
109
Merge medio
4g 11h
PR unite (30g)
26

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaGPU/GPUArrays.jl

Tutte le issue di JuliaGPU/GPUArrays.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.