Skip to content

Commit e668b74

Browse files
Merge pull request #225 from CSSLab/claude/optimize-onnx-download-sR01t
Move ONNX and Stockfish NNUE weights to GitHub Releases
2 parents c2afeea + bae8f0d commit e668b74

6 files changed

Lines changed: 14 additions & 3 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ yarn-error.log*
3636

3737
# typescript
3838
*.tsbuildinfo
39+
40+
# Large model weights - hosted on GitHub Releases, not committed to the repo
41+
/public/maia2/*.onnx
42+
/public/stockfish/*.nnue

public/maia2/maia_rapid.onnx

-88.9 MB
Binary file not shown.
-71.4 MB
Binary file not shown.
-3.36 MB
Binary file not shown.

src/contexts/MaiaEngineContext.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export const MaiaEngineContextProvider: React.FC<{ children: ReactNode }> = ({
3131

3232
const maia = useMemo(() => {
3333
const model = new Maia({
34-
model: '/maia2/maia_rapid.onnx',
34+
model:
35+
process.env.NEXT_PUBLIC_MAIA_MODEL_URL ??
36+
'https://raw.githubusercontent.com/CSSLab/maia-platform-frontend/e23a50e/public/maia2/maia_rapid.onnx',
3537
setStatus: setStatus,
3638
setProgress: setProgress,
3739
setError: setError,

src/lib/engine/stockfish.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,15 @@ const setupStockfish = (): Promise<StockfishWeb> => {
350350
locateFile: (name: string) => `/stockfish/${name}`,
351351
})
352352
.then(async (instance: StockfishWeb) => {
353+
// NNUE weights served via raw.githubusercontent.com permalink (CORS + COEP compatible).
354+
// Override with NEXT_PUBLIC_STOCKFISH_NNUE_BASE_URL for self-hosted deployments.
355+
const nnueBaseUrl =
356+
process.env.NEXT_PUBLIC_STOCKFISH_NNUE_BASE_URL ??
357+
'https://raw.githubusercontent.com/CSSLab/maia-platform-frontend/e23a50e/public/stockfish'
353358
// Load NNUE models before resolving
354359
Promise.all([
355-
fetch(`/stockfish/${instance.getRecommendedNnue(0)}`),
356-
fetch(`/stockfish/${instance.getRecommendedNnue(1)}`),
360+
fetch(`${nnueBaseUrl}/${instance.getRecommendedNnue(0)}`),
361+
fetch(`${nnueBaseUrl}/${instance.getRecommendedNnue(1)}`),
357362
])
358363
.then((responses) => {
359364
return Promise.all([

0 commit comments

Comments
 (0)