Skip to content

Add WebGPU compute shader support for GPU-accelerated matrix operations#84

Merged
InauguralPhysicist merged 2 commits intomainfrom
claude/eigenscript-gpu-support-01DVdYRP5RSwZ23qXkBhrGDr
Dec 7, 2025
Merged

Add WebGPU compute shader support for GPU-accelerated matrix operations#84
InauguralPhysicist merged 2 commits intomainfrom
claude/eigenscript-gpu-support-01DVdYRP5RSwZ23qXkBhrGDr

Conversation

@InauguralPhysicist
Copy link
Contributor

Implements a WebGPU/WGSL backend for EigenScript enabling GPU acceleration
in the browser:

Language changes:

  • Add 'gpu:' block syntax to lexer (GPU token)
  • Add GPUBlock AST node to parser for grouping GPU operations

WGSL Backend (wgsl_backend.py):

  • GPU-lite EigenValue struct (value + gradient only, 8 bytes)
  • Tiled matrix multiplication kernel with shared memory
  • Parallel reduction kernels for dot product and norm
  • Element-wise operation kernels (add, sub, mul, div, scale)
  • JavaScript/WebGPU runtime for browser integration

GPU-lite EigenValue model:

  • Unobserved GPU computation stays lean (f32 value + gradient)
  • Observation triggers device→host sync + full geometric promotion
  • Fits EigenScript's observer-effect semantics

Includes GPU playground demo and 18 passing tests.

Implements a WebGPU/WGSL backend for EigenScript enabling GPU acceleration
in the browser:

Language changes:
- Add 'gpu:' block syntax to lexer (GPU token)
- Add GPUBlock AST node to parser for grouping GPU operations

WGSL Backend (wgsl_backend.py):
- GPU-lite EigenValue struct (value + gradient only, 8 bytes)
- Tiled matrix multiplication kernel with shared memory
- Parallel reduction kernels for dot product and norm
- Element-wise operation kernels (add, sub, mul, div, scale)
- JavaScript/WebGPU runtime for browser integration

GPU-lite EigenValue model:
- Unobserved GPU computation stays lean (f32 value + gradient)
- Observation triggers device→host sync + full geometric promotion
- Fits EigenScript's observer-effect semantics

Includes GPU playground demo and 18 passing tests.
Comment on lines +9 to +15
from eigenscript.compiler.codegen.wgsl_backend import (
WGSLCodeGenerator,
WGSLKernel,
WGSLBuffer,
WGSLType,
generate_webgpu_runtime,
)
WGSLType,
generate_webgpu_runtime,
)
from eigenscript.parser.ast_builder import GPUBlock, Assignment, Identifier, Relation
"""

from dataclasses import dataclass
from typing import Dict, List, Optional, Set, Tuple
Comment on lines +22 to +38
from eigenscript.parser.ast_builder import (
ASTNode,
Literal,
Identifier,
BinaryOp,
UnaryOp,
Assignment,
FunctionDef,
Return,
Conditional,
Loop,
Relation,
Interrogative,
ListLiteral,
Index,
GPUBlock,
)
@InauguralPhysicist InauguralPhysicist merged commit 68a499b into main Dec 7, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants