Skip to content

feat: WebGPU Backend, UI Overhaul, and Performance Optimizations#71

Open
sergeyplis wants to merge 37 commits intomasterfrom
webgpu
Open

feat: WebGPU Backend, UI Overhaul, and Performance Optimizations#71
sergeyplis wants to merge 37 commits intomasterfrom
webgpu

Conversation

@sergeyplis
Copy link
Copy Markdown
Contributor

@sergeyplis sergeyplis commented Dec 17, 2025

Description: This PR introduces a major upgrade to BrainChop, integrating a WebGPU backend for accelerated inference, refreshing the UI/UX, and significantly optimizing performance and memory usage for large models.

Key Changes
🚀 WebGPU & Inference Backend

  • WebGPU Support: Implemented a full WebGPU backend for faster client-side inference. Huge thanks to @spikedoanz and @wpmed92
  • Smart Fallback: Added logic to automatically attempt progressively "safer" execution modes (WebGPU → WebGL) to ensure stability across devices.
  • Universal Runners: Standardized runners to handle both WebGL and WebGPU contexts seamlessly.
  • Backend Indicator: Added a visual indicator in the UI to show which backend is currently active.

⚡ Performance & Optimization

  • Faster Normalization: Optimized Quantile Normalization to use sampling, significantly reducing pre-processing time.
  • WebGL Memory Management: Improved memory estimation and implemented a "chunked argmax" strategy. This allows large models (e.g., 104-class, 50-class) to run on standard WebGL backends without memory crashes.
  • Stability: Fixed memory leaks to improve reliability during repeated drag-and-drop operations.

🎨 UI/UX Improvements

  • Visual Overhaul: Comprehensive CSS updates, harmonizing toolbar styles, fonts, and spacing.
  • About Section: Added a new "About" window detailing privacy (local processing), keyboard shortcuts (C for Clip, V for View), and model icon legends.
  • Streamlined Interface: Removed the "Clip Plane" checkbox in favor of the 'C' keyboard shortcut to declutter the UI.
  • Visualization: Enforced specific colormaps (Copper) for brain extraction/masking models.

🛠️ Infrastructure & Diagnostics

  • Unified Diagnostics: Centralized diagnostic logging for both WebGL and WebGPU to assist in debugging.
  • Deployment Fixes: Resolved pathing issues (favicon, relative paths) for GitHub Pages deployment.
  • Console Logging: Enabled better console output in production builds for easier troubleshooting.

@sergeyplis sergeyplis self-assigned this Dec 17, 2025
@sergeyplis sergeyplis added the enhancement New feature or request label Dec 17, 2025
sergeyplis and others added 10 commits December 17, 2025 19:02
Remove the window.alert() that fires on WebGPU inference failure,
which was blocking the existing fallback chain from proceeding
smoothly. Now shows a non-blocking status message instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… GitHub Pages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
resources[] was block-scoped inside try{} so the finally{} cleanup never
ran. Moved it to the outer scope so GPU buffers are properly destroyed on
failure. Also added a 1s delay before WebGL fallback to let the GPU release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cleaner webgl fallback from webgpu
rolling back the parameterization that did not work, so it is served correctly
trying another root to quickly save brainchop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants