Skip to content

Request IEEE fp32 division for SYCL kernels - #752

Merged
sayakpaul merged 4 commits into
huggingface:mainfrom
jiqing-feng:xpu-fp32-prec-div
Aug 13, 2026
Merged

Request IEEE fp32 division for SYCL kernels#752
sayakpaul merged 4 commits into
huggingface:mainfrom
jiqing-feng:xpu-fp32-prec-div

Conversation

@jiqing-feng

Copy link
Copy Markdown
Contributor

Summary

Adds -foffload-fp32-prec-div and -foffload-fp32-prec-sqrt to the SYCL build
flags, matching how PyTorch builds its own XPU kernels in torch-xpu-ops.

Without them the compiler defaults to a fast floating-point model in which fp32
division is allowed several ULP of error and a / b is lowered to a * rcp(b).
Kernels built this way return results that differ from the eager PyTorch ones in
the last bit, which breaks kernel tests that compare against PyTorch exactly.

These flags affect the offload backend and only take effect when passed to both
the device compile and the device link step, so the per-kernel sycl-flags in
build.toml cannot substitute for them. Applied to the torch and tvm_ffi
preambles alike.

Validation

Verified with kernels-community/activation on Intel Arc Pro B60 with
torch 2.13.0+xpu and oneAPI 2026.0. Its silu_and_mul and mul_and_silu
operators go from 42 failures to a fully passing suite (396 cases), with no
change in measured throughput.

The SYCL compiler defaults to a fast floating-point model in which fp32
division is allowed several ULP of error and `a / b` is lowered to
`a * rcp(b)`. Kernels built this way return results that differ from the
eager PyTorch ones in the last bit, which breaks kernel tests that compare
against PyTorch exactly.

Add -foffload-fp32-prec-div and -foffload-fp32-prec-sqrt, matching how
PyTorch builds its own XPU kernels in torch-xpu-ops. These affect the
offload backend and only take effect when passed to both the device compile
and the device link step, so per-kernel `sycl-flags` in build.toml cannot
substitute for them.

Verified with the activation kernel on Intel Arc Pro B60: its silu_and_mul
and mul_and_silu operators go from 42 failures to a fully passing suite,
with no change in measured throughput.

@drbh drbh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@sayakpaul
sayakpaul merged commit 3a5c09d into huggingface:main Aug 13, 2026
38 of 41 checks passed
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.

3 participants