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

Abierto
#866 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
julia
Área
performance

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).
Lenguaje dominante
Julia
Estrellas
462
Forks
109
Merge medio
4 d 11 h
PR fusionados (30 d)
26

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaGPU/GPUArrays.jl

Todos los issues de JuliaGPU/GPUArrays.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.