Skip to content

[executorch][native-ggml] Leave zero-frequency RoPE dims unrotated - #24990

Merged
SS-JIA merged 1 commit into
mainfrom
gh/SS-JIA/702/orig
Nov 12, 2026
Merged

SS-JIA merged 1 commit into
mainfrom
gh/SS-JIA/702/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #24846 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/702/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/702/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/701/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/702/orig
Differential Revision: D130721990
@diff-train-skip-merge

@pytorch-bot

pytorch-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24990

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 47 Pending

As of commit 89acfe7 with merge base fcc9575 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 12, 2026
@SS-JIA
SS-JIA added this pull request to stack #24995 November 12, 2026 20:32
Base automatically changed from gh/SS-JIA/701/orig to main November 12, 2026 21:18
## Ulterior Motive

Running Gemma 4 31B through ExecuTorch Native's GGML engine on CUDA, to find why it decodes slower than llama.cpp on the same GGUF.

## Rationale

**What**: A zero entry in a `native::rope` `inv_freq` table now leaves its pair of dims unrotated.

**Why**: Gemma 4's partial RoPE writes the dims it does not rotate as zero inverse frequencies, and the engine rejected such tables at load with `ggml: rope inv_freq has a zero entry`.

## Details

The engine passes `ggml_rope_ext` the factors `1 / inv_freq` with a frequency base of 1, so `theta = pos / factor`.

- **Before**: a zero `inv_freq` threw at load.
- **After**: its factor is infinite, so `theta = 0`: cos 1, sin 0, and the dims pass through unchanged, as in eager PyTorch.

`test_rope_zero_frequency_leaves_dims_unrotated` zeroes the upper half of a Llama RoPE's `inv_freq`.

Authored with Claude Code.

Differential Revision: [D130721990](https://our.internmc.facebook.com/intern/diff/D130721990/)


ghstack-source-id: 469829006
Pull-Request: #24846
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@SS-JIA
SS-JIA merged commit ce0d880 into main Nov 12, 2026
@SS-JIA
SS-JIA deleted the gh/SS-JIA/702/orig branch November 12, 2026 21:45

This branch was previously deployed

1 inactive deployment
cadence — 89acfe75 Deployed Nov 12, 2026 by SS-JIA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants