Environments
arch_gym.envs.AstraSimEnv module
- class arch_gym.envs.AstraSimEnv.AstraSimEnv(rl_form='random_walker', max_steps=5, num_agents=1, reward_formulation='None', reward_scaling=1)[source]
Bases:
Env- action_space: Space[ActType]
- close()[source]
Override close in your subclass to perform any necessary cleanup.
Environments will automatically
close()themselves when garbage collected or when the program exits.
- observation_space: Space[ObsType]
- render()[source]
Compute the render frames as specified by render_mode attribute during initialization of the environment.
The set of supported modes varies per environment. (And some third-party environments may not support rendering at all.) By convention, if render_mode is:
None (default): no render is computed.
human: render return None. The environment is continuously rendered in the current display or terminal. Usually for human consumption.
rgb_array: return a single frame representing the current state of the environment. A frame is a numpy.ndarray with shape (x, y, 3) representing RGB values for an x-by-y pixel image.
rgb_array_list: return a list of frames representing the states of the environment since the last reset. Each frame is a numpy.ndarray with shape (x, y, 3), as with rgb_array.
ansi: Return a strings (str) or StringIO.StringIO containing a terminal-style text representation for each time step. The text can include newlines and ANSI escape sequences (e.g. for colors).
Note
Make sure that your class’s metadata ‘render_modes’ key includes the list of supported modes. It’s recommended to call super() in implementations to use the functionality of this method.
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
arch_gym.envs.AstraSimWrapper module
arch_gym.envs.DRAMEnv module
- class arch_gym.envs.DRAMEnv.DRAMEnv(reward_formulation='power', cost_model='simulator')[source]
Bases:
Env- actionToConfigs(action)[source]
Converts actions output from the agent to update the configuration files.
- action_space: Space[ActType]
- get_observation(outstream)[source]
converts the std out from DRAMSys to observation of energy, power, latency [Energy (PJ), Power (mW), Latency (ns)]
- observation_space: Space[ObsType]
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
arch_gym.envs.DRAMEnv_RL module
arch_gym.envs.FARSIEnv module
arch_gym.envs.FARSI_sim_env module
arch_gym.envs.FARSI_sim_wrapper module
arch_gym.envs.MasteroEnv module
- class arch_gym.envs.MasteroEnv.MasteroEnv(rl_form: str = 'tdm', rl_algo: str = 'ppo', max_steps: int = 100, num_agents: int = 1, reward_formulation: str = 'latency', reward_scaling: str = 'false', mapping_file: str = 'mapping.csv', workload: str = 'resnet18', layer_id: int = 2, noc_bw: int = 1073741824, offchip_bw: int = 1073741824, l1_size: int = 1073741824, l2_size: int = 1073741824, num_pe: int = 1024)[source]
Bases:
Env- action_space: Space[ActType]
- observation_space: Space[ObsType]
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
- step(action)[source]
Run one timestep of the environment’s dynamics.
When end of episode is reached, you are responsible for calling
reset()to reset this environment’s state. Accepts an action and returns either a tuple (observation, reward, terminated, truncated, info).- Parameters:
action (ActType) – an action provided by the agent
- Returns:
- this will be an element of the environment’s
observation_space. This may, for instance, be a numpy array containing the positions and velocities of certain objects.
reward (float): The amount of reward returned as a result of taking the action. terminated (bool): whether a terminal state (as defined under the MDP of the task) is reached.
In this case further step() calls could return undefined results.
- truncated (bool): whether a truncation condition outside the scope of the MDP is satisfied.
Typically a timelimit, but could also be used to indicate agent physically going out of bounds. Can be used to end the episode prematurely before a terminal state is reached.
- info (dictionary): info contains auxiliary diagnostic information (helpful for debugging, learning, and logging).
This might, for instance, contain: metrics that describe the agent’s performance state, variables that are hidden from observations, or individual reward terms that are combined to produce the total reward. It also can contain information that distinguishes truncation and termination, however this is deprecated in favour of returning two booleans, and will be removed in a future version.
(deprecated) done (bool): A boolean value for if the episode has ended, in which case further
step()calls will return undefined results.A done signal may be emitted for different reasons: Maybe the task underlying the environment was solved successfully, a certain timelimit was exceeded, or the physics simulation has entered an invalid state.
- this will be an element of the environment’s
- Return type:
observation (object)
arch_gym.envs.RandomParameterEnv module
- class arch_gym.envs.RandomParameterEnv.RandomParameterEnv(natural=False)[source]
Bases:
Env- action_space: Space[ActType]
- observation_space: Space[ObsType]
- render()[source]
Compute the render frames as specified by render_mode attribute during initialization of the environment.
The set of supported modes varies per environment. (And some third-party environments may not support rendering at all.) By convention, if render_mode is:
None (default): no render is computed.
human: render return None. The environment is continuously rendered in the current display or terminal. Usually for human consumption.
rgb_array: return a single frame representing the current state of the environment. A frame is a numpy.ndarray with shape (x, y, 3) representing RGB values for an x-by-y pixel image.
rgb_array_list: return a list of frames representing the states of the environment since the last reset. Each frame is a numpy.ndarray with shape (x, y, 3), as with rgb_array.
ansi: Return a strings (str) or StringIO.StringIO containing a terminal-style text representation for each time step. The text can include newlines and ANSI escape sequences (e.g. for colors).
Note
Make sure that your class’s metadata ‘render_modes’ key includes the list of supported modes. It’s recommended to call super() in implementations to use the functionality of this method.
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
arch_gym.envs.SniperEnv module
- class arch_gym.envs.SniperEnv.SniperEnv[source]
Bases:
Env- actionToConfigs(action, cfg)[source]
Converts actions output from the agent to update the configuration files
- action_space: Space[ActType]
- observation_space: Space[ObsType]
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
- step(action)[source]
Run one timestep of the environment’s dynamics.
When end of episode is reached, you are responsible for calling
reset()to reset this environment’s state. Accepts an action and returns either a tuple (observation, reward, terminated, truncated, info).- Parameters:
action (ActType) – an action provided by the agent
- Returns:
- this will be an element of the environment’s
observation_space. This may, for instance, be a numpy array containing the positions and velocities of certain objects.
reward (float): The amount of reward returned as a result of taking the action. terminated (bool): whether a terminal state (as defined under the MDP of the task) is reached.
In this case further step() calls could return undefined results.
- truncated (bool): whether a truncation condition outside the scope of the MDP is satisfied.
Typically a timelimit, but could also be used to indicate agent physically going out of bounds. Can be used to end the episode prematurely before a terminal state is reached.
- info (dictionary): info contains auxiliary diagnostic information (helpful for debugging, learning, and logging).
This might, for instance, contain: metrics that describe the agent’s performance state, variables that are hidden from observations, or individual reward terms that are combined to produce the total reward. It also can contain information that distinguishes truncation and termination, however this is deprecated in favour of returning two booleans, and will be removed in a future version.
(deprecated) done (bool): A boolean value for if the episode has ended, in which case further
step()calls will return undefined results.A done signal may be emitted for different reasons: Maybe the task underlying the environment was solved successfully, a certain timelimit was exceeded, or the physics simulation has entered an invalid state.
- this will be an element of the environment’s
- Return type:
observation (object)
arch_gym.envs.TimeloopEnv module
- class arch_gym.envs.TimeloopEnv.TimeloopEnv(script_dir=None, output_dir=None, arch_dir=None, mapper_dir=None, workload_dir=None, target_val=None, num_cores=None, reward_formulation=None)[source]
Bases:
Env- action_space: Space[ActType]
- observation_space: Space[ObsType]
arch_gym.envs.TimeloopEnv_RL module
arch_gym.envs.archgym_env module
arch_gym.envs.custom_env module
- class arch_gym.envs.custom_env.CustomEnv(max_steps=10)[source]
Bases:
Env- action_space: Space[ActType]
- observation_space: Space[ObsType]
- render(mode='human')[source]
Compute the render frames as specified by render_mode attribute during initialization of the environment.
The set of supported modes varies per environment. (And some third-party environments may not support rendering at all.) By convention, if render_mode is:
None (default): no render is computed.
human: render return None. The environment is continuously rendered in the current display or terminal. Usually for human consumption.
rgb_array: return a single frame representing the current state of the environment. A frame is a numpy.ndarray with shape (x, y, 3) representing RGB values for an x-by-y pixel image.
rgb_array_list: return a list of frames representing the states of the environment since the last reset. Each frame is a numpy.ndarray with shape (x, y, 3), as with rgb_array.
ansi: Return a strings (str) or StringIO.StringIO containing a terminal-style text representation for each time step. The text can include newlines and ANSI escape sequences (e.g. for colors).
Note
Make sure that your class’s metadata ‘render_modes’ key includes the list of supported modes. It’s recommended to call super() in implementations to use the functionality of this method.
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
- step(action)[source]
Run one timestep of the environment’s dynamics.
When end of episode is reached, you are responsible for calling
reset()to reset this environment’s state. Accepts an action and returns either a tuple (observation, reward, terminated, truncated, info).- Parameters:
action (ActType) – an action provided by the agent
- Returns:
- this will be an element of the environment’s
observation_space. This may, for instance, be a numpy array containing the positions and velocities of certain objects.
reward (float): The amount of reward returned as a result of taking the action. terminated (bool): whether a terminal state (as defined under the MDP of the task) is reached.
In this case further step() calls could return undefined results.
- truncated (bool): whether a truncation condition outside the scope of the MDP is satisfied.
Typically a timelimit, but could also be used to indicate agent physically going out of bounds. Can be used to end the episode prematurely before a terminal state is reached.
- info (dictionary): info contains auxiliary diagnostic information (helpful for debugging, learning, and logging).
This might, for instance, contain: metrics that describe the agent’s performance state, variables that are hidden from observations, or individual reward terms that are combined to produce the total reward. It also can contain information that distinguishes truncation and termination, however this is deprecated in favour of returning two booleans, and will be removed in a future version.
(deprecated) done (bool): A boolean value for if the episode has ended, in which case further
step()calls will return undefined results.A done signal may be emitted for different reasons: Maybe the task underlying the environment was solved successfully, a certain timelimit was exceeded, or the physics simulation has entered an invalid state.
- this will be an element of the environment’s
- Return type:
observation (object)
arch_gym.envs.custom_env_2 module
arch_gym.envs.custom_gym module
- class arch_gym.envs.custom_gym.ExampleEnv[source]
Bases:
Env- action_space: Space[ActType]
- observation_space: Space[ObsType]
- render(mode='human')[source]
Compute the render frames as specified by render_mode attribute during initialization of the environment.
The set of supported modes varies per environment. (And some third-party environments may not support rendering at all.) By convention, if render_mode is:
None (default): no render is computed.
human: render return None. The environment is continuously rendered in the current display or terminal. Usually for human consumption.
rgb_array: return a single frame representing the current state of the environment. A frame is a numpy.ndarray with shape (x, y, 3) representing RGB values for an x-by-y pixel image.
rgb_array_list: return a list of frames representing the states of the environment since the last reset. Each frame is a numpy.ndarray with shape (x, y, 3), as with rgb_array.
ansi: Return a strings (str) or StringIO.StringIO containing a terminal-style text representation for each time step. The text can include newlines and ANSI escape sequences (e.g. for colors).
Note
Make sure that your class’s metadata ‘render_modes’ key includes the list of supported modes. It’s recommended to call super() in implementations to use the functionality of this method.
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
arch_gym.envs.customenv_wrapper module
arch_gym.envs.dramsys_wrapper module
arch_gym.envs.dramsys_wrapper_rl module
arch_gym.envs.envHelpers module
- class arch_gym.envs.envHelpers.CustomListDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]
Bases:
Dumper
- class arch_gym.envs.envHelpers.helpers[source]
Bases:
object- action_decoder_ga_astraSim(act_encoded)[source]
“scheduling-policy”: {“FIFO”, “LIFO”}, “collective-optimization”: {“localBWAware”, “baseline”}, “intra-dimension-scheduling”: {“FIFO”, “SCF”}, “inter-dimension-scheduling”: {“baseline”, “themis”}
- action_mapper(action, param)[source]
RL agent outputs actions in [0,1]
This function maps the action space to the actual values we split the action space (0,1) into equal parts depending on the number of valid actions each parameter can take We then bin the action to the appropriate range
- action_mapper_timeloop(action, param)[source]
RL agent outputs actions in [0,1] This function maps the action space to the actual values we split the action space (0,1) into equal parts depending on the number of valid actions each parameter can take We then bin the action to the appropriate range
- create_timeloop_dirs(agent_id, base_script_dir, base_output_dir, base_arch_dir)[source]
Creates the script, output and arch directories for a given agent_id for timeloop
- decode_action_list_rl(action_list, dimensions)[source]
Convert the continuous action list to a discrete action list depending upon the dimensions of the network layer
- decode_timeloop_action(action)[source]
Transforms action indexes to action dictionary yaml accepted by timeloop
- random_walk()[source]
configurations are ordered in this fashion
keys = [“PagePolicy”, “Scheduler”, “SchedulerBuffer”, “RequestBufferSize”, “CmdMux”, “RespQueue”, “RefreshPolicy”, “RefreshMaxPostponed”, “RefreshMaxPulledin”, “PowerDownPolicy”, “Arbiter”, “MaxActiveTransactions” ]
arch_gym.envs.envlogger_reader_test module
arch_gym.envs.envlogger_writer_test module
arch_gym.envs.loggers module
arch_gym.envs.maestero_wrapper module
arch_gym.envs.simpleEnv module
- class arch_gym.envs.simpleEnv.simpleEnv[source]
Bases:
Env- LF_MIN = 1
- RT_MAX = 10
- action_space: Space[ActType]
- max_steps = 10
- metadata: Dict[str, Any] = {'render.modes': ['human']}
- move_left = 0
- move_right = 1
- observation_space: Space[ObsType]
- reset()[source]
Resets the environment to an initial state and returns the initial observation.
This method can reset the environment’s random number generator(s) if
seedis an integer or if the environment has not yet initialized a random number generator. If the environment already has a random number generator andreset()is called withseed=None, the RNG should not be reset. Moreover,reset()should (in the typical use case) be called with an integer seed right after initialization and then never again.- Parameters:
seed (optional int) – The seed that is used to initialize the environment’s PRNG. If the environment does not already have a PRNG and
seed=None(the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG andseed=Noneis passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)
- Returns:
- Observation of the initial state. This will be an element of
observation_space (typically a numpy array) and is analogous to the observation returned by
step().- info (dictionary): This dictionary contains auxiliary information complementing
observation. It should be analogous to the
inforeturned bystep().
- Observation of the initial state. This will be an element of
- Return type:
observation (object)
- reward_away = -2
- reward_goal = 10
- reward_step = -1