@mineproness/tensorloop 2.1.64 → 2.1.65
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
package/src/Softmax/index.js
CHANGED
|
@@ -123,7 +123,7 @@ export class Softmax {
|
|
|
123
123
|
const targetBuffer = await this.gpu.createBuffer(target.length * Float32Array.BYTES_PER_ELEMENT)
|
|
124
124
|
const loss = await this.gpu.createBuffer(4 * tokenCount)
|
|
125
125
|
const acc = await this.gpu.createBuffer(4 * 2)
|
|
126
|
-
await this.gpu.WriteBuffer(targetBuffer, new
|
|
126
|
+
await this.gpu.WriteBuffer(targetBuffer, new Uint32Array(target))
|
|
127
127
|
const bind = await this.device.createBindGroup({
|
|
128
128
|
layout: await this.lossPipline.getBindGroupLayout(0),
|
|
129
129
|
entries: [
|
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 += f32(dW);
|
|
46
46
|
}
|
|
47
|
-
let vClap = weight[index] - params.lr * max(-
|
|
47
|
+
let vClap = weight[index] - params.lr * max(- 15.0, min(15.0, dWeights));
|
|
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 += f32(outGradient[token * u32(params.vocabSize) + outputIndex]);
|
|
53
53
|
}
|
|
54
|
-
bias[outputIndex] = bias[outputIndex] - params.lr * max(-
|
|
54
|
+
bias[outputIndex] = bias[outputIndex] - params.lr * max(- 15.0, min(15.0, dBias));
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/shaders/RB.wgsl
CHANGED
package/src/shaders/RF.wgsl
CHANGED
package/src/shaders/SB.wgsl
CHANGED
|
@@ -27,6 +27,10 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
|
27
27
|
let vocabIndex = index % params.vocabSize;
|
|
28
28
|
let start = token * params.vocabSize;
|
|
29
29
|
let end = start + params.vocabSize;
|
|
30
|
+
let total = params.tokenCount * params.vocabSize;
|
|
31
|
+
if (index >= total) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
30
34
|
var targetIndex = targetToken[token];
|
|
31
35
|
let total: u32 = params.tokenCount * params.vocabSize;
|
|
32
36
|
output[index] = probs[index];
|