Skip to content
mayresPublic
forked from SuriyaaMM/feather

About

Lower Precision Floating Point Operations

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

Feather

Feather is a high-performance emulation library that brings FP8 (E5M2 & E4M3) precision arithmetic to older GPU architectures (Ampere, Turing, Volta) that lack native hardware support.

By implementing custom bit-packing and optimized Triton kernels, Feather bypasses the memory bandwidth bottleneck, achieving 3x speedups over native PyTorch FP32 operations on memory-bound workloads.

Why Feather?

Modern deep learning benefits enormously from low-precision arithmetic, but native hardware support is gated behind the latest GPUs:

  • Native FP8: Exclusive to Ada Lovelace (RTX 40-series) and Hopper (H100).
  • Older Hardware (RTX 3090, A100, V100): Forced to use FP16 or FP32, leaving huge bandwidth potential on the table.
  • NOTE: Also supports FP16 packing.

Key Features

  • Software-Based FP8: Runs E5M2 and E4M3 on any CUDA GPU (RTX 20/30 series supported).
  • 3x Speedup: Validated 3.37x speedup on large GEMV operations.
  • Correctness:
    • E5M2: Direct bit-manipulation for maximum speed.
    • E4M3: Full software emulation (rebias + denorm flushing) for stability.

Benchmark Results

Performance measured on NVIDIA RTX 3050 (Ampere), comparing PyTorch Native (FP32) vs. Feather (FP8).

  • Task: Large Scale Matrix-Vector Multiplication (GEMV)

GEMV Performance

Matrix Shape PyTorch (FP32) Feather (FP8-E5M2) Feather (FP8-E4M3)
8192 x 8192 1,389 $\mu s$ 431 $\mu s$ 720 $\mu s$
16384 x 8192 2,862 $\mu s$ 841 $\mu s$ 1,368 $\mu s$
16384 x 16384 5,635 $\mu s$ 1,679 $\mu s$ 2,703 $\mu s$
  • Task: Flash Attention (FP8 vs FP16 vs FP32)

Flash Attention Performance

Performance comparison between torch.nn.functional.scaled_dot_product_attention (in FP32 and FP16) and Feather's custom Triton kernel (FP8).

Head Dim Sequence Length PyTorch (FP32) PyTorch (FP16) Feather (FP8)
64 128 64.9 $\mu s$ 60.9 $\mu s$ 35.7 $\mu s$
256 50.1 $\mu s$ 61.2 $\mu s$ 15.5 $\mu s$
512 85.0 $\mu s$ 93.7 $\mu s$ 26.0 $\mu s$
1024 252.4 $\mu s$ 307.5 $\mu s$ 50.6 $\mu s$
4096 3,707 $\mu s$ 4,738 $\mu s$ 600.1 $\mu s$
8192 15,604 $\mu s$ 18,827 $\mu s$ 2,056 $\mu s$
256 128 44.7 $\mu s$ 61.2 $\mu s$ 13.8 $\mu s$
256 46.8 $\mu s$ 62.7 $\mu s$ 57.2 $\mu s$
512 148.7 $\mu s$ 185.6 $\mu s$ 95.3 $\mu s$
1024 428.6 $\mu s$ 511.0 $\mu s$ 216.9 $\mu s$
4096 5,560 $\mu s$ 6,223 $\mu s$ 3,047 $\mu s$
8192 22,129 $\mu s$ 24,361 $\mu s$ 11,500 $\mu s$
512 128 44.2 $\mu s$ 61.4 $\mu s$ 14.2 $\mu s$
256 88.8 $\mu s$ 120.3 $\mu s$ 74.4 $\mu s$
512 191.4 $\mu s$ 236.8 $\mu s$ 121.5 $\mu s$
1024 702.1 $\mu s$ 813.3 $\mu s$ 269.1 $\mu s$
4096 8,966 $\mu s$ 9,724 $\mu s$ 3,090 $\mu s$
8192 33,290 $\mu s$ 35,965 $\mu s$ 9,887 $\mu s$

More results are in results/

Installation

Prerequisites

  • Python 3.10+
  • CUDA-capable GPU
  • uv package manager

Setup

# Clone the repository
git clone https://github.com/SuriyaaMM/feather
cd feather

# Install dependencies
uv sync 
source .venv/bin/activate

# Run benchmarks
uv run pytest benchmark/bench_FILE_NAME.py --benchmark-histogram=benchmark_results
# check benchmark/bench_*.py for filenames

Usage Example

import torch
import feather

# 1. Create standard data
matrix = torch.randn(16384, 16384, dtype=torch.float16, device='cuda')
vector = torch.randn(16384, dtype=torch.float16, device='cuda')

# 2. Pack data (Offline / Pre-processing step)
# Compresses memory usage by 2x (vs FP16) or 4x (vs FP32)
m_packed = feather.pack_fp8_tensor(matrix, mode="E5M2").cuda()
v_packed = feather.pack_fp8_tensor(vector, mode="E5M2").cuda()

# 3. Run Fast GEMV
# Returns FP32 result with FP32 accumulation
result = feather.gemv(m_packed, v_packed, original_shape=matrix.shape)

Roadmap

  • SDPA Kernels
  • Vulkan Support
  • Integration with Torch (Functional Forward Propagation)
  • Integration with Torch (Functional Backward Propagation)

License

MIT License - see LICENSE for details.

About

Lower Precision Floating Point Operations

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages