@mineproness/tensorloop 2.2.6 → 2.2.8
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 +1 -1
- package/src/Linear/index.js +1 -1
- package/src/RMSNorm/index.js +1 -1
- package/src/shaders/LB.wgsl +2 -2
package/package.json
CHANGED
package/src/Linear/index.js
CHANGED
|
@@ -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 *
|
|
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
|
|
package/src/RMSNorm/index.js
CHANGED
|
@@ -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
|
|
50
|
+
if (this.rms.size !== 4 * context) {
|
|
51
51
|
this.rms.destroy()
|
|
52
52
|
this.rms = await this.op.createBuffer(4 * context);
|
|
53
53
|
}
|
package/src/shaders/LB.wgsl
CHANGED
|
@@ -44,14 +44,14 @@ 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, -
|
|
47
|
+
let vClap = weight[index] - params.lr * clamp(dWeights, -8.0, 8.0);
|
|
48
48
|
weight[index] = vClap;
|
|
49
49
|
if (inputIndex == 0u) {
|
|
50
50
|
var dBias = 0.0;
|
|
51
51
|
for (var token = 0u; token < u32(params.tokenCount); token++) {
|
|
52
52
|
dBias += outGradient[token * u32(params.vocabSize) + outputIndex];
|
|
53
53
|
}
|
|
54
|
-
bias[outputIndex] = bias[outputIndex] - params.lr * clamp(dBias, -
|
|
54
|
+
bias[outputIndex] = bias[outputIndex] - params.lr * clamp(dBias, -8.0, 8.0);
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
}
|