[BUG][intel:xe2] shuffle_down of a local variable returns the lane's own value across the warp boundary

Abierto
#7,599 1 comentario 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
22/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Área
compilers, hpc

Línea de trabajo

The repro is in the issue body: a Mojo kernel calling max.gpu.primitives.warp.shuffle_down on a 32-lane block, comparing a local-variable operand against a directly loaded one. Start by reproducing it on the intel:xe2 target and confirming lanes 8-15 return their own value. The payload does not name the files where the lowering happens, so locating the cause is the hard part. Done means the local-operand shuffle matches the direct-load result, and lane_group_reduce with num_lanes=4, stride=8 returns 48.

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

Descripción

bug_feature_triaged Team: Mojo Libraries

Summary

max.gpu.primitives.warp.shuffle_down returns the calling lane's own value (not the source lane's value) for any lane whose source lane_id + offset crosses into the next warp — but only when the shuffled operand is a local variable. A directly-loaded value shuffles correctly across the warp boundary.

This is deterministic on the Intel Arc Pro B60 (Xe2) target.

Environment

  • Target: intel:xe2 (Arc Pro B60, 16-lane warp)
  • IGC 2.41.15, compute-runtime 1.17.39758
  • Built via Bazel with --target-accelerator=intel:xe2
  • Single device pinned via ZE_AFFINITY_MASK=1

Minimal repro

Value at lane i = i; block of 32 lanes (two 16-lane warps). Uses the full-mask form shuffle_down(val, offset).

from max.gpu import thread_idx
from max.gpu.primitives.warp import shuffle_down

def kernel(res: MutPointer[Scalar[.float32], MutAnyOrigin]):
    var lane = Int(thread_idx.x)
    var val: SIMD[.float32, 1] = SIMD[.float32, 1](Float32(lane))  # value at lane i == i

    var local = val   # LOCAL variable  (the trigger)
    # var direct = <a value loaded straight from memory, NOT via a local>  (control)

    # offset 8: lanes 8..15 read from lane+8, which crosses into the next warp at 16
    res[lane] = shuffle_down(val=local, offset=8)[0]   # WRONG on lanes 8-15
    # res[lane] = shuffle_down(val=direct, offset=8)[0]  # CORRECT everywhere

Observed (deterministic)

  • shuffle_down(local, 8) (local operand) → wrong on lanes 8–15: they get their own value, not the value from lane+8.
  • shuffle_down(local, 4) → wrong on lanes 12–15.
  • shuffle_down(direct, 8) (directly-loaded operand) → all correct, including the cross-warp reads (lane 0→8, lane 16→24).

The distinguishing factor is whether the operand is a local register vs. a directly-loaded value; the warp-boundary crossing alone is not sufficient (the direct case crosses the boundary and is correct).

Why it matters

  • This matches the "out-of-range shuffle returns self" signature, but it is triggered by cross-warp-local, not merely out-of-range.
  • It directly affects the stdlib lane_group_reduce butterfly (res = func(res, shuffle(res, off))) on any cross-warp use, so an out-of-warp strided group silently produces a wrong result on a 16-lane warp (e.g. lane_group_reduce with num_lanes=4, stride=8 returns 16 where the expected sum is 48).

Expected

shuffle_down(local, 8) should return the value from lane+8 for lanes 8–15 (the cross-warp case), matching the directly-loaded behavior.

Lenguaje dominante
Mojo
Estrellas
30.2k
Forks
3.2k
Merge medio
6 d 20 h
PR fusionados (30 d)
25

Preparar el entorno

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 modular/modular

Todos los issues de modular/modular

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.