Skip to content

[SYCL] Restore the nd_range default constructor - #22949

Open
arnavprabhu wants to merge 1 commit into
intel:syclfrom
arnavprabhu:fix/nd-range-default-constructor
Open

[SYCL] Restore the nd_range default constructor#22949
arnavprabhu wants to merge 1 commit into
intel:syclfrom
arnavprabhu:fix/nd-range-default-constructor

Conversation

@arnavprabhu

Copy link
Copy Markdown

Fixes #22940

Problem

PR #22908 removed nd_range's default constructor (nd_range() = default;)
to align the class with the SYCL 2020 specification, which does not declare
one. That broke code which default-constructs an nd_range and assigns it
later. The most visible casualty is CuTe's launch_policy
(include/cute/util/compat/launch_policy.hpp), used by PyTorch's XPU
flash-attention kernels, which holds an nd_range<3> member that gets
default-initialized:

error: constructor for 'compat::experimental::launch_policy<sycl::nd_range<3>, ...>'
must explicitly initialize the member '_range' which does not have a default constructor

Change

Restore nd_range() = default; as a backwards-compatibility extension. All
three members (globalSize, localSize, offset) are range/id objects,
both of which keep zero-initializing default constructors, so a
default-constructed nd_range is well-defined and produces zeroed ranges.

A comment in the header notes that the constructor is an extension beyond
SYCL 2020 and why it is kept.

Test plan

  • Extended sycl/test/basic_tests/nd_range.cpp to default-construct an
    nd_range<3> and assert the constituent ranges and offset are
    zero-initialized.

PR intel#22908 removed nd_range's default constructor to align with the SYCL 2020
specification, which does not define one. That broke code which relies on
default-constructing an nd_range and assigning it later, most notably CuTe's
launch_policy used by PyTorch's XPU flash-attention kernels.

Restore the constructor as a backwards-compatibility extension and add a test
that checks it zero-initializes the constituent ranges.

Fixes intel#22940
@arnavprabhu
arnavprabhu requested a review from a team as a code owner August 15, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux Pytorch build broken in 20260812 nightly

1 participant