Skip to content

Conversation

@ajberdy
Copy link
Contributor

@ajberdy ajberdy commented Jul 18, 2022

Issue #, if available:

#328

Description of changes:

Add openqasm generation step to openqasm integ tests.

Testing done:

tox -e integ-tests -- -k openqasm

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ajberdy ajberdy requested a review from kshitijc July 18, 2022 23:32
@ajberdy ajberdy requested a review from a team as a code owner July 18, 2022 23:32
@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #406 (f2a400c) into feature/openqasm_generation (e6f70f8) will not change coverage.
The diff coverage is 100.00%.

@@                      Coverage Diff                       @@
##           feature/openqasm_generation      #406    +/-   ##
==============================================================
  Coverage                       100.00%   100.00%            
==============================================================
  Files                               79        79            
  Lines                             5691      5583   -108     
  Branches                           816       780    -36     
==============================================================
- Hits                              5691      5583   -108     
Impacted Files Coverage Δ
src/braket/circuits/observables.py 100.00% <100.00%> (ø)
src/braket/circuits/result_types.py 100.00% <100.00%> (ø)
src/braket/circuits/gates.py 100.00% <0.00%> (ø)
src/braket/devices/local_simulator.py 100.00% <0.00%> (ø)
src/braket/tasks/gate_model_quantum_task_result.py 100.00% <0.00%> (ø)

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 e6f70f8...f2a400c. Read the comment docs.

Copy link
Contributor

@kshitijc kshitijc left a comment

Choose a reason for hiding this comment

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

Could we do this for all gate model tests here for better coverage ?

Comment on lines +257 to +271
factors = []
use_qubits = iter(target)
for obs in self._factors:
obs_target = QubitSet()
num_qubits = int(np.log2(obs.to_matrix().shape[0]))
for _ in range(num_qubits):
obs_target.add(next(use_qubits))
factors.append(
obs.to_ir(
target=obs_target,
ir_type=IRType.OPENQASM,
serialization_properties=serialization_properties,
)
)
for obs, targ in zip(self._factors, target)
)
return " @ ".join(factors)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix: this change allows 2q hermitians to consume 2 qubits of the target

def _to_openqasm(self, serialization_properties: OpenQASMSerializationProperties) -> str:
if not self.target:
return "#pragma braket result probability"
return "#pragma braket result probability all"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Service does not currently support exclusion of all due to lark restrictions

@ajberdy ajberdy requested a review from kshitijc July 20, 2022 23:59
result, shots, expected_var, expected_mean, expected_eigs
)
tasks = (circuit,) if not test_program else (circuit, circuit.to_ir(ir_type=IRType.OPENQASM))
print(circuit.to_ir(ir_type=IRType.OPENQASM))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, no

@ajberdy ajberdy merged commit ea73e31 into feature/openqasm_generation Jul 27, 2022
@ajberdy ajberdy deleted the openqasm-generation-integ-tests branch July 27, 2022 19:48
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

Successfully merging this pull request may close these issues.

2 participants