Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cur_metric.objective = optimizer.param_groups[0]["obj_k_1"][0].data.clone() IndexError: list index out of range #164

Open
SP-FA opened this issue Dec 27, 2023 · 1 comment

Comments

@SP-FA
Copy link

SP-FA commented Dec 27, 2023

I'm getting the following error when I run python dreamplace/placer.py test/ispd2005/adaptec1.json on the circuit_trainin branch:

========================================================
                       DREAMPlace
            Yibo Lin (http://yibolin.com)
   David Z. Pan (http://users.ece.utexas.edu/~dpan)
========================================================
[INFO   ] DREAMPlace - parameters = {'aux_input': '/home/yzc/git_repo/DREAMPlace/install/benchmarks/ispd2005/adaptec1/adaptec1.aux', 'lef_input': '', 'def_input': '', 'verilog_input': '', 'gpu': 1, 'num_bins_x': 512, 'num_bins_y': 512, 'global_place_stages': [{'num_bins_x': 512, 'num_bins_y': 512, 'iteration': 1000, 'learning_rate': 0.01, 'wirelength': 'weighted_average', 'optimizer': 'nesterov', 'Llambda_density_weight_iteration': 1, 'Lsub_iteration': 1}], 'target_density': 1.0, 'density_weight': 8e-05, 'random_seed': 1000, 'result_dir': 'results', 'scale_factor': 1.0, 'shift_factor': [0.0, 0.0], 'ignore_net_degree': 100, 'gp_noise_ratio': 0.025, 'enable_fillers': 1, 'global_place_flag': 1, 'legalize_flag': 1, 'detailed_place_flag': 1, 'stop_overflow': 0.07, 'dtype': 'float32', 'detailed_place_engine': '', 'detailed_place_command': '', 'plot_flag': 0, 'RePlAce_ref_hpwl': 350000, 'RePlAce_LOWER_PCOF': 0.95, 'RePlAce_UPPER_PCOF': 1.05, 'gamma': 4.0, 'RePlAce_skip_energy_flag': 0, 'random_center_init_flag': 1, 'sort_nets_by_degree': 0, 'num_threads': 8, 'dump_global_place_solution_flag': 0, 'dump_legalize_solution_flag': 0, 'routability_opt_flag': 0, 'route_num_bins_x': 512, 'route_num_bins_y': 512, 'node_area_adjust_overflow': 0.15, 'max_num_area_adjust': 3, 'adjust_nctugr_area_flag': 0, 'adjust_rudy_area_flag': 1, 'adjust_pin_area_flag': 1, 'area_adjust_stop_ratio': 0.01, 'route_area_adjust_stop_ratio': 0.01, 'pin_area_adjust_stop_ratio': 0.05, 'unit_horizontal_capacity': 1.5625, 'unit_vertical_capacity': 1.45, 'unit_pin_capacity': 0.058, 'max_route_opt_adjust_rate': 2.0, 'route_opt_adjust_exponent': 2.0, 'pin_stretch_ratio': 1.414213562, 'max_pin_opt_adjust_rate': 1.5, 'deterministic_flag': 0, 'circuit_training_mode': 0}
[WARNING] DEF input file not specified, cannot output DEF file; set to DEFSIMPLE
[INFO   ] lef_input = 
[INFO   ] def_input = 
[INFO   ] verilog_input = 
[INFO   ] bookshelf_aux_input = /home/yzc/git_repo/DREAMPlace/install/benchmarks/ispd2005/adaptec1/adaptec1.aux
[INFO   ] bookshelf_pl_input = 
[INFO   ] def_size_input = 
[INFO   ] def_output = -out.def
[INFO   ] rpt_output = 
[INFO   ] target_util = 0
[INFO   ] max_displace = 0
[INFO   ] bin size = (10, 10) #rows
[INFO   ] sbin size = (5, 5) #rows
[INFO   ] bin_space_threshold = 0.2
[INFO   ] abu = 2,10 5,5 10,2 20,1 
[INFO   ] def_ignore_cells = 
[INFO   ] macro_obs_aware_layers = 
[INFO   ] enable_place = true
[INFO   ] enable_legalize = true
[INFO   ] evaluate_overlap = false
[INFO   ] move_multi_row_cell = true
[INFO   ] align_power_line = true
[INFO   ] cluster_cell = false
[INFO   ] sort_nets_by_degree = false
[INFO   ] file_format = BOOKSHELF
[INFO   ] max_iters = 6
[WARNING] no DEF file specified
[WARNING] no Verilog file specified
[INFO   ] reading /home/yzc/git_repo/DREAMPlace/install/benchmarks/ispd2005/adaptec1/adaptec1.aux
[WARNING] no additional Bookshelf .pl file specified
[WARNING] 20285 nets with 24352 pins from same nodes
[WARNING] 4210 nets should be ignored due to not enough pins
[INFO   ] sort nodes in the order of movable and fixed
[INFO   ] Group cells for fence regions
[INFO   ] Construct 0 groups
[INFO   ] Fence region groups done
[DEBUG  ] num_terminals 543, numFixed 543, numPlaceBlockages 0, num_terminal_NIs 0
[DEBUG  ] fixed area overlap: 4.91641e+07 fixed area total: 6.4094e+07, space area = 6.50265e+07
[INFO   ] DREAMPlace - set shift_factor = (459, 459), as original row bbox = (459, 459, 11151, 11139)
[INFO   ] DREAMPlace - set scale_factor = 1, as site_width = 1
[INFO   ] DREAMPlace - shift coordinate system by (459, 459), scale coordinate system by 1
[INFO   ] DREAMPlace - 
================================= Benchmark Statistics =================================
#nodes = 211447, #terminals = 543, # terminal_NIs = 0, #movable = 210904, #nets = 221142
die area = (0, 0, 10692, 10680) 1.14191e+08
row height = 12, site width = 1
num_bins = 512x512, bin sizes = 1.74023x1.73828
#pins = 919701, #movable_pins = 905028
total_movable_node_area = 3.72863e+07, total_fixed_node_area = 4.91641e+07, total_space_area = 6.50265e+07
utilization = 0.573402, target_density = 1
use placeable_area = 6.50265e+07 to compute fillers
total_filler_node_area = 2.77402e+07, #fillers = 160067, filler sizes = 14.442x12
========================================================================================
[INFO   ] DREAMPlace - reading benchmark takes 2.88953 seconds
[INFO   ] DREAMPlace - reading database takes 2.89 seconds
[INFO   ] DREAMPlace - move cells to the center of layout with random noise
[WARNING] DREAMPlace - net weights are all the same, ignored
[INFO   ] DREAMPlace - non-linear placement initialization takes 0.19 seconds
[INFO   ] DREAMPlace - 512x512 bins #bins 512x512, bin sizes 1.74023x1.73828, max_num_bins = 6, padding = 0
[INFO   ] dreamplace.ops.electric_potential.electric_potential - regard 0 cells as movable macros in global placement
[WARNING] DREAMPlace - quadratic density penalty is disabled, density weight update is forced to be based on HPWL
[INFO   ] DREAMPlace - use nesterov optimizer
[INFO   ] DREAMPlace - add 2.5% noise
[INFO   ] dreamplace.ops.electric_potential.electric_potential - fixed density map: average 187.546, max 435.602, bin area 435.602
[INFO   ] DREAMPlace - nesterov initialization takes 0.0860898 seconds
[INFO   ] DREAMPlace - density_weight = 7.495676E-12
[INFO   ] DREAMPlace - optimizer step 0.042 ms
Traceback (most recent call last):
  File "/home/yzc/git_repo/DREAMPlace-circuit_training/install/dreamplace/Placer.py", line 174, in <module>
    place(params)
  File "/home/yzc/git_repo/DREAMPlace-circuit_training/install/dreamplace/Placer.py", line 47, in place
    metrics = placer(params, placedb)
  File "/home/yzc/git_repo/DREAMPlace-circuit_training/install/dreamplace/NonLinearPlace.py", line 449, in __call__
    one_descent_step(
  File "/home/yzc/git_repo/DREAMPlace-circuit_training/install/dreamplace/NonLinearPlace.py", line 316, in one_descent_step
    cur_metric.objective = optimizer.param_groups[0]["obj_k_1"][0].data.clone()
IndexError: list index out of range

But it can running successfully on the master branch.

I add the parameter set_to_none=False at NonLinearPlace.py L277 and then it can finish without issues. I want to know if this is the correct method of correction. Is it?

My environment is:
Ubuntu 22.0.4
Python 3.9.18
PyTorch 2.0.1

@zhuhanqing
Copy link
Contributor

Hi, this error is because pytorch 2.0 will set set_to_none=True by default, while it is not desired in our code. You should add set_to_none=False or replace the optimizer.zero_grad() to the following to keep compatibility for different pytorch versions.

# For backward compatibility
                    # PyTorch 1.7 introduced zero_grad(set_to_none=False)
                    # PyTorch 2.0 changed set_to_none=True
                    if "set_to_none" in inspect.signature(optimizer.zero_grad).parameters: 
                        optimizer.zero_grad(set_to_none=False)
                    else:
                        optimizer.zero_grad()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants