@danielsimonjr/mathts-matrix 0.3.2 → 0.4.1
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/dist/index.js +29 -5
- package/package.json +70 -70
package/dist/index.js
CHANGED
|
@@ -1461,11 +1461,25 @@ init_DenseMatrix();
|
|
|
1461
1461
|
init_SparseMatrix();
|
|
1462
1462
|
|
|
1463
1463
|
// src/backends/Backend.ts
|
|
1464
|
+
import { GPU_MIN_ELEMENTS } from "@danielsimonjr/mathts-gpu";
|
|
1464
1465
|
var DEFAULT_BACKEND_HINTS = {
|
|
1465
1466
|
wasmThreshold: 1e3,
|
|
1466
1467
|
// > 1000 elements
|
|
1467
|
-
|
|
1468
|
-
//
|
|
1468
|
+
// ⚠️ THIS ROUTE IS DORMANT. Both GPU branches gate on `backendRegistry.has('gpu')`,
|
|
1469
|
+
// and NOTHING ever registers a 'gpu' backend: `register-backends.ts` registers
|
|
1470
|
+
// only `jsBackend` + `wasmBackend`, and no other call site calls `register()`.
|
|
1471
|
+
// (`GPUMatrixBackend` does declare `type = 'gpu'` — it is simply never handed to
|
|
1472
|
+
// the registry.) So `has('gpu')` is permanently false, no matrix op has ever been
|
|
1473
|
+
// selected onto the GPU through the BackendManager, and this number has never been
|
|
1474
|
+
// read on a live path.
|
|
1475
|
+
//
|
|
1476
|
+
// GPU matrix work reaches the device a different way: `gpuMatmul` and friends
|
|
1477
|
+
// call `gpuMatrixBackend` directly, which gates on its own `minElements`
|
|
1478
|
+
// (= GPU_MIN_ELEMENTS). This value is aligned to that single canonical
|
|
1479
|
+
// threshold so the codebase no longer carries four divergent GPU magic numbers
|
|
1480
|
+
// (it was 100_000 here, 50_000 / 10_000 / 200_000 in BackendManager, against a
|
|
1481
|
+
// live 65_536) — a trap for whoever eventually wires this route up.
|
|
1482
|
+
gpuThreshold: GPU_MIN_ELEMENTS,
|
|
1469
1483
|
preferredBackend: "js"
|
|
1470
1484
|
};
|
|
1471
1485
|
var BackendRegistry = class {
|
|
@@ -3703,6 +3717,9 @@ function createGPUMatrixBackend(config) {
|
|
|
3703
3717
|
return new GPUMatrixBackend(config);
|
|
3704
3718
|
}
|
|
3705
3719
|
|
|
3720
|
+
// src/backends/BackendManager.ts
|
|
3721
|
+
import { GPU_MIN_ELEMENTS as GPU_MIN_ELEMENTS2 } from "@danielsimonjr/mathts-gpu";
|
|
3722
|
+
|
|
3706
3723
|
// src/config.ts
|
|
3707
3724
|
var DEFAULT_CONFIG3 = {
|
|
3708
3725
|
backends: {
|
|
@@ -3773,11 +3790,18 @@ var DEFAULT_EXTENDED_HINTS = {
|
|
|
3773
3790
|
// matmul: the SIMD-WASM kernel wins from ~256 elems (16²), solidly 1.3–2.2× (measured,
|
|
3774
3791
|
// tools/benchmarks/matmul-threshold.mjs); below that copy/alloc overhead dominates (8²
|
|
3775
3792
|
// loses, 12² marginal). Dropped 500→256 to stop forcing 16²–22² matmuls onto JS.
|
|
3776
|
-
|
|
3777
|
-
|
|
3793
|
+
// ⚠️ Every `gpu:` threshold below is DORMANT — `selectBackend` gates the GPU
|
|
3794
|
+
// branch on `backendRegistry.has('gpu')`, and no 'gpu' backend is ever
|
|
3795
|
+
// registered (register-backends.ts registers js + wasm only). They are aligned
|
|
3796
|
+
// to the single canonical GPU_MIN_ELEMENTS rather than left as four divergent
|
|
3797
|
+
// magic numbers (50_000 / 10_000 / 200_000 against a live 65_536), which would
|
|
3798
|
+
// mislead whoever wires this route up. GPU matrix work currently reaches the
|
|
3799
|
+
// device via `gpuMatmul` -> `gpuMatrixBackend`, not through this manager.
|
|
3800
|
+
multiply: { wasm: 256, gpu: GPU_MIN_ELEMENTS2 },
|
|
3801
|
+
decomposition: { wasm: 100, gpu: GPU_MIN_ELEMENTS2 },
|
|
3778
3802
|
// transpose WASM is retired (memory-bound, lost 4–6×) — WASMBackend.transpose always uses
|
|
3779
3803
|
// JS regardless of this gate; kept high so the manager doesn't even select the WASM backend.
|
|
3780
|
-
transpose: { wasm: 2e3, gpu:
|
|
3804
|
+
transpose: { wasm: 2e3, gpu: GPU_MIN_ELEMENTS2 }
|
|
3781
3805
|
},
|
|
3782
3806
|
autoSIMD: true,
|
|
3783
3807
|
fallbackOnError: true
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@danielsimonjr/mathts-matrix",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Matrix operations for MathTS with WASM/WebGPU backend support",
|
|
5
|
-
"author": "Daniel Simon Jr.",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"module": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"README.md"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsup src/index.ts --format esm --dts --clean && node scripts/copy-wasm.mjs",
|
|
23
|
-
"copy:wasm": "node scripts/copy-wasm.mjs",
|
|
24
|
-
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
25
|
-
"test": "vitest run",
|
|
26
|
-
"test:watch": "vitest",
|
|
27
|
-
"test:coverage": "vitest run --coverage",
|
|
28
|
-
"typecheck": "tsc --noEmit",
|
|
29
|
-
"lint": "eslint src --ext .ts",
|
|
30
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
31
|
-
"clean": "rm -rf dist",
|
|
32
|
-
"build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake && node scripts/copy-wasm.mjs"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@danielsimonjr/mathts-core": "^0.6.0",
|
|
36
|
-
"@danielsimonjr/mathts-gpu": "^0.
|
|
37
|
-
"@danielsimonjr/mathts-parallel": "^0.3.4"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/node": "^25.5.2",
|
|
41
|
-
"tsup": "^8.0.0",
|
|
42
|
-
"typescript": "^5.3.0",
|
|
43
|
-
"vitest": "^4.1.5",
|
|
44
|
-
"@webgpu/types": "^0.1.67"
|
|
45
|
-
},
|
|
46
|
-
"publishConfig": {
|
|
47
|
-
"access": "public"
|
|
48
|
-
},
|
|
49
|
-
"repository": {
|
|
50
|
-
"type": "git",
|
|
51
|
-
"url": "https://github.com/danielsimonjr/mathts",
|
|
52
|
-
"directory": "matrix"
|
|
53
|
-
},
|
|
54
|
-
"keywords": [
|
|
55
|
-
"math",
|
|
56
|
-
"matrix",
|
|
57
|
-
"linear-algebra",
|
|
58
|
-
"typescript",
|
|
59
|
-
"wasm",
|
|
60
|
-
"webgpu"
|
|
61
|
-
],
|
|
62
|
-
"peerDependencies": {
|
|
63
|
-
"@webgpu/types": "^0.1.67"
|
|
64
|
-
},
|
|
65
|
-
"peerDependenciesMeta": {
|
|
66
|
-
"@webgpu/types": {
|
|
67
|
-
"optional": true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielsimonjr/mathts-matrix",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Matrix operations for MathTS with WASM/WebGPU backend support",
|
|
5
|
+
"author": "Daniel Simon Jr.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup src/index.ts --format esm --dts --clean && node scripts/copy-wasm.mjs",
|
|
23
|
+
"copy:wasm": "node scripts/copy-wasm.mjs",
|
|
24
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"test:coverage": "vitest run --coverage",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"lint": "eslint src --ext .ts",
|
|
30
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
31
|
+
"clean": "rm -rf dist",
|
|
32
|
+
"build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake && node scripts/copy-wasm.mjs"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@danielsimonjr/mathts-core": "^0.6.0",
|
|
36
|
+
"@danielsimonjr/mathts-gpu": "^0.2.0",
|
|
37
|
+
"@danielsimonjr/mathts-parallel": "^0.3.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^25.5.2",
|
|
41
|
+
"tsup": "^8.0.0",
|
|
42
|
+
"typescript": "^5.3.0",
|
|
43
|
+
"vitest": "^4.1.5",
|
|
44
|
+
"@webgpu/types": "^0.1.67"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/danielsimonjr/mathts",
|
|
52
|
+
"directory": "matrix"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"math",
|
|
56
|
+
"matrix",
|
|
57
|
+
"linear-algebra",
|
|
58
|
+
"typescript",
|
|
59
|
+
"wasm",
|
|
60
|
+
"webgpu"
|
|
61
|
+
],
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@webgpu/types": "^0.1.67"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"@webgpu/types": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|