Skip to content

Commit e924f6c

Browse files
committed
metal : revert unnecessary change
1 parent 7ebd4ac commit e924f6c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ggml-metal.metal

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef struct {
2929
typedef struct {
3030
half d; // delta
3131
half m; // min
32+
uint8_t qh[4]; // 5-th bit of quants
3233
uint8_t qs[QK5_1 / 2]; // nibbles / quants
3334
} block_q5_1;
3435

@@ -2210,17 +2211,17 @@ void dequantize_q4_0(device const block_q4_0 *xb, short il, thread type4x4 & reg
22102211
}
22112212

22122213
template <typename type4x4>
2213-
void dequantize_q4_1(device const block_q4_1 *xb, short il, thread type4x4 & reg) {
2214-
device const uint16_t * qs = ((device const uint16_t *)xb + 2);
2214+
void dequantize_q4_0(device const block_q4_0 *xb, short il, thread type4x4 & reg) {
2215+
device const uint16_t * qs = ((device const uint16_t *)xb + 1);
22152216
const float d1 = il ? (xb->d / 16.h) : xb->d;
22162217
const float d2 = d1 / 256.f;
2217-
const float m = xb->m;
2218+
const float md = -8.h * xb->d; // was: max / -8;
22182219
const ushort mask0 = il ? 0x00F0 : 0x000F;
22192220
const ushort mask1 = mask0 << 8;
22202221

22212222
for (int i=0;i<8;i++) {
2222-
reg[i/2][2*(i%2)+0] = ((qs[i] & mask0) * d1) + m;
2223-
reg[i/2][2*(i%2)+1] = ((qs[i] & mask1) * d2) + m;
2223+
reg[i/2][2*(i%2)+0] = d1 * (qs[i] & mask0) + md;
2224+
reg[i/2][2*(i%2)+1] = d2 * (qs[i] & mask1) + md;
22242225
}
22252226
}
22262227

0 commit comments

Comments
 (0)