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 CrosstalkParams to API docs and docs cleanup #219

Merged
merged 14 commits into from
Dec 11, 2023
9 changes: 5 additions & 4 deletions .github/workflows/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

extensions = [
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
Expand Down Expand Up @@ -36,10 +37,10 @@
pytketdoc_base = "https://tket.quantinuum.com/api-docs/"

intersphinx_mapping = {
"https://docs.python.org/3/": None,
pytketdoc_base: None,
"https://qiskit.org/documentation/": None,
"http://docs.qulacs.org/en/latest/": None,
"python": ("https://docs.python.org/3/", None),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This updates some deprecated syntax to allow the use of sphinx > 6.2.0

"pytket": (pytketdoc_base, None),
"qiskit": ("https://qiskit.org/documentation/", None),
"qulacs": ("http://docs.qulacs.org/en/latest/", None),
}

autodoc_member_order = "groupwise"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx >= 4.3.2, <6.2.0
sphinx == 6.2.1
sphinx_book_theme >= 1.0.1, <2.0
sphinx-copybutton
sphinx-autodoc-typehints
11 changes: 10 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,44 @@ API documentation
~~~~~~~~~~~~~~~~~

.. autoclass:: pytket.extensions.qiskit.IBMQBackend
:special-members:
:special-members: __init__
:show-inheritance:
:members:

.. autoclass:: pytket.extensions.qiskit.IBMQEmulatorBackend
:special-members: __init__
:show-inheritance:
:members:

.. autoclass:: pytket.extensions.qiskit.AerBackend
:special-members: __init__
:show-inheritance:
:inherited-members:
:members:

.. autoclass:: pytket.extensions.qiskit.AerStateBackend
:special-members: __init__
:inherited-members:
:show-inheritance:
:members:

.. autoclass:: pytket.extensions.qiskit.AerUnitaryBackend
:special-members: __init__
:show-inheritance:
:inherited-members:
:members:

.. automodule:: pytket.extensions.qiskit
:members: qiskit_to_tk, tk_to_qiskit, process_characterisation

.. automodule:: pytket.extensions.qiskit.tket_backend
:show-inheritance:
:members:
:special-members: __init__

.. automodule:: pytket.extensions.qiskit.backends.crosstalk_model
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the three classes CrosstalkParams, NoisyCircuitBuilder and FractionalUnitary.

These are the only three classes which have tests so I assumed they were the only user facing classes. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: Only CrosstalkParams is user facing

:members: CrosstalkParams, NoisyCircuitBuilder, FractionalUnitary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a simplier import path for these classes? They do look a bit squashed in the API docs.


.. automodule:: pytket.extensions.qiskit.tket_pass
:special-members: __init__
Expand Down
11 changes: 2 additions & 9 deletions pytket/extensions/qiskit/backends/crosstalk_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
@dataclass
class FractionalUnitary:
"""
Wrapper for a fractional unitary gate
Wrapper for a fractional unitary gate.

:param cmd: the fractional UnitaryBox wrapped in a pytket Command
:param n_fractions: the number of fractional gates
used to compose the original unitary gate.
Expand Down Expand Up @@ -74,28 +75,20 @@ class CrosstalkParams:
Stores various parameters for modelling crosstalk noise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These types will be automatically inferred by the sphinx-autodoc-typehints extension. We won't have to write them down in multiple places.

:param zz_crosstalks: symmetric crosstalks between qubit pairs
:type zz_crosstalks: `Dict[Tuple[Qubit, Qubit], float]`
:param single_q_phase_errors: dict specify the single qubit phase error
on each qubit
:type single_q_phase_errors: `Dict[Qubit, float]`
:param two_q_induced_phase_errors: keys of dictionary specify the control
and target qubit index, while the values are tuples with the spectator
qubit index and the amount of phase error to be applied.
:type two_q_induced_phase_errors: `Dict[Tuple[Qubit, Qubit], Tuple[Qubit, float]]`
:param non_markovian_noise: List storing the non-Markovian noise parameters.
Each tuple in the list contains the qubit index and the zx, zz noise parameters.
:type non_markovian_noise: `List[Tuple[Qubit, float, float]]`
:param virtual_z: If True, then don't break any single qubit Z gate into
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The sphinx_autodoc_typehints extension allows these types to be inferred from the source code so we no longer need to put these types in two different places.

unitary fractions, instead add the full unitary.
:type bool
:param N: hyperparameter specifies splices per second.
1/N must divide all gate times.
:type: float
:param gate_times: python dict to store the gate time information.
:type gate_times: `Dict[Tuple[OpType, Tuple[Qubit, ...]], float]`
:param phase_damping_error: dict specify amplitude phase damping error
on each qubit
:type phase_damping_error: `Dict[Qubit, float]`
:param amplitude_damping_error: dict pecify amplitude damping error
on each qubit
"""
Expand Down
15 changes: 9 additions & 6 deletions pytket/extensions/qiskit/backends/ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,15 @@ def process_circuits(
"""
See :py:meth:`pytket.backends.Backend.process_circuits`.

Supported `kwargs`:
- `postprocess`: apply end-of-circuit simplifications and classical
postprocessing to improve fidelity of results (bool, default False)
- `simplify_initial`: apply the pytket ``SimplifyInitial`` pass to improve
fidelity of results assuming all qubits initialized to zero (bool, default
False)
:Keyword Arguments:
* `postprocess`:
apply end-of-circuit simplifications and classical
postprocessing to improve fidelity of results (bool, default False)
* `simplify_initial`:
apply the pytket ``SimplifyInitial`` pass to improve
fidelity of results assuming all qubits initialized to zero
(bool, default False)

"""
circuits = list(circuits)

Expand Down
Loading