@mineproness/tensorloop 2.2.4 → 2.2.6
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/Softmax/index.js +1 -1
- package/src/shaders/LB.wgsl +2 -2
package/package.json
CHANGED
package/src/Softmax/index.js
CHANGED
|
@@ -119,7 +119,7 @@ export class Softmax {
|
|
|
119
119
|
if(!this.acc) this.acc = await this.gpu.createBuffer(4 * 1)
|
|
120
120
|
await this.gpu.WriteBuffer(targetBuffer, new Uint32Array(target))
|
|
121
121
|
const bindGroup1 = await this.gpu.createBindGroup(this.lossPipline, 0, [probs.mainBuffer, targetBuffer, this.loss, this.paramsForward])
|
|
122
|
-
const bindGroup2 = await this.gpu.createBindGroup(this.accPipline, 0 , [this.paramsForward, probs.mainBuffer,
|
|
122
|
+
const bindGroup2 = await this.gpu.createBindGroup(this.accPipline, 0 , [this.paramsForward, probs.mainBuffer, this.acc, targetBuffer])
|
|
123
123
|
await this.gpu.RunPipline(encoder, this.lossPipline, bindGroup1, Math.ceil((tokenCount / 4)))
|
|
124
124
|
await this.gpu.RunPipline(encoder, this.accPipline, bindGroup2, 1)
|
|
125
125
|
await this.gpu.submitQueue(encoder)
|
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, -1.0, 1.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, -1.0, 1.0);
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
}
|