Skip to content

Avoid full-heap collection after every compiled forward binding - #243

Closed
voipmonitor wants to merge 1 commit into
mainfrom
astra/k31-forward-binding-gc
Closed

voipmonitor wants to merge 1 commit into
mainfrom
astra/k31-forward-binding-gc

Conversation

@voipmonitor

Copy link
Copy Markdown
Collaborator

Loading a large compiled-forward catalog repeatedly collects the full Python heap after binding each forward. Retained forward owners grow throughout that loop, so every full collection rescans objects that must remain alive for warmup, capture, and native execution.

Use generation-zero collection after each forward in the single-rank and tensor-parallel loading paths. Keep full collection at phase boundaries, including the end of tensor-parallel warmup. The existing memory-pressure rule still promotes a young-generation collection to a full collection when available host memory falls below 8 GiB. Guard validation, kernel ownership, and explicit capture-state release retain their existing behavior.

This removes repeated full-heap scans during preparation. It does not change captured arithmetic or native inference, and no isolated end-to-end preparation speedup is claimed.

Validation: 72 focused CPU tests passed, covering reclamation of promoted cycles under memory pressure, retained compiled guards, distributed artifact sharing, and cached-catalog owner release. Run python -m pytest -q tests/preparation/test_host_memory.py tests/preparation/test_aot_group.py tests/preparation/test_forward_artifact_sharing.py. GPU preparation has not been rerun on this branch.

Compiled-forward loading retains an expanding catalog of guards and kernel
owners. Full collection after each binding rescans those live objects.

Use generation-zero collection after per-forward capture-state release in
single-rank and tensor-parallel preparation. Keep full collection at phase
boundaries and escalation below 8 GiB available host memory.

This removes repeated full-heap scans during preparation without changing
captured arithmetic or native execution. No isolated preparation speedup is
claimed.

Seventy-two CPU tests pass for low-memory promoted-cycle reclamation,
compiled guard ownership, distributed artifact sharing, and cached-catalog
owner release. GPU preparation has not been rerun on this branch.

Design-Signed-Off-By: Codex (GPT-6); design-review=cfcf
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