@mineproness/tensorloop 2.1.74 → 2.1.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mineproness/tensorloop",
3
- "version": "2.1.74",
3
+ "version": "2.1.75",
4
4
  "description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called Tensorloop.",
5
5
  "keywords": [
6
6
  "ai",
@@ -18,21 +18,21 @@ var<workgroup> partial: array<f32, 64>;
18
18
 
19
19
  const D: u32 = %embeddingSize%u;
20
20
  const EPSILON: f32 = 1e-6;
21
+
21
22
  @compute @workgroup_size(64)
22
23
  fn main(@builtin(local_invocation_index) lid: u32, @builtin(workgroup_id) wid: vec3<u32>) {
23
- let dim = wid.x * 64u + local_invocation_index;
24
- if (dim >= D) {
25
- return;
26
- }
24
+ let dim = wid.x * 64u + lid;
27
25
  let T = arrayLength(&sumSquares);
28
- let lr = params[0];
29
26
  var sum = 0.0;
30
- var token = lid;
31
- while (token < T) {
32
- let idx = token * D + dim;
33
- let r = sqrt(sumSquares[token] / f32(D) + EPSILON);
34
- sum += gradOutput[idx] * input[idx] / r;
35
- token += 64u;
27
+ if (dim < D) {
28
+ var token = lid;
29
+
30
+ while (token < T) {
31
+ let idx = token * D + dim;
32
+ let r = sqrt(sumSquares[token] / f32(D) + EPSILON);
33
+ sum += gradOutput[idx] * input[idx] / r;
34
+ token += 64u;
35
+ }
36
36
  }
37
37
  partial[lid] = sum;
38
38
  workgroupBarrier();
@@ -47,7 +47,8 @@ fn main(@builtin(local_invocation_index) lid: u32, @builtin(workgroup_id) wid: v
47
47
  workgroupBarrier();
48
48
  stride /= 2u;
49
49
  }
50
- if (lid == 0u) {
51
- gamma[dim] -= lr * partial[0];
50
+ if (lid == 0u && wid.x * 64u < D) {
51
+ let dimToUpdate = wid.x * 64u;
52
+ gamma[dimToUpdate] -= params[0] * partial[0];
52
53
  }
53
54
  }