@@ -233,7 +233,12 @@ pub struct Target {
233233 pub concurrent_measurements : Option < Vec < Vec < PhysicalQubit > > > ,
234234 gate_map : IndexMap < String , TargetProperties > ,
235235 global_operations : HashMap < u32 , HashSet < String > > ,
236- qarg_gate_map : HashMap < Qargs , HashSet < String > > ,
236+ // This uses `IndexMap` not because it's necessary for determinism (though it will help), but so
237+ // it retains the specific iteration order it is constructed with. The order `qargs` are
238+ // encountered during construction are _usually_ going to be quite structured, and structure
239+ // here means that graphs built from qargs (like the coupling graph) will have their edges
240+ // ordered in much cache- and branch-prediction-friendlier orders than if they are randomised.
241+ qarg_gate_map : IndexMap < Qargs , HashSet < String > > ,
237242 has_angle_bounds : bool ,
238243}
239244
@@ -326,7 +331,7 @@ impl Target {
326331 concurrent_measurements,
327332 gate_map : IndexMap :: default ( ) ,
328333 global_operations : HashMap :: default ( ) ,
329- qarg_gate_map : HashMap :: default ( ) ,
334+ qarg_gate_map : IndexMap :: default ( ) ,
330335 has_angle_bounds : false ,
331336 } )
332337 }
@@ -847,10 +852,7 @@ impl Target {
847852 ) ;
848853 }
849854 self . gate_map = gate_map;
850- self . qarg_gate_map = state
851- . get_item ( "qarg_gate_map" ) ?
852- . unwrap ( )
853- . extract :: < HashMap < Qargs , HashSet < String > > > ( ) ?;
855+ self . qarg_gate_map = state. get_item ( "qarg_gate_map" ) ?. unwrap ( ) . extract ( ) ?;
854856 self . global_operations = state
855857 . get_item ( "global_operations" ) ?
856858 . unwrap ( )
0 commit comments