Add TraceAlignmentSolver post-pack phase to fix #12#76
Open
brone1323 wants to merge 1 commit intotscircuit:mainfrom
Open
Add TraceAlignmentSolver post-pack phase to fix #12#76brone1323 wants to merge 1 commit intotscircuit:mainfrom
brone1323 wants to merge 1 commit intotscircuit:mainfrom
Conversation
After PartitionPackingSolver, strongly-connected pads on neighbouring chips can land at a small (0.1-0.5 unit) Y or X delta apart, which renders as visible zig-zag traces in the schematic - the symptom seen in repro tscircuit#11 (SI7021). The new TraceAlignmentSolver iterates each chip with at least one inter-chip strong connection, computes the average displacement that would put every connecting pad on the same axis as its partner pin, and applies the displacement only when: 1. it does not cause an AABB intersection with any other chip, and 2. the chip's own total off-axis pad delta strictly decreases. The accept-only-if-improving rule keeps multi-partner chips with conflicting pulls in place. Two passes give downstream chips a chance to align after upstream chips have moved. On the SI7021 repro, this drops the worst-case off-axis pad delta from 0.5 to 0.125 (75% reduction) without introducing any new chip overlaps. The phase is registered as the final pipeline step; getOutputLayout(), visualize(), and preview() all prefer its output when available.
|
@brone1323 is attempting to deploy a commit to the tscircuit Team on Vercel. A member of the Team first needs to authorize it. |
Author
Demo videoGenerated programmatically (HTML deck → Playwright recordVideo → ffmpeg). Hosted as a release asset on the fork to comply with the Algora claim requirement. Sammy / @brone1323 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim #12
Problem
Issue #12 asks for a layout fix. The repro in merged PR #11 (SI7021) renders with visible zig-zag on traces between strongly-connected chips. The root cause: after
PartitionPackingSolversnaps each chip to a packing-grid coordinate, the pads on each chip are at fixed offsets from the chip center, so two strongly-connected pads on neighbouring chips often end up at a small (0.1–0.5 unit) off-axis delta. That delta becomes a visible zig-zag in the schematic.Concrete numbers from the SI7021 repro (output of the existing pipeline):
R1.1(top pin, offset y=+0.5) lands at world-y 0.65, but its partnerU1.4(right side, offset y=+0.2) lands at world-y 0.20. Trace zig-zag = 0.45 units. Same shape forR2.1↔U1.3. Worst-case off-axis pad delta across the whole layout: 0.50.Approach
Add a single new solver,
TraceAlignmentSolver, registered as the final phase ofLayoutPipelineSolverafterPartitionPackingSolver. For each chip with at least one inter-chip strong pin connection:The "strictly-decreases" guard is the part that lets us safely include multi-partner chips. If a chip is pulled toward two different partners with conflicting alignment requirements, the average nudge is rejected for failing to improve the chip's own metric. The phase runs two passes so that downstream chips can re-align after upstream chips move.
Result on the SI7021 repro
After the alignment phase:
R1nudged down 0.475 →R1.1aligns within 0.025 ofU1.4, and within 0.025 ofSJ1.3(the resistor's other strong partner)R2nudged up 0.525 → similar alignment withU1.3andSJ1.1LayoutPipelineSolver.checkForOverlapsAABB check)Differentiation vs other open PRs
PRs #39 / #44 / #61 / #74 all attack different defects. This PR attacks the off-axis pad delta on strongly-connected pin pairs - independent of decoupling-cap clustering, voltage net direction, and chip-overlap resolution. The four can stack.
OverlapResolutionSolver: resolves residual chip overlaps. Different defect (overlap, not zig-zag).Files touched
lib/solvers/TraceAlignmentSolver/TraceAlignmentSolver.ts(new)lib/solvers/LayoutPipelineSolver/LayoutPipelineSolver.ts(register new phase, prefer aligned layout ingetOutputLayout/visualize/preview)tests/TraceAlignmentSolver/TraceAlignmentSolver01.test.ts(new)Tests
bun test tests/TraceAlignmentSolver/- both new tests passbun test tests/LayoutPipelineSolver/ tests/PartitionPackingSolver/- 11 existing pipeline tests still passThe
tests/IdentifyDecouplingCapsSolver/IdentifyDecouplingCapsSolver06.test.tsfailure is pre-existing onmain(unrelatedconvertCircuitJsonToSchematicSimulationSvgexport missing incircuit-to-svg); confirmed reproducible without this PR's changes.