From 8a0160647a70970209d24fa268aa48dda439ebdd Mon Sep 17 00:00:00 2001 From: Ebrahim Songhori Date: Wed, 31 Jul 2024 21:28:14 -0700 Subject: [PATCH] Changing the env 1) Disabled auto-reset in this case. 2) Added a flag to disable mixed-size placement for infeasible state. PiperOrigin-RevId: 658255328 Change-Id: I7403b54bb12fd893b910e0fae1e50ac7d97f6cea --- circuit_training/environment/environment.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/circuit_training/environment/environment.py b/circuit_training/environment/environment.py index cfd643f..4f56497 100644 --- a/circuit_training/environment/environment.py +++ b/circuit_training/environment/environment.py @@ -156,6 +156,7 @@ def __init__( node_order: str = 'descending_size_macro_first', save_snapshot: bool = True, save_partial_placement: bool = False, + mixed_size_dp_at_infeasible: bool = True, ): """Creates a CircuitEnv. @@ -188,6 +189,8 @@ def __init__( save_snapshot: If true, save the snapshot placement. save_partial_placement: If true, eval also saves the placement even if RL does not place all nodes when an episode is done. + mixed_size_dp_at_infeasible: If true, run mixed size DP at infeasible + states. Only effective when std_cell_placer_mode is 'dreamplace'. """ self._global_seed = global_seed if not netlist_file: @@ -211,6 +214,7 @@ def __init__( ) self._save_snapshot = save_snapshot self._save_partial_placement = save_partial_placement + self._mixed_size_dp_at_infeasible = mixed_size_dp_at_infeasible self._observation_config = observation_config.ObservationConfig() @@ -597,22 +601,25 @@ def step(self, action: int) -> tuple[ObsType, float, bool, Any]: self._current_mask = self._get_mask() if not self._done and not np.any(self._current_mask): + self._done = True logging.info( 'Actions took before becoming infeasible: %s', self._current_actions ) - if self._std_cell_placer_mode == 'dreamplace': + if ( + self._std_cell_placer_mode == 'dreamplace' + and self._mixed_size_dp_at_infeasible + ): logging.info( 'Using DREAMPlace mixed-size placer for the rest of the macros and' ' std cell clusters.' ) - self._done = True cost, info = self.call_analytical_placer_and_get_cost( infeasible_state=True ) - return self.reset(), cost, True, info + return self._get_obs(), cost, True, info else: info = {cost: -1.0 for cost in COST_COMPONENTS} - return self.reset(), self.INFEASIBLE_REWARD, True, info + return self._get_obs(), self.INFEASIBLE_REWARD, True, info cost, info = self.call_analytical_placer_and_get_cost()