Skip to content

Commit

Permalink
fix random walker"
Browse files Browse the repository at this point in the history
  • Loading branch information
jared-ni committed Nov 8, 2023
1 parent cc98976 commit e201fa2
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions sims/AstraSim/trainRandomWalkerAstraSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def generate_random_actions(action_dict, system_knob, network_knob):

return action_dict

=======
def write_network(dimension):
def dim_helper(dim, val):
return [val for _ in range(dim)]
Expand Down Expand Up @@ -227,7 +226,7 @@ def generate_random_actions(dimension):
# action['workload'] = write_workload()

return action
>>>>>>> main:sims/AstraSim/train_randomwalker_AstraSim.py


def log_results_to_csv(filename, fitness_dict):
df = pd.DataFrame([fitness_dict['reward']])
Expand Down Expand Up @@ -267,7 +266,6 @@ def main(_):
settings_dir_path = os.path.dirname(settings_file_path)
proj_root_path = os.path.abspath(settings_dir_path)

<<<<<<< HEAD:sims/AstraSim/trainRandomWalkerAstraSim.py
astrasim_archgym = os.path.join(proj_root_path, "astrasim-archgym")

# TODO: V1 SPEC:
Expand All @@ -283,8 +281,6 @@ def main(_):
systems_folder, "4d_ring_fc_ring_switch_baseline.txt")
workload_file = "all_reduce/allreduce_0.65.txt"

=======
>>>>>>> main:sims/AstraSim/train_randomwalker_AstraSim.py
exe_path = os.path.join(proj_root_path, "run_general.sh")
network_config = os.path.join(proj_root_path, "general_network.json")
system_config = os.path.join(proj_root_path, "general_system.txt")
Expand Down Expand Up @@ -315,7 +311,6 @@ def main(_):
start = time.time()

step_results = {}
<<<<<<< HEAD:sims/AstraSim/trainRandomWalkerAstraSim.py

# INITIATE action dict
action_dict = {}
Expand All @@ -329,31 +324,16 @@ def main(_):

# TODO: parse knobs (all variables to change in action_dict)
system_knob, network_knob = parse_knobs(knobs_spec)
=======
>>>>>>> main:sims/AstraSim/train_randomwalker_AstraSim.py

best_reward, best_observation, best_actions = 0.0, 0.0, {}

for i in range(FLAGS.num_episodes):
logging.info('Episode %r', i)

for step in range(FLAGS.num_steps):
<<<<<<< HEAD:sims/AstraSim/trainRandomWalkerAstraSim.py
# pass into generate_random_actions(dimension, knobs)
action_dict = generate_random_actions(
action_dict, system_knob, network_knob)
=======
# generate random actions
action = generate_random_actions(dimension)

# write the three config files
with open("general_network.json", "w") as outfile:
outfile.write(json.dumps(action['network'], indent=4))

with open("general_system.txt", 'w') as file:
for key, value in action["system"].items():
file.write(f'{key}: {value}\n')
>>>>>>> main:sims/AstraSim/train_randomwalker_AstraSim.py

# with open("general_workload.txt", 'w') as file:
# file.write(action["workload"]["value"])
Expand All @@ -375,14 +355,10 @@ def main(_):

end = time.time()

<<<<<<< HEAD:sims/AstraSim/trainRandomWalkerAstraSim.py
print("Best Reward: ", best_reward)
print("Best Observation: ", best_observation)
print("Best Parameters: ", best_actions)
print("Total Time Taken: ", end - start)
=======
print("Total Time taken: ", end - start)
>>>>>>> main:sims/AstraSim/train_randomwalker_AstraSim.py
print("Total Useful Steps: ", env.useful_counter)


Expand Down

0 comments on commit e201fa2

Please sign in to comment.