Skip to content

Add RotaryEmbeddings(23) - CPU#24980

Merged
titaiwangms merged 10 commits intomicrosoft:mainfrom
titaiwangms:titaiwang/add_rotary_embeddings_23
Jun 25, 2025
Merged

Add RotaryEmbeddings(23) - CPU#24980
titaiwangms merged 10 commits intomicrosoft:mainfrom
titaiwangms:titaiwang/add_rotary_embeddings_23

Conversation

@titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented Jun 6, 2025

Description

Add ONNX RotaryEmbedding(23) following https://github.com/onnx/onnx/blob/main/docs/Operators.md#RotaryEmbedding. The PR uses contrib op RotaryEmbedding implementation under the hood.

The main difference between this op and the contrib op is that the position_ids in ONNX RotaryEmbedding is optional. When it's not provided, cos_cache and sin_cache should be 3d.

Motivation and Context

Fix #24556
Reference #23507

@titaiwangms titaiwangms changed the title Add RotaryEmbeddings(23) Add RotaryEmbeddings(23) - CPU Jun 17, 2025
@titaiwangms titaiwangms marked this pull request as ready for review June 17, 2025 00:05
@titaiwangms titaiwangms requested a review from tianleiwu June 17, 2025 00:06
@titaiwangms
Copy link
Contributor Author

@tianleiwu Could you help me reason the CI failing? It seems the code only fails on Windows Asan

@tianleiwu
Copy link
Contributor

tianleiwu commented Jun 18, 2025

@titaiwangms, the code crashed (maybe there is bug in either test code or the kernel):

[ RUN ] RotaryEmbeddingTest.RotaryEmbedding_Interleaved_NoPosIds_SmallData_LlamaMSFT
1: =================================================================
1: ==12148==ERROR: AddressSanitizer: unknown-crash on address 0x119c4a2fe0c0 at pc 0x7ff7dd41f007 bp 0x0010901c09f0 sp 0x0010901c0a00
1: READ of size 32 at 0x119c4a2fe0c0 thread T0
1: #0 0x7ff7dd41f006 in rope_avx2::`anonymous namespace'::RopeKernel_Avx2_fp32_Impl<1> D:\a_work\onnxruntime\onnxruntime\onnxruntime\core\mlas\lib\rotary_embedding_kernel_avx2.cpp:238
1: #1 0x7ff7dd41f2d4 in rope_avx2::RopeKernel_Avx2_fp32(float const *, float const *, float const *, unsigned __int64, bool, float *)

Could you review the test case setup and the kernel code?

@titaiwangms titaiwangms requested a review from tianleiwu June 24, 2025 16:01
@titaiwangms
Copy link
Contributor Author

@tianleiwu @gramalingam @xadupre PTAL
I need this one merged to start RotaryEmbedding with cuda, I can fix the minor issues in the next PR if there is any.

@titaiwangms titaiwangms merged commit 6cffd1a into microsoft:main Jun 25, 2025
85 of 88 checks passed
titaiwangms added a commit that referenced this pull request Jul 7, 2025
Follow up #24980
Fix #24556

Add ONNX RotaryEmbedding(23) following
https://github.com/onnx/onnx/blob/main/docs/Operators.md#RotaryEmbedding.
The PR uses contrib op RotaryEmbedding implementation under the hood.

The main difference between this op and the contrib op is that the
position_ids in ONNX RotaryEmbedding is optional. When it's not
provided, cos_cache and sin_cache should be 3d.
daijh pushed a commit to daijh/onnxruntime that referenced this pull request Jul 10, 2025
Follow up microsoft#24980
Fix microsoft#24556

Add ONNX RotaryEmbedding(23) following
https://github.com/onnx/onnx/blob/main/docs/Operators.md#RotaryEmbedding.
The PR uses contrib op RotaryEmbedding implementation under the hood.

The main difference between this op and the contrib op is that the
position_ids in ONNX RotaryEmbedding is optional. When it's not
provided, cos_cache and sin_cache should be 3d.
qti-yuduo pushed a commit to CodeLinaro/onnxruntime that referenced this pull request Aug 8, 2025
Follow up microsoft#24980
Fix microsoft#24556

Add ONNX RotaryEmbedding(23) following
https://github.com/onnx/onnx/blob/main/docs/Operators.md#RotaryEmbedding.
The PR uses contrib op RotaryEmbedding implementation under the hood.

The main difference between this op and the contrib op is that the
position_ids in ONNX RotaryEmbedding is optional. When it's not
provided, cos_cache and sin_cache should be 3d.
sanketkaleoss pushed a commit to sanketkaleoss/onnxruntime that referenced this pull request Aug 11, 2025
Follow up microsoft#24980
Fix microsoft#24556

Add ONNX RotaryEmbedding(23) following
https://github.com/onnx/onnx/blob/main/docs/Operators.md#RotaryEmbedding.
The PR uses contrib op RotaryEmbedding implementation under the hood.

The main difference between this op and the contrib op is that the
position_ids in ONNX RotaryEmbedding is optional. When it's not
provided, cos_cache and sin_cache should be 3d.
quic-ankus pushed a commit to CodeLinaro/onnxruntime that referenced this pull request Nov 25, 2025
### Description
<!-- Describe your changes. -->

Add ONNX RotaryEmbedding(23) following
https://github.com/onnx/onnx/blob/main/docs/Operators.md#RotaryEmbedding.
The PR uses contrib op RotaryEmbedding implementation under the hood.

The main difference between this op and the contrib op is that the
`position_ids` in ONNX RotaryEmbedding is optional. When it's not
provided, `cos_cache` and `sin_cache` should be 3d.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

Fix microsoft#24556
Reference microsoft#23507
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.

[Feature Request] Implement RotaryEmbedding-23

4 participants