Closed frankharkins closed 8 months ago
I am getting the error when I run locally but not when I run the notebook in Quantum Lab. @kaelynj would you have any insight on this issue?
Thanks for reproducing! I'm using the package versions in scripts/nb-tester/requirements.txt
. Do you know if we should pin to quantum lab?
Thanks for reproducing! I'm using the package versions in
scripts/nb-tester/requirements.txt
. Do you know if we should pin to quantum lab?
I'm afraid the inner workings of Lab are wholly mysterious to me :) I can ask around and see!
Thanks! It seems lab is using Qiskit 0.44.3
, but has plans to upgrade to 0.45.1
, after which this notebook should break in lab too.
In general if we are using a better version of Qiskit I don't think we should downgrade our docs pages to align with what Jupyter lab is doing, lab should be updating to the latest versions and if the content breaks there it should be lab's responsibility to fix their environment
This doesn't sound like a Lab issue - it's currently working in lab and is broken when the current version of Qiskit is used.
Checking into this, the FakeProvider
backends are being deprecated for 1.0 and are being migrated to qiskit-ibm-runtime
. I'll work on changing the imports for this and update the notebook.
URL to the relevant documentation
docs/transpile/transpiler-stages.ipynb
Select all that apply
Describe the fix.
The notebook does not run from start to finish. When running using our notebook testing script, the following code raises an error:
Full traceback
```pytb --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[5], line 5 2 ghz.h(0) 3 ghz.cx(0, range(1, 5)) ----> 5 pass_manager = generate_preset_pass_manager( 6 optimization_level=level, 7 backend=backend, 8 scheduling_method="asap" 9 ) 10 circ = pass_manager.run(ghz, backend) 11 circ.draw(output="mpl") File ~/Documents/documentation/.tox/py311/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/__init__.py:264, in generate_preset_pass_manager(optimization_level, backend, target, basis_gates, inst_map, coupling_map, instruction_durations, backend_properties, timing_constraints, initial_layout, layout_method, routing_method, translation_method, scheduling_method, approximation_degree, seed_transpiler, unitary_synthesis_method, unitary_synthesis_plugin_config, hls_config, init_method, optimization_method, _skip_target) 262 pm = level_2_pass_manager(pm_config) 263 elif optimization_level == 3: --> 264 pm = level_3_pass_manager(pm_config) 265 else: 266 raise ValueError(f"Invalid optimization level {optimization_level}") File ~/Documents/documentation/.tox/py311/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/level3.py:106, in level_3_pass_manager(pass_manager_config) 103 else: 104 pre_optimization = common.generate_pre_op_passmanager(remove_reset_in_zero=False) --> 106 sched = plugin_manager.get_passmanager_stage( 107 "scheduling", scheduling_method, pass_manager_config, optimization_level=3 108 ) 110 return StagedPassManager( 111 pre_init=pre_init, 112 init=init, (...) 118 scheduling=sched, 119 ) File ~/Documents/documentation/.tox/py311/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/plugin.py:259, in PassManagerStagePluginManager.get_passmanager_stage(self, stage_name, plugin_name, pm_config, optimization_level) 255 return self._build_pm( 256 self.optimization_plugins, stage_name, plugin_name, pm_config, optimization_level 257 ) 258 elif stage_name == "scheduling": --> 259 return self._build_pm( 260 self.scheduling_plugins, stage_name, plugin_name, pm_config, optimization_level 261 ) 262 else: 263 raise TranspilerError(f"Invalid stage name: {stage_name}") File ~/Documents/documentation/.tox/py311/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/plugin.py:276, in PassManagerStagePluginManager._build_pm(self, stage_obj, stage_name, plugin_name, pm_config, optimization_level) 274 raise TranspilerError(f"Invalid plugin name {plugin_name} for stage {stage_name}") 275 plugin_obj = stage_obj[plugin_name] --> 276 return plugin_obj.obj.pass_manager(pm_config, optimization_level) File ~/Documents/documentation/.tox/py311/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/builtin_plugins.py:569, in AsapSchedulingPassManager.pass_manager(self, pass_manager_config, optimization_level) 566 inst_map = pass_manager_config.inst_map 567 target = pass_manager_config.target --> 569 return common.generate_scheduling( 570 instruction_durations, scheduling_method, timing_constraints, inst_map, target 571 ) File ~/Documents/documentation/.tox/py311/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/common.py:545, in generate_scheduling(instruction_durations, scheduling_method, timing_constraints, inst_map, target) 540 scheduling.append(ContainsInstruction("delay")) 541 scheduling.append( 542 TimeUnitConversion(instruction_durations, target=target), condition=_contains_delay 543 ) 544 if ( --> 545 timing_constraints.granularity != 1 546 or timing_constraints.min_length != 1 547 or timing_constraints.acquire_alignment != 1 548 or timing_constraints.pulse_alignment != 1 549 ): 550 # Run alignment analysis regardless of scheduling. 552 def _require_alignment(property_set): 553 return property_set["reschedule_required"] AttributeError: 'NoneType' object has no attribute 'granularity' ```The problem seems to be
PassManagerConfig.from_backend
doesn't set thetiming_constraints
attribute. I've checked this withFakeAuckland
(used in the notebook), as well asQiskitRuntimeService().backend("ibm_kyoto")
.I'm not sure if this is a bug in Qiskit, but we need to modify the notebook so it runs correctly.