Back to Research Index
RFC•
2024-09-15
•Author: Swasthik Shetty•Status: ACCEPTED

RFC 001: Lock-Free Strided Tensor Core and Memory Invariants

Foundational architectural specification for darkforest-core storage and striding

RFC 001: Lock-Free Strided Tensor Core and Memory Invariants

RFC 2024-09-15 Authors: Swasthik Shetty

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.

Key Finding: 64-byte alignment enables single-instruction AVX-512 aligned loads while signed strides unlock zero-copy reverse tensor operations.

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.