Metadata-Version: 2.4
Name: gpuarray
Version: 0.4.0
Summary: NumPy-like GPU array library that works on every GPU — NVIDIA, AMD, Intel, Apple Silicon. No CUDA required.
Author: Arnav Kewalram
License: MIT
Project-URL: Homepage, https://github.com/arnavkewalram/gpuarray
Project-URL: Repository, https://github.com/arnavkewalram/gpuarray
Keywords: gpu,numpy,webgpu,array,compute,cuda-alternative
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: <3.14,>=3.10
Description-Content-Type: text/markdown
Requires-Dist: wgpu>=0.19
Requires-Dist: numpy>=1.24
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"

# gpuarray

NumPy-like GPU array library that works on **every GPU** — NVIDIA, AMD, Intel, Apple Silicon. No CUDA required.

Powered by [WebGPU](https://www.w3.org/TR/webgpu/) via [wgpu-py](https://github.com/pygfx/wgpu-py). Uses Metal on macOS, Vulkan on Windows/Linux, and DirectX 12 on Windows.

## Install

```bash
pip install gpuarray
```

## Usage

```python
import gpuarray as gp

# Create arrays on GPU
a = gp.array([1, 2, 3, 4, 5])
b = gp.ones(5) * 3

# Operations run on GPU
c = a + b
d = a * b
e = gp.dot(a, b)

# Read back to CPU
print(c.to_numpy())  # [4. 5. 6. 7. 8.]

# Matrix multiply
A = gp.ones((512, 512))
B = gp.ones((512, 512))
C = gp.matmul(A, B)  # runs on GPU

# Reductions
total = gp.sum(a)
avg = gp.mean(a)

# Math functions
x = gp.exp(a)
y = gp.log(a)
z = gp.sqrt(a)
```

## Why?

**CuPy** only works on NVIDIA GPUs with CUDA. **gpuarray** works on every GPU:

| GPU | CuPy | gpuarray |
|-----|------|----------|
| NVIDIA (CUDA) | ✓ | ✓ |
| AMD (Vulkan) | ✗ | ✓ |
| Intel (Vulkan) | ✗ | ✓ |
| Apple Silicon (Metal) | ✗ | ✓ |

## Supported Operations

### Array Creation
`array`, `zeros`, `ones`, `arange`, `linspace`

### Elementwise Binary
`+`, `-`, `*`, `/`, `**` (with arrays or scalars)

### Elementwise Unary
`exp`, `log`, `sqrt`, `abs`, `neg`, `relu`, `sigmoid`, `tanh`

### Reductions
`sum`, `mean`, `max`, `min`

### Linear Algebra
`dot`, `matmul`

## Performance

Benchmarks on Intel UHD 630 (integrated GPU) vs NumPy (CPU with SIMD):

| Operation | NumPy | gpuarray | Speedup |
|-----------|-------|----------|---------|
| add 10M elements | 11.6ms | 19.9ms | 0.59x |
| matmul 512x512 | 1.3ms | 1.0ms | **1.22x** |
| sum 10M | 4.3ms | 12.5ms | 0.34x |

The integrated GPU shows speedup on compute-heavy operations (matmul). Discrete GPUs (RTX 3080, RX 7900, etc.) will show much larger speedups across all operations.

## Requirements

- Python 3.10-3.13
- Any GPU supported by WebGPU (most GPUs from 2015+)
- No CUDA, no special drivers — just your system GPU

## How It Works

1. Arrays are stored as WebGPU GPU buffers
2. Operations dispatch WGSL compute shaders to the GPU
3. Pipelines are cached — repeated operations don't recompile
4. Results stay on GPU until you call `.to_numpy()`

## License

MIT
