Skip to content

abhikumar63/AeroTensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AeroTensor 🔥🍎

A High-Performance, Zero-Copy C++ Math & Tensor Library for Apple Silicon.

AeroTensor is a strictly native, dependency-free C++20 library designed from the ground up to exploit the unified memory architecture of Apple's M-series chips. By directly bridging modern C++ with Apple's Metal Performance Shaders (MPS) and the Accelerate framework, it delivers hardware-accelerated tensor computations without the overhead of heavy third-party ecosystems.

🚀 Key Architectural Pillars

1. Zero-Copy Paradigm

At the heart of AeroTensor is a strict Zero-Copy principle. On traditional architectures, moving data between the CPU and discrete GPUs across the PCIe bus creates a massive bottleneck. AeroTensor exploits Apple Silicon’s unified memory by ensuring both the CPU and GPU operate on the exact same physical memory allocations.

  • All data resides natively in MTLBuffer objects configured with MTLResourceStorageModeShared.
  • Tensors are instantly accessible by both the overarching C++ application and the Metal compute units, ensuring deterministic, latency-free synchronization.

2. Pure Native Toolchain & Dependency-Free

AeroTensor imposes a strict zero third-party dependency rule for production code.

  • Written in pure C++20.
  • Built on foundational Apple frameworks: Accelerate for CPU-bound vectorized operations and Metal Performance Shaders (MPSGraph) for GPU-bound math processing logic.
  • Exception: Uses Catch2 via CMake FetchContent strictly for testing infrastructure, avoiding any raw dependencies checked into the repository.

3. Hardware-Accelerated Data Types

  • BFloat16 First: Floating-point computations natively target BFloat16, automatically taking advantage of hardware-acceleration vectors in modern M-series chips for superior data throughput, especially pertinent in deep learning mathematics.
  • Robust Abstraction: The library employs a templated N-dimensional Tensor class. It utilizes the PIMPL (Pointer to IMPLementation) idiom to seamlessly bridge C++ and Metal/Objective-C++ without leaking Objective-C headers into pure C++ translation units.

🧠 Math & Operator Design

The library isn't just about static container abstractions; it enforces highly optimized mathematical operations:

  • No Raw Loops: Our core constitution prohibits raw scalar loops for matrix operations. All linear algebraic and reduction operations are dispatched through highly optimized, hardware-specific kernels or MPSGraph.
  • Compute Graph Execution: Implements a dynamic ComputeGraph mechanism to track tensor operations and map complex equations to natively executable sequences efficiently on the GPU.
  • Strict Memory Management: Relies on rigorous smart pointer (std::shared_ptr) lifecycles and custom memory handling strategies to ensure deterministic allocation and deallocation of heavy tensor states.

🛠 Building the Project

Prerequisites

  • Apple Silicon Mac (M1/M2/M3/M4 series)
  • macOS 13.0+ (Ventura or newer recommended)
  • Xcode Command Line Tools (Clang with full C++20 support)
  • CMake 3.24+

Build Instructions

# Clone the repository
git clone https://github.com/abhikumar63/AeroTensor.git
cd AeroTensor

# Generate CMake build system and build
mkdir build && cd build
cmake ..
make -j$(sysctl -n hw.ncpu)

Running Tests

Our test suite strongly anchors on Catch2 to validate mathematical correctness, matrix multiplication (MatMul) bindings, and rigorous zero-copy assertions.

# Execute native tests 
ctest --output-on-failure
# Or run the executable directly for detailed output
./tests/test_matmul

🤝 Contributing & Guidelines

We welcome architectural enhancements, especially concerning the optimization of the MPSGraph execution contexts or extending BFloat16/Float16 standard library mathematical operators.

If contributing, please remember:

  1. Adhere strictly to the project constitution: Native Apple frameworks only, absolute Zero-Copy via MTLBuffer, and C++20 standards.
  2. Ensure Zero Objective-C++ leakage into public include/ headers.
  3. Validate all memory barriers between CPU/GPU access steps.

Harnessing the absolute limits of bare-metal Apple hardware.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors