-
Notifications
You must be signed in to change notification settings - Fork 98
fix(qwen3): cap PerToken CUDA Graph buckets #848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5b77c70
1fd04d8
2e5224c
824f5d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ use pegainfer_kernels::ops::numeric_policy; | |
| use pegainfer_kv_cache::KvBuffer; | ||
| use pegainfer_kv_cache::KvView; | ||
|
|
||
| use super::batch_decode::DecodeGraphPlan; | ||
| use super::batch_decode::DecodeGraphUse; | ||
| use super::batch_decode_buffers::BatchDecodeBuffers; | ||
| use super::config::PREFILL_ATTENTION_CTA_TILE_Q; | ||
| use super::prefill::PrefillBuffers; | ||
|
|
@@ -61,17 +63,41 @@ impl Qwen3Model { | |
| let decode_tokens = vec![0u32; profile_decode_rows]; | ||
| let decode_adapters = vec![None; profile_decode_rows]; | ||
|
|
||
| // Force the decode CUDA-Graph/buffer path before the unified peak | ||
| // sample. The synthetic views are short, but the pre-allocated decode | ||
| // arena and graph state are the same serving objects used later. Skip it | ||
| // for uncompiled-group models: the unified sample below bounds their KV. | ||
| // Eager under TP: ranks profile uncoordinated, so an in-profile capture | ||
| // would hit the same deadlock the sweep avoids (see `PrecapturePhase`). | ||
| // Exercise decode before the unified peak sample. PerToken first captures | ||
| // every retained graph into this one buffer set so their cumulative | ||
| // residency remains live under the later eager/unified probes. Skip this | ||
| // for uncompiled-group modles; the unified sample below bounds their KV. | ||
| // TP stays eager because its ranks profile independently. | ||
| if self.config.decode_group_is_compiled() { | ||
| let graph_plan = DecodeGraphPlan::new(decode_bufs.policy_at_construction); | ||
| if self.enable_cuda_graph | ||
| && self.tensor_parallel.world_size == 1 | ||
| && graph_plan.requires_cumulative_profile() | ||
| { | ||
| for graph_rows in graph_plan.retained_buckets() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This loop reserves only the full-SM Please reject PerToken+overlap at the existing guard or profile both caches. The guard is the smaller fix if this diagnostic combination is unsupported. |
||
| anyhow::ensure!( | ||
| graph_rows <= profile_decode_rows, | ||
| "retained decode Graph bucket {graph_rows} exceeds profile row capacity \ | ||
| {profile_decode_rows}" | ||
| ); | ||
| self.batch_decode( | ||
| &decode_tokens[..graph_rows], | ||
| &decode_views[..graph_rows], | ||
| &decode_adapters[..graph_rows], | ||
| kv_buffer.buffer(), | ||
| &layout, | ||
| decode_bufs, | ||
| DecodeGraphUse::Serve, | ||
| )?; | ||
| self.ctx.sync()?; | ||
| mark_peak()?; | ||
| } | ||
| } | ||
|
|
||
| let graph_use = if self.tensor_parallel.world_size > 1 { | ||
| crate::batch_decode::DecodeGraphUse::Eager | ||
| DecodeGraphUse::Eager | ||
| } else { | ||
| crate::batch_decode::DecodeGraphUse::Serve | ||
| DecodeGraphUse::Serve | ||
| }; | ||
| self.batch_decode( | ||
| &decode_tokens, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is reached by the unconditional TP sweep at bucket 40, after model/KV allocation, worker startup and watchdog creation. Returning
Errdropssweep_done_tx; the watchdog deliberately remains armed and later callsstd::process::abort(), so even a caller that handles the error can lose the process ten minutes later.If PerToken+TP is unsupported, please reject it at the start of
from_runtime_with_lora_options(). This does not require TP-specific cap handling or restoring the deleted TP test.