Skip to content

PR #28877: [XLA]Clamp num_workers to avoid partition overflow #97046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

copybara-service[bot]
Copy link

PR #28877: [XLA]Clamp num_workers to avoid partition overflow

Imported from GitHub PR openxla/xla#28877

When invoking Worker::Parallelize in parallel_for(), the number of workers was previously set to thread_pool_->NumThreads(), which could exceed the number of tasks (n). This mismatch could lead to out-of-bounds access when workers attempt to access partitions that don't exist.

This ensures that:

  • The number of worker threads does not exceed the number of tasks
  • Each worker maps safely to a valid partition index
  • Partition and worker ranges stay aligned, preventing undefined behavior

Change-Id: I5c3ab319f73009452d27b4db43f7905c5e136c2b
Copybara import of the project:

--
d72f403a8312b995d5db6112d0e5cb8ad9befff1 by Sharif Inamdar sharif.inamdar@arm.com:

[XLA]Clamp num_workers to avoid partition overflow

When invoking Worker::Parallelize in parallel_for(), the number
of workers was previously set to thread_pool_->NumThreads() in
oneDNN, which could exceed the number of tasks (n). This mismatch
could lead to out-of-bounds access when workers attempt to access
partitions that don't exist.

Fixed by moving the clamping logic to Worker::Parallelize for
all paths.

This ensures that:

  • The number of worker threads does not exceed the number of tasks
  • Each worker maps safely to a valid partition index
  • Partition and worker ranges stay aligned, preventing undefined
    behavior

Added simple unit test to test for all usecases.

Change-Id: I5c3ab319f73009452d27b4db43f7905c5e136c2b

Merging this change closes #28877

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#28877 from isharif168:fix-worker-partition-safety d72f403a8312b995d5db6112d0e5cb8ad9befff1

@copybara-service copybara-service bot force-pushed the exported_pr_782956620 branch 2 times, most recently from 6ac02c9 to 27bcefc Compare July 16, 2025 15:38
Imported from GitHub PR openxla/xla#28877

When invoking Worker::Parallelize in parallel_for(), the number of workers was previously set to thread_pool_->NumThreads(), which could exceed the number of tasks (n). This mismatch could lead to out-of-bounds access when workers attempt to access partitions that don't exist.

This ensures that:
- The number of worker threads does not exceed the number of tasks
- Each worker maps safely to a valid partition index
- Partition and worker ranges stay aligned, preventing undefined behavior

Change-Id: I5c3ab319f73009452d27b4db43f7905c5e136c2b
Copybara import of the project:

--
d72f403a8312b995d5db6112d0e5cb8ad9befff1 by Sharif Inamdar <sharif.inamdar@arm.com>:

[XLA]Clamp num_workers to avoid partition overflow

When invoking Worker::Parallelize in parallel_for(), the number
of workers was previously set to thread_pool_->NumThreads() in
oneDNN, which could exceed the number of tasks (n). This mismatch
could lead to out-of-bounds access when workers attempt to access
partitions that don't exist.

Fixed by moving the clamping logic to Worker::Parallelize for
all paths.

This ensures that:
- The number of worker threads does not exceed the number of tasks
- Each worker maps safely to a valid partition index
- Partition and worker ranges stay aligned, preventing undefined
  behavior

Added simple unit test to test for all usecases.

Change-Id: I5c3ab319f73009452d27b4db43f7905c5e136c2b

Merging this change closes #28877

PiperOrigin-RevId: 783796500
@copybara-service copybara-service bot force-pushed the exported_pr_782956620 branch from 27bcefc to fcef98c Compare July 16, 2025 17:06
@copybara-service copybara-service bot merged commit fcef98c into master Jul 16, 2025
@copybara-service copybara-service bot deleted the exported_pr_782956620 branch July 16, 2025 17:07
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.

Opening bug #27833 again, since not able to compile tensorflow on debian 9
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy