Algorithmadvanced
Annealing-based analog sizing
Also called ASTRX/OBLX, simulation-based analog synthesis.
Ochotta, Rutenbar and Carley's sizing that evaluates candidate circuits by fast AWE-based analysis and searches device sizes by simulated annealing.
- Solves
- Analog circuit sizing
- Time
- O(K m (E + d)) worst
- Space
- O(d) extra
- Where
- E = the time of one performance evaluation; K = the number of temperatures; d = the number of variables; m = the number of moves per temperature
- Model
- Real RAM
- Properties
- anytimerandomizednot exactiterativerandomized
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Emil S. Ochotta, Rob A. Rutenbar, L. Richard Carley, 1996
Annealing-based analog sizing chooses the device sizes and biases of a fixed analog circuit by simulated annealing: it scores each candidate by a cost that adds the objective and weighted penalties for the missed specifications, and it evaluates each candidate by a fast analysis instead of by hand-written design equations. Its topic is analog sizing and layout, one of the five topics of this sub-area. Ochotta, Rutenbar and Carley built it as ASTRX/OBLX in 1994 to 1996: ASTRX compiles the circuit and its specifications into a cost function, and OBLX anneals it, with asymptotic waveform evaluation (AWE) for the linear behavior of each candidate. It is a heuristic: no bound on how far its result is from the best design is known.
In plain words
To size a circuit by search, you need two things: a way to score a design, and a way to choose which design to try next.
The score adds up how much power or area the design uses and how badly it misses each target, with a large weight on the misses. A design that meets every target pays only for its power and area.
The search starts from a random design and keeps changing one size at a time. A change that lowers the score is kept. A change that raises it is sometimes kept too, more often early on and less often later, so that the search can climb out of a poor valley before it settles. The best design seen is the answer.
Each score needs an analysis of the circuit. ASTRX/OBLX made that analysis fast enough to run tens of thousands of times.
The problem
The input is a circuit of fixed topology with unknowns (widths, lengths, bias currents, capacitor values), each on a grid of allowed values, an evaluator that gives the performance vector , the specifications (an upper bound is written the same way with ), and an objective such as power or area. The output is a point that meets the specifications with a small . This is the analog circuit sizing problem with a penalty in place of the hard constraints:
The algorithm
ASTRX reads the circuit, the device models and the specifications, and writes the cost function. OBLX runs the annealing over it.
ANNEAL-SIZE(grids, C, T0, α, m, T_min, rng)- 1
x ← a random point of the grids; c ← C(x); best ← x - 2
T ← T0 - 3
while T > T_min - 4
repeat m times - 5
y ← x with one variable moved by a random number of grid steps, at most r(T) - 6
δ ← C(y) − c ▷ evaluates p(y): AWE in OBLX, a closed form here - 7
if δ ≤ 0 or rng() < exp(−δ / T) then x ← y; c ← c + δ - 8
if c < C(best) then best ← x - 9
T ← α T - 10
return best and C(best)
Line L7 is the Metropolis rule. Line L5 shrinks the reach as the temperature falls, so the search takes long jumps early and small steps late. This rule is a simple choice of this page; OBLX has its own move set and schedule. Line L8 keeps the best point seen, which can differ from the point where the run ends.
What ASTRX/OBLX adds to this loop. Three ideas made the loop practical for real circuits.
- AWE for the small-signal behavior. A candidate's gain, bandwidth and phase margin come from its linearized circuit. AWE gives a low-order Padé model of a transfer function from a few moments of the circuit, much faster than a full AC sweep with a simulator.
- The relaxed-dc formulation. Solving the nonlinear DC operating point for every candidate is slow. ASTRX/OBLX makes the node voltages extra variables of the search, and adds the violation of Kirchhoff's current law at each node to the cost. At the end of a good run these terms are near zero, so the circuit is biased where the search left it, without a Newton solve in the loop.
- Real device models. The transistors are evaluated with full device models, not with hand-derived equations, so a new circuit needs no new design equations. The models still have fitted parameters, and the result is checked by simulation.
Example
The code of this page sizes a common-source stage with a current-source load and a 1 pF load capacitor. The unknowns are (41 values from 0.5 to 50 µm), (41 values from 0.5 to 2.5 µm) and the bias current (201 values from 1 to 100 µA). The evaluator is the square-law model, not AWE, with , , gain with , and bandwidth . Two constants are fitted to a process, µA/V² and µm/V; the gate capacitance fF/µm² is a process value. The specifications are a gain-bandwidth of at least 10 MHz, a gain of at least 100 and an overdrive of at least 0.15 V, each with weight 10. The objective is .
A run with random.Random(0), , and :
| step | (µm) | (µm) | (µA) | cost | best so far | |
|---|---|---|---|---|---|---|
| start | 1 | 7.924 | 1.80 | 1.259 | 9.709 | 9.709 |
| after temperature 1 | 1 | 5.000 | 1.40 | 8.128 | 0.883 | 0.677 |
| after temperature 11 | 0.599 | 6.295 | 2.50 | 4.898 | 1.349 | 0.588 |
| after temperature 61 | 0.046 | 1.991 | 1.05 | 5.370 | 0.558 | 0.509 |
| end (180 temperatures) | 0.0001 | 1.991 | 0.95 | 4.898 | 0.509 | 0.502 |
The start misses two specifications: its overdrive is 0.053 V and its bandwidth 6.99 MHz, which cost , plus 0.269 for current and area. At high temperature the run accepts about half of its moves, including some that raise the cost: after temperature 11 it sits at 1.349, with the best at 0.588. It ends in a local minimum of cost 0.509, but line L8 kept a better point it passed, µm, µm, µA, of cost 0.502. An exhaustive search of all grid points confirms that this is the least cost on the grid. It meets every specification, with a gain of 140, a bandwidth of 10.04 MHz and an overdrive of 0.150 V.
The geometric program with the same model and continuous sizes needs 4.74 µA. The grid needs 4.79 µA, because and can take only grid values.
Correctness
The proofs are in the proof file. What is proved:
- The run returns a grid point and its cost, and that cost is at most the cost of every point it visited. So it never beats an exhaustive search of the grid.
- On a finite grid, the penalty is exact when the weights are large enough: if each exceeds the least feasible objective divided by the least positive violation on the grid, then every point of least cost is feasible and has the least objective among the feasible points. With continuous sizes this fails, and a point of least cost can miss a specification by a little.
What is not proved: that the run finds the least cost. The convergence theorem of annealing needs a logarithmic schedule and an unbounded run; ASTRX/OBLX and the code use a fixed number of geometric steps. And the least cost is a property of the evaluator: the result is the best design for the model of the circuit, and it is checked by a full simulation.
What is measured, on the toy of the example (not a benchmark): the grid has 31 local minima under moves of one step in one variable. With the schedule above, 38 of the 40 runs with seeds 0 to 39 reached the grid optimum, and the other two ended within 0.018 in cost. With and 10 moves per temperature, none of the 40 did. Ochotta, Rutenbar and Carley report circuits sized by ASTRX/OBLX and checked by simulation; those are their measurements, on their circuits, and this page does not repeat their numbers.
Proof: What annealing-based sizing returns, when its penalty is exact, and what is not provedpartial
Notation. The variables take values on a finite grid , with the allowed values of variable (a width, a length, a current). The performance of a point is a vector , computed by an evaluator: AWE and device models in ASTRX/OBLX, a closed-form square-law model in the code of this page. A specification is a bound with . Its relative violation is . The point is feasible if every . The objective is , and the cost is
ANNEAL-SIZE is the pseudocode of the page, lines L1 to L10.
Lemma 1 (the returned value). ANNEAL-SIZE returns a point and the number , and for every point that the run visited.
Proof. Invariant: after line L1 and after each pass of lines L5 to L8, , , and is a visited point of least cost so far, with . It holds after L1. Line L5 builds from by changing one index and clamping it to the range, so . Line L6 sets . If line L7 accepts, the new is , and . Otherwise nothing changes. Line L8 updates whenever the current point is cheaper. The loop ends because is multiplied by in line L9 and stops below .
In floating point, may differ from by rounding. The code returns the cost it carried, and the tests recompute and compare.
Corollary 2 (it never beats exhaustive search). . The test compares the run with this minimum, found by evaluating at every point of the grid.
Lemma 3 (an exact penalty on a finite grid). Let the feasible set be nonempty, let , and let
be the least positive violation on the grid. If for every , then every minimum of over is feasible, and it minimizes over .
Proof. is finite, so is a minimum of finitely many positive numbers and . Let . Some , so , because . A feasible minimizer of has . So no infeasible point is a minimum of . On , .
The bound needs the grid. With continuous variables the violation can be as small as we like, and the minimum of can sit just outside , trading a small violation for a smaller . ASTRX/OBLX also changes the weights during the run; this page does not model that.
What is not proved. The run does not in general return .
- The Metropolis rule of line L7 makes the Boltzmann distribution stationary at a fixed when the proposal is symmetric. The proposal of line L5 is not symmetric at the edges of the grid, where a step is clamped, and its reach shrinks with . So the chain of the code is not shown to have as its stationary law.
- The convergence theorem of annealing needs a schedule like with at least the depth of the deepest trap, and an unbounded run. Line L9 cools geometrically and stops after a fixed number of steps, as ASTRX/OBLX and most practical annealers do, so the theorem does not apply.
- The cost is a property of the evaluator. A minimum of is a best design for the model of the circuit, not for the circuit.
What is measured. On the toy common-source stage of the code (a grid of points, with the constants and specifications of the code), the exhaustive search finds the grid optimum µm, µm, µA. The grid has 31 local minima under moves of one step in one variable. With , , 100 moves per temperature and , the runs with seeds 0 to 39 of random.Random reached the grid optimum in 38 of 40 runs, and the other two were within 0.018 in cost. With and 10 moves per temperature, none of the 40 runs did. These are runs of the code of this page on a toy input; they are not benchmark results.
Complexity
With temperatures, moves per temperature, variables and an evaluation time , a run takes time and extra space beyond the evaluator. With falling from to by a factor , ; the example has and , so 18,000 evaluations, against 337,881 for the exhaustive search of its grid. The cost is all in . For a closed-form model, is constant. For AWE, is one sparse factorization of the linearized circuit plus a few solves for the moments. A full simulation of each candidate would make much larger, which is why ASTRX/OBLX used AWE.
Properties
- Randomized. The result depends on the seed. Several runs with different seeds give a spread of results; the best of them is kept.
- Anytime. The best point so far is always available.
- No design equations. A new topology needs a netlist and specifications, not a new set of equations. This is the main difference from geometric programming sizing, which needs every specification in posynomial form, but which proves that its optimum is global for its model.
- Any specification. The cost does not need to be convex or smooth, so phase margin, slew rate and noise enter as they are.
Variants and improvements
- Other evaluators. Later simulation-based sizers call a full circuit simulator for each candidate, which removes the AWE approximation but costs more per evaluation.
- Other searches. The same cost has been searched with a genetic algorithm, with local search from many starts, and with models fitted to simulation data, as in the response surface method.
- Yield. Draw the device parameters from a mismatch model such as the Pelgrom model, and score a candidate by the fraction of samples that meet the specifications.
- Hybrid with geometric programming. Use a geometric program on fitted posynomials to find a starting point, and anneal from there against the full evaluator.
When to use it
Use it when the specifications do not fit a convex form, or when the device models are too detailed for hand equations, and when each evaluation is cheap enough to run many thousands of times. When the specifications can be written as posynomials of the sizes, a geometric program is faster and gives the global optimum of its model, so it is the better first choice.
Pitfalls
- Cooling too fast. With a fast schedule the run stops in a local minimum. On the toy of the example, with 10 moves per temperature never reached the optimum in 40 runs.
- Weights too small. With small penalty weights the least cost can be a design that misses a specification by a little, and the run reports it as the answer. Check the feasibility of the result, not only its cost.
- Trusting the evaluator. AWE and the device models are approximations, and the device models have fitted constants. Simulate the result with the full models, and at the process corners.
- Leaving the region of the model. A search over sizes can move a transistor out of saturation, where a small-signal model of the gain is wrong. Add specifications that keep each device in its region, as the overdrive bound of the example does.
- Relaxed-dc residue. With node voltages as variables, a run that stops early leaves a design whose Kirchhoff's current law residue is not zero. Solve the DC operating point of the final design and check that it is the one the search assumed.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/annealing-analog-sizing/. The authors are listed in prov/A4H89F.jsonl.
"""Annealing-based analog sizing in the style of ASTRX/OBLX, on a toy circuit.
The search is the one of the page: a cost that adds the objective and
weighted penalties for the violated specifications, moves that change one
size by a few grid steps, the Metropolis rule, and geometric cooling.
The circuit is a common-source stage with an ideal current-source load and
a load capacitor. ASTRX/OBLX evaluates a circuit with AWE and real device
models; here the evaluation is the closed-form square-law (Level 1) model.
Its constants are fitted to a process, not derived:
KP = 200 the transconductance factor k' = mu C_ox, in uA/V^2
LAM0 = 0.1 lambda = LAM0 / L, in um/V
The others are a process value and the specifications:
CGA = 0.005 the gate capacitance per area, in pF/um^2
C0 = 1.0 the load capacitance, in pF
Units: W and L in um, I in uA, g_m in uS, C in pF, so g_m / (2 pi C) is in MHz.
"""
import math
KP = 200.0
LAM0 = 0.1
CGA = 0.005
C0 = 1.0
# The specifications: (name, target, weight); each one is "performance >= target".
SPECS = (("gbw_mhz", 10.0, 10.0), ("gain", 100.0, 10.0), ("vov", 0.15, 10.0))
I_REF = 10.0 # the objective is I / I_REF + W L / A_REF: the current, then the area
A_REF = 100.0
def grids():
"""The sizes that the search may use: W, L and I on fixed grids."""
ws = [0.5 * 10 ** (k / 20) for k in range(41)] # 0.5 to 50 um
ls = [0.5 + 0.05 * k for k in range(41)] # 0.5 to 2.5 um
cur = [10 ** (k / 100) for k in range(201)] # 1 to 100 uA
return [ws, ls, cur]
def performance(w, l, i):
"""The square-law small-signal model of the stage (the stand-in for AWE)."""
gm = math.sqrt(2 * KP * (w / l) * i)
vov = math.sqrt(2 * i * l / (KP * w))
gds = LAM0 / l * i
cl = C0 + CGA * w * l
return {"gm": gm, "vov": vov, "gain": gm / gds, "gbw_mhz": gm / (2 * math.pi * cl), "cl": cl}
def cost(point, specs=SPECS):
"""The objective plus the weighted relative violation of each specification."""
w, l, i = point
perf = performance(w, l, i)
c = i / I_REF + w * l / A_REF
for name, target, weight in specs:
c += weight * max(0.0, (target - perf[name]) / target)
return c
def feasible(point, specs=SPECS):
perf = performance(*point)
return all(perf[name] >= target for name, target, _ in specs)
def anneal(rng, grid=None, t0=1.0, alpha=0.95, moves=100, t_min=1e-4, specs=SPECS):
"""Simulated annealing over the grid indices. Returns (best point, best cost, indices).
rng is a random.Random; the run is a function of its seed.
"""
grid = grid or grids()
sizes = [len(g) for g in grid]
def at(idx):
return tuple(grid[d][idx[d]] for d in range(len(grid)))
x = [rng.randrange(s) for s in sizes] # @line L1
c = cost(at(x), specs)
best, best_c = list(x), c
t = t0 # @line L2
while t > t_min: # @line L3
reach = max(1, round(max(sizes) / 4 * t / t0))
for _ in range(moves): # @line L4
y = list(x) # @line L5: move one variable by a few grid steps
d = rng.randrange(len(sizes))
step = rng.randint(1, reach) * rng.choice((-1, 1))
y[d] = min(sizes[d] - 1, max(0, y[d] + step))
if y == x:
continue
delta = cost(at(y), specs) - c # @line L6
if delta <= 0 or rng.random() < math.exp(-delta / t): # @line L7
x, c = y, c + delta
if c < best_c: # @line L8
best, best_c = list(x), c
t *= alpha # @line L9
return at(best), best_c, best # @line L10
test_annealing_analog_sizing.py 80 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/annealing-analog-sizing/. The authors are listed in prov/A4H89F.jsonl.
import itertools
import math
import random
import unittest
import annealing_analog_sizing as a
def grid_optimum(specs=a.SPECS):
"""The brute force: the cost of every point of the grid."""
return min(itertools.product(*a.grids()), key=lambda p: a.cost(p, specs))
class TestModel(unittest.TestCase):
def test_hand_values(self):
# The point of the geometric programming example: W 1.58 um, L 0.75 um, I 4.74 uA.
p = a.performance(1.580, 0.75, 4.740)
self.assertAlmostEqual(p["vov"], 0.15, places=3)
self.assertAlmostEqual(p["gain"], 2 * 0.75 / (a.LAM0 * p["vov"]), places=9)
self.assertAlmostEqual(p["gain"], 100, delta=0.1)
self.assertAlmostEqual(p["gbw_mhz"], 10, delta=0.01)
self.assertAlmostEqual(p["gm"], 2 * 4.740 / p["vov"], places=9)
def test_penalty(self):
w, l, i = 1.0, 0.5, 2.0
perf = a.performance(w, l, i)
expect = i / a.I_REF + w * l / a.A_REF
for name, target, weight in a.SPECS:
expect += weight * max(0.0, (target - perf[name]) / target)
self.assertAlmostEqual(a.cost((w, l, i)), expect, places=12)
self.assertFalse(a.feasible((w, l, i)))
self.assertGreater(a.cost((w, l, i)), i / a.I_REF + w * l / a.A_REF)
class TestAnneal(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.opt = grid_optimum()
cls.opt_cost = a.cost(cls.opt)
def test_grid_optimum_is_feasible(self):
self.assertTrue(a.feasible(self.opt))
def test_reaches_grid_optimum(self):
# Measured on this toy: seeds 0 to 11 all reach the grid optimum.
for seed in range(12):
p, c, idx = a.anneal(random.Random(seed))
g = a.grids()
self.assertEqual(p, tuple(g[d][idx[d]] for d in range(3)))
self.assertAlmostEqual(c, a.cost(p), places=9)
self.assertAlmostEqual(c, self.opt_cost, places=12)
self.assertTrue(a.feasible(p))
def test_never_beats_brute_force(self):
for seed in range(20):
_, c, _ = a.anneal(random.Random(seed), alpha=0.5, moves=10)
self.assertGreaterEqual(c, self.opt_cost - 1e-12)
def test_deterministic(self):
r1 = a.anneal(random.Random(7), alpha=0.8, moves=20)
r2 = a.anneal(random.Random(7), alpha=0.8, moves=20)
self.assertEqual(r1, r2)
def test_other_specs(self):
specs = (("gbw_mhz", 5.0, 10.0), ("gain", 150.0, 10.0), ("vov", 0.2, 10.0))
opt = grid_optimum(specs)
self.assertTrue(a.feasible(opt, specs))
best = math.inf
for seed in range(3):
_, c, _ = a.anneal(random.Random(seed), specs=specs)
self.assertGreaterEqual(c, a.cost(opt, specs) - 1e-12)
best = min(best, c)
self.assertAlmostEqual(best, a.cost(opt, specs), places=12)
if __name__ == "__main__":
unittest.main()
History
Earlier sizing tools, the equation-based and knowledge-based tools surveyed by Gielen and Rutenbar, used design equations derived by hand for each topology. Ochotta, Rutenbar and Carley presented ASTRX/OBLX at DAC in 1994 and in IEEE Transactions on CAD in 1996. It replaced the hand equations by a compiled cost function, evaluated with AWE (Pillage and Rohrer 1990), the relaxed-dc formulation and full device models, and searched it with simulated annealing. Hershenson, Boyd and Lee took the opposite route in 2001, with hand equations in posynomial form and a convex solver.
References
- Emil S. Ochotta, Rob A. Rutenbar and L. Richard Carley, Synthesis of high-performance analog circuits in ASTRX/OBLX, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 15(3), 273 to 294, 1996, the compilation of a circuit and its specifications into a cost function (ASTRX), the evaluation of each candidate by AWE, the relaxed-dc formulation, and the annealing search (OBLX)
- E. S. Ochotta, R. A. Rutenbar and L. R. Carley, ASTRX/OBLX, tools for rapid synthesis of high-performance analog circuits, DAC 1994, 24 to 30, the conference version of the method
- Lawrence T. Pillage and Ronald A. Rohrer, Asymptotic waveform evaluation for timing analysis, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 9(4), 352 to 366, 1990, the moment matching by a Pade approximation that ASTRX/OBLX uses to evaluate the linear behavior of a candidate
- Georges G. E. Gielen and Rob A. Rutenbar, Computer-aided design of analog and mixed-signal integrated circuits, Proceedings of the IEEE 88(12), 1825 to 1854, 2000, the section on analog circuit sizing, with equation-based and simulation-based methods and the place of ASTRX/OBLX among them
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag A4H89F Edit this page History Report an error Markdown