Skip to content

Add debug logging for threading and parallelization dec… #3

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eginez
Copy link

@eginez eginez commented Jun 13, 2025

…isions

Adds debug logging across Rust and Python components to help diagnose threading behavior and parallelization decisions. Includes logging for:

  • Rust threading decisions in getenv_use_multiple_threads()
  • PassManager parallel execution choices and process counts
  • SABRE layout trial count configuration
  • parallel_map execution paths and results

Co-Authored with the help of: Claude

Summary

Details and comments

…isions

Adds debug logging across Rust and Python components to help diagnose
threading behavior and parallelization decisions. Includes logging for:
- Rust threading decisions in getenv_use_multiple_threads()
- PassManager parallel execution choices and process counts
- SABRE layout trial count configuration
- parallel_map execution paths and results

Co-Authored with the help of: Claude
@eginez eginez changed the title Add comprehensive debug logging for threading and parallelization dec… Add debug logging for threading and parallelization dec… Jun 13, 2025
@eginez eginez requested a review from Copilot June 13, 2025 16:25
Copy link

@Copilot 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

Adds debug logging across Python and Rust components to help diagnose threading and parallelization decisions.

  • Python: Injected logger.debug statements in should_run_in_parallel, parallel_map, SABRE trial count, and PassManager execution paths.
  • Rust: Emits threading decision to stderr when QISKIT_DEBUG_THREADING is set.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
qiskit/utils/parallel.py Added logging import, logger setup, and debug statements around parallel decisions and execution.
qiskit/transpiler/preset_passmanagers/builtin_plugins.py Added debug logging in _get_trial_count for SABRE threading trials.
qiskit/passmanager/passmanager.py Added debug logs in callback_func for serial vs parallel PassManager runs.
crates/accelerate/src/lib.rs Added Rust debug printing under QISKIT_DEBUG_THREADING environment variable.
Comments suppressed due to low confidence (1)

qiskit/utils/parallel.py:197

  • The environment variable QISKIT_IN_PARALLEL is only reset in the KeyboardInterrupt branch, so other exceptions leave it set to TRUE. Consider moving the reset into a finally block to ensure it's always restored.
os.environ["QISKIT_IN_PARALLEL"] = "FALSE"

@@ -239,6 +244,9 @@ def callback_func(**kwargs):
del callback
del kwargs

logger.debug("PassManager running %d programs in parallel with %d processes",
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

The serial execution branch assigns to out but lacks a return, so execution always falls through to the parallel path. Add a return statement inside the if-block to avoid unintended parallel runs.

Copilot uses AI. Check for mistakes.


// Log threading decision if debug logging is enabled
if env::var("QISKIT_DEBUG_THREADING").is_ok() {
eprintln!(
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

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

[nitpick] Using eprintln! for debug output is inconsistent with typical Rust logging practices. Consider using the log crate to emit debug-level messages and integrate with existing logging infrastructure.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant