Locate one expert's 2D matrix inside a 3D GGUF expert tensor. */
| 5527 | fprintf(stderr, "ds4: n-gram embeddings must use original BF16, got type %u\n", t); |
| 5528 | exit(1); |
| 5529 | } |
| 5530 | if (w->ple_embd->ndim != 2 || w->ple_embd->dim[0] != DS4_N_PLE_HEAD_DIM || |
| 5531 | w->ple_embd->dim[1] < g_ds4_qwen4_ple.n_rows) { |
| 5532 | fprintf(stderr, "ds4: per_layer_token_embd layout [%" PRIu64 ", %" PRIu64 "] does not " |
| 5533 | "cover %u x %" PRIu64 " hash rows\n", |
| 5534 | w->ple_embd->dim[0], w->ple_embd->dim[1], DS4_N_PLE_HEAD_DIM, |
| 5535 | g_ds4_qwen4_ple.n_rows); |
| 5536 | exit(1); |
| 5537 | } |
| 5538 | } |
| 5539 | |
| 5540 | const bool have_output = weights_have_output_head(w); |
| 5541 | if (require_output && !have_output) ds4_die("required output head tensors are missing"); |
| 5542 | if (weights_have_partial_output_head(w) && !have_output) ds4_die("partial output head in GGUF"); |
| 5543 | if (have_output) { |
| 5544 | tensor_expect_layout(w->output_hc_norm, DS4_TENSOR_F32, 1, hc_dim, 0, 0); |
| 5545 | tensor_expect_qwen4_dense_layout(w->output_hc_down, 2, hc_dim, DS4_N_HC_LOWRANK, 0); |
| 5546 | tensor_expect_qwen4_dense_layout(w->output_hc_up, 2, DS4_N_HC_LOWRANK, hc_dim, 0); |
| 5547 | tensor_expect_qwen4_dense_layout(w->output, 2, DS4_N_EMBD, DS4_N_VOCAB, 0); |
| 5548 | } |
| 5549 | |
| 5550 | for (uint32_t il = layer_start; il <= layer_end; il++) { |
| 5551 | const ds4_layer_weights *l = &w->layer[il]; |
| 5552 | if (!weights_qwen4_layer_has_required(l, il)) { |
no test coverage detected