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

Add an example notebook for two-qubit entangling gates #154

Merged
merged 5 commits into from
Dec 8, 2021

Conversation

alex-simm
Copy link
Collaborator

@alex-simm alex-simm commented Nov 29, 2021

What

In contrast to the existing two qubit example (examples/two_qubits.ipynb), this this an example that specifically optimises entangling gates.

Why

Because the optimisation doesn't work. It usually converges to 50-55% fidelity. Either I'm missing something or there is a bug in the C3 code. In any case, we could use this example to find out what's wrong. Maybe someone can point out if or why the optimisation cannot work like this.
It is working now using cross-resonance. The final fidelity is about 99%.

How

Similar to the existing two qubit example, but with a CNOT gate. I tried the same with other SU(4) gates (SWAP, iSWAP, ...) and with LBFGS instead of CMAES, but none of those converged to a good fidelity.

Remarks

Checklist

  • Tests - Added unit tests for new code, regression tests for bugs and updated the integration tests if required
  • Formatting & Linting - black and flake8 have been used to ensure styling guidelines are met
  • Type Annotations - All new code has been type annotated in the function signatures using type hints
  • Docstrings - Docstrings have been provided for functions in the numpydoc style
  • Documentation - The tutorial style documentation has been updated to explain changes & new features
  • Notebooks - Example notebooks have been updated to incorporate changes and new features
  • Changelog - A short note on this PR has been added to the Upcoming Release section

@codecov
Copy link

codecov bot commented Nov 29, 2021

Codecov Report

Merging #154 (79de597) into dev (1e5de95) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #154   +/-   ##
=======================================
  Coverage   71.41%   71.41%           
=======================================
  Files          36       36           
  Lines        5220     5220           
=======================================
  Hits         3728     3728           
  Misses       1492     1492           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e5de95...79de597. Read the comment docs.

@lazyoracle
Copy link
Member

The tests break because Tensorflow 2.7 drops support for Python 3.6.x (which is fair I guess). I am not sure if that means we drop support for Tensorflow greater than 2.6.x or we drop support for Python less than 3.7.x (I prefer the latter).

@lazyoracle
Copy link
Member

@alex-simm Can you rebase on dev? Hopefully all tests should pass and this PR would be ready for merge.

@alex-simm
Copy link
Collaborator Author

@alex-simm Can you rebase on dev? Hopefully all tests should pass and this PR would be ready for merge.

done

Copy link
Member

@lazyoracle lazyoracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[UPDATE] - This is now resolved.

The notebooks are run in the CI as a sort of integration test to ensure code changes don't break examples and they are always up to date. A high number of iterations can cause the CI to run for very long durations thus bottlenecking development. Can you update the number of function evaluations to something like 100 (instead of 1000) with a comment to increase the evaluations for better results?

# increase maxfevals to 500+ for better results
opt = OptimalControl(
    dir_path=log_dir,
    fid_func=fidelities.average_infid_set,
    fid_subspace=["Q1", "Q2"],
    pmap=parameter_map,
    algorithm=algorithms.cmaes,
    options={
        "popsize": 15,
        "maxfevals": 100
    },
    run_name="cnot12"
)

@lazyoracle lazyoracle added this to the 1.4 milestone Dec 7, 2021
@lazyoracle
Copy link
Member

@alex-simm Is this ready to merge from your end?

@alex-simm
Copy link
Collaborator Author

@alex-simm Is this ready to merge from your end?

Yes it is. I guess the remaining items on the checklist don't apply here

@lazyoracle lazyoracle merged commit c23e830 into q-optimize:dev Dec 8, 2021
@lazyoracle lazyoracle mentioned this pull request Dec 23, 2021
@alex-simm alex-simm deleted the two-qubit-example-notebook branch January 19, 2022 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants