the live sequence to host memory, if it is long enough to be worth the copy
| 308 | |
| 309 | // the live sequence to host memory, if it is long enough to be worth the copy |
| 310 | void Session::park_live_() { |
| 311 | const std::vector<int>& hist = e_.history(); |
| 312 | if (cache_->budget == 0 || hist.size() < PARK_MIN) return; |
| 313 | for (const Conv& p : cache_->parked) // already parked as it is (a conversation brought back and left unchanged) |
| 314 | if (p.kv->tokens == hist) return; |
| 315 | Conv c; |
| 316 | const auto t_park = std::chrono::steady_clock::now(); |
| 317 | c.kv = e_.save_state(true); |
| 318 | c.ckpts = live_.ckpts; |
| 319 | c.len = hist.size(); |
| 320 | c.used = live_.used; |
| 321 | cache_->parked.push_back(std::move(c)); |
| 322 | std::fprintf(stderr, "conversation cache: parked %zu tokens in %.0f ms, parked=%zu bytes=%zu\n", hist.size(), ms_since(t_park), |
| 323 | cache_->parked.size(), bytes_held()); |
| 324 | } |
| 325 | |
| 326 | void Session::park() { |
| 327 | e_.use_lane(lane_); |