Skip to content

[comgr][hotswap] Bound symbol-less return inference memory - #3608

Closed
harsh-amd wants to merge 2 commits into
ROCm:amd-stagingfrom
harsh-amd:users/harsh/hotswap-upstream-draft-04c-memory-bound
Closed

[comgr][hotswap] Bound symbol-less return inference memory#3608
harsh-amd wants to merge 2 commits into
ROCm:amd-stagingfrom
harsh-amd:users/harsh/hotswap-upstream-draft-04c-memory-bound

Conversation

@harsh-amd

Copy link
Copy Markdown

Scope

Bound symbol-less return-inference memory without changing the accepted fixed-point result.

Clean review range

Review status

Draft for early review. GitHub cannot base an upstream ROCm PR on a branch in the fork, so the Files changed view is temporarily cumulative with unmerged prerequisites. Review the clean fork PR and exact source commits linked above. This branch will be rebased and reduced after dependencies land; do not merge the cumulative snapshot.

#3598 remains unchanged as the immutable 2,685/2,685 integration reference.

Validation provenance

The source commits are exact ancestors of corpus-tested ab3cdd6. The cumulative integration passed 2,685/2,685 corpus paths, 213/213 HotswapMCTests, and COMGR lit with 168 passed, 14 unsupported, and 0 failed. Standalone current-staging formatting, focused tests, CI, and the appropriate corpus transition gate are required before this draft becomes ready.

@lamb-j lamb-j added comgr Related to Code Object Manager hotswap Related to the Comgr Hotswap feature labels Jul 27, 2026
@SourishW
SourishW force-pushed the users/harsh/hotswap-upstream-draft-04c-memory-bound branch from ea602cd to 8afcbe2 Compare July 29, 2026 02:16
@SourishW

Copy link
Copy Markdown

PR #3608 reduces peak memory use when HotSwap infers return regions for functions that have no symbol. The previous approach checked every candidate against every other candidate, which did not scale. This PR processes candidates in a single pass and skips any that have already been ruled out. A follow-up commit frees discarded candidates from memory immediately and ensures the selection order is deterministic. Translation output is unchanged.

Focused tests

HotswapMCTests: 175/175 passed

This includes:

  • end-to-end rejection of overlapping symbol-less return regions;
  • transitive rejection propagation;
  • a 16K-component scale test;
  • verification that invalidated heap-backed SmallVector storage is released.

Full offline corpus

Corpus: original July 24, 2026 HotSwap corpus (2,685 paths, gfx1250).

There were 0 pass-to-fail regressions, 0 new crashes, and 0 new timeouts. For all 2,645 objects that succeeded in both builds: 0 changed output hashes, 0 changed output sizes.

Built COMGR hashes:

baseline:  edc94cdb041ab0f736f50a875cb311bcba3491042145b386513aba8ad936893b
candidate: d54d5f2df4bed440c0b91bac045f70cc6596967f63870841e04c3e23b8981c1d

Docker runtime smoke

Image: registry-sc-harbor.amd.com/hotswap/therock-hotswap-gfx1250:a20260724-base-tests-corpus
Node: heliosr-1b114-b02-3.mnb.dcgpu, gfx1250
Test: rocThrust #64 (merge_key_value.hip) with ROCR_VISIBLE_DEVICES=0, HSA_HOTSWAP_VERBOSE=1, AMD_COMGR_HOTSWAP_ENTRY_TRAMPOLINES=0, LD_LIBRARY_PATH=/opt/therock/lib

  • Baseline: 1/1 CTest passed, 16/16 gtests passed
  • Candidate COMGR: 1/1 CTest passed, 16/16 gtests passed

@harsh-amd
harsh-amd marked this pull request as ready for review July 29, 2026 02:46

@harsh-amd harsh-amd left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 8afcbe217e7069cd46ba265c1efe0b916b589f66 against merge base 2f69da2a91b3392dbe6cbe38c1e9692199093f29.

The streaming owner/tombstone state machine preserves the old singleton-overlap-component result for direct and transitive overlaps, while releasing invalidated region vectors. A fresh standalone Release production build succeeded, and HotswapMCTests passed 175/175 in both Release and exact ASan builds.

One process item also needs updating before landing: the PR description still says this is a cumulative draft that must not be merged, links the old #3598 source commit, and reports the older 213-test validation. The current PR is marked ready, is cleanly based on amd-staging, contains two commits, and has current 175-test/corpus results in a comment. Please update the description so the review range and landing status are unambiguous.

No semantic correctness issues found; the remaining code issue is the formatter failure noted inline.

llvm::SmallVector<SymbolLessReturnRegion, 4> Regions;
std::vector<int64_t> RegionOwner(5, -1);

EXPECT_TRUE(claimSymbolLessReturnRegion(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Please run git clang-format over the final review range. The required code_formatter check currently fails on this block and several later assertions in the new ownership tests; the CI formatter diff starts here.

@harsh-amd
harsh-amd requested a review from paulzzy July 29, 2026 20:40
harsh-amd and others added 2 commits July 29, 2026 15:20
Filter symbol-less call groups that are already declared or externally reachable, and replace the final quadratic overlap scan with streaming ownership tombstones. Preserve transitive overlap rejection while releasing invalid region instruction vectors, and cover the ownership transition with focused and end-to-end tests.

Co-authored-by: Paul-Zhang <31449988+paulzzy@users.noreply.github.com>
Swap invalidated regions with empty storage so heap-backed SmallVectors are released immediately. Deduplicate overlapping owners deterministically with sort/unique and test the storage-release invariant.
@SourishW
SourishW force-pushed the users/harsh/hotswap-upstream-draft-04c-memory-bound branch from 8afcbe2 to a38e862 Compare July 29, 2026 22:22
@harsh-amd harsh-amd closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comgr Related to Code Object Manager hotswap Related to the Comgr Hotswap feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants