SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Algorithm 1 Training in Hub-generation Phase.
Input: Number of iterations n_iters, minibatch size m, condition images c, real route images  $\mathbf{x}^{(rt)}$  generative model mode mode  $\in$  {GAN,VAE,DPM}, maximum time step  $T$  in DPM.   
for iter from 1 to n_iters do   
Sample minibatch of m condition images  $\{\mathbf{c}_1,\dots ,\mathbf{c}_m\}$  , real route images  $\{\mathbf{x}_1^{(rt)},\dots ,\mathbf{x}_m^{(rt)}\}$  .   
Compute  $\mathbf{x}_i^{(hub)}$  and  $\mathbf{x}_i^{(msk)}$  for each  $\mathbf{x}_i^{(rt)}$  , and compose  $\mathbf{x}_i = \{\mathbf{x}_i^{(hub)},\mathbf{x}_i^{(rt)},\mathbf{x}_i^{(msk)}\} (i =$ $1,\dots ,m)$  .   
if mode  $=$  GAN then Sample minibatch of m noise images  $\{\mathbf{z}_1,\dots ,\mathbf{z}_m\}$  , where  $\mathbf{z}_i\sim \mathcal{N}(\mathbf{0},\mathbf{I})$ $(i = 1,\dots ,m)$  Ascend the stochastic gradient of the discriminator in Eq. 4:  $\nabla_{\phi}\left[\frac{1}{m}\sum_{i = 1}^{m}\left[\log D_{\phi}(\mathbf{x}_{i}) + \log (1 - D_{\phi}(p_{\theta}(\mathbf{x}|\mathbf{c} = \mathbf{c}_{i},\mathbf{z} = \mathbf{z}_{i}))\right]\right]$  .   
Sample minibatch of m noise images  $\{\mathbf{z}_1,\dots ,\mathbf{z}_m\}$  .   
Descend the stochastic gradient of the generator in Eq. 4:  $\nabla_{\theta}\left[\frac{1}{m}\sum_{i = 1}^{m}\left[\log (1 - D_{\phi}(p_{\theta}(\mathbf{x}|\mathbf{c} = \mathbf{c}_{i},\mathbf{z} = \mathbf{z}_{i})))\right]\right]$  .   
else if mode  $=$  VAE then Sample minibatch of m noise images  $\{\epsilon_1,\dots ,\epsilon_m\}$  , where  $\epsilon_i\sim \mathcal{N}(\mathbf{0},\mathbf{I})$ $(i = 1,\dots ,m)$  Compute  $\{\mathbf{z}_1,\dots ,\mathbf{z}_m\}$  using the reparameterization trick [26];   
Descend the stochastic gradient of Eq. 6:  $\nabla_{\theta ,\phi}\left[\frac{1}{m}\sum_{i = 1}^{m}\left(-KL(q_{\phi}(\mathbf{z}|\mathbf{x} = \mathbf{x}_i,\mathbf{c} = \mathbf{c}_i)\| p_{\theta}(\mathbf{z}|\mathbf{c} = \mathbf{c}_i)\right) + \log p_{\theta}\left(\mathbf{x}|\mathbf{c} = \mathbf{c}_i,\mathbf{z} = \mathbf{z}_i)\right)\right]$  // Let  $L = 1$    
else if mode  $=$  DPM then Sample minibatch of m noise images  $\{\epsilon_1,\dots ,\epsilon_m\}$  , where  $\epsilon_i\sim \mathcal{N}(\mathbf{0},\mathbf{I})$ $(i = 1,\dots ,m)$  Sample minibatch of m time steps  $\{t_1,\dots ,t_m\}$  , where  $t_i\sim \mathcal{U}(\{1,\dots ,T\})$ $(i = 1,\dots ,m)$  Descend the stochastic gradient of Eq. 8:  $\nabla_{\theta}\left[\mathbb{E}_{\mathbf{x},\mathbf{c},\epsilon \sim \mathcal{N}(\mathbf{0},\mathbf{I}),t\sim \mathcal{U}\{\{t\}_{t = 1}^T\}}\left[||\epsilon -\epsilon_{\theta}(\mathbf{z}_t,\mathbf{c},t)||^2\right]\right]$  Output: Trained models with parameters  $\theta$  and  $\phi$
Algorithm 2 Training in Pin-hub-connection Phase.
Input: Number of iterations  $n_{-}$  iters, minibatch size  $B$    
for iter from 1 to n_iter do Sample  $B$  random point sets  $\bar{V} = \{V_1,\dots ,V_B\}$  Construct valid RES sets  $R^{(V_i)}$  for each point set  $V_{i}$  . Sample a single RES  $r_i\sim R^{(V_i)}$  for each point set  $V_{i}$  Linearly evaluate the actual length  $b(V_{i},r_{i})$  . Descend the gradient in the actor network according to Eq. 2 using reinforcement algorithm [52]:  $\frac{1}{B}\sum_{i = 1}^{B}[b_{\zeta}(V_i) - b(V_i,r_i)]\nabla_{\xi}[p_{\xi}(r_i)];$  Descend the gradient in the critic network according to Eq. 3:  $\nabla_{\zeta}\left[\frac{1}{B}\sum_{i = 1}^{B}\| b_{\zeta}(V_i) - b(V_i,r_i)\| ^2\right].$  Output: The trained model with parameters  $\xi$  and  $\zeta$
C Definition and Theorem
C.1 2-pin Problem
Fig. 8 gives an example of the '2-pin' problem, which is the simplest version of global routing, but it turns out to be an NP-Complete problem [27, 31].
C.2 Bonus of RSMT Reconstruction
Lemma 1. Rectilinear Steiner points are hubs.
Algorithm 3 Sampling Routes.
Input: Condition image  $\mathbf{c}_0$ , generative model mode mode  $\in \{GAN, VAE, DPM\}$ , trained generative models and the RSMT connection model, DDIM [45] timesteps  $\{\hat{t}_1, \dots, \hat{t}_d\}$ , guide weight  $w$  in DPM.  
// Hub-generation Phase.  
if mode = GAN then  
Sample a noise sample  $\mathbf{z}_0 \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$ ;  
Generate  $\mathbf{x}_0 = p_\theta(\mathbf{x}|\mathbf{c} = \mathbf{c}_0, \mathbf{z} = \mathbf{z}_0)$ ;  
else if mode = VAE then  
Sample a noise sample  $\mathbf{z}_0 \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$ ;  
Generate  $\mathbf{x}_0 = p_\theta(\mathbf{x}|\mathbf{c} = \mathbf{c}_0, \mathbf{z} = \mathbf{z}_0)$ ;  
else if mode = DPM then  
Sample a noise sample  $\mathbf{x}_{\hat{t}_d} = \epsilon_{\hat{t}_d} \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$ ;  
for  $\hat{t}_j$  from  $\hat{t}_d$  to  $\hat{t}_1$  do  
    Compute previous  $\alpha_{\hat{t}_{j-1}}$  and current  $\alpha_{\hat{t}_j}$ ;  
Predict the noise:  $\hat{\epsilon}_{\hat{t}_j} = (1 + w) \cdot \epsilon_\theta(\mathbf{x}_{\hat{t}_j}, \mathbf{c}_{\hat{t}_j}, \hat{t}_j) - w \cdot \epsilon_\theta(\mathbf{x}_{\hat{t}_j}, \hat{t}_j)$ ;  
Predict  $\mathbf{x}_0$ :  $p_{\mathbf{x}_0} \gets (\mathbf{z}_{\hat{t}_d} - \sqrt{1 - \alpha_{\hat{t}_j}} \hat{\epsilon}_{\hat{t}_j}) / \sqrt{\alpha_{\hat{t}_j}}$ ;  
Compute variance:  $\sigma_{\hat{t}_j}(\eta) = \eta \sqrt{(1 - \alpha_{\hat{t}_{j-1}}) / (1 - \alpha_{\hat{t}_j})(1 - \alpha_{\hat{t}_j} / \alpha_{\hat{t}_{j-1}})}$ ;  
// We directly set  $\eta = 0$  here.  
Compute the direction pointing to  $\mathbf{x}_{\hat{t}_j}$ :  $d_{\mathbf{x}_{\hat{t}_j}} = \sqrt{1 - \alpha_{\hat{t}_{j-1}} - \sigma_{\hat{t}_j}^2} \cdot \hat{\epsilon}_{\hat{t}_j}$ ;  
Compute  $\mathbf{x}_{\hat{t}_{j-1}}$ :  $\mathbf{x}_{\hat{t}_{j-1}} = \sqrt{\alpha_{\hat{t}_{j-1}}} \cdot p_{\mathbf{x}_0} + d_{\mathbf{x}_{\hat{t}_j}} + \sigma_{\hat{t}_j}(\eta) \cdot \epsilon_{\hat{t}_j}$ , where  $\epsilon_{\hat{t}_j} \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$ .  
Finally, we have  $\mathbf{x}_0$ ;  
// Denote  $\mathbf{x} = \mathbf{x}_0$ , and  $\mathbf{x}_{ij}$  as its element in  $i$ -th row and  $j$ -th column.  
Compute the binarized strip mask  $\tilde{\mathbf{x}}^{(msk)}$  according to Eq. 1, where each  $\tilde{\mathbf{x}}^{(msk)}$  is computed as:  
\[
\tilde{\mathbf{x}}^{(msk)}_ij = \mathbb{I}\left[\max\left(\frac{1}{m}\sum_{i=1}^{m}\mathbf{x}_{ij}^{(msk)}, \frac{1}{n}\sum_{j=1}^{n}\mathbf{x}_{ij}^{(msk)}\right) > \frac{1}{2}\right];  
// Note that  $\mathbf{x} = \{\mathbf{x}^{(hub)}, \mathbf{x}^{(rt)}, \mathbf{x}^{(msk)}\}$ .  
Compute the masked hubs:  $\hat{\mathbf{x}}^{(hub)} = \mathbf{x}_{ij}^{(hub)} \times \tilde{\mathbf{x}}^{(msk)}$ ;  
Obtain the union of hubs and pins  $V$ ;  
// Pin-hub-connection Phase.  
Obtain the RES  $r$  according to the maximum  $p_\xi(r_i)$ , where  $r_i \sim R(V)$ ;  
Compare 8 transformations introduced in Sec. 3.2 and pick the optimal route with the shortest length. Output: The generated route and its length.
Proof According to Hanan theory [13], the rectilinear Steiner points can be restricted to the Hanan grid. The definition of hubs in this paper implies that all the routed points on the intersection of Hanan grid are hubs, so rectilinear Steiner points must be hubs.  $\square$
Proof According to Lemma 1, since all the rectilinear Steiner points are hubs, there is no need to introduce extra rectilinear Steiner points when generating an R-MST towards all the hubs. So, the RSMT problem is degraded to an R-MST problem, which has been proved to be addressed in  $O(n \log n)$  time complexity [21].
D Experimental Protocols
D.1 Dataset.
Real-world Datasets ISPD-07 [38] and ISPD-98 [1], and the simulated dataset constructed by [31] (we call 'DRL') are employed in this work.
Table 6: Summary of the test dataset. We respectively show the scale size, vertical/horizontal capacity, number of nets, and average/maximum number of pins for each net.
CASE	IBM01	IBM02	IBM03	IBM04	IBM05	IBM06	DRL-8	DRL-16
SIZE	64×64	80×64	80×64	96×64	128×64	128×64	8×8	16×16
CAP. (V / H)	24 / 28	44 / 68	40 / 60	40 / 46	84 / 126	40 / 66	4 / 4	6 / 6
#NETS	11507	18429	21621	26163	27777	33354	20	30
AVG. #PINS	4.31	4.88	4.10	3.86	5.25	4.21	5.25	6.12
MAX #PINS	42	134	55	46	17	35	8	10
In line with [6], we construct training datasets by adopting [34] to route on ISPD-07 benchmarks and we declare the details unstated in [6]. We initialize the capacity given by the benchmarks and sequentially route the nets using the results of [34]. Each time the capacity is updated, a condition image, consisting of the current capacity and the positions of pins to be routed in the next net, is generated. Meanwhile, a ground-truth route image is generated and saved correspondingly. By clipping them to the same scale  $64 \times 64$  (if possible) randomly, the image will be saved to different directories, i.e., Route-small-4, Route-small, Route-large-4, and Route-large, according to the number of pins  $n_p$  and their HPWL. Specifically,
1) Route-small-4:  $n_p \leq 4$  and  $HPWL \leq 16$ ;
2) Route-small:  $n_p > 4$  and  $HPWL \leq 16$ ;
3) Route-large-4:  $n_p \leq 4$  and  $HPWL > 16$ ;
4) Route-large:  $n_p > 4$  and  $HPWL > 16$ .
Examples are partly shown in Fig. 10. This division on the one hand originates according to the observation from [6] that the average pin number is about 4 in most chip cases, as shown in Table 6, and on the other hand, we would like to show the non-connectivity of previous generative global routing approaches under different situations. We choose bigblue4, newblue3, newblue4, and newblue7 (name of the cases in ISPD-07) as the training cases and generate 15K training samples for each case's each category. Thus, we have a total of nearly 240K (some categories cannot generate a maximum of 15K samples). In Table 2, we test the cases of adaptec1, adaptec2, newblue1, newblue2, bigblue1, and bigblue2 in ISPD-07 with a total 10K samples for each category.
Cases in ISPD-98 and DRL are used as test data in Table 3 and Fig. 5; however, their scales are not the same as the input data. So, we clip the ISPD-98 and pad the DRL to ensure scale consistence. Very few  $(<0.1\%)$  nets in ISPD-98 cannot satisfy the input scale due to their exceeded pin positions. For these special samples, we divide them into multiple samples and then feed them to the model. Note that there might be better solutions to deal with the scale problem, e.g., the input-size-adapting module in [6], but it is not the main focus of this work. Moreover, two simulated dataset DRL-8 and DRL-16, whose scales are respectively  $8\times 8$  and  $16\times 16$ , are generated using the tool introduced by [31]. We randomly generate 10 cases for DRL-8 and DRL-16, respectively. More information about the test dataset is detailed in Table 6.
D.2 Baselines.
The baselines referred in Table 3 are introduced as follows:
1) Labyrinth [24], a classical routing algorithm that discusses how the concept of pattern routing can be used to guide the router to a solution that minimizes interconnect delay without damaging the routability of the circuit;
2) BoxRouter [8], a classical global router that first employs a pre-routing strategy to identify the most congest area and then performs box expansion and progressive integer linear programming(ILP);
3)  $DQN$  [31], a reinforcement learning global routing algorithm with  $\mathrm{A}^*$  router burn-in memory and conjoint optimization;
<https://github.com/haiguanl/DQNGLOBALRouting
4) PRNet [6], a joint learning framework that together addresses the placement and routing problems, where the routing is based on generative approaches.
In the RSMT construction experiment in Sec. 4.4, the referred baselines are:
1) GeoSteiner [51], the optimal RSMT construction solver;
2)  $R$ -MST, an efficient implementation of R-MST construction with time complexity of  $O(n \log n)$ ;
3) BGA [23], a practical  $O(n \log^2 n)$  sub-optimal solution of RSMT construction with heuristics.
4) FLUTE [53], a fast and accurate RSMT construction approach by using a look-up table. Note that it can reach the optimal solution for nets up to 9 degrees.
5)  $REST$  [33], a state-of-the-art RL-based approach that uses an actor-critic network to predict the Rectilinear edge sequence (RES) for RSMT construction.
D.3 Model Setting.
In the hub-generation phase, VAE employs a CNN [48] structure while GAN uses a ResNet [14, 22] structure, which is in line with [6], but we make some revisions. For instance, [6] utilizes a bi-discriminator [54] to inject the correctness constraint to the objectives, but our proposed HubRouter no longer requires it within the two-phase learning scheme. In addition, the model structure of DPM follows [17] due to the condition guidance and uses a U-Net [41] structure, but we make it lightweight to achieve more rapid sampling time. Fig. 9 details the components of the generative models in this work. In the pin-hub-connection phase, we follow REST [33] to use a multi-head attention encoder [49] in its auto-encoder framework.
E Experimental Analysis
E.1 Hyperparameters
We search hyperparameters on the validation dataset with the learning rate in [0.001, 0.0001] and reduce the learning rates by 0.96 after every 10 epochs until the validation loss no longer decreases for over 20 epochs or the number of epochs reaches a maximum of 200. In the hub-generation phase, we optionally choose three generative models, including GAN, VAE, and DPM. For GAN and VAE, we use similar structures and search the number of ResNet blocks in [3, 6, 9] and the number of downsampling/upsampling layers in [2, 3, 4]. For DPM, we search the number of DDIM steps in [25, 50, 75], the guide weight  $w$  in [0.0, 1.5, 2.0], and the maximum timestep in [500, 1000]. The best models are chosen by the optimal wirelength rate while keeping the generation time tolerable. Each experiment is trained with a batch size of 64 and the optimizer Adam [25] with the decay rate of first(second)-order moment estimation 0.5(0.999) and the L2 penalty coefficient 0.01. In the experiments in Sec. 4, the number of ResNet blocks and the number of downsampling/upsampling layers for GAN and VAE are respectively set as 9 and 2. For DPM, we set the number of DDIM steps as 50, the guide weight  $w$  as 1.5, and the maximum timestep as 500. In the pin-hub-connection, we follow REST [33] and employ the model with adjusted parameters.
E.2 Correspondence between Hub and Route
The main idea of the two-phase learning scheme originates from our observation and curiosity - whether the hub and the route have high correspondence. If so, we could conclude that the optimal final routes would approximately be the same for generating hubs or generating routes directly. According to the definition in Def. 1, it is apparent that each route can uniquely determine its hubs, but regretfully the opposite is not true. That is to say, when given a group of hubs, we cannot decide uniquely what their original route is; however, we empirically find the correspondence between hubs and routes is high. To show this, we generate the hubs according to the definition for each net in ISPD-07 and then use these generated hubs and pins to construct RSMT. As shown in Table 7, the correspondence rates are respectively  $99.7\%$  and  $98.18\%$  for Route-small-4 and Route-large-4 and importantly these two categories occupy large proportions (totally over  $80\%$ ) in ISPD-98 and ISPD-07 cases. Though the correspondence rate in Route-large is not high, the mean square error
<https://github.com/cuhk-eda/REST
(a) Model Structure of GAN.
(b) Model Structure of VAE.
Transformer Encoder
DPM
(c) Model Structure of DPM.
Figure 9: Model Components of a) GAN; b) VAE; c) DPM.
Table 7: Correspondence between hubs and routes. The correspondence rate and mean square error (MSE) are computed on ISPD-07 cases.
Category	Route-small-4	Route-small	Route-large-4	Route-large
Correspondence Rate (%)	99.7	80.31	98.18	48.75
MSE	< 10-5	0.0004	0.0002	0.003
Proportion in ISPD-98 (%)	65.38	4.69	15.94	13.99
Proportion in ISPD-07 (%)	66.25	9.67	14.89	9.19
Table 8: Relative error on ISPD-98 cases. The first line introduces the theoretical lower bound introduced in [7]. Optimal results are in bold.
Model	IBM01	IBM02	IBM03	IBM04	IBM05	IBM06
Lower Bound [7]	60142	165863	145678	162734	409709	275868
Labyrinth [22]	0.262	0.589	0.693	0.551	0.181	1.093
BoxRouter [7]	0.059	0.107	0.03	0.105	0.015	0.077
PRNet [6]	0.03	0.115	0.106	0.129	0.176	0.198
HR-GAN	0.015	0.028	0.023	0.026	0.036	0.039
(MSE) between the generated route and the real one is still extremely low. These observations ensure that the hub generation can be effective for global routing.
E.3 Relative Error on ISPD-98 cases
To judge the improvement of gaining on the optimal wirelength rather than the absolute value, we further compare the relative error in Table 8, where the relative error is computed as  $(WL - b) / b$ . Here,  $b$  denotes the theoretical lower bound [8]. As shown in this table, the WL promotion of HubRouter is notable compared with the SOTA generative global routing method (PRNet).
E.4 Generation Time and Connection Time
We present the breakdown of the inference time for each phase on ISPD-98 (IBM01-06) and GRL cases in Table 9. From an overall perspective, the connection phase has comparable time costs for the three generative models. The generation phase, however, dominates the overall time consumption. This indicates that HubRouter achieves faster performance than other generative models by reducing the time spent in the connection phase.
Table 9: Generation and connection time in the experiments on ISPD-98 (IBM01-06) and GRL cases.
Metric	Model	IBM01	IBM02	IBM03	IBM04	IBM05	IBM06	GRL-8	GRL-16
Generation Time (Sec.)	HR-VAE	8.13	6.68	7.47	8.01	9.90	12.18	5.78	5.77
HR-DPM	1802	2841	3014	3839	4329	5110	36.76	49.55
HR-GAN	40.12	45.36	49.02	61.33	68.47	91.50	6.04	6.26
Connection Time (Sec.)	HR-VAE	1.67	3.23	2.87	5.09	5.08	5.04	0.04	0.11
HR-DPM	1.80	3.51	2.88	4.99	5.04	4.98	0.04	0.11
HR-GAN	1.72	3.30	2.84	5.00	5.04	5.11	0.04	0.11
E.5 Route Generation Results
Examples of the condition and real route images, as well as the route generation results of Route-small-4, Route-small, Route-large-4, Route-large introduced in Appendix D.1 are depicted in Fig. 10.
(a) Route-small-4.
(b) Route-small.
(c) Route-large-4.
(d) Route-large.
Figure 10: Condition images (first line), Real route images (second line), and the route images generated by our propose two-phase learning scheme (third line), randomly sampled in a) Route-small-4; b) Route-small; c) Route-large-4; d) Route-large.