perf(prefill): profile spans for input embedding/PLE and row init sources/upload
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f6b48226e3
commit
fdb1071783
@@ -274,10 +274,13 @@ impl<'ctx> OriginalPromptExecutor<'ctx>{
|
||||
drop(input_span);
|
||||
let init_span=prof::span(PStage::Initialize,drain);
|
||||
let mut sources=Vec::new();sources.try_reserve_exact(tokens.len()).map_err(|_|Error::InputAllocation)?;
|
||||
let sources_span=prof::span(PStage::InitSources,None);
|
||||
for local in 0..tokens.len(){sources.push(PromptDeviceSource::from_original(binding,self.context,&txn,local)?);}
|
||||
drop(sources_span);
|
||||
let upload_span=prof::span(PStage::InitUpload,drain);
|
||||
let prompt=self.prompt.as_mut().ok_or(Error::IdentityMismatch)?;
|
||||
let rows=PromptDeviceRows::initialize(binding,dense,self.context,prompt,arena.begin_rows(tokens.len()).map_err(driver_error)?,sources)?;
|
||||
drop(init_span);
|
||||
drop(upload_span);drop(init_span);
|
||||
let mut carrier=Carrier::Plain(rows);
|
||||
for layer in binding.ordered_layers(){
|
||||
let index=layer.index();let role=super::super::gr::GrRole::Attention(index);
|
||||
|
||||
@@ -115,8 +115,11 @@ impl InputStage {
|
||||
txn.input_predecessors()?,
|
||||
binding.input_constants(),
|
||||
)?;
|
||||
let embedding_span = super::prefill_profile::span(super::prefill_profile::Stage::InputEmbedding, None);
|
||||
let embedding = binding.embedding_row(token.get()).map_err(binding_error)?;
|
||||
let streams = ResidualStreams::broadcast(&embedding)?;
|
||||
drop(embedding_span);
|
||||
let _ple_span = super::prefill_profile::span(super::prefill_profile::Stage::InputPle, None);
|
||||
let ple = cache.gather(kar, &rows)?;
|
||||
Ok(InputReady {
|
||||
binding: binding.identity(),
|
||||
|
||||
@@ -13,8 +13,16 @@ use std::time::{Duration, Instant};
|
||||
pub(crate) enum Stage {
|
||||
/// Host input staging of every row (token embedding, KAR/PLE inputs).
|
||||
Input,
|
||||
/// Token embedding rows of the input staging (KAR path).
|
||||
InputEmbedding,
|
||||
/// PLE rows of the input staging (KAR gather, KAR path).
|
||||
InputPle,
|
||||
/// Row source keys and the initial R/PLE upload.
|
||||
Initialize,
|
||||
/// Row source keys and their finite checks.
|
||||
InitSources,
|
||||
/// Initial R/PLE staging and upload.
|
||||
InitUpload,
|
||||
/// Layer-one PLE application and its history.
|
||||
Ple,
|
||||
/// Chronological per-row session validation of every phase.
|
||||
@@ -56,8 +64,8 @@ pub(crate) enum Stage {
|
||||
/// Expert-cache slot loan for the chunk's arena (expert tier only).
|
||||
Lend,
|
||||
}
|
||||
const STAGES: [Stage; 22] = [
|
||||
Stage::Input, Stage::Initialize, Stage::Ple, Stage::Validate, Stage::AttnRead, Stage::Gdn, Stage::GdnStateIn,
|
||||
const STAGES: [Stage; 26] = [
|
||||
Stage::Input, Stage::InputEmbedding, Stage::InputPle, Stage::Initialize, Stage::InitSources, Stage::InitUpload, Stage::Ple, Stage::Validate, Stage::AttnRead, Stage::Gdn, Stage::GdnStateIn,
|
||||
Stage::GdnCompute, Stage::GdnStateOut, Stage::Qsa,
|
||||
Stage::FfnRead, Stage::Moe, Stage::MoePrepare, Stage::MoeSpans, Stage::MoeRing, Stage::MoeFinish, Stage::Inject,
|
||||
Stage::Final, Stage::DraftKv, Stage::FinishPreview, Stage::Publish, Stage::Lend,
|
||||
@@ -66,7 +74,11 @@ impl Stage {
|
||||
fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Input => "input",
|
||||
Self::InputEmbedding => "input.embedding",
|
||||
Self::InputPle => "input.ple",
|
||||
Self::Initialize => "init",
|
||||
Self::InitSources => "init.sources",
|
||||
Self::InitUpload => "init.upload",
|
||||
Self::Ple => "ple",
|
||||
Self::Validate => "validate",
|
||||
Self::AttnRead => "attn_read",
|
||||
|
||||
Reference in New Issue
Block a user