Arena allocator for ToT einsum (cases involving outer-Hadamard)#545
Open
zhihao-deng wants to merge 7 commits into
Open
Arena allocator for ToT einsum (cases involving outer-Hadamard)#545zhihao-deng wants to merge 7 commits into
zhihao-deng wants to merge 7 commits into
Conversation
- arena_sizeof_invariant_suite: drop platform-specific absolute baselines (328/16/248 were Apple-arm64/libc++ only); keep relative ImplLayoutAllocator == ImplLayoutMaster invariant + monostate static_asserts. - cont_engine: reset arena_plan_ after std::move into op_ so later reads see "no plan" rather than a moved-from optional. - arena_kernels: one-line intent note on trivial kernels' tight packing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces an "arena" pipeline that pre-allocate storage for ToT einsum, replacing per-cell heap allocations. Wired end-to-end through the contraction engine, einsum dispatch, and actual ops. Currently, permutation is not supported.
Contents
tensor/arena.h— one-shot bump allocator overstd::pmr::memory_resourcewith aliasingshared_ptrslab co-ownership, plus a runtime kill switch (detail::arena_disabled()) for safe fallback.tensor/arena_kernels.h— ToT trivial-op kernels (scale, add, etc.) that allocate inner cells contiguously in the arena slab.tensor/arena_einsum.h— regime-A (outer-Hadamard)ContractionArenaPlan: derives result outer/inner ranges and constructs non-empty inner cells in a single slab; supportsleft_range/right_range/gemm_result_rangeinner-shape derivation.expressions/cont_engine.h— threads an optional arena plan into the contraction op; plan isstd::moved intoop_and the local optional is reset so later reads see "no plan".einsum/tiledarray.h— hooks regime-A arena dispatch into the einsum entry point.tensor/tensor.h+tile_op/contract_reduce.h— route ToT trivial ops and contract-reduce through the arena kernels when a plan is present.Tests
tests/arena.cpp— allocator + slice/claim semanticstests/arena_kernels.cpp— ToT trivial-op kernelstests/arena_tot_trivial.cpp— tensor-level routingtests/arena_einsum_unit_suite.cpp— regime-A plan + dispatchtests/arena_sizeof_invariant_suite.cpp— layout invariantstests/cases/case_hec_{e,ec,h,scale}.cpp+case_4d_e.cpp— end-to-end contraction-engine cases (Hadamard / contraction / scale shapes)