STRA-338 params: ExpertCache::choose_loan takes LoanRequest, QsaPromptAttention::attend_selected takes QsaPromptSources (no external callers)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
1da95236fe
commit
eb780392b8
+2
-7
@@ -64,18 +64,13 @@ impl<'ctx> OriginalExpertCache<'ctx> {
|
||||
}
|
||||
self.slot_handle(slot)
|
||||
}
|
||||
/// The chunk and slot count the prompt may borrow from the cache tail (see `LoanRequest`).
|
||||
pub fn choose_loan(
|
||||
&self,
|
||||
requested: usize,
|
||||
auto: bool,
|
||||
auto_max: usize,
|
||||
context: usize,
|
||||
lend_percent: usize,
|
||||
request: crate::original_expert_slots::LoanRequest,
|
||||
needed: impl FnMut(usize) -> Result<usize>,
|
||||
) -> Result<Option<(usize, usize)>> {
|
||||
self.ensure_live()?;
|
||||
let request =
|
||||
crate::original_expert_slots::LoanRequest { requested, is_auto: auto, auto_max, context, lend_percent };
|
||||
self.table.choose_loan(request, needed)
|
||||
}
|
||||
/// generate.cpp `part_slots`: the slots from the end of the cache that hold `bytes_needed`.
|
||||
|
||||
@@ -15,6 +15,12 @@ pub struct QsaAttentionInputs<'loan, 'buffers> {
|
||||
pub(crate) steps: &'loan DeviceBuffer<'buffers>,
|
||||
pub(crate) t: usize,
|
||||
}
|
||||
/// What one prompt attention pass reads besides its inputs: the staged prompt, its KV and the KV snapshot.
|
||||
pub struct QsaPromptSources<'loan, 'ctx, 'kv> {
|
||||
pub stage: &'loan QsaPromptStage<'ctx>,
|
||||
pub kv: &'kv QsaPromptKv<'ctx>,
|
||||
pub snapshot: &'loan QsaKvSnapshot,
|
||||
}
|
||||
pub const QSA_PROMPT_ATTENTION_BYTES: usize = 1_572_868; //64*6144 F32 +4B status
|
||||
pub struct QsaPromptAttention<'ctx> {
|
||||
capacity: usize,
|
||||
|
||||
+2
-3
@@ -143,12 +143,11 @@ impl<'ctx> QsaPromptAttention<'ctx> {
|
||||
pub fn attend_selected<'loan>(
|
||||
&'loan mut self,
|
||||
w: &mut NativeBatchWorkspace<'ctx>,
|
||||
stage: &'loan QsaPromptStage<'ctx>,
|
||||
kv: &QsaPromptKv<'ctx>,
|
||||
snapshot: &'loan QsaKvSnapshot,
|
||||
sources: QsaPromptSources<'loan, 'ctx, '_>,
|
||||
inputs: &QsaAttentionInputs<'_, '_>,
|
||||
switches: SelectSwitches,
|
||||
) -> Result<QsaPromptAttentionCompletion<'loan, 'ctx>> {
|
||||
let QsaPromptSources { stage, kv, snapshot } = sources;
|
||||
let caps = self.module.as_ref().ok_or(Error::ContextPoisoned)?.caps();
|
||||
let device = DeviceCaps { cc_major: caps[0], cc_minor: caps[1], max_shared_optin: caps[2] };
|
||||
let kernel = select(PoolPresence::int8(), Shapes::QWEN, QWEN_SELECTION, device, switches)
|
||||
|
||||
@@ -117,7 +117,7 @@ pub use qsa_native_batch::{
|
||||
pub use qsa_native_decode::{QSA_NATIVE_DECODE_BYTES, QsaNativeDecode, QsaNativeDecodeCompletion};
|
||||
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
|
||||
pub use qsa_prompt_attention::{
|
||||
QSA_PROMPT_ATTENTION_BYTES, QsaAttentionInputs, QsaPromptAttention, QsaPromptAttentionCompletion,
|
||||
QSA_PROMPT_ATTENTION_BYTES, QsaAttentionInputs, QsaPromptAttention, QsaPromptAttentionCompletion, QsaPromptSources,
|
||||
};
|
||||
#[cfg(all(any(target_os = "linux", target_os = "windows"), target_arch = "x86_64"))]
|
||||
pub use qsa_prompt_index::{
|
||||
|
||||
Reference in New Issue
Block a user