Skip to content

fix(allocator): reuse pinned free blocks - #569

Merged
voltjia merged 1 commit into
refactor/adopt-modern-infini-stackfrom
fix/reuse-pinned-free-blocks
Sep 11, 2026
Merged

fix(allocator): reuse pinned free blocks#569
voltjia merged 1 commit into
refactor/adopt-modern-infini-stackfrom
fix/reuse-pinned-free-blocks

Conversation

@voltjia

@voltjia voltjia commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Reuse free allocator blocks even while a captured graph retains their underlying storage.
  • Keep graph pins responsible for preventing premature trim or free, rather than making every pinned address exclusive to one graph.
  • Update the runtime contract test to cover both size-class and large-block reuse.

Motivation

The modern-stack PagedCompiler captures decode graphs for many batch sizes. The allocator previously refused to reuse a free block whose pin_count was nonzero, so each captured graph duplicated its scratch storage. At the documented NVIDIA capacity boundary, this caused PinnableBlockAllocator allocation failures during P01 warmup and P04 reset_cache.

The same two-line allocator change was validated on NVIDIA A100-SXM4-80GB:

Workload Before With pinned-free reuse
P01, 9G-8B, BF16, batch 64, input 4096, output 256, TP1 Allocator error code 2 during warmup Success, total_time=33219.85 ms
P04, FM9G-70B, BF16, batch 64, input 4096, output 256, TP8 Allocator error code 2 during reset_cache Success, total_time=46100.18 ms

Allocator tracing for P01 showed underlying allocation events falling from 17331 to 5097 with this change.

Type of Change

  • fix — bug fix

Test Results of Involved Models on Supported Platforms

Platform Result
NVIDIA A100-SXM4-80GB P01 and P04 capacity cases completed with the allocator reuse change; logs were retained from the diagnostic run.
Local static contracts python -m unittest test.static.test_infinicore_runtime_contracts -v: 55/55 passed.
Local static suite python -m unittest discover -s test/static -p 'test_*.py' -v: 104/104 passed.

Benchmark / Performance Impact

This is primarily a capacity and correctness fix. The successful diagnostic runs are listed under Motivation. P01 used an instrumented diagnostic library, so its wall time is not used for performance attribution; P04 was uninstrumented and completed in 46100.18 ms.

Notes for Reviewers

The important invariant is that graph destruction still releases its PinLease, and trim still refuses to free blocks with a nonzero pin_count. Reuse is allowed only after tensor owners mark the block !in_use; this restores sequential same-stream graph behavior without releasing addresses that captured graphs reference.

The A100 diagnostic validation used the historical modern-stack checkout that reproduced the failures plus this allocator change. Static tests and formatting were run on the exact PR head.

CI / ChatOps

CI will be triggered manually after the PR is created.


Checklist

Title, Branch, and Commits

  • PR title follows Conventional Commits.
  • Branch name follows <type>/xxx-yyyy-zzzz.
  • Commit message follows Conventional Commits.
  • Small PR is a single squashable commit.
  • No stray merge commits from main.
  • No fixup! / squash! / wip commits remain.
  • Existing PR/branch/commit that followed the legacy issue format.

Scope and Design

  • Changes are minimal.
  • No dead code, debug prints, or ownerless TODOs.
  • No unrelated formatting churn.
  • No public API changes.

General Code Hygiene

  • Comments explain the non-obvious ownership invariant.
  • Modified files end with a newline.
  • No trailing whitespace, mixed indentation, or BOMs.
  • Code references in comments and messages use backticks where appropriate.
  • Comments and error messages are English.
  • Comments are complete sentences.

C++ Specific

  • Code follows the repository formatting and style conventions.
  • RAII and existing allocator ownership are preserved.
  • Changed files are formatted with the repository formatter configuration.
  • No changes reference csrc/models/llama_legacy/.

Python Specific

  • Changed Python test code is PEP 8 compliant and formatted.
  • No changes reference python/infinilm/auto_config.py.

Testing

  • NVIDIA A100 P01/P04 diagnostic capacity runs passed.
  • Target runtime contract test passed.
  • Full local static suite passed.
  • Single request test not rerun on the exact PR head; allocator behavior was covered by the two capacity workloads and static contracts.
  • Offline performance test passed for the affected P01/P04 capacity cases in the diagnostic validation.
  • Sanity test not rerun; this allocator fix is covered by targeted runtime contracts.
  • Service test not rerun; no service API behavior was changed.

Build, CI, and Tooling

  • Fresh full build and CI are pending on the PR head.

Documentation

  • No user-facing API, build flag, or workflow changed.

Security and Safety

  • No secrets, private hosts, customer data, or hardware identifiers are committed.
  • No new unsafe ownership or pointer lifetime is introduced.

@voltjia
voltjia merged commit f21b8f9 into refactor/adopt-modern-infini-stack Sep 11, 2026
8 of 9 checks passed
@voltjia
voltjia deleted the fix/reuse-pinned-free-blocks branch September 11, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant