MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / hc_pre_batch

Function hc_pre_batch

server/src/deepseek4/deepseek4_graph.cpp:2059–2093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2057 const int pos_i = kv_start + i;
2058 float * col = mvals.data() + (size_t) i * n_attn;
2059 for (int r = 0; r < n_raw; ++r) {
2060 const int pos_r = end <= w.n_swa
2061 ? r
2062 : (end - 1) - ((end - 1 - r) % w.n_swa);
2063 if (pos_r > pos_i) col[r] = -1e30f;
2064 }
2065 if (n_comp_attn > 0) {
2066 const int visible = ds4_comp_rows_used(
2067 lc.comp_kv, lc.n_comp, ratio, pos_i);
2068 for (int c = visible; c < n_comp_attn; ++c) {
2069 col[n_raw + c] = -1e30f;
2070 }
2071 }
2072 int old_row = 0;
2073 for (int t = 0; t < n_tokens; ++t) {
2074 if (kv_start + t < w.n_swa) continue;
2075 if (t <= i) {
2076 col[n_raw + n_comp_attn + old_row] = -1e30f;
2077 }
2078 ++old_row;
2079 }
2080 }
2081 f32_array_inputs->push_back({cmask, std::move(mvals)});
2082 score_mask = ggml_reshape_2d(ctx, cmask, n_attn, n_tokens);
2083 }
2084 }
2085 const bool direct_indexer_topk = indexer_topk &&
2086 ds4_env_flag("DFLASH_DS4_DIRECT_INDEXER_TOPK");
2087 if (indexer_topk) {
2088 if (!score_mask) {
2089 score_mask = ggml_new_tensor_2d(
2090 ctx, GGML_TYPE_F32, n_attn, n_tokens);
2091 ggml_set_input(score_mask);
2092 f32_array_inputs->push_back({
2093 score_mask,
2094 std::vector<float>((size_t) n_attn * n_tokens, 0.0f),
2095 });
2096 }

Callers 1

Calls 3

ds4_parallel_for_tokensFunction · 0.85
hc_pre_auto_intoFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected