Streaming compressor update for one token. It projects kv/score rows, * updates the rolling state, and emits a compressed KV row on ratio boundaries. */
| 8663 | uint64_t *bytes_out) { |
| 8664 | if (bytes_out) *bytes_out = 0; |
| 8665 | if (!w || !bytes_out) return false; |
| 8666 | |
| 8667 | ds4_model_map_span_vec spans; |
| 8668 | const bool include_token = |
| 8669 | weights_layer_has_required(&w->layer[0], 0); |
| 8670 | if (!weights_model_map_decode_static_spans(w, |
| 8671 | include_token, |
| 8672 | weights_have_output_head(w), |
| 8673 | &spans)) { |
| 8674 | return false; |
| 8675 | } |
| 8676 | *bytes_out = model_map_span_vec_total_bytes(&spans); |
| 8677 | free(spans.v); |
| 8678 | return true; |
| 8679 | } |
| 8680 | |
| 8681 | static DS4_MAYBE_UNUSED bool weights_model_map_token_spans( |
| 8682 | const ds4_weights *w, |
| 8683 | ds4_model_map_span_vec *spans) { |
| 8684 | if (!w || !spans) return false; |
| 8685 | memset(spans, 0, sizeof(*spans)); |
| 8686 | model_map_span_vec_include_one(spans, w->token_embd); |
| 8687 | return model_map_span_vec_finish(spans); |
| 8688 | } |
| 8689 | |
| 8690 | static DS4_MAYBE_UNUSED bool weights_model_map_output_spans( |
| 8691 | const ds4_weights *w, |
| 8692 | ds4_model_map_span_vec *spans) { |
| 8693 | if (!w || !spans) return false; |
| 8694 | memset(spans, 0, sizeof(*spans)); |
| 8695 | model_map_span_vec_include_output(spans, w); |
| 8696 | return model_map_span_vec_finish(spans); |
| 8697 | } |
| 8698 | |
| 8699 | static void mtp_weights_bind(ds4_mtp_weights *w, const ds4_model *m) { |
| 8700 | memset(w, 0, sizeof(*w)); |
| 8701 | |
| 8702 | w->hc_head_base = required_tensor(m, "mtp.0.hc_head_base.weight"); |
| 8703 | w->hc_head_fn = required_tensor(m, "mtp.0.hc_head_fn.weight"); |
| 8704 | w->hc_head_scale = required_tensor(m, "mtp.0.hc_head_scale.weight"); |
| 8705 | w->e_proj = required_tensor(m, "mtp.0.e_proj.weight"); |
| 8706 | w->h_proj = required_tensor(m, "mtp.0.h_proj.weight"); |
| 8707 | w->enorm = required_tensor(m, "mtp.0.enorm.weight"); |
| 8708 | w->hnorm = required_tensor(m, "mtp.0.hnorm.weight"); |
| 8709 | w->norm = required_tensor(m, "mtp.0.norm.weight"); |
| 8710 | |
| 8711 | ds4_layer_weights *l = &w->block; |
| 8712 | l->hc_attn_fn = required_tensor(m, "mtp.0.hc_attn_fn.weight"); |
| 8713 | l->hc_attn_scale = required_tensor(m, "mtp.0.hc_attn_scale.weight"); |
| 8714 | l->hc_attn_base = required_tensor(m, "mtp.0.hc_attn_base.weight"); |
| 8715 | l->attn_norm = required_tensor(m, "mtp.0.attn_norm.weight"); |
| 8716 | l->attn_q_a = required_tensor(m, "mtp.0.attn_q_a.weight"); |
| 8717 | l->attn_q_a_norm = required_tensor(m, "mtp.0.attn_q_a_norm.weight"); |
| 8718 | l->attn_q_b = required_tensor(m, "mtp.0.attn_q_b.weight"); |
| 8719 | l->attn_kv = required_tensor(m, "mtp.0.attn_kv.weight"); |
| 8720 | l->attn_kv_a_norm = required_tensor(m, "mtp.0.attn_kv_a_norm.weight"); |
| 8721 | l->attn_sinks = required_tensor(m, "mtp.0.attn_sinks.weight"); |
| 8722 | l->attn_output_a = required_tensor(m, "mtp.0.attn_output_a.weight"); |
no test coverage detected