Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SCENARIO_LIMIT=""
EFFORT=""
SAMPLE_TIMEOUT=""
INCLUDE_ASSIGNABLE=false
DEFAULT_SOLVER_NAME="AutoroutingPipelineSolver"

default_concurrency() {
getconf _NPROCESSORS_ONLN 2>/dev/null || nproc 2>/dev/null || echo 4
Expand Down Expand Up @@ -51,6 +52,10 @@ Options:
--include-assignable Include assignable pipelines (excluded by default)
-h, --help Show this help

Defaults:
Running ./benchmark.sh with no parameters benchmarks only AutoroutingPipelineSolver.
Use "all" to benchmark every available solver.

Examples:
./benchmark.sh
./benchmark.sh AutoroutingPipelineSolver
Expand Down Expand Up @@ -126,6 +131,10 @@ done

CMD=(bun "scripts/benchmark/index.ts" "--concurrency" "$CONCURRENCY")

if [ -z "$SOLVER_NAME" ]; then
SOLVER_NAME="$DEFAULT_SOLVER_NAME"
fi

if [ -n "$SOLVER_NAME" ] && [ "$SOLVER_NAME" != "_" ] && [ "$SOLVER_NAME" != "all" ]; then
CMD+=("--solver" "$SOLVER_NAME")
fi
Expand Down
37 changes: 15 additions & 22 deletions lib/solvers/HyperHighDensitySolver/HyperSingleIntraNodeSolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { MultiHeadPolyLineIntraNodeSolver2 } from "../HighDensitySolver/MultiHea
import { MultiHeadPolyLineIntraNodeSolver3 } from "../HighDensitySolver/MultiHeadPolyLineIntraNodeSolver/MultiHeadPolyLineIntraNodeSolver3_ViaPossibilitiesSolverIntegration"
import {
HighDensitySolverA01,
HighDensitySolverA02 as HighDensityA02Solver,
HighDensitySolverA03 as HighDensityA03Solver,
} from "@tscircuit/high-density-a01"
import { FixedTopologyHighDensityIntraNodeSolver } from "../FixedTopologyHighDensityIntraNodeSolver"

Expand All @@ -26,7 +26,7 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
| SingleTransitionCrossingRouteSolver
| SingleTransitionIntraNodeSolver
| FixedTopologyHighDensityIntraNodeSolver
| HighDensityA02Solver
| HighDensityA03Solver
> {
override getSolverName(): string {
return "HyperSingleIntraNodeSolver"
Expand All @@ -48,7 +48,7 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
this.connMap = opts.connMap
this.constructorParams = opts
this.effort = opts.effort ?? 1
this.MAX_ITERATIONS = 10_000_000 * this.effort
this.MAX_ITERATIONS = 20_000_000 * this.effort
this.GREEDY_MULTIPLIER = 5
this.MIN_SUBSTEPS = 100
}
Expand All @@ -63,7 +63,7 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
["closedFormSingleTrace"],
// ["closedFormTwoTrace"],
["highDensityA01"],
["highDensityA02"],
["highDensityA03"],
["fixedTopologyHighDensityIntraNodeSolver"],
]
}
Expand Down Expand Up @@ -204,10 +204,10 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
],
},
{
name: "highDensityA02",
name: "highDensityA03",
possibleValues: [
{
HIGH_DENSITY_A02: true,
HIGH_DENSITY_A03: true,
},
],
},
Expand All @@ -217,7 +217,7 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
computeG(solver: IntraNodeRouteSolver) {
if (
(solver as any) instanceof HighDensitySolverA01 ||
(solver as any) instanceof HighDensityA02Solver
(solver as any) instanceof HighDensityA03Solver
) {
return (solver as any).iterations / 1_000_000
}
Expand Down Expand Up @@ -254,30 +254,23 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
solver.MAX_ITERATIONS = 10_000_000
return solver as any
}
if (hyperParameters.HIGH_DENSITY_A02) {
const solver = new HighDensityA02Solver({
if (hyperParameters.HIGH_DENSITY_A03) {
const solver = new HighDensityA03Solver({
nodeWithPortPoints: this.nodeWithPortPoints,
outerGridCellSize: 0.1,
outerGridCellThickness: 2,
innerGridCellSize: 0.4,
highResolutionCellSize: 0.1,
highResolutionCellThickness: 8,
lowResolutionCellSize: 0.4,
viaDiameter: this.constructorParams.viaDiameter ?? 0.3,
viaMinDistFromBorder: 0.15,
traceMargin: 0.15,
enableDeferredConflictRepair: true,
maxDeferredRepairPasses: 48,
edgePenaltyStrength: 0.2,
// This likely needs to be corrected to use the actual trace width-
// but using anything but 0.1 for traceThickness is causing issues
// needs more debugging- repro01 in the high-density-a01 repo
// has a good reproduction
traceThickness: 0.1, // this.constructorParams.traceWidth ?? 0.15,
hyperParameters: {
greedyMultiplier: 1.2,
shuffleSeed: hyperParameters.SHUFFLE_SEED ?? 0,
ripCost: 1,
},
hyperParameters,
})
solver.MAX_ITERATIONS = 20_000_000 * this.effort
solver.MAX_ITERATIONS *= this.effort
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical bug: MAX_ITERATIONS multiplication operator changed from assignment to compound assignment.

The old code was:

solver.MAX_ITERATIONS = 20_000_000 * this.effort

The new code is:

solver.MAX_ITERATIONS *= this.effort

This changes the behavior from setting an explicit value to multiplying whatever default value HighDensityA03Solver has for MAX_ITERATIONS. If the default is not 20_000_000, this will cause different iteration limits and potentially affect solver performance or correctness.

Fix: Change to explicit assignment like the A01 solver above it, or verify that multiplying the default value is intentional:

solver.MAX_ITERATIONS = 20_000_000 * this.effort
Suggested change
solver.MAX_ITERATIONS *= this.effort
solver.MAX_ITERATIONS = 20_000_000 * this.effort

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

return solver as any
}
if (hyperParameters.CLOSED_FORM_TWO_TRACE_SAME_LAYER) {
Expand Down Expand Up @@ -325,7 +318,7 @@ export class HyperSingleIntraNodeSolver extends HyperParameterSupervisorSolver<
let routes: HighDensityIntraNodeRoute[]
if (
(solver.solver as any) instanceof HighDensitySolverA01 ||
(solver.solver as any) instanceof HighDensityA02Solver
(solver.solver as any) instanceof HighDensityA03Solver
) {
routes = (solver.solver as any).getOutput()
} else {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@types/react-dom": "^19.0.3",
"@vercel/node": "^5.1.7",
"@vitejs/plugin-react": "^4.3.4",
"bun-match-svg": "^0.0.14",
"circuit-json-to-connectivity-map": "^0.0.19",
"circuit-to-svg": "^0.0.220",
"clsx": "^2.1.1",
Expand All @@ -62,11 +63,10 @@
"typescript": "^5.9.3",
"use-mouse-matrix-transform": "^1.3.0",
"vite": "^6.0.11",
"vite-tsconfig-paths": "^5.1.4",
"bun-match-svg": "^0.0.14"
"vite-tsconfig-paths": "^5.1.4"
},
"dependencies": {
"@tscircuit/high-density-a01": "^0.0.18",
"@tscircuit/high-density-a01": "^0.0.21",
"fast-json-stable-stringify": "^2.1.0",
"object-hash": "^3.0.0"
}
Expand Down
Loading
Loading