[COMGR] Harden gfx1250 HotSwap rewriting and fail closed#3387
Draft
jammm wants to merge 4 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.
Also see https://github.com/jammm/hotswap_repros/blob/main/docs/PR_3387_MAPPING.md
Summary
This PR is stacked on
ROCm/llvm-project#3374 at
fae9307759fd7961e479747fd4822d889c925399.PR #3374 already provides:
islands
This PR adds the remaining cross-pass correctness machinery needed when several
required transformations interact in one large, multi-function code object:
A required transformation now succeeds only when its placement, source-window
ownership, control-flow assumptions, encoding, ELF growth, and metadata update
can all be established. Otherwise the complete rewrite fails without returning
a partially transformed code object.
These gaps were exposed by gfx1250 code objects captured while running
DeepSeek V4 Pro through the open-source ATOM/AITER stack. The captures were
reduced to focused COMGR tests and standalone reproducers. The implementation
is general to gfx1250 HotSwap and contains no model-specific paths.
fae9307759fd7961e479747fd4822d889c9253993d900e5b002dusers/jam/hotswap-zero-failures-amd-staging-v2Issues Observed In The Open-Source Workload
Far-return placement and scratch liveness
Large AITER mHC and activation objects contained required sites outside
short-branch range. Some sites had no contiguous source window large enough for
a far-return sequence, while candidate original SGPR pairs or VCC were live on
only some outgoing paths. Large RCCL code objects additionally exposed
fragmented gateway space, protected callable extents, and order-sensitive relay
allocation.
This PR proves a candidate pair dead from the exact resume point across all
modeled successors before reusing it. VCC is subject to the same proof.
Fallback SGPR allocation remains resource-accounted. Gateway, relay, branch
island, and source-window placement respect descriptors, symbols, relocations,
callable entries, materialized PC transfers, and generated-code ownership.
The implementation preserves PR #3374's SCC-neutral
s_get_pc_i64/s_add_nc_u64/s_set_pc_i64routing and does not generates_add_pc_i64.DS2 combined-delay ownership
Generated A8W8, top-k, activation, and RCCL objects contained multiple required
DS2 rewrites protected by one combined
s_delay_alu. Applying or relocatingone member independently could consume another member's delay, source window,
or only reachable gateway.
This PR plans all required DS2 members owned by one delay window as one
transaction. Address and destination dependencies, split ordering, alignment,
required
s_wait_dscnt 0placement, source windows, and gateway routes arevalidated together. Unsupported tuples, offsets, ownership graphs, or routes
fail the complete rewrite.
PC-sensitive tensor descriptor repair
Grouped-MoE captures contained
tensor_load_to_ldssites without the canonicaladjacent scalar-delay slot. Other sites had no spare SGPR for the earlier
save-and-restore approach. Relocating the tensor instruction is not valid
because its linked PC participates in its behavior.
This PR keeps the tensor instruction at its original address. It accepts one
of three proofs:
path and can be masked in place
Descriptor entries, visible callable symbols, direct calls and returns,
materialized PC transfers, opaque control flow, and arbitrary indirect ingress
participate in the proof. A bypassing or unresolved entry disables the proof
and causes the required rewrite to fail closed.
Two retained no-scratch captures still reach a later tensor site whose
descriptor placement cannot be proven. They are intentional fail-closed
negative cases: the API returns an error and produces no output object.
WMMA VGPR-MSB, delays, and hazards
A captured K=128 A8W8 object required a WMMA split after a loop header. The
earlier straight-line recovery rejected it with:
A captured logits object also combined the required split with a protected
dependency window, a barrier, a PC-sensitive tensor load, and WMMA hazards.
Moving only the WMMA would leave the original delay describing the wrong
instruction sequence.
This PR computes all four VGPR-MSB fields as a forward CFG fixed point across
branches, loops, joins, and SETREG updates. A split is emitted only when the
complete incoming mode is exact. The upper K=64 operation is encoded under the
required mode and the incoming mode is restored afterward.
Supported combined-delay windows are demerged atomically. WMMA semantic
replacement, reconstructed delays, and RAW, WAR, and WAW hazard repair share
one ownership plan. Conflicting reachable state, unresolved ingress, interior
entries, overlapping dependency windows, or unsupported ownership fail closed.
Hard-clause entry paths
A sparse-prefill object associated with a DeepSeek V4 Pro runtime fault
contained an entry-path
s_clausebefore any compatible VMEM operation. Otherobjects showed that deleting every clause is also incorrect.
This PR validates clause family, membership, scope, and transformed members,
then uses a must-analysis over every modeled entry path. Malformed,
mixed-family, transformed-member, and initial-VMEM clauses are removed. A
uniform same-family clause is preserved only when every modeled path has
already executed a compatible VMEM operation.
Cross-pass transactions and repeated rewriting
PR #3374 already records a required-site failure. This PR extends that state
through every semantic pass and adds prepare/commit ownership for shared source
instructions, delay windows, scratch reservations, gateways, and metadata.
The complete appended layout is reserved before final branch fixups. ELF growth
validates executable load coverage, header relocation, symbols, protected
extents, kernel descriptors, and resource metadata before committing.
Generated executable pools carry a non-allocating structural note describing
their layout and target stepping. A later invocation accepts a pool only when
the note, section, executable segment, layout, and target state agree.
Malformed, incomplete, overlapping, unmarked, or target-mismatched state fails
closed. A supported B0-to-A0 output is byte-identical when rewritten to A0
again.
Callable-Control-Flow ABI
HotSwap requires input code objects to follow the AMDGPU
callable-control-flow ABI.
In particular, an
s_swap_pc_i64that writes the standard link pairs[30:31]must be a call to a callable function entry represented by the codeobject. This is an input precondition, not an inference made from MC's generic
instruction classification.
If the target entry or link behavior cannot be resolved from the represented
control-flow information, HotSwap treats the ingress and link state as
unknown. It does not use that transfer as an optimistic call boundary for
liveness, relocation, clause, or must-definition proofs. A required rewrite
that depends on such a proof fails closed.
Generated provenance notes describe structural layout and rewrite state. They
do not authenticate untrusted input. HotSwap assumes input from a trusted
compiler or an earlier trusted HotSwap invocation.
Validation
Fresh host validation from the PR #3374-based source and COMGR build:
HotswapMCTestsHotswapElfTestsThe two full-suite failures are
device-lib-linking.cl, whose device-libraryexpectation differs from the installed SDK, and
spirv-tests/unbundle-compressed.hip, whose expected payload magic differsfrom that SDK's compressed bundle output. All HotSwap-filtered tests pass.
Focused host coverage includes:
The exact-object validation set includes the captured mHC, activation, logits,
A8W8, mxscale, tensor no-delay, sparse-prefill, and RCCL objects. Supported
objects must complete a first rewrite, pass ELF and disassembly checks, and
produce a byte-identical second rewrite. The two retained tensor negative
objects must return an error without producing output.
Direct device reproducers and RCCL controls are run in separate fresh processes
with HotSwap enabled and disabled. Acceptance is based on process status, exact
output comparisons where available, rewrite diagnostics, runtime library maps,
and absence of GPU fault signatures.
Evidence Boundaries
faults, but object-to-fault provenance alone does not prove HotSwap causality.
reproducer for every transform it contains.
HotSwap fix is attributed to it.
reported by their COMGR rewrite logs.
Scope
documentation, and tests.
base of this work.
is not introduced here.
TargetParser.hinclude change selects the header available in theinstalled LLVM SDK and does not change rewrite semantics.