Optimize anchor-only graph transformer inference - #732
Merged
Conversation
yliu2-sc
reviewed
Aug 5, 2026
yliu2-sc
reviewed
Aug 7, 2026
yliu2-sc
reviewed
Aug 7, 2026
yliu2-sc
approved these changes
Aug 10, 2026
zfan3-sc
reviewed
Aug 10, 2026
kmontemayor2-sc
force-pushed
the
kmonte/anchor-only-final-layer
branch
from
August 10, 2026 23:15
58aa3d2 to
3960125
Compare
zfan3-sc
approved these changes
Aug 11, 2026
kmontemayor2-sc
marked this pull request as ready for review
August 11, 2026 23:04
kmontemayor2-sc
requested review from
mkolodner-sc,
nshah-sc,
svij-sc and
xgao4-sc
as code owners
August 11, 2026 23:04
kmontemayor2-sc
enabled auto-merge
August 11, 2026 23:04
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 11, 2026
kmontemayor2-sc
force-pushed
the
kmonte/anchor-only-final-layer
branch
from
August 11, 2026 23:52
93d3c36 to
d91ec97
Compare
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.
Summary
At batch size 1,120 on a Tesla T4, this reduces median graph-transformer transform + encoder latency from 1,298.46 ms to 781.69 ms and raises throughput from 862.6 to 1,432.8 anchors/s (+66.1%).
mainanchor_onlyreadout discards every final-layer output except token zero. The specialized final-layer path keeps full-sequence keys, values, and source relation features, but computes query-side attention, relation-message targets, output projection, and feed-forward work only for the anchor.The encoder selection logic enables this path during evaluation with
anchor_onlyreadout. Relation-aware attention uses a rectangular anchor-query bias while preserving full-sequence keys.Relation-aware T4 measurements retain the same benefit:
Both cases use nonzero learned relation parameters and match the full path within
1.0431e-7maximum absolute error.Correctness
The production-count T4 fixture produced:
1.0431e-72.2403e-7The new real-tensor tests compare the specialized output with an independently evaluated full-sequence reference. They exercise:
Validation
tychecks pass.git diff --checkpasses.The benchmark graph topology, input features, and initial weights are synthetic. A checkpoint-backed L4 validation remains the next deployment gate.
Full diff: 322d351...6989558