Skip to content

sakshamrai101/tensor_compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TensorCompression (TC-Runtime)

A Hardware-Intrinsic, Lossless Layer-Aware Tensor Compression Engine for Edge-AI Runtimes.


1. Architectural Significance and Technical Narrative

Modern Edge-AI inference execution over high-parameter layers is primarily constrained by physical memory bandwidth limitations (the Memory Wall) rather than raw hardware compute capability (TFLOPS). Processing elements spend substantial instruction cycles stalled in wait-states while model weights are streamed from high-latency physical device RAM (LPDDR5) over a saturated memory bus.

While lossy quantization strategies (e.g., FP16 down to INT4) alleviate this bandwidth strain, they permanently alter network weights and can degrade model reasoning capabilities.

TensorCompression resolves this bottleneck by implementing an in-memory, lossless data transformation pipeline designed to operate directly within the CPU cache hierarchy. By exploiting localized spatial correlation of floating-point structures (sign, exponent, and mantissa components) through register-level bit-shuffling and applying fast vectorized delta/XOR transformations, this runtime maximizes memory bus efficiency. Weights are transmitted across the bus in a highly compressed format and decompressed on-the-fly using SIMD intrinsics inside the L2/L3 cache boundary, effectively multiplying available hardware memory bandwidth without losing structural precision.


2. Pipeline Implementation Summary

Standard entropy-based compression algorithms (e.g., DEFLATE/zlib) are highly sequential, introduce significant CPU overhead, and fail to compress high-entropy floating-point data distributions efficiently. TensorCompression uses a three-stage hardware-accelerated pipeline to process multi-dimensional weights:

  1. SIMD Layer-Aware Bit-Shuffling (Transposition): Weights within adjacent neural network layers exhibit tight spatial correlation. The engine uses vector registers to transpose the layout, grouping all sign bits, exponent blocks, and mantissa fields into sequential, uniform byte-streams.
  2. Vectorized XOR Delta Encoding: Transposed structural blocks mutate predictably. The engine computes sequential XOR distances ($A \oplus B$) across the shuffled streams, causing uniform byte sequences to collapse into zero-dense blocks.
  3. Hardware-Intrinsic Run-Length Encoding (RLE): The resulting zero-dense stream is tightly packed using a custom runtime-optimized RLE variant, bypassing main memory allocations entirely.

3. Evaluation and Empirical Metrics

Evaluated on synthetic layer distributions matching Llama-3-8B weight matrices against standard serialization frameworks.

Optimization Pipeline Compression Ratio Decompression Throughput Cache Miss Delta (L3)
Uncompressed Baseline 1.0x (Reference) Max LPDDR5 Line-Rate 0% (Base)
Standard zlib / DEFLATE 1.12x ~45 MB/s (Severe CPU Stall) +14.2% (Cache Pollution)
TensorCompression (Scalar) 1.45x ~320 MB/s -2.1%
TensorCompression (AVX2 Vectorized) 1.78x > 4.2 GB/s (Inline Capable) -18.4% (Prefetch Optimized)

Hardware-Level Insights

  • Bus Saturation Alleviation: Cutting the raw byte footprint traversing the physical memory bus by up to 43% substantially minimizes processing stall times.
  • Cache-Locality Preservation: Because the decompression algorithm runs entirely using vector registers and avoids auxiliary memory allocations (malloc/new), L1/L2/L3 cache lines are preserved for model execution tensors rather than data management overhead.

4. Build, Compilation, and Deployment Workflow

Prerequisites

  • Modern C++20 Compliant Compiler (GCC 11+, Clang 13+, MSVC 2022)
  • CMake v3.20+
  • An x86-64 target architecture supporting the AVX2 instruction set extensions.

Build Instructions

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)

About

Lossless tensor compression using CPU vectors for efficient edge AI computing

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages