Optimize anchor-only graph transformer inference - #732
Draft
kmontemayor2-sc wants to merge 3 commits into
Draft
Conversation
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