Skip to content

Add regression tests for host caching allocator stats accounting - #183067

Closed
ailzhang wants to merge 1 commit into
mainfrom
host_caching_alloc_test
Closed

ailzhang wants to merge 1 commit into
mainfrom
host_caching_alloc_test

Conversation

@ailzhang

Copy link
Copy Markdown
Contributor

Two regression tests in TestCuda for host_memory_stats() bookkeeping issues that were resolved by PR #171662 ("Add configurable threshold to avoid power-of-two rounding for large pinned memory allocations") via the introduction of the maybe_cache_block helper that consolidated free()'s no-events fast path and process_events_for_specific_size:

  1. test_host_memory_stats_active_after_free_no_events

    Asserts active_bytes.current and active_requests.current return to 0 after a plain pin-and-drop cycle. Without the fix, free()'s no-events fast path pushed the block back to the free list without decrementing the active bucket stats, so the counters grew monotonically on every cycle even though the memory was correctly recycled.

  2. test_host_memory_stats_active_after_event_drain

    Asserts the same after a pin / non_blocking H2D / drop / empty_cache sequence, plus that active_bytes.freed and active_requests.freed are non-negative. process_events_for_specific_size used to decrement active_bytes_bucket_stats by its int64_t size parameter, which is -1 when invoked via process_events. Subtracting -1 quietly added a byte per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab (add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR #171662 and pass after the PR lands.

@pytorch-bot

pytorch-bot Bot commented May 10, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/183067

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 8684c03 with merge base 7ee00f1 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label May 10, 2026
@ailzhang
ailzhang requested review from awgu and ngimel May 10, 2026 00:59
@ngimel

ngimel commented May 10, 2026

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 10, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@ailzhang

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Tried to rebase and push PR #183067, but it was already up to date. Try rebasing against main by issuing:
@pytorchbot rebase -b main

@ailzhang

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase -b main

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here

Two regression tests in TestCuda for host_memory_stats() bookkeeping
issues that were resolved by PR #171662 ("Add configurable threshold to
avoid power-of-two rounding for large pinned memory allocations") via
the introduction of the maybe_cache_block helper that consolidated
free()'s no-events fast path and process_events_for_specific_size:

1. test_host_memory_stats_active_after_free_no_events

   Asserts active_bytes.current and active_requests.current return to 0
   after a plain pin-and-drop cycle. Without the fix, free()'s no-events
   fast path pushed the block back to the free list without decrementing
   the active bucket stats, so the counters grew monotonically on every
   cycle even though the memory was correctly recycled.

2. test_host_memory_stats_active_after_event_drain

   Asserts the same after a pin / non_blocking H2D / drop / empty_cache
   sequence, plus that active_bytes.freed and active_requests.freed are
   non-negative. process_events_for_specific_size used to decrement
   active_bytes_bucket_stats by its int64_t size parameter, which is -1
   when invoked via process_events. Subtracting -1 quietly added a byte
   per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab
(add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR #171662 and
pass after the PR lands.
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased host_caching_alloc_test onto refs/remotes/origin/main, please pull locally before adding more changes (for example, via git checkout host_caching_alloc_test && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the host_caching_alloc_test branch from ee11617 to 8684c03 Compare May 10, 2026 16:44
@ailzhang

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request May 13, 2026
…orch#183067)

Two regression tests in TestCuda for host_memory_stats() bookkeeping issues that were resolved by PR pytorch#171662 ("Add configurable threshold to avoid power-of-two rounding for large pinned memory allocations") via the introduction of the maybe_cache_block helper that consolidated free()'s no-events fast path and process_events_for_specific_size:

1. test_host_memory_stats_active_after_free_no_events

   Asserts active_bytes.current and active_requests.current return to 0 after a plain pin-and-drop cycle. Without the fix, free()'s no-events fast path pushed the block back to the free list without decrementing the active bucket stats, so the counters grew monotonically on every cycle even though the memory was correctly recycled.

2. test_host_memory_stats_active_after_event_drain

   Asserts the same after a pin / non_blocking H2D / drop / empty_cache sequence, plus that active_bytes.freed and active_requests.freed are non-negative. process_events_for_specific_size used to decrement active_bytes_bucket_stats by its int64_t size parameter, which is -1 when invoked via process_events. Subtracting -1 quietly added a byte per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab (add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR pytorch#171662 and pass after the PR lands.
Pull Request resolved: pytorch#183067
Approved by: https://github.com/ngimel
Alokksinha00 pushed a commit to Alokksinha00/pytorch that referenced this pull request May 15, 2026
…orch#183067)

Two regression tests in TestCuda for host_memory_stats() bookkeeping issues that were resolved by PR pytorch#171662 ("Add configurable threshold to avoid power-of-two rounding for large pinned memory allocations") via the introduction of the maybe_cache_block helper that consolidated free()'s no-events fast path and process_events_for_specific_size:

1. test_host_memory_stats_active_after_free_no_events

   Asserts active_bytes.current and active_requests.current return to 0 after a plain pin-and-drop cycle. Without the fix, free()'s no-events fast path pushed the block back to the free list without decrementing the active bucket stats, so the counters grew monotonically on every cycle even though the memory was correctly recycled.

2. test_host_memory_stats_active_after_event_drain

   Asserts the same after a pin / non_blocking H2D / drop / empty_cache sequence, plus that active_bytes.freed and active_requests.freed are non-negative. process_events_for_specific_size used to decrement active_bytes_bucket_stats by its int64_t size parameter, which is -1 when invoked via process_events. Subtracting -1 quietly added a byte per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab (add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR pytorch#171662 and pass after the PR lands.
Pull Request resolved: pytorch#183067
Approved by: https://github.com/ngimel
@github-actions
github-actions Bot deleted the host_caching_alloc_test branch June 11, 2026 02:33
aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
…orch#183067)

Two regression tests in TestCuda for host_memory_stats() bookkeeping issues that were resolved by PR pytorch#171662 ("Add configurable threshold to avoid power-of-two rounding for large pinned memory allocations") via the introduction of the maybe_cache_block helper that consolidated free()'s no-events fast path and process_events_for_specific_size:

1. test_host_memory_stats_active_after_free_no_events

   Asserts active_bytes.current and active_requests.current return to 0 after a plain pin-and-drop cycle. Without the fix, free()'s no-events fast path pushed the block back to the free list without decrementing the active bucket stats, so the counters grew monotonically on every cycle even though the memory was correctly recycled.

2. test_host_memory_stats_active_after_event_drain

   Asserts the same after a pin / non_blocking H2D / drop / empty_cache sequence, plus that active_bytes.freed and active_requests.freed are non-negative. process_events_for_specific_size used to decrement active_bytes_bucket_stats by its int64_t size parameter, which is -1 when invoked via process_events. Subtracting -1 quietly added a byte per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab (add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR pytorch#171662 and pass after the PR lands.
Pull Request resolved: pytorch#183067
Approved by: https://github.com/ngimel
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…orch#183067)

Two regression tests in TestCuda for host_memory_stats() bookkeeping issues that were resolved by PR pytorch#171662 ("Add configurable threshold to avoid power-of-two rounding for large pinned memory allocations") via the introduction of the maybe_cache_block helper that consolidated free()'s no-events fast path and process_events_for_specific_size:

1. test_host_memory_stats_active_after_free_no_events

   Asserts active_bytes.current and active_requests.current return to 0 after a plain pin-and-drop cycle. Without the fix, free()'s no-events fast path pushed the block back to the free list without decrementing the active bucket stats, so the counters grew monotonically on every cycle even though the memory was correctly recycled.

2. test_host_memory_stats_active_after_event_drain

   Asserts the same after a pin / non_blocking H2D / drop / empty_cache sequence, plus that active_bytes.freed and active_requests.freed are non-negative. process_events_for_specific_size used to decrement active_bytes_bucket_stats by its int64_t size parameter, which is -1 when invoked via process_events. Subtracting -1 quietly added a byte per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab (add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR pytorch#171662 and pass after the PR lands.
Pull Request resolved: pytorch#183067
Approved by: https://github.com/ngimel
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…orch#183067)

Two regression tests in TestCuda for host_memory_stats() bookkeeping issues that were resolved by PR pytorch#171662 ("Add configurable threshold to avoid power-of-two rounding for large pinned memory allocations") via the introduction of the maybe_cache_block helper that consolidated free()'s no-events fast path and process_events_for_specific_size:

1. test_host_memory_stats_active_after_free_no_events

   Asserts active_bytes.current and active_requests.current return to 0 after a plain pin-and-drop cycle. Without the fix, free()'s no-events fast path pushed the block back to the free list without decrementing the active bucket stats, so the counters grew monotonically on every cycle even though the memory was correctly recycled.

2. test_host_memory_stats_active_after_event_drain

   Asserts the same after a pin / non_blocking H2D / drop / empty_cache sequence, plus that active_bytes.freed and active_requests.freed are non-negative. process_events_for_specific_size used to decrement active_bytes_bucket_stats by its int64_t size parameter, which is -1 when invoked via process_events. Subtracting -1 quietly added a byte per drained event and pushed active_bytes.freed negative.

Both tests use 2 iterations to exercise both the new-slab (add_allocated_block) and cache-reuse (get_free_block) allocation paths.

Verified that both tests fail on the parent commit of PR pytorch#171662 and pass after the PR lands.
Pull Request resolved: pytorch#183067
Approved by: https://github.com/ngimel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants