Skip to content

Commit

Permalink
Fix parallel_map publishing for an input of len=1 (Qiskit#1394)
Browse files Browse the repository at this point in the history
* Fix parallezation in transpile.compile

* Revert "Fix parallezation in transpile.compile"

This reverts commit 98e78d0.

* remove oops files

* fix progress bar being used for single circuit.

* add to changelog
  • Loading branch information
nonhermitian authored and jaygambetta committed Nov 30, 2018
1 parent 57339a0 commit 2e85367
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 52 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Fixed
(#1226)
- Fixed a bug where the transpiler moved middle-of-circuit measurements to the
end (#1334)
- parallel_map no longer creates a progress bar for a single circuit (#1394).

Removed
"""""""
Expand Down
3 changes: 1 addition & 2 deletions qiskit/transpiler/_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ def parallel_map(task, values, task_args=tuple(), task_kwargs={}, # pylint: dis
terra.transpiler.parallel.update: One of the parallel task has finished.
terra.transpiler.parallel.finish: All the parallel tasks have finished.
"""
Publisher().publish("terra.transpiler.parallel.start", len(values))
if len(values) == 1:
Publisher().publish("terra.transpiler.parallel.finish")
return [task(values[0], *task_args, **task_kwargs)]

Publisher().publish("terra.transpiler.parallel.start", len(values))
nfinished = [0]

def _callback(_):
Expand Down
80 changes: 30 additions & 50 deletions test/python/notebooks/test_pbar_status.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:43.165035Z",
"start_time": "2018-11-08T10:45:43.159335Z"
"end_time": "2018-11-30T18:31:09.603098Z",
"start_time": "2018-11-30T18:31:09.592395Z"
}
},
"outputs": [],
Expand All @@ -21,11 +21,11 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:44.644196Z",
"start_time": "2018-11-08T10:45:43.510868Z"
"end_time": "2018-11-30T18:31:12.323585Z",
"start_time": "2018-11-30T18:31:09.837946Z"
}
},
"outputs": [],
Expand All @@ -38,11 +38,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:44.650086Z",
"start_time": "2018-11-08T10:45:44.647285Z"
"end_time": "2018-11-30T18:31:12.328399Z",
"start_time": "2018-11-30T18:31:12.325595Z"
}
},
"outputs": [],
Expand All @@ -61,11 +61,11 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:45.031931Z",
"start_time": "2018-11-08T10:45:44.676683Z"
"end_time": "2018-11-30T18:31:12.687639Z",
"start_time": "2018-11-30T18:31:12.329882Z"
}
},
"outputs": [],
Expand All @@ -83,11 +83,11 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:45.386513Z",
"start_time": "2018-11-08T10:45:45.036608Z"
"end_time": "2018-11-30T18:31:13.159985Z",
"start_time": "2018-11-30T18:31:12.694658Z"
}
},
"outputs": [],
Expand All @@ -105,11 +105,11 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:45.753892Z",
"start_time": "2018-11-08T10:45:45.392912Z"
"end_time": "2018-11-30T18:31:13.621412Z",
"start_time": "2018-11-30T18:31:13.166373Z"
}
},
"outputs": [],
Expand All @@ -127,11 +127,11 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:46.105671Z",
"start_time": "2018-11-08T10:45:45.760346Z"
"end_time": "2018-11-30T18:31:14.319363Z",
"start_time": "2018-11-30T18:31:13.873318Z"
}
},
"outputs": [],
Expand All @@ -149,41 +149,20 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2018-11-08T10:45:46.631733Z",
"start_time": "2018-11-08T10:45:46.114140Z"
"end_time": "2018-11-30T18:31:15.401804Z",
"start_time": "2018-11-30T18:31:15.396004Z"
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "949eee6697e548d88bfc6f661e38eb4c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HTML(value=''), IntProgress(value=0, bar_style='info', max=10)))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e2b5d98867c2487d801ee260db31e474",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HTML(value=\"<p style='font-size:16px;'>Job Status : job is actively running </p>\"),))"
]
},
"metadata": {},
"output_type": "display_data"
"name": "stderr",
"output_type": "stream",
"text": [
"UsageError: Cell magic `%%qiskit_job_status` not found.\n"
]
}
],
"source": [
Expand Down Expand Up @@ -276,6 +255,7 @@
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand Down

0 comments on commit 2e85367

Please sign in to comment.