qiskit-experiments icon indicating copy to clipboard operation
qiskit-experiments copied to clipboard

Random error when saving figures for a composite experiment

Open coruscating opened this issue 1 year ago • 2 comments

What is the current behavior?

Saving a composite experiment to the cloud service results in occasional random failures that don't save the figure:

Traceback (most recent call last):
  File "qiskit-experiments-test/qiskit_experiments/framework/experiment_data.py", line 993, in _run_analysis_callback
    callback(self, **kwargs)
  File "qiskit-experiments-test/qiskit_experiments/framework/base_analysis.py", line 181, in run_analysis
    expdata.add_figures(figures, figure_names=self.options.figure_names)
  File "qiskit-experiments-test/qiskit_experiments/framework/experiment_data.py", line 75, in _wrapped
    return_val = func(self, *args, **kwargs)
  File "qiskit-experiments-test/qiskit_experiments/framework/experiment_data.py", line 1191, in add_figures
    figure = plot_to_svg_bytes(figure)
  File "qiskit-experiments-test/qiskit_experiments/database_service/utils.py", line 94, in plot_to_svg_bytes
    figure.savefig(
  File "experiments-main/lib/python3.8/site-packages/matplotlib/figure.py", line 3343, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2342, in print_figure
    self.figure.draw(renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/figure.py", line 3140, in draw
    mimage._draw_list_compositing_images(
  File "experiments-main/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 3064, in draw
    mimage._draw_list_compositing_images(
  File "experiments-main/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/text.py", line 752, in draw
    bbox, info, descent = self._get_layout(renderer)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/text.py", line 386, in _get_layout
    w, h, d = _get_text_metrics_with_cache(
  File "experiments-main/lib/python3.8/site-packages/matplotlib/text.py", line 97, in _get_text_metrics_with_cache
    return _get_text_metrics_with_cache_impl(
  File "experiments-main/lib/python3.8/site-packages/matplotlib/text.py", line 105, in _get_text_metrics_with_cache_impl
    return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/backends/backend_svg.py", line 1317, in get_text_width_height_descent
    return self._text2path.get_text_width_height_descent(s, prop, ismath)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/textpath.py", line 60, in get_text_width_height_descent
    self.mathtext_parser.parse(s, 72, prop)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/mathtext.py", line 226, in parse
    return self._parse_cached(s, dpi, prop)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/mathtext.py", line 247, in _parse_cached
    box = self._parser.parse(s, fontset, fontsize, dpi)
  File "experiments-main/lib/python3.8/site-packages/matplotlib/_mathtext.py", line 1992, in parse
    result = self._expression.parseString(s)
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 1131, in parse_string
    loc, tokens = self._parse(instring, 0)
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 921, in _parseCache
    value = self._parseNoCache(instring, loc, doActions, callPreParse)
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 817, in _parseNoCache
    loc, tokens = self.parseImpl(instring, pre_loc, doActions)
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 3864, in parseImpl
    loc, resultlist = self.exprs[0]._parse(
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 921, in _parseCache
    value = self._parseNoCache(instring, loc, doActions, callPreParse)
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 856, in _parseNoCache
    tokens = fn(instring, tokens_start, ret_tokens)
  File "experiments-main/lib/python3.8/site-packages/pyparsing/core.py", line 291, in wrapper
    ret = func(*args[limit:])
  File "experiments-main/lib/python3.8/site-packages/matplotlib/_mathtext.py", line 2028, in non_math
    symbols = [Char(c, self.get_state()) for c in s]
  File "experiments-main/lib/python3.8/site-packages/matplotlib/_mathtext.py", line 2028, in <listcomp>
    symbols = [Char(c, self.get_state()) for c in s]
  File "experiments-main/lib/python3.8/site-packages/matplotlib/_mathtext.py", line 2005, in get_state
    return self._state_stack[-1]
TypeError: 'NoneType' object is not subscriptable

Steps to reproduce the problem

exp1 = T1(physical_qubits=[2], delays=np.arange(1e-6, 6e-4, 5e-5))
exp2 = T2Hahn(physical_qubits=[2], delays=np.arange(1e-6, 6e-4, 5e-5))
exp = BatchExperiment([exp1, exp2], flatten_results=False)
exp_data = exp.run(backend, shots=1000)
exp_data.auto_save = True
exp_data.block_for_results()

coruscating avatar May 31 '23 16:05 coruscating

It seems like I can't recreate the bug. I ran the script above on ibmq_jakarta (using qiskit_ibm_provider) and it seems to work.

Experiment details:

  • Backend: ibmq_jakarta.
  • Batch Experiment ID: ed5b46d8-93ad-4df7-98ec-b4dd734a180d.
  • T2Hahn Experiment ID: e47f0be0-4c53-40a6-9de5-f7770f251513.
  • T1 Experiment ID: 6a46e745-546c-4052-97a9-c8b899d18d14.

@coruscating, does this error occur each time you run the script, or does it occasionally arise?

ItamarGoldman avatar Oct 02 '23 07:10 ItamarGoldman

@ItamarGoldman This was a randomly occurring error. I'll check again if it can be reproduced.

coruscating avatar Oct 23 '23 13:10 coruscating