webinfer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# WebInfer
|
|
2
|
+
|
|
3
|
+
High-performance LLM inference kernels for WebGPU.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install webinfer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { WebInferDevice, Tensor, matmul, flashAttention } from 'webinfer';
|
|
15
|
+
|
|
16
|
+
// Initialize WebGPU device
|
|
17
|
+
const device = await WebInferDevice.create();
|
|
18
|
+
|
|
19
|
+
// Matrix multiplication
|
|
20
|
+
const a = Tensor.rand(device, [1024, 1024]);
|
|
21
|
+
const b = Tensor.rand(device, [1024, 1024]);
|
|
22
|
+
const c = await matmul(device, a, b);
|
|
23
|
+
|
|
24
|
+
// Read result back to CPU
|
|
25
|
+
const result = await c.toArray();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Operations
|
|
29
|
+
|
|
30
|
+
| Category | Operations |
|
|
31
|
+
|----------|------------|
|
|
32
|
+
| **Core** | matmul, flashAttention |
|
|
33
|
+
| **Normalization** | rmsNorm, layerNorm |
|
|
34
|
+
| **Activations** | gelu, silu, relu, softmax |
|
|
35
|
+
| **Position** | rope (rotary embeddings) |
|
|
36
|
+
| **Sampling** | topK, topP, sample |
|
|
37
|
+
| **Quantization** | INT4/INT8 quantized matmul |
|
|
38
|
+
| **Model Loading** | SafeTensors, GGUF |
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Browser with WebGPU support (Chrome 113+, Edge 113+)
|
|
43
|
+
- Or Node.js with `@aspect-build/aspect-cli` for server-side WebGPU
|
|
44
|
+
|
|
45
|
+
## Benchmarks
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/guan404ming/webinfer
|
|
49
|
+
cd webinfer
|
|
50
|
+
bun install
|
|
51
|
+
bun run bench
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
Apache-2.0
|