Skip to content

[SYCL] Restore the nd_range default constructor - #22949

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

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

Conversation

@arnavprabhu

@arnavprabhu arnavprabhu commented Aug 15, 2026

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;. 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 and offset.

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
Comment thread sycl/include/sycl/nd_range.hpp Outdated
@KornevNikita

Copy link
Copy Markdown
Contributor

Note for reviewers - please do not merge it right now. We need a few days to discuss this and decide if we want to put it to SYCL 2020 (most likely) or to create a oneapi extension.

@dvrogozh

Copy link
Copy Markdown
Contributor

if we want to put it to SYCL 2020 (most likely) or to create a oneapi extension.

Please, keep me updated on this.

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

3 participants