a dense matrix for q8s_gemv: Q8_0 slices move to the split layout (other types stay as they are)
| 435 | } |
| 436 | // a dense matrix for q8s_gemv: Q8_0 slices move to the split layout (other types stay as they are) |
| 437 | DW dense(DW w) { |
| 438 | if (w.type != T_Q8_0) return w; |
| 439 | const size_t bytes = (size_t) w.n_out * w.row_bytes, nblk = bytes / 34; |
| 440 | std::vector<uint8_t> h(bytes); |
| 441 | ck(cudaMemcpy(h.data(), w.p, bytes, cudaMemcpyDeviceToHost), "dense: download"); |
| 442 | if (store) store->free_dev(c.dev, w.p, bytes); // the upload just before: its room is used again |
| 443 | else ck(cudaFree(w.p), "dense: free"); |
| 444 | if (track) track->erase(std::remove(track->begin(), track->end(), (void*) w.p), track->end()); // not freed twice |
| 445 | c.bytes -= bytes; |
| 446 | std::vector<int8_t> q(nblk * 32); |
| 447 | std::vector<uint16_t> d(nblk); |
| 448 | for (size_t b = 0; b < nblk; ++b) { |
| 449 | std::memcpy(&d[b], &h[b * 34], 2); |
| 450 | std::memcpy(&q[b * 32], &h[b * 34 + 2], 32); |
| 451 | } |
| 452 | w.p = nullptr; |
| 453 | w.s.q = put<int8_t>(q.data(), q.size()); |
| 454 | w.s.d = put<uint16_t>(d.data(), d.size() * 2); |
| 455 | return w; |
| 456 | } |
| 457 | // bf16 values [n] as the split int8 layout (per 32 values: d = amax / 127, ggml's rounding) |
| 458 | Q8S q8split_bf16(const uint16_t* v, size_t n) { |
| 459 | std::vector<int8_t> q(n); |
no test coverage detected