Download prefill_mark.patch from kolinfluence/oaica-cpu-prefill-profile-e265bbf: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/datasets/kolinfluence/oaica-cpu-prefill-profile-e265bbf/resolve/main/prefill_mark.patch
- Command line
-
hf download hf://datasets/kolinfluence/oaica-cpu-prefill-profile-e265bbf/prefill_mark.patch
-
curl -L -o prefill_mark.patch https://huggingface.co/datasets/kolinfluence/oaica-cpu-prefill-profile-e265bbf/resolve/main/prefill_mark.patch
2 kB
| diff --git a/src/prefill.rs b/src/prefill.rs | |
| index cd230c0..c3659a3 100644 | |
| --- a/src/prefill.rs | |
| +++ b/src/prefill.rs | |
| pub fn forward_prefill( | |
| return Vec::new(); | |
| } | |
| if tokens.len() == 1 { | |
| - return crate::forward::forward(model, tokens[0], pos0, st); | |
| + let t = std::time::Instant::now(); | |
| + let r = crate::forward::forward(model, tokens[0], pos0, st); | |
| + if std::env::var("OAICA_PROF_SPLIT").is_ok() { | |
| + eprintln!("[mark] decode_us={}", t.elapsed().as_micros()); | |
| + } | |
| + return r; | |
| } | |
| let mut off = 0usize; | |
| let mut logits = Vec::new(); | |
| + let t_all = std::time::Instant::now(); | |
| + let _stage0 = std::time::Instant::now(); | |
| while off < tokens.len() { | |
| let n = (tokens.len() - off).min(sc.rows); | |
| logits = forward_chunk(model, &tokens[off..off + n], pos0 + off, st, sc, n); | |
| off += n; | |
| } | |
| + if std::env::var("OAICA_PROF_SPLIT").is_ok() { | |
| + eprintln!("[mark] prefill_us={}", t_all.elapsed().as_micros()); | |
| + } | |
| + if std::env::var("OAICA_MARK").is_ok() { | |
| + eprintln!("[chunk_total] {} us over {} chunks (incl. embeds, excludes load)", | |
| + _stage0.elapsed().as_micros(), | |
| + tokens.len().div_ceil(sc.rows)); | |
| + } | |
| logits | |
| } | |
| fn forward_chunk( | |
| ) -> Vec<f32> { | |
| let cfg = &model.cfg; | |
| let d = cfg.n_embd; | |
| + let _mark0 = std::time::Instant::now(); | |
| + let _m = |name: &str, off: std::time::Instant| { | |
| + if std::env::var("OAICA_MARK").is_ok() { | |
| + eprintln!("[stage] {name} {}", off.elapsed().as_micros()); | |
| + } | |
| + }; | |
| debug_assert!(n <= sc.rows && sc.d == d); | |
| debug_assert_eq!(tokens.len(), n); | |
| fn forward_chunk( | |
| sc.pos[p] = pos0 + p; | |
| } | |
| + _m("embed", _mark0); | |
| let mut attn_idx = 0usize; | |
| let mut rec_idx = 0usize; | |
| // `OAICA_PROF=1`: per-phase microseconds for the whole chunk (prefill is | |