How zfyre/placerl works
Project type and purpose
• This repository implements a reinforcement learning (RL) based chip placement method (“PlaceRL”) that uses visual representation learning.
• The README explains how to run the placement via PPO2 (or alternative via DDPG) and provides benchmarks (adaptec1 and ariane) as well as performance comparisons with other methods.
• The project is organized as a full-stack research tool focusing on RL, simulation (environment), model training, and benchmark circuit evaluation.
File structure and map components
• Entry Points (Driver Scripts):
• “maskplace/PPO2.py”: Main script to start training or testing the RL agent.
• “maskplace/DDPG.py”: Alternative RL algorithm for chip placement.
(These form the “Controller/Entry” layer of the system.)
• RL Algorithm Core:
• “maskplace/PPO2.py” & “maskplace/DDPG.py” include the RL code, training loop, and hyper-parameter handling.
• “maskplace/nnet.py”: Contains neural network definitions potentially used by the RL agents.
• “maskplace/model/pretrained_model.pkl”: A serialized file holding pretrained model weights for inference or warm-start training.
• Simulation Environment:
• “maskplace/place_env/place_env.py”: Defines the custom gym-like environment used for chip placement simulation.
• “maskplace/place_env/__init__.py”: Initializes the environment module.
• Benchmark and Data Components:
• “maskplace/adaptec1/…” (includes adaptec1.aux, adaptec1.nets, adaptec1.nodes, adaptec1.pl, adaptec1.scl, adaptec1.wts): Provides benchmark circuit definitions and associated data files for the “adaptec1” benchmark.
• “maskplace/ariane/…” (includes __init__.py, graph.proto, laiyao.proto, laiyao_pb2.py, netlist.pb.txt, read_info.py): Offers benchmark files and protobuffer definitions for the “ariane” benchmark.
• Database / Data Processing Components:
• “maskplace/place_db.py” & “maskplace/place_db_proto.py”: Likely handle database interactions or protocol definitions that manage placement data.
• “maskplace/comp_res.py”: Possibly computes and compares placement results (e.g., cost metrics).
• Utility / Additional Modules:
• “maskplace/prim.py”: Could provide core placement primitives or helper methods.
• “_config.yml”: Configuration file for setting system parameters.
• Assets and Visual Representations:
• “README.md”: Provides high-level instructions and benchmark performance visualizations.
a. Main components and add explicit file names:
• Entry/Controller Component:
• Node: “PPO2 Controller” (Points to maskplace/PPO2.py)
• Node: “DDPG Controller” (Points to maskplace/DDPG.py)
• RL Core and Model:
• Node: “Neural Network Module” (Points to maskplace/nnet.py)
• Node: “Pretrained Model” (Points to maskplace/model/pretrained_model.pkl)
• Environment:
• Node: “Placement Environment” (Points to maskplace/place_env/place_env.py and maskplace/place_env/__init__.py)
• Benchmark Data:
• Node: “Adaptec1 Benchmark” (Points to files in maskplace/adaptec1: adaptec1.aux, adaptec1.nets, adaptec1.nodes, adaptec1.pl, adaptec1.scl, adaptec1.wts)
• Node: “Ariane Benchmark” (Points to files in maskplace/ariane: graph.proto, laiyao.proto, laiyao_pb2.py, netlist.pb.txt, read_info.py)
• Data Handling and Processing:
• Node: “Placement Database Manager” (Points to maskplace/place_db.py and maskplace/place_db_proto.py)
• Node: “Computation / Evaluation” (Points to maskplace/comp_res.py)
• Node: “Placement Primitives” (Points to maskplace/prim.py)
• Configuration and Assets:
• Node: “Configuration” (Points to _config.yml)
• Node: “Visual Assets” (Points to imgs/ directory with its subfolders)
• Node: “Documentation” (Points to README.md)
b. Relationships and Interactions:
• The controller scripts (PPO2.py or DDPG.py) initialize the RL process, access the neural network module (nnet.py) and load model weights (pretrained_model.pkl).
• The RL agent interacts with the simulation environment (place_env/place_env.py) to perform actions and receive state information.
• Depending on the benchmark being used, the agent loads data from the benchmark directories (adaptec1 or ariane). For instance, the “Ariane Benchmark” node may feed data into the environment.
• Placement data and results are passed to the database manager (place_db.py and place_db_proto.py) and evaluated via comp_res.py.
• Configuration parameters from _config.yml govern various aspects of the training and simulation.
c. Important Architectural Patterns:
• The design follows a modular pattern where the RL algorithm, environment, benchmark data, and helper modules are maintained in separate components.
• It leverages a separation of concerns: controllers handle the execution flow, the environment encapsulates simulation details, benchmark directories provide data, and additional modules handle evaluation and database operations.
• Use of protobuf files in the ariane module indicates a well-defined data interchange structure for benchmark definition.
d. Relevant Technologies:
• Python (entry-level code in PPO2.py, DDPG.py, etc.)
• PyTorch (for the deep learning components found in nnet.py)
• OpenAI Gym (for the custom environment in place_env)
• Protocol Buffers (in ariane directory: graph.proto, laiyao.proto, etc.)
• Supporting libraries: matplotlib, tqdm