Skip to content

Commit

Permalink
Fix: Backwards compatibility with add_instruction
Browse files Browse the repository at this point in the history
- Fixed wrong additions to HashMaps in the rust side causing instructions to be missing.
- Other tweaks and fixes.
  • Loading branch information
raynelfss committed Apr 13, 2024
1 parent abe88cf commit 94cbb85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions crates/accelerate/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,7 @@ impl Target {
.max(qarg.vec.iter().cloned().fold(0, u32::max) as usize + 1),
);
}
if let Some(x) = qargs_val.get_mut(&qarg) {
let prop_qarg: Option<PyObject> = properties[&qarg].clone();
*x = prop_qarg;
}
qargs_val.insert(qarg.clone(), properties[&qarg].clone());
self.qarg_gate_map
.entry(qarg)
.and_modify(|e| {
Expand All @@ -280,9 +277,7 @@ impl Target {
)));
}
}
if let Some(gate_name) = self.gate_map.get_mut(&instruction_name) {
*gate_name = qargs_val;
}
self.gate_map.insert(instruction_name, qargs_val);
self.instruction_durations = None;
self.instruction_schedule_map = None;
Ok(())
Expand All @@ -308,7 +303,7 @@ impl Target {
// For debugging
if !self.gate_map.contains_key(&instruction) {
panic!(
"Provided instruction : '{:?}' not in this Target.",
"Provided instruction: '{:?}' not in this Target.",
&instruction
);
};
Expand Down
2 changes: 1 addition & 1 deletion qiskit/transpiler/_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def check_obj_params(parameters, obj):
return False
return True

return self._Target.instructions_supported(
return self._Target.instruction_supported(
inspect.isclass,
isinstance,
Parameter,
Expand Down

0 comments on commit 94cbb85

Please sign in to comment.