Skip to content
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

Maximum iteration reached. max_iteration=1000 #5832

Closed
jasonlarkin opened this issue Feb 10, 2021 · 1 comment · Fixed by #9612
Closed

Maximum iteration reached. max_iteration=1000 #5832

jasonlarkin opened this issue Feb 10, 2021 · 1 comment · Fixed by #9612
Labels
bug Something isn't working

Comments

@jasonlarkin
Copy link

jasonlarkin commented Feb 10, 2021

Information

  • Qiskit Terra version:

qiskit 0.23.3
qiskit-aer 0.7.3
qiskit-aqua 0.8.1
qiskit-ibmq-provider 0.12.0
qiskit-ignis 0.5.1
qiskit-rng 0.2.1
qiskit-terra 0.16.4

  • Python version:

python --version
Python 3.8.1

  • Operating system:

cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

What is the current behavior?

I am getting the same transpile optimization_level=3 error as here:
#5627
But I have updated to terra==0.16.4

More notes here:
https://qiskit.slack.com/archives/C7SS31917/p1612935056097500

Steps to reproduce the problem

backend = provider.get_backend('ibmq_ourense')
noise_model = NoiseModel.from_backend(backend.properties())
qc = transpile(qc,optimization_level=3,
backend_properties=backend.properties(),
basis_gates=noise_model.basis_gates,
coupling_map=backend._configuration.coupling_map)

it is a variational circuit, and if I only allow the parameters to evolve to the circ1 state (which has successfully transpiled, circ1_untran(spiled) is before transpilation), the transpile optimization_level=3 succeeds (this is circ1).
If I allow the variational parameters to evolve further, eventually transpile will fail.

File "/home/jmlarkin/.conda/envs/IQS/lib/python3.8/site-packages/qiskit/transpiler/runningpassmanager.py", line 311, in iter
raise TranspilerError("Maximum iteration reached. max_iteration=%i" % self.max_iteration)
qiskit.transpiler.exceptions.TranspilerError: 'Maximum iteration reached. max_iteration=1000'

circ2_untran
circ1_untran
circ1

The circuit qasm definitions are here

circ1.qasm.txt
circ1_untran.qasm.txt
circ2_untran.qasm.txt

What is the expected behavior?

Expected behavior is ability to transpile the circuit with the above settings.

Suggested solutions

Not sure?

@jasonlarkin jasonlarkin added the bug Something isn't working label Feb 10, 2021
@kdk
Copy link
Member

kdk commented Feb 18, 2021

