-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,20 @@ pub fn getenv_use_multiple_threads() -> bool { | |
| .unwrap_or_else(|_| "FALSE".to_string()) | ||
| .to_uppercase() | ||
| == "TRUE"; | ||
| !parallel_context || force_threads | ||
|
|
||
| let result = !parallel_context || force_threads; | ||
|
|
||
| // Log threading decision if debug logging is enabled | ||
| if env::var("QISKIT_DEBUG_THREADING").is_ok() { | ||
| eprintln!( | ||
|
||
| "Rust threading decision: {} (parallel_context={}, force_threads={})", | ||
| if result { "MULTI_THREADED" } else { "SINGLE_THREADED" }, | ||
| parallel_context, | ||
| force_threads | ||
| ); | ||
| } | ||
|
|
||
| result | ||
| } | ||
|
|
||
| import_exception!(qiskit.exceptions, QiskitError); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
|
|
||
| import dill | ||
|
|
||
| from qiskit.utils.parallel import parallel_map, should_run_in_parallel | ||
| from qiskit.utils.parallel import parallel_map, should_run_in_parallel, CPU_COUNT | ||
| from .base_tasks import Task, PassManagerIR | ||
| from .exceptions import PassManagerError | ||
| from .flow_controllers import FlowControllerLinear | ||
|
|
@@ -227,7 +227,12 @@ def callback_func(**kwargs): | |
|
|
||
| # If we're not going to run in parallel, we want to avoid spending time `dill` serializing | ||
| # ourselves, since that can be quite expensive. | ||
| if len(in_programs) == 1 or not should_run_in_parallel(num_processes): | ||
| use_parallel = should_run_in_parallel(num_processes) | ||
| if len(in_programs) == 1 or not use_parallel: | ||
| if len(in_programs) == 1: | ||
| logger.debug("PassManager running single program serially") | ||
| else: | ||
| logger.debug("PassManager running %d programs serially (parallel disabled)", len(in_programs)) | ||
| out = [ | ||
| _run_workflow(program=program, pass_manager=self, callback=callback, **kwargs) | ||
| for program in in_programs | ||
|
|
@@ -239,6 +244,9 @@ def callback_func(**kwargs): | |
| del callback | ||
| del kwargs | ||
|
|
||
| logger.debug("PassManager running %d programs in parallel with %d processes", | ||
|
||
| len(in_programs), num_processes or CPU_COUNT) | ||
|
|
||
| # Pass manager may contain callable and we need to serialize through dill rather than pickle. | ||
| # See https://github.com/Qiskit/qiskit-terra/pull/3290 | ||
| # Note that serialized object is deserialized as a different object. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.