@imaduddin/fastbrain 1.0.8 → 1.0.9
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
|
@@ -124,7 +124,7 @@ export class Softmax {
|
|
|
124
124
|
if(!encoder2) await this.gpu.submitQueue(encoder)
|
|
125
125
|
return this.dLogits
|
|
126
126
|
}
|
|
127
|
-
async crossEntropy(probs, target) {
|
|
127
|
+
async crossEntropy(probs, target, encoderMain) {
|
|
128
128
|
const encoder = encoderMain ? encoderMain : this.device.createCommandEncoder();
|
|
129
129
|
const tokenCount = probs.size / (this.vocabSize * Float32Array.BYTES_PER_ELEMENT);
|
|
130
130
|
if (!Number.isInteger(tokenCount) || tokenCount <= 0) {
|
package/src/shaders/LB.wgsl
CHANGED
|
@@ -47,7 +47,7 @@ fn main(@builtin(workgroup_id) wid: vec3<u32>, @builtin(local_invocation_id) lid
|
|
|
47
47
|
|
|
48
48
|
if (tokens > 0u) {
|
|
49
49
|
let idx = weightBase + j;
|
|
50
|
-
weight[idx] -= params.lr *
|
|
50
|
+
weight[idx] -= params.lr * grad;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -66,6 +66,6 @@ fn main(@builtin(workgroup_id) wid: vec3<u32>, @builtin(local_invocation_id) lid
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (tid == 0u && tokens > 0u) {
|
|
69
|
-
bias[outputIndex] -= params.lr *
|
|
69
|
+
bias[outputIndex] -= params.lr * sharedBias[0];
|
|
70
70
|
}
|
|
71
71
|
}
|