Thanks for reporting this @jasonlarkin . Can you clarify which circuits you are using as the input to your call to transpile? (Some example code demonstrating how to build your circuits, and how you're trying to transpile them would be really helpful.) Also, can you check which gates are listed in backend.configuration().basis_gates?

mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Jan 10, 2023
The test_qv_natural UnitarySynthesis test is designed to test that when
the pulse efficient flag is set on the default unitary synthesis plugin
for the UnitarySynthesis pass the output from synthesis is only emitting
entangling gates in the natural direction implemented on the target.
However, when running on Windows with Python 3.11 and numpy 1.24 we're
seeing a non-zero failure rate (in CI it's ~5% across all jobs) of this
test likely do to fp precision. When this failure occurs it appears as
the failure from detailed in issues Qiskit#5832 and Qiskit#9177 as the test was
creating a pass manager that mirrors the optimization loop used in the
preset pass managers. The optimization loop is failing to converge on a
fixed depth as the unitary synthesis is oscillating between multiple
equivalent outputs. However, in this case the test doesn't need the
full complexity of the optimization loop as we're just trying to verify
the output of unitary synthesis is equivalent with different options and
that the output is valid given different options. This can be done with
a single iteration of the loop and doesn't require trying to fully
optimize the circuit. This commit reduces the complexity of the test to
remove the loop from the optimization stage in the custom pass manager
so the test is now just running a single iteration of UnitarySynthesis
and comparing the output. This will hopefully make the test stable in CI
moving forward avoiding this failure mode.
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Jan 10, 2023
The test_qv_natural UnitarySynthesis test is designed to test that when
the pulse efficient flag is set on the default unitary synthesis plugin
for the UnitarySynthesis pass the output from synthesis is only emitting
entangling gates in the natural direction implemented on the target.
However, when running on Windows with Python 3.11 and numpy 1.24 we're
seeing a non-zero failure rate (in CI it's ~5% across all jobs) of this
test likely do to fp precision. When this failure occurs it appears as
the failure from detailed in issues Qiskit#5832 and Qiskit#9177 as the test was
creating a pass manager that mirrors the optimization loop used in the
preset pass managers. The optimization loop is failing to converge on a
fixed depth as the unitary synthesis is oscillating between multiple
equivalent outputs. However, in this case the test doesn't need the
full complexity of the optimization loop as we're just trying to verify
the output of unitary synthesis is equivalent with different options and
that the output is valid given different options. This can be done with
a single iteration of the loop and doesn't require trying to fully
optimize the circuit. This commit reduces the complexity of the test to
remove the loop from the optimization stage in the custom pass manager
so the test is now just running a single iteration of UnitarySynthesis
and comparing the output. This will hopefully make the test stable in CI
moving forward avoiding this failure mode.
mergify bot pushed a commit that referenced this issue Jan 11, 2023
* Simplify UnitarySynthesis pass test test_qv_natural

The test_qv_natural UnitarySynthesis test is designed to test that when
the pulse efficient flag is set on the default unitary synthesis plugin
for the UnitarySynthesis pass the output from synthesis is only emitting
entangling gates in the natural direction implemented on the target.
However, when running on Windows with Python 3.11 and numpy 1.24 we're
seeing a non-zero failure rate (in CI it's ~5% across all jobs) of this
test likely do to fp precision. When this failure occurs it appears as
the failure from detailed in issues #5832 and #9177 as the test was
creating a pass manager that mirrors the optimization loop used in the
preset pass managers. The optimization loop is failing to converge on a
fixed depth as the unitary synthesis is oscillating between multiple
equivalent outputs. However, in this case the test doesn't need the
full complexity of the optimization loop as we're just trying to verify
the output of unitary synthesis is equivalent with different options and
that the output is valid given different options. This can be done with
a single iteration of the loop and doesn't require trying to fully
optimize the circuit. This commit reduces the complexity of the test to
remove the loop from the optimization stage in the custom pass manager
so the test is now just running a single iteration of UnitarySynthesis
and comparing the output. This will hopefully make the test stable in CI
moving forward avoiding this failure mode.

* Retrigger CI

Co-authored-by: Jake Lishman <[email protected]>
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Feb 17, 2023
This commit adds a new transpiler pass MinimumPoint which is used to
find a local minimum point from the property set between executions of
the pass. This is similar to the existing FixedPoint pass but will find
the minimum fixed point over the past n exeuctions as opposed to finding
a when two subsequent exectuions are at the same point. This is then
used in optimization level 3 because the 2q unitary synthesis
optimization that is part of the optimization loop can occasionally get
stuck oscillating between multiple different equivalent decompositions
which prevents the fixed point condition from ever being reached. By
checking that we've reached the minimum over the last 5 executions we
ensure we're reaching an exit condition in this situation.

Fixes Qiskit#5832
Fixes Qiskit#9177

(the underlying cause of the optimization loop's inability to converge
at optimization level 3 is not fixed here, there is still a root cause
of instability in UnitarySynthesis this just changes the loop exit
condition so we're never stuck in an infinte loop)
mtreinish added a commit to mtreinish/qiskit-core that referenced this issue Mar 29, 2023
This commit adds a new transpiler pass MinimumPoint which is used to
find a local minimum point from the property set between executions of
the pass. This is similar to the existing FixedPoint pass but will find
the minimum fixed point over the past n exeuctions as opposed to finding
a when two subsequent exectuions are at the same point. This is then
used in optimization level 3 because the 2q unitary synthesis
optimization that is part of the optimization loop can occasionally get
stuck oscillating between multiple different equivalent decompositions
which prevents the fixed point condition from ever being reached. By
checking that we've reached the minimum over the last 5 executions we
ensure we're reaching an exit condition in this situation.

Fixes Qiskit#5832
Fixes Qiskit#9177

(the underlying cause of the optimization loop's inability to converge
at optimization level 3 is not fixed here, there is still a root cause
of instability in UnitarySynthesis this just changes the loop exit
condition so we're never stuck in an infinte loop)
ElePT pushed a commit to ElePT/qiskit that referenced this issue Apr 5, 2023
* Add MinimumPoint transpiler pass

This commit adds a new transpiler pass MinimumPoint which is used to
find a local minimum point from the property set between executions of
the pass. This is similar to the existing FixedPoint pass but will find
the minimum fixed point over the past n exeuctions as opposed to finding
a when two subsequent exectuions are at the same point. This is then
used in optimization level 3 because the 2q unitary synthesis
optimization that is part of the optimization loop can occasionally get
stuck oscillating between multiple different equivalent decompositions
which prevents the fixed point condition from ever being reached. By
checking that we've reached the minimum over the last 5 executions we
ensure we're reaching an exit condition in this situation.

Fixes Qiskit#5832
Fixes Qiskit#9177

(the underlying cause of the optimization loop's inability to converge
at optimization level 3 is not fixed here, there is still a root cause
of instability in UnitarySynthesis this just changes the loop exit
condition so we're never stuck in an infinte loop)

* Doc copy-paste error cleanups

* Rework logic to track state with a dataclass

This commit reworks the logic of the pass to track the state via a
dataclass instead of using separate property set fields. This cleans up
the code for dealing with checking the current state relative to earlier
iterations by making the access just attributes instead of secret
strings. At the same time the tests were updated to handle this new data
structure comments were added to better explain the logic flow being
tested.

* Fix doc typo

* Apply suggestions from code review

Co-authored-by: Jake Lishman <[email protected]>

* Update slots syntax for dataclass to be compatible with Python < 3.10

* Update property set check in tests

---------

Co-authored-by: Jake Lishman <[email protected]>
giacomoRanieri pushed a commit to giacomoRanieri/qiskit-terra that referenced this issue Apr 16, 2023
* Add MinimumPoint transpiler pass

This commit adds a new transpiler pass MinimumPoint which is used to
find a local minimum point from the property set between executions of
the pass. This is similar to the existing FixedPoint pass but will find
the minimum fixed point over the past n exeuctions as opposed to finding
a when two subsequent exectuions are at the same point. This is then
used in optimization level 3 because the 2q unitary synthesis
optimization that is part of the optimization loop can occasionally get
stuck oscillating between multiple different equivalent decompositions
which prevents the fixed point condition from ever being reached. By
checking that we've reached the minimum over the last 5 executions we
ensure we're reaching an exit condition in this situation.

Fixes Qiskit#5832
Fixes Qiskit#9177

(the underlying cause of the optimization loop's inability to converge
at optimization level 3 is not fixed here, there is still a root cause
of instability in UnitarySynthesis this just changes the loop exit
condition so we're never stuck in an infinte loop)

* Doc copy-paste error cleanups

* Rework logic to track state with a dataclass

This commit reworks the logic of the pass to track the state via a
dataclass instead of using separate property set fields. This cleans up
the code for dealing with checking the current state relative to earlier
iterations by making the access just attributes instead of secret
strings. At the same time the tests were updated to handle this new data
structure comments were added to better explain the logic flow being
tested.

* Fix doc typo

* Apply suggestions from code review

Co-authored-by: Jake Lishman <[email protected]>

* Update slots syntax for dataclass to be compatible with Python < 3.10

* Update property set check in tests

---------

Co-authored-by: Jake Lishman <[email protected]>
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this issue May 22, 2023
* Add MinimumPoint transpiler pass

This commit adds a new transpiler pass MinimumPoint which is used to
find a local minimum point from the property set between executions of
the pass. This is similar to the existing FixedPoint pass but will find
the minimum fixed point over the past n exeuctions as opposed to finding
a when two subsequent exectuions are at the same point. This is then
used in optimization level 3 because the 2q unitary synthesis
optimization that is part of the optimization loop can occasionally get
stuck oscillating between multiple different equivalent decompositions
which prevents the fixed point condition from ever being reached. By
checking that we've reached the minimum over the last 5 executions we
ensure we're reaching an exit condition in this situation.

Fixes Qiskit#5832
Fixes Qiskit#9177

(the underlying cause of the optimization loop's inability to converge
at optimization level 3 is not fixed here, there is still a root cause
of instability in UnitarySynthesis this just changes the loop exit
condition so we're never stuck in an infinte loop)

* Doc copy-paste error cleanups

* Rework logic to track state with a dataclass

This commit reworks the logic of the pass to track the state via a
dataclass instead of using separate property set fields. This cleans up
the code for dealing with checking the current state relative to earlier
iterations by making the access just attributes instead of secret
strings. At the same time the tests were updated to handle this new data
structure comments were added to better explain the logic flow being
tested.

* Fix doc typo

* Apply suggestions from code review

Co-authored-by: Jake Lishman <[email protected]>

* Update slots syntax for dataclass to be compatible with Python < 3.10

* Update property set check in tests

---------

Co-authored-by: Jake Lishman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants