def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator. This function recreates the exact same parameter set as the sample LULESH specifications. The point of this file is to present an example of how to generate custom parameters. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() params = { "TRIAL": { "values": [i for i in range(1, 10)], "label": "TRIAL.%%" }, "SIZE": { "values": [10, 10, 10, 20, 20, 20, 30, 30, 30], "label": "SIZE.%%" }, "ITERATIONS": { "values": [10, 20, 30, 10, 20, 30, 10, 20, 30], "label": "ITERATIONS.%%" } } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator. This function generates a 1D distribution of points for a single variable, using the Chebyshev points scaled to the requested range. The point of this file is to present an example of using external libraries and helper functions to generate parameter value distributions. This technique can be used to build reusable/modular sampling libraries that pgen can hook into. :params env: A StudyEnvironment object containing custom information. :params kwargs: A dictionary of keyword arguments this function uses. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() # Unpack any pargs passed in x_min = int(kwargs.get('X_MIN', '0')) x_max = int(kwargs.get('X_MAX', '1')) num_pts = int(kwargs.get('NUM_PTS', '10')) x_pts, ypts = chebyshev_dist([x_min, x_max], num_pts) params = { "X": { "values": list(x_pts), "label": "X.%%" }, } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(env, **kwargs): p_gen = ParameterGenerator() # Unpack any pargs passed in num_nodes = kwargs.get('num_nodes', '1').split(" ") mb_size = kwargs.get('mb_size', '1').split(" ") procs_per_trainer = kwargs.get('ppt', '1').split(" ") iter_per_tournament = kwargs.get('ipt', '1') lr_scaling = kwargs.get('lr_scaling', 'False').split(" ") num_nodes_values = [] mb_sizes_values = [] procs_per_trainer_values = [] ltfbbi_values = [] lr_values = [] trial_values = [] for trial, param_combo in enumerate(iter.product(num_nodes,mb_size,procs_per_trainer,lr_scaling)): num_nodes_values.append(param_combo[0]) mb_sizes_values.append(param_combo[1]) procs_per_trainer_values.append(param_combo[2]) ltfbbi_values.append(int(int(iter_per_tournament) / int(param_combo[1]))) if param_combo[3] == 'True': lr_values.append(3e-4 * (int(param_combo[1])/512)) else: lr_values.append(3e-4) trial_values.append(trial) params = { "0TRIAL": { "values": trial_values, "label": "t%%" }, "1NUM_NODES": { "values": num_nodes_values, "label": "n%%" }, "2BATCH_SIZE": { "values": mb_sizes_values, "label": "bs%%" }, "3PPT": { "values": procs_per_trainer_values, "label": "ppt%%" }, "4LTFBBI": { "values": ltfbbi_values, "label": "LTFBbi%%" }, "5LR": { "values": lr_values, "label": "lr%%" }, } for key in sorted(params): value = params[key] p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(): """ Create a custom populated ParameterGenerator. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() params = { "X0": { "values": [x0 for x0, x1, x2 in x], "label": "X0.%%" }, "X1": { "values": [x1 for x0, x1, x2 in x], "label": "X1.%%" }, "X2": { "values": [x2 for x0, x1, x2 in x], "label": "X2.%%" } } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(**kwargs): """ Create a custom populated ParameterGenerator. This function recreates the exact same parameter set as the sample LULESH specifications. The point of this file is to present an example of how to generate custom parameters. :params kwargs: A dictionary of keyword arguments this function uses. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() trials = int(kwargs.get("trials")) size_min = int(kwargs.get("smin")) size_max = int(kwargs.get("smax")) iterations = int(kwargs.get("iter")) params = { "TRIAL": { "values": [i for i in range(1, trials)], "label": "TRIAL.%%" }, "SIZE": { "values": [randint(size_min, size_max) for i in range(1, trials)], "label": "SIZE.%%" }, "ITERATIONS": { "values": [iterations for i in range(1, trials)], "label": "ITERATIONS.%%" } } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator. This function recreates the exact same parameter set as the sample LULESH specifications. The point of this file is to present an example of how to generate custom parameters. :returns: A ParameterGenerator populated with parameters. """ nn_ecfp_pparams = hsw.parse_params( ['--config', env.find('JSON_FILE').value]) commands = hsw.build_search(nn_ecfp_pparams).generate_maestro_commands() p_gen = ParameterGenerator() params = { "COMMAND": { "values": [command for command in commands], "label": ["COMMAND.%s" % str(i) for i in range(len(commands))] }, } for key, value in params.items(): print(value) p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(env, **kwargs): p_gen = ParameterGenerator() params = { "X2": {"values": [1 / i for i in range(3, 6)], "label": "X2.%%"}, "N_NEW": {"values": [2 ** i for i in range(1, 4)], "label": "N_NEW.%%"}, } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() key = "TEST" names = ["test1", "test2", "test3", "test4", "test5"] values = ["1", "2", "3", "4", "5"] label = "TEST.{}" for i in range(0, len(names)): p_gen.add_parameter(key, values[i], label, names[i]) return p_gen
def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator with a single Parameter. :params env: A StudyEnvironment object containing custom information. :params kwargs: A dictionary of keyword arguments this function uses. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() key = "TEST" names = ["test1", "test2", "test3", "test4", "test5"] values = ["1", "2", "3", "4", "5"] label = "TEST.{}" for i in range(0, len(names)): p_gen.add_parameter(key, values[i], label, names[i]) return p_gen
def maestro_pgen(self): """ Returns a maestrowf Parameter Generator object containing samples """ if not MAESTROWF: raise Exception("maestrowf is not installed\n" + "the maestro_pgen is not supported") if self._pgen is not None: return self._pgen pgen = ParameterGenerator() params = _convert_dict_to_maestro_params(self.get_samples()) for key, value in params.items(): pgen.add_parameter(key, value["values"], value["label"]) self._pgen = pgen return pgen
def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator. This function recreates the exact same parameter set as the sample LULESH specifications. The difference here is that itertools is employed to programatically generate the samples instead of manually writing out all of the combinations. :params env: A StudyEnvironment object containing custom information. :params kwargs: A dictionary of keyword arguments this function uses. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() sizes = (10, 20, 30) iterations = (10, 20, 30) size_values = [] iteration_values = [] trial_values = [] for trial, param_combo in enumerate(iter.product(sizes, iterations)): size_values.append(param_combo[0]) iteration_values.append(param_combo[1]) trial_values.append(trial) params = { "TRIAL": { "values": trial_values, "label": "TRIAL.%%" }, "SIZE": { "values": size_values, "label": "SIZE.%%" }, "ITER": { "values": iteration_values, "label": "ITER.%%" }, } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_custom_generator(env, **kwargs): """ Create a custom populated ParameterGenerator. This function adapts the LULESH custom generator to randomly generate values for the SIZE parameter within a prescribed range. An optional seed is included, which if present on the command line or in the spec's env block will allow reproducible random values. :params env: A StudyEnvironment object containing custom information. :params kwargs: A dictionary of keyword arguments this function uses. :returns: A ParameterGenerator populated with parameters. """ p_gen = ParameterGenerator() trials = int(kwargs.get("trials", env.find("TRIALS").value)) size_min = int(kwargs.get("smin", env.find("SMIN").value)) size_max = int(kwargs.get("smax", env.find("SMAX").value)) iterations = int(kwargs.get("iter", env.find("ITER").value)) r_seed = kwargs.get("seed", env.find("SEED").value) seed(a=r_seed) params = { "TRIAL": { "values": [i for i in range(1, trials)], "label": "TRIAL.%%" }, "SIZE": { "values": [randint(size_min, size_max) for i in range(1, trials)], "label": "SIZE.%%" }, "ITERATIONS": { "values": [iterations for i in range(1, trials)], "label": "ITERATIONS.%%" } } for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen
def get_parameters(self): """ Generate a ParameterGenerator object from the global parameters. :returns: A ParameterGenerator with data from the specification. """ params = ParameterGenerator() for key, value in self.globals.items(): if "name" not in value: params.add_parameter(key, value["values"], value["label"]) else: params.add_parameter(key, value["values"], value["label"], value["name"]) return params
def get_custom_generator(env, **kwargs) -> ParameterGenerator: """ Generates parameters to feed at the CL to hello_world.py. """ p_gen: ParameterGenerator = ParameterGenerator() params: Dict[str, Union[List[float], str]] = { "X2": { "values": [1 / i for i in range(3, 6)], "label": "X2.%%" }, "N_NEW": { "values": [2**i for i in range(1, 4)], "label": "N_NEW.%%" }, } key: str value: Union[List[float], str] for key, value in params.items(): p_gen.add_parameter(key, value["values"], value["label"]) return p_gen