profile: free-VRAM notes along the stack's life; smoke honours LELEKA_ORIGINAL_SERVE_KV_RESIDENT
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
5b4c817f60
commit
a0fbf6762e
@@ -92,6 +92,9 @@ fn original_serve_smoke_prompt_decode_mtp_verify_commit_reset_cancel_sample() {
|
||||
let mut config = StackConfig::new(env::var("LELEKA_SMOKE_MAX_CONTEXT").ok().and_then(|v| v.parse().ok()).unwrap_or(4096));
|
||||
config.capacity = env::var("LELEKA_ORIGINAL_SERVE_CAPACITY").ok().and_then(|v| v.parse().ok()).unwrap_or(1024);
|
||||
config.rt_directory = env::var_os("LELEKA_ORIGINAL_SERVE_RT_DIR").map(PathBuf::from);
|
||||
if let Some(cells) = env::var("LELEKA_ORIGINAL_SERVE_KV_RESIDENT").ok().and_then(|v| v.parse().ok()) {
|
||||
config.kv_resident = cells;
|
||||
}
|
||||
// LELEKA_SMOKE_PROMPT_CACHE=0: every request reads its whole prompt (the first-request experiments)
|
||||
if env::var("LELEKA_SMOKE_PROMPT_CACHE").is_ok_and(|v| v == "0") {
|
||||
config.conversation = None;
|
||||
|
||||
@@ -270,6 +270,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
let formats = expert_formats(binding).map_err(at("expert_formats"))?;
|
||||
let layout = prefill_layout_options(config.capacity, max_cells, &blobs);
|
||||
|
||||
vram_note(context, "open begin");
|
||||
let embedding = OriginalPromptEmbedding::load(binding, context).map_err(at("OriginalPromptEmbedding::load"))?;
|
||||
let output = OriginalNativeOutput::load(binding, context, NativeHeadDispatch::default(), true).map_err(at("OriginalNativeOutput::load"))?;
|
||||
let kar = match binding.kar_ple_binding() {
|
||||
@@ -278,6 +279,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
};
|
||||
let dense = DenseWeightCache::new_original_prompt_capacity(binding, context, config.capacity).map_err(at("DenseWeightCache::new_original_prompt_capacity"))?;
|
||||
let moe = MoeWeightCache::new_original_prompt_arena(binding, context, layout).map_err(at("MoeWeightCache::new_original_prompt_arena"))?;
|
||||
vram_note(context, "after embedding, output, kar, dense, moe");
|
||||
let mut session = QwenSession::for_binding_on_shared_device(binding, shared);
|
||||
let request = OriginalMtpRequest::ring_int8(settings.mtp_load_t(), config.capacity, settings.coupled, MTP_RESIDENT_CELLS);
|
||||
let (executor, draft) = match &config.rt_directory {
|
||||
@@ -295,11 +297,13 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
(executor, draft)
|
||||
}
|
||||
};
|
||||
vram_note(context, "after prompt executor and draft");
|
||||
let mut executor = executor;
|
||||
// generate.cpp: the expert cache is sized after everything else, and the prompt path's own buffers
|
||||
// after the cache when it cannot borrow them; without the tier the order is unchanged.
|
||||
let tier = config.expert_tier.enabled();
|
||||
let mut arena = if tier { None } else { Some(context.original_prefill_arena(layout).map_err(at("original_prefill_arena"))?) };
|
||||
vram_note(context, "before cache (arena)");
|
||||
let history = OriginalNativePenaltyHistory::new(binding, context).map_err(at("OriginalNativePenaltyHistory::new"))?;
|
||||
let ple_history = context.allocate(PLE_HISTORY_BYTES).map_err(at("ple_history"))?;
|
||||
let ple_scratch = context.allocate(PLE_SCRATCH_BYTES).map_err(at("ple_scratch"))?;
|
||||
@@ -308,6 +312,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
let empty_draft = draft.checkpoint(binding, &session).map_err(at("draft.checkpoint"))?;
|
||||
let conversation = config.conversation.clone().map(ServeConversation::new);
|
||||
let residency = ResidencyState::new(&config.expert_tier);
|
||||
vram_note(context, "before expert tier");
|
||||
let mut loan = None;
|
||||
let expert_cache = match original_serve_residency::open_tier(binding, context, &moe, &config.expert_tier, config.capacity)
|
||||
.map_err(at("expert tier"))?
|
||||
@@ -331,6 +336,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
vram_note(context, "after expert tier");
|
||||
let initial_owners: Vec<Option<(usize, usize)>> = expert_cache
|
||||
.as_ref()
|
||||
.map(|cache| (0..cache.slots()).map(|slot| cache.slot_owner(slot)).collect())
|
||||
@@ -605,6 +611,7 @@ impl<'a, 'ctx> OriginalServeStack<'a, 'ctx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
vram_note(context, "decode after assemble");
|
||||
crate::bringup_trace!("DBG[{:.0}s] decode: assemble -> {}", dbg_el(), if assembled.is_ok() { "ok" } else { "ERR" });
|
||||
let resources = match assembled {
|
||||
Ok(resources) => resources,
|
||||
@@ -1049,6 +1056,14 @@ impl<'ctx> PromptChunk<'_, 'ctx> {
|
||||
|
||||
static DBG_T0: std::sync::OnceLock<std::time::Instant> = std::sync::OnceLock::new();
|
||||
/// Bring-up tracing clock (seconds since the first call); remove together with the DBG lines.
|
||||
/// `LELEKA_SERVE_PROFILE=1`: the card's free VRAM at a point of the stack's life (where the auto-sized cache's room goes).
|
||||
fn vram_note(context: &Context<'_>, label: &str) {
|
||||
if profile::enabled() {
|
||||
if let Ok((free, total)) = context.memory_info() {
|
||||
eprintln!("DBG vram {label}: free {} MiB of {} MiB", free >> 20, total >> 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
pub(crate) fn dbg_el() -> f32 {
|
||||
DBG_T0.get_or_init(std::time::Instant::now).elapsed().as_secs_f32()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user