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

Incorrect parameters in the RB runcard example #1011

Closed
biankawolo opened this issue Oct 16, 2024 · 11 comments
Closed

Incorrect parameters in the RB runcard example #1011

biankawolo opened this issue Oct 16, 2024 · 11 comments

Comments

@biankawolo
Copy link

Dear Qibo!
Fot standard RB for one qubit "if a dictionary is given (in actions.yml) the list will be built" - not true :) There seems to be a problem with yml file. I put in my actions:

depths:
     start: 1
     stop: 50
      step: 25

and it does not generate any report.
Thanks for help!

@alecandido alecandido changed the title BR problem with dictionary for circle depth RB problem with dictionary for circle depth Oct 16, 2024
@alecandido
Copy link
Member

alecandido commented Oct 16, 2024

@biankawolo just a general comment: to provide help for a bug, it is important to be able to reproduce (otherwise there will be a lot more guessing-in-the-wild involved).

So, please, whenever you file a bug report (starting from this one), provide:

  1. a full minimal runcard to reproduce it
    • do not include parts that are not necessary
    • just the minimum that is needed (to the best of your understanding) to generate the undesired behavior
  2. the versions of the sotware used, in particular
    • Qibocal version/branch
    • (Qibolab, if manually installed - otherwise it should be inferred from Qibocal)
    • which platform you're using (the name is in the runcard, so just point to the branch of qibolab_platforms_qrc)

@biankawolo
Copy link
Author

@alecandido
Yest You are fully right! But this was just a formal trace of a problem because I spoke about it with Edoardo and he will have a look at it. Thanx!

@alecandido
Copy link
Member

Yest You are fully right! But this was just a formal trace of a problem because I spoke about it with Edoardo and he will have a look at it. Thanx!

That's great, I'm confident @Edoardo-Pedicillo will be able to help you :)

However, the purpose of issues is also to track possible problems even as a reference to the other users (which may encounter the same ones), and to the other developers (which may help to solve it, or point it to other users).
So, making it reproducible may (in general) help you and rest of the Qibocal crowd :D

@biankawolo
Copy link
Author

@alecandido good point! I have not thought about that:) thankx!

@biankawolo
Copy link
Author

biankawolo commented Oct 16, 2024

So Edoardo told me to put it all, because it might be a bigger issue.
I'm using qibolab: OPX1000 branch,
qibolab_platforms_qrc ---qw5q-platinum
qibocal---- main
My actions :

  # - id: standard rb
  #   priority: 0
  #   operation: standard_rb
  #   parameters:
  #     depths:
  #       start: 1
  #       stop: 102
  #       step: 25
  #     niter: 3
  #     nshots: 500
  #     uncertainties: std
  #     #n_bootstrap: 10
  #     # unrolling: True

The routine tries to execute itself and then at the end it crashes
And the error log looks like this:

Traceback (most recent call last):
  File "/nfs/users/bianka.woloncewicz/.envs/october/bin/qq", line 8, in <module>
    sys.exit(command())
  File "/nfs/users/bianka.woloncewicz/.envs/october/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/nfs/users/bianka.woloncewicz/.envs/october/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/nfs/users/bianka.woloncewicz/.envs/october/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nfs/users/bianka.woloncewicz/.envs/october/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nfs/users/bianka.woloncewicz/.envs/october/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/cli/_base.py", line 75, in auto
    autocalibrate(runcard, folder, force, update)
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/cli/autocalibration.py", line 42, in autocalibrate
    history = runcard.run(
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/auto/runcard.py", line 63, in run
    instance.run_protocol(
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/auto/execute.py", line 131, in run_protocol
    completed = task.run(platform=self.platform, targets=self.targets, mode=mode)
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/auto/task.py", line 160, in run
    completed.results, completed.results_time = operation.fit(completed.data)
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/auto/operation.py", line 42, in wrapper
    out = func(*args, **kwds)
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/protocols/randomized_benchmarking/standard_rb.py", line 104, in _fit
    return fit(data.qubits, data)
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/protocols/randomized_benchmarking/utils.py", line 710, in fit
    error_bars = data_uncertainties(
  File "/nfs/users/bianka.woloncewicz/qibocal/src/qibocal/protocols/randomized_benchmarking/utils.py", line 211, in data_uncertainties
    (100 - method) / 2,
TypeError: unsupported operand type(s) for -: 'int' and 'str'

If you need anything else please let me know!

@biankawolo biankawolo changed the title RB problem with dictionary for circle depth RB problem Oct 16, 2024
@alecandido
Copy link
Member

I assume you're using the Qibolab opx1000 branch, qiboteam/qibolab#1045, and the qibolab_platforms_qrc's qw5q-qm branch, qiboteam/qibolab_platforms_qrc#179.

So, the problem apparently is that method is a str, and it doesn't make much sense to subtract 100 by a string of text...

Investigation

Not sure in the first place why it is called method, but it is assigned to data.uncertainties in the preceding call:

The data are just the RBData, as expected:

def _fit(data: RBData) -> StandardRBResult:
"""Takes a data frame, extracts the depths and the signal and fits it with
an exponential function y = Ap^x+B.
Args:
data (RBData): Data from the data acquisition stage.
Returns:
StandardRBResult: Aggregated and processed data.
"""
return fit(data.qubits, data)

generated by the rb_acquisition()
return rb_acquisition(params, platform, targets)

(everything linear here).

The rb_acquisition() fills data after them being initialized in the setup() function

data, noise_model, backend = setup(params, platform, single_qubit=True)

data.register_qubit(
RBType,
(qubit_id, depth),
dict(
samples=samples[index[0] : index[1]][:, nqubit],
),
)
data.circuits = indexes
data.npulses_per_clifford = npulses_per_clifford

which is setting the .uncertainties attribute after the params one
uncertainties=params.uncertainties,

which in this case are the StandardRBParameters
class StandardRBParameters(Parameters):
"""Standard Randomized Benchmarking runcard inputs."""
depths: Union[list, Depthsdict]
"""A list of depths/sequence lengths.
If a dictionary is given the list will be build.
"""
niter: int
"""Sets how many iterations over the same depth value."""
uncertainties: Optional[float] = None

So, the question is: why the uncertainties parameter in your runcard is a str instead of a float?

I.e. the error is all generated by this:

     uncertainties: std

@alecandido
Copy link
Member

I guess you just used the runcard from

# - id: standard rb inhomogeneous
# operation: standard_rb
# targets: [0, 1, 3]
# parameters:
# depths: [1, 3, 3, 5]
# niter: 5
# nshots: 50
# uncertainties: std
# noise_model: PauliErrorOnX
# noise_params: [0.01, 0.01, 0.01]

that's the explanation.

Which is now conflicting with the documentation of that field

uncertainties: Optional[float] = None
"""Method of computing the error bars of the signal and uncertainties of
the fit.
If ``None``,
it computes the standard deviation. Otherwise it computes the corresponding confidence interval. Defaults `None`.
"""

That was changed in 8fde113 in #718.
So, the example runcard is simply outdated (which should be fixed @Edoardo-Pedicillo), but you should put a numerical value in that field. Or just omit the field (delete that line from your runcard), and rely on the default value.

@biankawolo
Copy link
Author

Thanx I ll try that!

@alecandido
Copy link
Member

Thanx I ll try that!

Whenever you tried, remember to report the outcome!

@biankawolo
Copy link
Author

It works!

@alecandido
Copy link
Member

Thanks for the confirmation!

@alecandido alecandido changed the title RB problem Incorrect parameters in the RB runcard example Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants