From fade749a4c44b8fc7e10e761786634b7a34e8c66 Mon Sep 17 00:00:00 2001 From: AditiR_42 Date: Thu, 16 Nov 2023 16:18:13 -0500 Subject: [PATCH] automate random walker --- aco/DeepSwarm/deepswarm/backends.py | 5 ++-- bo/AstraSimEstimator.py | 14 --------- settings/default_astrasim.yaml | 1 - sims/AstraSim/trainRandomWalkerAstraSim.py | 35 +++++----------------- 4 files changed, 10 insertions(+), 45 deletions(-) diff --git a/aco/DeepSwarm/deepswarm/backends.py b/aco/DeepSwarm/deepswarm/backends.py index b5f6dc11..35745309 100644 --- a/aco/DeepSwarm/deepswarm/backends.py +++ b/aco/DeepSwarm/deepswarm/backends.py @@ -18,6 +18,7 @@ from arch_gym.envs.AstraSimWrapper import make_astraSim_env from arch_gym.envs.SniperEnv import SniperEnv from arch_gym.envs.DRAMEnv import DRAMEnv +from arch_gym.envs.AstraSimEnv import AstraSimEnv from arch_gym.envs.envHelpers import helpers import json import envlogger @@ -344,7 +345,7 @@ class DummyAstraSim(): """Dummy placeholder for DRAMSys to do POC""" def __init__(self, path, exp_name, traject_dir, log_dir, reward_formulation, use_envlogger): - self.env = SniperEnv() + self.env = AstraSimEnv() self.helper = helpers() self.fitness_hist = {} @@ -409,8 +410,6 @@ def __init__(self, path, exp_name, traject_dir, log_dir, reward_formulation, use "hbm-scale": [node.hbmScale1, node.hbmScale2, node.hbmScale3] } - # ADD 5 DIMENSIONS + account for dimension variable - for node in path: system_knob, network_knob = self.parse_knobs(self.knobs_spec) dicts = [(system_knob, 'system'), (network_knob, 'network')] diff --git a/bo/AstraSimEstimator.py b/bo/AstraSimEstimator.py index 9e0b6c0a..b57b71db 100644 --- a/bo/AstraSimEstimator.py +++ b/bo/AstraSimEstimator.py @@ -187,20 +187,6 @@ def get_params(self, deep=False): } def set_params(self, **params): - """ - scheduling-policy: LIFO - endpoint-delay: 1 - active-chunks-per-dimension: 1 - preferred-dataset-splits: 64 - boost-mode: 1 - all-reduce-implementation: direct_ring_halvingDoubling - all-gather-implementation: direct_ring_halvingDoubling - reduce-scatter-implementation: direct_ring_halvingDoubling - all-to-all-implementation: direct_direct_direct - collective-optimization: localBWAware - intra-dimension-scheduling: FIFO - inter-dimension-scheduling: baseline - """ _params = params self.action_dict["scheduling_policy"] = _params["scheduling_policy"] self.action_dict["collective_optimization"] = _params["collective_optimization"] diff --git a/settings/default_astrasim.yaml b/settings/default_astrasim.yaml index 8849f1cd..86ad00e8 100644 --- a/settings/default_astrasim.yaml +++ b/settings/default_astrasim.yaml @@ -15,7 +15,6 @@ Nodes: ArchParamsNode: attributes: # network attributes - topologyName: ["Hierarchical"] topologiesPerDim1: ["Ring", "FullyConnected", "Switch"] topologiesPerDim2: ["Ring", "FullyConnected", "Switch"] topologiesPerDim3: ["Ring", "FullyConnected", "Switch"] diff --git a/sims/AstraSim/trainRandomWalkerAstraSim.py b/sims/AstraSim/trainRandomWalkerAstraSim.py index d5b020e1..efa6cf5e 100644 --- a/sims/AstraSim/trainRandomWalkerAstraSim.py +++ b/sims/AstraSim/trainRandomWalkerAstraSim.py @@ -32,25 +32,6 @@ 'Which reward formulation to use?') FLAGS = flags.FLAGS -# define which parameters are affected by dimension count -DIMENSION_PARAMS = { - # network parameters - "topology-name": [False], "topologies-per-dim": [True, "diff"], - "dimension-type": [True, "same"], "dimensions-count": [False], - "units-count": [True, "diff"], "links-count": [True, "diff"], - "link-latency": [True, "same"], "link-bandwidth": [True, "diff"], - "nic-latency": [True, "same"], "router-latency": [True, "same"], - "hbm-latency": [True, "same"], "hbm-bandwidth": [True, "same"], - "hbm-scale": [True, "same"], - # system parameters - "scheduling-policy": [False], "endpoint-delay": [False], - "active-chunks-per-dimension": [False], "preferred-dataset-splits": [False], - "boost-mode": [False], "all-reduce-implementation": [True, "diff"], - "all-gather-implementation": [True, "diff"], "reduce-scatter-implementation": [True, "diff"], - "all-to-all-implementation": [True, "diff"], "collective-optimization": [False], - "intra-dimension-scheduling": [False], "inter-dimension-scheduling": [False] -} - # network: parses the network file def parse_network(network_file, action_dict): action_dict['network'] = {} @@ -96,24 +77,24 @@ def parse_knobs(knobs_spec): def generate_random_actions(dimension, action_dict, system_knob, network_knob): dicts = [(system_knob, 'system'), (network_knob, 'network')] for dict_type, dict_name in dicts: + knobs = dict_type.keys() + knobs.remove("num-dims") for knob in dict_type.keys(): - if isinstance(dict_type[knob], set): - if DIMENSION_PARAMS[knob][0]: - if DIMENSION_PARAMS[knob][1] == "diff": + if isinstance(dict_type[knob][0], set): + if dict_type[knob][1] == "FALSE": action_dict[dict_name][knob] = [random.choice( list(dict_type[knob])) for _ in range(dimension)] - else: + elif dict_type[knob][1] == "TRUE": choice = random.choice(list(dict_type[knob])) action_dict[dict_name][knob] = [choice for _ in range(dimension)] else: action_dict[dict_name][knob] = random.choice( list(dict_type[knob])) else: - if DIMENSION_PARAMS[knob][0]: - if DIMENSION_PARAMS[knob][1] == "diff": + if dict_type[knob][1] == "FALSE": action_dict[dict_name][knob] = [random.randint( dict_type[knob][1], dict_type[knob][2])] - else: + elif dict_type[knob][1] == "TRUE": choice = random.randint(dict_type[knob][1], dict_type[knob][2]) action_dict[dict_name][knob] = [choice for _ in range(dimension)] else: @@ -228,7 +209,7 @@ def main(_): for step in range(FLAGS.num_steps): # pass into generate_random_actions(dimension, knobs) action_dict = generate_random_actions( - action_dict['network']['dimensions-count'], action_dict, system_knob, network_knob) + action_dict['network']['num-dims'], action_dict, system_knob, network_knob) # with open("general_workload.txt", 'w') as file: # file.write(action["workload"]["value"])