Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion qiskit/dagcircuit/dagcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ def add_calibration(self, gate, qubits, schedule, params=None):
Exception: if the gate is of type string and params is None.
"""
if isinstance(gate, Gate):
self._calibrations[gate.name][(tuple(qubits), tuple(gate.params))] = schedule
self._calibrations[gate.name][
(tuple(qubits), tuple(float(p) for p in gate.params))
] = schedule
else:
self._calibrations[gate][(tuple(qubits), tuple(params or []))] = schedule

Expand Down
4 changes: 2 additions & 2 deletions qiskit/transpiler/passes/calibration/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def rescale_cr_inst(instruction: Play, theta: float, sample_mult: int = 16) -> P
gaussian_area = abs(amp) * sigma * np.sqrt(2 * np.pi) * math.erf(n_sigmas)
area = gaussian_area + abs(amp) * width

target_area = abs(theta) / (np.pi / 2.0) * area
sign = theta / abs(theta)
target_area = abs(float(theta)) / (np.pi / 2.0) * area
sign = theta / abs(float(theta))

if target_area > gaussian_area:
width = (target_area - gaussian_area) / abs(amp)
Expand Down
12 changes: 9 additions & 3 deletions qiskit/transpiler/passes/scheduling/alap.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ def pad_with_delays(qubits: List[int], until, unit) -> None:
# validate node.op.duration
if node.op.duration is None:
indices = [bit_indices[qarg] for qarg in node.qargs]
raise TranspilerError(
f"Duration of {node.op.name} on qubits {indices} is not found."
)
if dag.has_calibration_for(node):
node.op.duration = dag.calibrations[node.op.name][
(tuple(indices), tuple(float(p) for p in node.op.params))
].duration

if node.op.duration is None:
raise TranspilerError(
f"Duration of {node.op.name} on qubits {indices} is not found."
)
if isinstance(node.op.duration, ParameterExpression):
indices = [bit_indices[qarg] for qarg in node.qargs]
raise TranspilerError(
Expand Down
12 changes: 9 additions & 3 deletions qiskit/transpiler/passes/scheduling/asap.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,15 @@ def pad_with_delays(qubits: List[int], until, unit) -> None:
# validate node.op.duration
if node.op.duration is None:
indices = [bit_indices[qarg] for qarg in node.qargs]
raise TranspilerError(
f"Duration of {node.op.name} on qubits {indices} is not found."
)
if dag.has_calibration_for(node):
node.op.duration = dag.calibrations[node.op.name][
(tuple(indices), tuple(float(p) for p in node.op.params))
].duration

if node.op.duration is None:
raise TranspilerError(
f"Duration of {node.op.name} on qubits {indices} is not found."
)
if isinstance(node.op.duration, ParameterExpression):
indices = [bit_indices[qarg] for qarg in node.qargs]
raise TranspilerError(
Expand Down