Skip to content

fix: correct device guards and reject pool growth during capture - #51

Merged
gongchensu merged 3 commits into
InfiniTensor:refactor/modern-infini-stack-reviewfrom
gongchensu:fix/modern-infini-stack-review
Oct 15, 2026
Merged

gongchensu merged 3 commits into
InfiniTensor:refactor/modern-infini-stack-reviewfrom
gongchensu:fix/modern-infini-stack-review

Conversation

@gongchensu

@gongchensu gongchensu commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Validate enabled device types before dispatch in include/infini/rt/device_guard.h, and restore the previous device even when the guard initially selects the already-current device.
  • Reject CUDA pool growth during native stream capture in src/reusable_memory_pool.cc, while allowing cached-block reuse. Document the preallocation requirement in include/infini/rt/reusable_memory_pool.h.
  • Add kEventNotReady mappings for Iluvatar, Hygon, T-Head, MetaX, Mars, and Moore so the existing generator can emit their IsEventNotReady dispatch cases.
  • Add DeviceGuard and CUDA pool capture regression tests, and extend native runtime tests with event-status classification checks.

Base: refactor/modern-infini-stack-review@b413816.
Head: fix/modern-infini-stack-review@86b2326.

Motivation

The refactor branch introduces runtime utilities with several boundary cases:

  • A backend that was not built can assert in Debug or be incorrectly reported as selected in Release, allowing a pool to report a different device from the actual allocation backend.
  • A guard that starts on the requested device skips restoration even if code inside its scope later changes the device type or index.
  • A pool cache miss during CUDA capture creates graph-owned allocation nodes without the corresponding replay lifetime management; subsequent graph launches can fail. Rejecting growth before allocation provides an immediate error and preserves capture for cached blocks.
  • Event-capable backends without kEventNotReady fall through to false in the generated public helper, misclassifying a normal pending event.

Type of Change

  • feat - new feature / new backend capability / new public API
  • fix - bug fix
  • perf - performance improvement without behavior change
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • Hygon (WITH_HYGON)
  • MetaX (WITH_METAX)
  • Moore (WITH_MOORE)
  • Cambricon (WITH_CAMBRICON)
  • Ascend (WITH_ASCEND)
  • Build system / CMake / generated headers
  • Public headers / installed consumer API
  • Documentation only

Smoke Build and Test Result

paste smoke build and test output here

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU
NVIDIA
Iluvatar
Hygon
MetaX
Moore
Cambricon
Ascend
Full `ctest` output (optional)
paste here

Benchmark / Performance Impact

Notes for Reviewers

Reject unavailable devices before dispatch and prevent CUDA pool growth during native capture. Complete event not-ready mappings and cover the failure paths with regression tests.
@gongchensu gongchensu self-assigned this Oct 15, 2026
@gongchensu
gongchensu merged commit e719c28 into InfiniTensor:refactor/modern-infini-stack-review Oct 15, 2026
4 checks passed
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