Skip to content

Migrate log functions to sycl:: in XPU kernels and refactor types#3725

Open
orrangetabby17 wants to merge 4 commits into
mainfrom
shuxin/log
Open

Migrate log functions to sycl:: in XPU kernels and refactor types#3725
orrangetabby17 wants to merge 4 commits into
mainfrom
shuxin/log

Conversation

@orrangetabby17
Copy link
Copy Markdown

@orrangetabby17 orrangetabby17 commented May 21, 2026

This pull request updates various mathematical kernel implementations to consistently use SYCL-provided logarithmic functions (sycl::log, sycl::log1p) instead of the standard C++ math library (std::log, std::log1p). This change improves compatibility and performance on SYCL-supported devices, and ensures consistent behavior across the codebase. Additionally, there are minor type and header updates to support these changes.

Logarithmic function migration:

  • Replaced all uses of std::log and std::log1p with sycl::log and sycl::log1p, including files like ActivationMishKernels.cpp, ActivationSoftplusKernels.cpp, BinaryMiscOpsKernels.cpp, LogAddExpKernels.cpp, LossCTCKernels.cpp, MathExtensions.h, Philox4x32.h, and SoftMaxKernels.cpp.

Type and header consistency:

  • Introduced or updated the use of at::opmath_type for correct type promotion in mathematical operations.
  • Added missing headers such as <c10/util/complex.h> to ensure proper compilation.

ASM difference:

  • log: std: 1×math.log  sycl: 1×math.log + some additional instructions.
  • log10: std: 1×math.log  sycl:  no math instruction.
  • log2: std: 1×math.log  sycl: no math instruction.

These changes collectively improve device compatibility, numerical correctness, and maintainability of the SYCL backend.

@github-actions github-actions Bot added disable_e2e Disable all e2e test jobs for the PR disable_distributed Disable distributed UT test jobs for the PR labels May 21, 2026
@chuanqi129 chuanqi129 marked this pull request as draft May 21, 2026 06:16
@chuanqi129 chuanqi129 marked this pull request as ready for review May 21, 2026 06:16
@orrangetabby17 orrangetabby17 requested a review from jianyizh May 21, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disable_distributed Disable distributed UT test jobs for the PR disable_e2e Disable all e2e test jobs for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants