def test_generate_germs_with_candidate_germ_counts(self): germs = germsel.find_germs(self.mdl_target_noisy, randomize=False, candidate_germ_counts={ 3: 'all upto', 4: 10, 5: 10, 6: 10 })
def test_build_up_breadth(self): germs = germsel.find_germs_breadthfirst(self.neighbors, self.germ_set, **self.options) # TODO assert correctness algorithm_kwargs = dict(germs_list=self.germ_set, **self.options) germs_driver = germsel.find_germs(self.mdl_target_noisy, randomize=False, algorithm='greedy', algorithm_kwargs=algorithm_kwargs)
def test_grasp_germ_set_optimization(self): soln = germsel.find_germs_grasp(self.neighbors, self.germ_set, alpha=0.1, **self.options) # TODO assert correctness best, initial, local = germsel.find_germs_grasp(self.neighbors, self.germ_set, alpha=0.1, return_all=True, **self.options) # TODO shouldn't this pass? # self.assertEqual(soln, best) algorithm_kwargs = dict(germs_list=self.germ_set, **self.options) soln_driver = germsel.find_germs(self.mdl_target_noisy, randomize=False, algorithm='grasp', algorithm_kwargs=algorithm_kwargs)
def test_optimize_integer_germs_slack_with_fixed_slack(self): finalGerms = germsel.find_germs_integer_slack(self.mdl_target_noisy, self.germ_set, fixed_slack=0.1, verbosity=4) # TODO assert correctness finalGerms_all, weights, scores = germsel.find_germs_integer_slack( self.mdl_target_noisy, self.germ_set, fixed_slack=0.1, return_all=True, verbosity=4) self.assertEqual(finalGerms, finalGerms_all) algorithm_kwargs = dict(germs_list=self.germ_set, fixed_slack=0.1) finalGerms_driver = germsel.find_germs( self.mdl_target_noisy, randomize=False, algorithm='slack', algorithm_kwargs=algorithm_kwargs, verbosity=4) self.assertEqual(finalGerms_driver, finalGerms)
def test_generate_germs_raises_on_bad_algorithm(self): with self.assertRaises(ValueError): germsel.find_germs(self.mdl_target_noisy, algorithm='foobar')
def test_auto_experiment_design(self): # Let's construct a 1-qubit $X(\pi/2)$, $Y(\pi/2)$, $I$ model for which we will need to find germs and fiducials. target_model = mc.create_explicit_model_from_expressions( [('Q0', )], ['Gi', 'Gx', 'Gy'], ["I(Q0)", "X(pi/2,Q0)", "Y(pi/2,Q0)"]) # ## Hands-off # We begin by demonstrating the most hands-off approach. # We can generate a germ set simply by providing the target model. (and seed so it's deterministic) germs = germsel.find_germs(target_model, seed=2017) # In the same way we can generate preparation and measurement fiducials. prepFiducials, measFiducials = fidsel.find_fiducials(target_model) #test return_all - this just prints more info... p, m = fidsel.find_fiducials(target_model, algorithm_kwargs={'return_all': True}) #test invalid algorithm with self.assertRaises(ValueError): fidsel.find_fiducials(target_model, algorithm='foobar') # Now that we have germs and fiducials, we can construct the list of experiments we need to perform in # order to do GST. The only new things to provide at this point are the sizes for the experiments we want # to perform (in this case we want to perform between 0 and 256 gates between fiducial pairs, going up # by a factor of 2 at each stage). maxLengths = [0] + [2**n for n in range(8 + 1)] listOfExperiments = gstcircuits.create_lsgst_circuits( target_model.operations.keys(), prepFiducials, measFiducials, germs, maxLengths) # The list of `Circuit` that the previous function gave us isn't necessarily the most readable # form to present the information in, so we can write the experiment list out to an empty data # file to be filled in after the experiments are performed. graspGerms = germsel.find_germs(target_model, algorithm='grasp', seed=2017, num_gs_copies=2, candidate_germ_counts={ 3: 'all upto', 4: 10, 5: 10, 6: 10 }, candidate_seed=2017, algorithm_kwargs={'iterations': 1}) slackPrepFids, slackMeasFids = fidsel.find_fiducials( target_model, algorithm='slack', algorithm_kwargs={'slack_frac': 0.25}) fidsel.find_fiducials( target_model, algorithm='slack' ) # slacFrac == 1.0 if don't specify either slack_frac or fixed_slack germsMaxLength3 = germsel.find_germs( target_model, candidate_germ_counts={3: 'all upto'}, seed=2017) uniformPrepFids, uniformMeasFids = fidsel.find_fiducials( target_model, max_fid_length=3, algorithm='grasp', algorithm_kwargs={'iterations': 100}) incompletePrepFids, incompleteMeasFids = fidsel.find_fiducials( target_model, max_fid_length=1) nonSingletonGerms = germsel.find_germs( target_model, num_gs_copies=2, force=None, candidate_germ_counts={4: 'all upto'}, algorithm='grasp', algorithm_kwargs={'iterations': 5}, seed=2017) omitIdentityPrepFids, omitIdentityMeasFids = fidsel.find_fiducials( target_model, omit_identity=False, ops_to_omit=['Gi'])