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

Offen
#7,599 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
22/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Bereich
compilers, hpc

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Mojo
Sterne
30.2k
Forks
3.2k
Ø Merge
6 T. 20 Std.
Gemergte PRs (30 T.)
25

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modular/modular

Alle Issues in modular/modular

Ähnliche Issues

Weitere Issues zu Compilers

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.