@mineproness/tensorloop 2.2.6 → 2.2.7

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.2.6",
3
+ "version": "2.2.7",
4
4
  "description": "Raw-JAVASCRIPT Based Matirx and AI LLM Package called Tensorloop.",
5
5
  "keywords": [
6
6
  "ai",
@@ -181,7 +181,7 @@ export class Linear {
181
181
  })
182
182
  // console.log((await this.gpu.readBuffer(this.input.size, this.input))[0])
183
183
  await this.gpu.RunPipline(encoder, this.dInputBackward, bind2, Math.ceil((this.embeddingSize * tokenCount) / 256));
184
- await this.gpu.RunPipline(encoder, this.backwardPipline, bind, Math.ceil((this.vocabSize * tokenCount) / 256));
184
+ await this.gpu.RunPipline(encoder, this.backwardPipline, bind, Math.ceil((this.vocabSize * this.embeddingSize) / 256));
185
185
  await this.device.queue.submit([encoder.finish()])
186
186
  return this.gradientBuffer
187
187
 
@@ -47,7 +47,7 @@ export class RMSNorm {
47
47
  }
48
48
  let context = input.size / (this.embeddingSize * 4)
49
49
  if (!this.rms) this.rms = await this.op.createBuffer(4 * context);
50
- if (this.rms.size !== 4 * context * this.embeddingSize) {
50
+ if (this.rms.size !== 4 * context) {
51
51
  this.rms.destroy()
52
52
  this.rms = await this.op.createBuffer(4 * context);
53
53
  }
@@ -44,14 +44,16 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
44
44
  let dW = inputValue * gradient;
45
45
  dWeights += dW;
46
46
  }
47
- let vClap = weight[index] - params.lr * clamp(dWeights, -1.0, 1.0);
47
+ dWeights /= params.tokenCount;
48
+ let vClap = weight[index] - params.lr * clamp(dWeights, -8.0, 8.0);
48
49
  weight[index] = vClap;
49
50
  if (inputIndex == 0u) {
50
51
  var dBias = 0.0;
51
52
  for (var token = 0u; token < u32(params.tokenCount); token++) {
52
53
  dBias += outGradient[token * u32(params.vocabSize) + outputIndex];
53
54
  }
54
- bias[outputIndex] = bias[outputIndex] - params.lr * clamp(dBias, -1.0, 1.0);
55
+ dBias /= params.tokenCount;
56
+ bias[outputIndex] = bias[outputIndex] - params.lr * clamp(dBias, -8.0, 8.0);
55
57
 
56
58
  }
57
59
  }