Skip to content

Conversation

@kimishpatel
Copy link
Contributor

@kimishpatel kimishpatel commented Nov 14, 2025

Stack from ghstack (oldest at bottom):

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

Differential Revision: D85532081

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 14, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 3 Pending, 1 Unrelated Failure

As of commit 117b6e7 with merge base 4aaa7ff (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 14, 2025
kimishpatel added a commit that referenced this pull request Nov 14, 2025
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

ghstack-source-id: 323355686
Pull Request resolved: #15830
@manuelcandales manuelcandales added the release notes: ops & kernels Changes to the opset and any new / changed kernel implementations label Nov 14, 2025
@mergennachin mergennachin requested a review from Copilot November 17, 2025 16:15
Copilot finished reviewing on behalf of mergennachin November 17, 2025 16:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds parallel processing to the slice_copy operation in ExecutorTorch to improve performance during large prefills in LLMs, where slice_copy can take 5-10% of execution time (primarily from rope implementation slicing).

Key Changes:

  • Added multithreading support to compute_slice function with workload-based thresholds
  • Parallel execution distributes work across leading dimensions using parallel_for
  • Single-threaded fallback maintained for smaller workloads

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
kernels/portable/cpu/util/targets.bzl Adds threadpool dependency required for parallel execution support
kernels/portable/cpu/util/slice_util.cpp Implements parallel slice_copy with multithreading when leading_dims ≥ 8 and total_elements ≥ 32768, maintaining single-threaded fallback for smaller workloads

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (use_multithreading) {
// Use parallel_for to distribute work across leading dimensions
// Calculate grain size based on number of elements per leading dimension
const int64_t elements_per_leading_dim = length * trailing_dims;
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

The variable elements_per_leading_dim is calculated but never used. It appears this was intended for grain size calculation but MIN_LEADING_DIMS_FOR_MT is used instead. Consider removing this unused variable or using it to calculate a more dynamic grain size based on workload characteristics.

Suggested change
const int64_t elements_per_leading_dim = length * trailing_dims;

Copilot uses AI. Check for mistakes.
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 20, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
ghstack-source-id: 324784683
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 21, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 324975499

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 22, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325110790

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 23, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325206643

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 23, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325251276

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 23, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325262631

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 24, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325372208

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 24, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325397489

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Nov 25, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 325668666

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 326932760

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 326932760

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 326986639

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327095994

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327095994

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327106882

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327110500

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327113306

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 4, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327186826

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 6, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327614758

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.

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

[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Dec 7, 2025
Pull Request resolved: #15830

When doing large prefills in LLMs, slice_copy takes about 5-10% time.
Mainly coming from slicing in the rope implementation.
ghstack-source-id: 327630241

Differential Revision: [D85532081](https://our.internmc.facebook.com/intern/diff/D85532081/)
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. fb-exported meta-exported release notes: ops & kernels Changes to the opset and any new / changed kernel implementations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants