SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2412.07167 · NeurIPS · 2024

Reinforcement Learning Policy as Macro Regulator Rather than Macro Placer

Xi Lin, Ke Xue, Chao Qian, Yunqi Shi, Ruo-Tong Chen, Shixiong Kai, Siyuan Xu

arXiv · PDF · Open in the Atlas

Code that ran

3 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2412.07167.json · badge: /api/ran/2412.07167.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
lamda-bbo/macro-regulator canonical (classifier label)
classifier basis: classifier_2025
3 ran · 3 no recorded run
FunctionStatusWhere it lives
Critic Ran
ran on a synthesized input
lamda-bbo/macro-regulator/src/agent.py
code served (permissive licence) · get_code("0acb8db9ab90a6f8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F

class StateParsing:

    def __init__(self, args) -> None:
        self.args = args
        self.grid = args.grid

    def get_state(self, place_idx, old_canvas, new_canvas, regular_mask, position_mask, wire_mask, next_regular_mask, next_position_mask, next_wire_mask, size_x, size_y):
        return np.concatenate((np.array([place_idx]), old_canvas.flatten(), new_canvas.flatten(), regular_mask.flatten(), position_mask.flatten(), wire_mask.flatten(), next_regular_mask.flatten(), next_position_mask.flatten(), next_wire_mask.flatten(), np.array([size_x / self.grid, size_y / self.grid])), axis=0)

    def state2canvas(self, state, new=True):
        if len(state.shape) == 1:
            if new:
                return state[1 + self.grid * self.grid:1 + self.grid * self.grid * 2].reshape(self.grid, self.grid)
            else:
                return state[1:1 + self.grid * self.grid].reshape(self.grid, self.grid)
        elif len(state.shape) == 2:
            if new:
                return state[:, 1 + self.grid * self.grid:1 + self.grid * self.grid * 2].reshape(-1, self.grid, self.grid)
            else:
                return state[:, 1:1 + self.grid * self.grid].reshape(-1, self.grid, self.grid)
        else:
            raise NotImplementedError

    def state2regular_mask(self, state, next_next_macro=False):
        if len(state.shape) == 1:
            if next_next_macro:
                return state[1 + self.grid * self.grid * 5:1 + self.grid * self.grid * 6].reshape(self.grid, self.grid)
            else:
                return state[1 + self.grid * self.grid * 2:1 + self.grid * self.grid * 3].reshape(self.grid, self.grid)
        elif len(state.shape) == 2:
            if next_next_macro:
                return state[:, 1 + self.grid * self.grid * 5:1 + self.grid * self.grid * 6].reshape(-1, self.grid, self.grid)
            else:
                return state[:, 1 + self.grid * self.grid * 2:1 + self.grid * self.grid * 3].reshape(-1, self.grid, self.grid)
        else:
            raise NotImplementedError

    def state2position_mask(self, state, next_next_macro=False):
        if len(state.shape) == 1:
            if next_next_macro:
                return state[1 + self.grid * self.grid * 6:1 + self.grid * self.grid * 7].reshape(self.grid, self.grid)
            else:
                return state[1 + self.grid * self.grid * 3:1 + self.grid * self.grid * 4].reshape(self.grid, self.grid)
        elif len(state.shape) == 2:
            if next_next_macro:
                return state[:, 1 + self.grid * self.grid * 6:1 + self.grid * self.grid * 7].reshape(-1, self.grid, self.grid)
            else:
                return state[:, 1 + self.grid * self.grid * 3:1 + self.grid * self.grid * 4].reshape(-1, self.grid, self.grid)
        else:
            raise NotImplementedError

    def state2wire_mask(self, state, next_next_macro=False):
        if len(state.shape) == 1:
            if next_next_macro:
                return state[1 + self.grid * self.grid * 7:1 + self.grid * self.grid * 8].reshape(self.grid, self.grid)
            else:
                return state[1 + self.grid * self.grid * 4:1 + self.grid * self.grid * 5].reshape(self.grid, self.grid)
        elif len(state.shape) == 2:
            if next_next_macro:
                return state[:, 1 + self.grid * self.grid * 7:1 + self.grid * self.grid * 8].reshape(-1, self.grid, self.grid)
            else:
                return state[:, 1 + self.grid * self.grid * 4:1 + self.grid * self.grid * 5].reshape(-1, self.grid, self.grid)
        else:
            raise NotImplementedError

class Critic(nn.Module):

    def __init__(self, args, cnn_coarse):
        super(Critic, self).__init__()
        self.args = args
        self.fc1 = nn.Linear(64, 64)
        self.fc2 = nn.Linear(64, 64)
        self.state_value = nn.Linear(64, 1)
        self.pos_emb = nn.Embedding(1400, 64)
        self.net = nn.Sequential(nn.Linear(786, 512), nn.ReLU(), nn.Linear(512, 256), nn.ReLU(), nn.Linear(256, 64), nn.ReLU(), nn.Linear(64, 1))
        self.cnn_coarse = cnn_coarse
        self.state_parsing = StateParsing(args=args)

    def forward(self, x):
        x1 = F.relu(self.fc1(self.pos_emb(x[:, 0].long())))
        x2 = F.relu(self.fc2(x1))
        value = self.state_value(x2)
        return value

class Args:
    def __init__(self):
        self.grid = 8

INIT_ARGS = {
    'args': Args(),
    'cnn_coarse': nn.Identity()
}

ARGS = {
    'x': torch.randint(0, 1400, (2, 1))
}

if __name__ == '__main__':
    critic = Critic
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MyCNN Ran
ran on a synthesized input
lamda-bbo/macro-regulator/src/agent.py
code served (permissive licence) · get_code("abe476154e541e08")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

INIT_ARGS = {}

# MyCNN expects input of shape (batch, 6, height, width)
# The CNN processes 6 input channels -> 12 -> 12 -> 1 output channel
x = torch.randn(2, 6, 8, 8)

ARGS = {'x': x}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 4, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
StateParsing Ran
ran on a synthesized input
lamda-bbo/macro-regulator/src/agent.py
code served (permissive licence) · get_code("efadeb286d748395")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned ndarray, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a simple args object with grid attribute
class Args:
    def __init__(self):
        self.grid = 4

args = Args()

INIT_ARGS = {
    'args': args
}

# Create test data for get_state method
grid_size = args.grid
place_idx = 5
old_canvas = np.random.rand(grid_size, grid_size)
new_canvas = np.random.rand(grid_size, grid_size)
regular_mask = np.random.rand(grid_size, grid_size)
position_mask = np.random.rand(grid_size, grid_size)
wire_mask = np.random.rand(grid_size, grid_size)
next_regular_mask = np.random.rand(grid_size, grid_size)
next_position_mask = np.random.rand(grid_size, grid_size)
next_wire_mask = np.random.rand(grid_size, grid_size)
size_x = 10
size_y = 12

ARGS = {
    'place_idx': place_idx,
    'old_canvas': old_canvas,
    'new_canvas': new_canvas,
    'regular_mask': regular_mask,
    'position_mask': position_mask,
    'wire_mask': wire_mask,
    'next_regular_mask': next_regular_mask,
    'next_position_mask': next_position_mask,
    'next_wire_mask': next_wire_mask,
    'size_x': size_x,
    'size_y': size_y
}

METHOD = 'get_state'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Actor Not yet run
unverified (harvested, no recorded run)
lamda-bbo/macro-regulator/src/agent.py
code served (permissive licence) · get_code("f29f84d9f963b618")
How it ran

no invocation recorded.

MyCNNCoarse Not yet run
unverified (harvested, no recorded run)
lamda-bbo/macro-regulator/src/agent.py
code served (permissive licence) · get_code("a61761b2b57d4b53")
How it ran

no invocation recorded.

PPOAgent Not yet run
unverified (harvested, no recorded run)
lamda-bbo/macro-regulator/src/agent.py
code served (permissive licence) · get_code("50b02050ffbd0527")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In modern chip design, placement aims at placing millions of circuit modules, which is an essential step that significantly influences power, performance, and area (PPA) metrics. Recently, reinforcement learning (RL) has emerged as a promising technique for improving placement quality, especially macro placement. However, current RL-based placement methods suffer from long training times, low generalization ability, and inability to guarantee PPA results. A key issue lies in the problem formulation, i.e., using RL to place from scratch, which results in limits useful information and inaccurate rewards during the training process. In this work, we propose an approach that utilizes RL for the refinement stage, which allows the RL policy to learn how to adjust existing placement layouts, thereby receiving sufficient information for the policy to act and obtain relatively dense and precise rewards. Additionally, we introduce the concept of regularity during training, which is considered an important metric in the chip design industry but is often overlooked in current RL placement methods. We evaluate our approach on the ISPD 2005 and ICCAD 2015 benchmark, comparing the global half-perimeter wirelength and regularity of our proposed method against several competitive approaches. Besides, we test the PPA performance using commercial software, showing that RL as a regulator can achieve significant PPA improvements. Our RL regulator can fine-tune placements from any method and enhance their quality. Our work opens up new possibilities for the application of RL in placement, providing a more effective and efficient approach to optimizing chip design. Our code is available at https://github.com/lamda-bbo/macro-regulator.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2412.07167")
get_code_for_paper("2412.07167")
have("2412.07167")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2412.07167.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2412.07167.svg)](https://syntology.ai/paper/2412.07167)

Connect an agent — have() is free.