Add debug logging for threading and parallelization dec…#3
Draft
Add debug logging for threading and parallelization dec…#3
Conversation
…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
There was a problem hiding this comment.
Pull Request Overview
Adds debug logging across Python and Rust components to help diagnose threading and parallelization decisions.
- Python: Injected
logger.debugstatements inshould_run_in_parallel,parallel_map, SABRE trial count, and PassManager execution paths. - Rust: Emits threading decision to stderr when
QISKIT_DEBUG_THREADINGis 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"
| del callback | ||
| del kwargs | ||
|
|
||
| logger.debug("PassManager running %d programs in parallel with %d processes", |
There was a problem hiding this comment.
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.
|
|
||
| // Log threading decision if debug logging is enabled | ||
| if env::var("QISKIT_DEBUG_THREADING").is_ok() { | ||
| eprintln!( |
There was a problem hiding this comment.
[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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…isions
Adds debug logging across Rust and Python components to help diagnose threading behavior and parallelization decisions. Includes logging for:
Co-Authored with the help of: Claude
Summary
Details and comments