MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / state_write_meta

Method state_write_meta

smallthinker/src/llama-kv-cache-unified.cpp:1288–1312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1286}
1287
1288void llama_kv_cache_unified::state_write_meta(llama_io_write_i & io, const std::vector<std::pair<uint32_t, uint32_t>> & cell_ranges, llama_seq_id seq_id) const {
1289 for (const auto & range : cell_ranges) {
1290 for (uint32_t i = range.first; i < range.second; ++i) {
1291 std::vector<llama_seq_id> seq_ids;
1292
1293 for (llama_seq_id cur = 0; cur < (int) n_seq_max; ++cur) {
1294 if (cur == seq_id || seq_id == -1) {
1295 if (cells.seq_has(i, cur)) {
1296 seq_ids.push_back(cur);
1297 }
1298 }
1299 }
1300
1301 const llama_pos pos = cells.pos_get(i);
1302 const uint32_t n_seq_id = seq_ids.size();
1303
1304 io.write(&pos, sizeof(pos));
1305 io.write(&n_seq_id, sizeof(n_seq_id));
1306
1307 for (const auto & seq_id : seq_ids) {
1308 io.write(&seq_id, sizeof(seq_id));
1309 }
1310 }
1311 }
1312}
1313
1314void llama_kv_cache_unified::state_write_data(llama_io_write_i & io, const std::vector<std::pair<uint32_t, uint32_t>> & cell_ranges) const {
1315 const uint32_t v_trans = this->v_trans ? 1 : 0;

Callers

nothing calls this directly

Calls 5

seq_hasMethod · 0.80
pos_getMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected