Skip to content

[Device] synchronizeDevice as a no-op, and eager abs over every real dtype and layout - #538

Closed
student-Jungmin wants to merge 2 commits into
pending-1116from
npu-sync-abs
Closed

student-Jungmin wants to merge 2 commits into
pending-1116from
npu-sync-abs

Conversation

@student-Jungmin

Copy link
Copy Markdown
Collaborator

Stacked on #537 (branch pending-1116). Two eager device fixes, found while running TritonBench on npu.

  • [Device] synchronizeDevice is a no-op, like synchronizeStream and synchronizeEvent. The npu device is synchronous. Before this, torch.accelerator.synchronize() raised "Backend doesn't support synchronizing all streams", and TritonBench stopped after the first implementation of every operator.
  • [Device] Eager abs dispatches over every real dtype, including f16, bf16, i32 and i64. A non-contiguous input is computed on a contiguous copy. Before this, abs accepted only contiguous f32, and 13 of the 15 test cases failed. Bool and complex are not covered.

Test: tests/system/test_device_runtime_ops.py covers sync plus abs on 5 dtypes x 3 layouts against CPU. Before: synchronize fails and 13/15 abs cases fail. After: 16/16 pass. It was run in the torchsim_base-77eac17860ce image with PTB pending-1116 overlaid.

… event

The device runs synchronously, so the guard already answers synchronizeStream and
synchronizeEvent with nothing to wait for, but not synchronizeDevice: torch's default
raised "Backend doesn't support synchronizing all streams on device" from
torch.accelerator.synchronize() (seen in TritonBench).
The abs stub accepted Float only and refused a non-contiguous input, so bf16/fp16
abs on npu failed (TritonBench fp8_gemm). It now dispatches over
AT_DISPATCH_ALL_TYPES_AND2(Half, BFloat16), computing in opmath, and a
non-contiguous iteration runs on a contiguous copy of the input before copying the
result back. tests/system/test_device_runtime_ops.py checks f32/f16/bf16/i32/i64
on a contiguous tensor, a transpose and a strided slice against the CPU.
@student-Jungmin

Copy link
Copy Markdown
Collaborator Author

Replaced by #541, rebased onto #539 (pending-1116 is retired).

@YWHyuk
YWHyuk deleted the npu-sync-abs branch November 19, 2026 05:29
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.

1 participant