Skip to content

[EXTRA] Simplify StructuralMap engine policy - #771

Merged
tqchen merged 1 commit into
apache:mainfrom
tqchen:refactor/structural-map-engine-policy
Sep 9, 2026
Merged

[EXTRA] Simplify StructuralMap engine policy#771
tqchen merged 1 commit into
apache:mainfrom
tqchen:refactor/structural-map-engine-policy

Conversation

@tqchen

@tqchen tqchen commented Sep 9, 2026

Copy link
Copy Markdown
Member

[EXTRA] Simplify StructuralMap engine policy

StructuralMap needs identity state only to keep variables consistent when
descent rewrites a definition. Callback results are separate: callbacks run
at every occurrence in their selected pre- or post-descent position.

Make default C++ descent the sole owner of FreeVar and DAG remapping, with
definitions binding rewritten results and unchanged simple definitions left
absent. Keep the remap ABI stable and use an owned raw-pointer-keyed store for
efficient identity lookups.

Adopt whole raw TVMFFIAny results by value while leaving destructor-visible
slot moves pointer-based. Initialize owning Any storage member-wise so GCC
retains scalar state and avoids an overlapping narrow-store/wide-reload stall.

Update existing C++ and Python expectations in place and document
StructuralMap as post(D(pre)) alongside StructuralWalk's stateless tree
traversal. Rust remains unchanged for a follow-up.

@tqchen
tqchen force-pushed the refactor/structural-map-engine-policy branch 2 times, most recently from cf40162 to 8eb6c7c Compare September 9, 2026 15:22
@tqchen

tqchen commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Impact of the recent StructuralMap speed improvements (#768 and this PR)

Preliminary numbers from a minimal benchmark (a mini-TIR built from tvm-ffi types: a split/fuse expression tree and SeqStmt blocks), one pinned core, 21 interleaved processes per state, median of process medians, ns/node, with hooks following this PR's map policy and writing fields back only when changed. OLD is the engine before #768 (e74e58f), UC is current main with #768 (UnchangedOr results), NEW is this PR; deltas against OLD. never is a callback that matches nothing; retained hands the engine a shared root, moved the sole reference.

x86 (AMD EPYC 7413)

arm fixture ownership OLD (ns/node) UC (#768) (ns/node) NEW (this PR) (ns/node)
never split-fuse-distinct retained 25.01 20.49 (-18.1%) 11.31 (-54.8%)
never seq-256 retained 28.35 22.08 (-22.1%) 14.67 (-48.3%)
subst split-fuse-distinct retained 48.20 45.98 (-4.6%) 34.65 (-28.1%)
subst split-fuse-distinct moved 40.46 34.99 (-13.5%) 22.15 (-45.3%)
swap seq-256 retained 36.98 32.81 (-11.3%) 24.05 (-35.0%)
swap seq-256 moved 34.37 32.41 (-5.7%) 24.21 (-29.6%)

aarch64 (Neoverse V2)

arm fixture ownership OLD (ns/node) UC (#768) (ns/node) NEW (this PR) (ns/node)
never split-fuse-distinct retained 47.10 25.75 (-45.3%) 8.84 (-81.2%)
never seq-256 retained 53.55 36.05 (-32.7%) 14.80 (-72.4%)
subst split-fuse-distinct retained 83.04 75.44 (-9.2%) 47.34 (-43.0%)
subst split-fuse-distinct moved 72.24 50.08 (-30.7%) 25.34 (-64.9%)
swap seq-256 retained 67.97 48.53 (-28.6%) 26.11 (-61.6%)
swap seq-256 moved 61.02 45.94 (-24.7%) 21.37 (-65.0%)

@tqchen
tqchen force-pushed the refactor/structural-map-engine-policy branch 3 times, most recently from 5ac5299 to eb283f8 Compare September 9, 2026 18:29
StructuralMap needs identity state only to keep variables consistent when
descent rewrites a definition. Callback results are separate: callbacks run
at every occurrence in their selected pre- or post-descent position.

Make default C++ descent the sole owner of FreeVar and DAG remapping, with
definitions binding rewritten results and unchanged simple definitions left
absent. Keep the remap ABI stable and use an owned raw-pointer-keyed store for
efficient identity lookups.

Adopt whole raw TVMFFIAny results by value while leaving destructor-visible
slot moves pointer-based. Initialize owning Any storage member-wise so GCC
retains scalar state and avoids an overlapping narrow-store/wide-reload stall.

Update existing C++ and Python expectations in place and document
StructuralMap as post(D(pre)) alongside StructuralWalk's stateless tree
traversal. Rust remains unchanged for a follow-up.
@tqchen
tqchen force-pushed the refactor/structural-map-engine-policy branch from eb283f8 to b085f41 Compare September 9, 2026 20:45
@tqchen
tqchen merged commit c5e636b into apache:main Sep 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants