RFC 001: Lock-Free Strided Tensor Core and Memory Invariants
Abstract: This RFC establishes the memory invariants, alignment guarantees, and striding semantics for Dark Forest tensors. We propose a 64-byte aligned SIMD layout backed by atomic version counters and signed strides.
Motivation
Existing frameworks frequently couple tensor memory metadata with dynamic Python references or complex reference-counting hierarchies. Dark Forest decouples tensor metadata into small, stack-allocated descriptor structs (Shape, Strides) while storing raw data in a cache-aligned allocation buffer.
Specification
1. 64-Byte Alignment
All tensor allocations must be padded and aligned to 64-byte cache line boundaries. This guarantees:
- Zero cross-cache-line split penalties for 512-bit vector registers.
- Immediate eligibility for CUDA host-registered pinned memory mapping.
2. Atomic Version Counter
Each tensor maintains an AtomicU64 version counter. In-place mutating operations (add_, zero_) increment this counter. Autograd views retain the counter value at creation time; if the counter has changed during backward evaluation, a panic is raised with an explicit stale-view diagnostic.