Download src/loop/day_loop.h from Ozomozyan/hkimi: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/Ozomozyan/hkimi/resolve/main/src/loop/day_loop.h
- Command line
-
hf download hf://Ozomozyan/hkimi/src/loop/day_loop.h
-
curl -L -o day_loop.h https://huggingface.co/Ozomozyan/hkimi/resolve/main/src/loop/day_loop.h
1.91 kB
| // Options and results of answering, shared by the two ways of writing: | |
| // real Kimi alone (reader_greedy) and draft and check (loop/draft_loop.h). | |
| namespace hk { | |
| struct DayOptions { | |
| int max_new = 256; // tokens to produce at most | |
| int max_rounds = 1000; // safety cap on draft/check rounds | |
| std::vector<int32_t> stop_ids; // generation ends after one of these | |
| int draft_len = 0; // tokens drafted per round; 0 = chosen each round (best_check_len) | |
| // What one more position adds to a sweep, as a share of a sweep over one position. | |
| // Only where the estimate starts (0 = 0.085): the loop corrects it from its own sweep times. | |
| double extra_cost = 0; | |
| }; | |
| struct RoundInfo { | |
| int drafted = 0, accepted = 0; // accepted: drafted tokens real Kimi let through | |
| bool fixed = false; | |
| double draft_seconds = 0, sweep_seconds = 0; | |
| int64_t sweep_bytes = 0; | |
| }; | |
| struct DayResult { | |
| std::vector<int32_t> tokens; // the continuation (prompt not included) | |
| std::vector<RoundInfo> rounds; | |
| int fixes = 0; | |
| bool stopped = false; // ended on a stop token | |
| double seconds = 0, draft_seconds = 0, sweep_seconds = 0; | |
| int64_t sweep_bytes = 0; | |
| }; | |
| struct DayCallbacks { | |
| std::function<void(const int32_t* tokens, int n)> on_approved; // final tokens, in order | |
| std::function<void(const int32_t* tokens, int n)> on_draft; // a fresh unverified draft (may be discarded) | |
| }; | |
| // Greedy decoding with the reader alone, one sweep per token. Slow, but it is | |
| // the ground truth the draft-and-check loop is tested against. | |
| std::vector<int32_t> reader_greedy(Reader& reader, const std::vector<int32_t>& prompt, int max_new, | |
| const std::vector<int32_t>& stop_ids); | |
| } // namespace hk | |