https://github.com/zanussbaum/surfgrad
webgpu autograd library
https://github.com/zanussbaum/surfgrad
autograd inference machine-learning tensor webgpu wsgl
Last synced: 3 months ago
JSON representation
webgpu autograd library
- Host: GitHub
- URL: https://github.com/zanussbaum/surfgrad
- Owner: zanussbaum
- License: apache-2.0
- Created: 2024-09-26T17:38:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-24T01:35:03.000Z (5 months ago)
- Last Synced: 2025-06-28T10:04:37.554Z (4 months ago)
- Topics: autograd, inference, machine-learning, tensor, webgpu, wsgl
- Language: TypeScript
- Homepage:
- Size: 613 KB
- Stars: 26
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# surfgrad
---

**surfgrad** is a high-performance, WebGPU-powered AutoGrad library that enables browser-based tensor operations with GPU acceleration.
Key Features:
- 🚀 Blazing-fast tensor operations leveraging WebGPU
- 🧠 Automatic differentiation for deep learning in the browser
- 🌐 Zero backend dependencies - runs entirely client-side
- 📦 Lightweight and easy to integrate into existing web projectsPerfect for running tensor operations and (in the future) machine learning models in the browser!
It's heavily inspired by [micrograd](https://github.com/karpathy/micrograd),
[tinygrad](https://github.com/tinygrad/tinygrad), and [PyTorch](https://github.com/pytorch/pytorch) and aims to leverage the power of WebGPU/WGSL for in-browser machine learning.## Usage
---
`surfgrad` supports basic tensor operations such as `matmul`, `mul`, `add`, `exp`, and `log`.
To use `surfgrad`,
```typescript
import { Tensor } from "surfgrad";const tensorA = new Tensor(new Float32Array([1, 2, 3, 4]), [2, 2], true);
const tensorB = new Tensor(new Float32Array([5, 6, 7, 8]), [2, 2], true);const [result, executionTime] = await tensorA.matmul(tensorB);
console.log(result);
await result.backward();
```
## Testing
---
`surfgrad` has unit tests and integration tests. To run the unit tests, run the following command:
```bash
npm run unit
```and to run the integration tests, run the following command:
```bash
npm run integration
```## Benchmarks
---
We also have benchmarks that can be helpful to demonstrate the performance of the `matmul` kernels.
To run the benchmarks, run the following command:```bash
npm run benchmark
```and open a browser to `localhost:9000`.
This will run the benchmarks for the library and display the results.
## Contributing
---
Contributions to `surfgrad` are welcome! If you'd like to contribute, please fork the repository and submit a pull request.
## License
---
SurfGrad is licensed under the Apache 2.0 License.