sm120 ATTN_DAILY for the MTP draft step: opt-in LELEKA_SM120_ATTN_DAILY_MTP=1 (default off, not run on the GPU yet)
The draft step attends over the 32,768-cell MTP window (512 chunks, one query): with the opt-in, the Original chunk kernel and chain_qsa_decode_merge_n of that step become sm120_attn_daily.ptx's leleka_qsa_decode_chunk_daily / leleka_qsa_decode_merge_v2 (module slot 22 after the chain slot; the window_ids pre-launch keys on the new chunk entry too). sm120_probe `attn512` byte-compares the pair against the Original on the draft shape and times them; it has not been run yet (no GPU slot), so the switch stays default off. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
7636ec5d91
commit
d6aee34af4
@@ -662,12 +662,18 @@ impl<'ctx> OriginalMtpFullForward<'ctx> {
|
||||
for (p, e) in &symbols::ASSETS[..symbols::CHAIN_ASSET] {
|
||||
o.modules.push(Rc::new(FM::load(p, e)?));
|
||||
}
|
||||
if chain_mtp_assets() {
|
||||
if chain_mtp_assets() || daily_mtp() {
|
||||
// chain_window.ptx: loaded only when selected, and only if it is the sealed one
|
||||
crate::original_verify::chain::CHAIN.sealed()?;
|
||||
let (p, e) = &symbols::ASSETS[symbols::CHAIN_ASSET];
|
||||
o.modules.push(Rc::new(FM::load(p, e)?));
|
||||
}
|
||||
if daily_mtp() {
|
||||
// sm120_attn_daily.ptx: the draft step's attention (opt-in, LELEKA_SM120_ATTN_DAILY_MTP=1); slot 22 follows the chain slot
|
||||
crate::original_verify::sm120::ATTN_DAILY.sealed()?;
|
||||
let (p, e) = &symbols::ASSETS[symbols::DAILY_ASSET];
|
||||
o.modules.push(Rc::new(FM::load(p, e)?));
|
||||
}
|
||||
Ok(())
|
||||
})();
|
||||
let pop = g.finish();
|
||||
@@ -865,6 +871,13 @@ fn push(
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
/// `LELEKA_SM120_ATTN_DAILY_MTP=1` (opt-in, default off, untested on the real model): the MTP draft step's attention chunk and merge are upstream's
|
||||
/// `attn_chunk_kernel_pre75` / `attn_merge_v2_kernel` (sm120_attn_daily.cu, byte-identical to the Original's by the probe) instead of the Original's chunk
|
||||
/// kernel and `chain_qsa_decode_merge_n`. sm_120 only.
|
||||
fn daily_mtp() -> bool {
|
||||
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*ON.get_or_init(|| std::env::var("LELEKA_SM120_ATTN_DAILY_MTP").is_ok_and(|v| v == "1"))
|
||||
}
|
||||
/// `LELEKA_CHAIN` selects a group that launches from the chain module inside the MTP draft program.
|
||||
fn chain_mtp_assets() -> bool {
|
||||
let f = crate::original_verify::chain::flags();
|
||||
@@ -1014,10 +1027,11 @@ impl OriginalMtpFullForward<'_> {
|
||||
let (pa, pm, pl, ident) = o.attention(p.ring)?;
|
||||
let chain_mtp = crate::original_verify::chain::flags().mtp;
|
||||
// the Original's chunk kernel in both modes (the load-hoisted variant measured no faster); only the merge changes
|
||||
let daily = daily_mtp();
|
||||
push(
|
||||
&mut v,
|
||||
19,
|
||||
0,
|
||||
if daily { symbols::DAILY_ASSET } else { 19 },
|
||||
if daily { symbols::DAILY_CHUNK } else { 0 },
|
||||
[CHUNKS as u32, 2, 1],
|
||||
[256, 1, 1],
|
||||
0,
|
||||
@@ -1049,13 +1063,24 @@ impl OriginalMtpFullForward<'_> {
|
||||
F::U64(attn),
|
||||
F::I64(SCRATCH_FLOATS as i64),
|
||||
];
|
||||
if chain_mtp {
|
||||
if daily {
|
||||
// merge_v2 takes the step words after n_chunks: (acc, m, l, n_chunks, steps, attn, stride)
|
||||
merge_args = vec![
|
||||
F::U64(pa),
|
||||
F::U64(pm),
|
||||
F::U64(pl),
|
||||
F::I32(CHUNKS as i32),
|
||||
F::U64(p.step),
|
||||
F::U64(attn),
|
||||
F::I64(SCRATCH_FLOATS as i64),
|
||||
];
|
||||
} else if chain_mtp {
|
||||
merge_args.push(F::U64(p.step)); // the row's step words: n_ids bounds the merge to the chunks that hold cells
|
||||
}
|
||||
push(
|
||||
&mut v,
|
||||
if chain_mtp { symbols::CHAIN_ASSET } else { 19 },
|
||||
if chain_mtp { symbols::CHAIN_QSA_MERGE_N } else { 1 },
|
||||
if daily { symbols::DAILY_ASSET } else if chain_mtp { symbols::CHAIN_ASSET } else { 19 },
|
||||
if daily { symbols::DAILY_MERGE_V2 } else if chain_mtp { symbols::CHAIN_QSA_MERGE_N } else { 1 },
|
||||
[24, 1, 1],
|
||||
[256, 1, 1],
|
||||
0,
|
||||
@@ -2433,7 +2458,7 @@ impl OriginalMtpForwardProgram<'_> {
|
||||
if command.asset == 16 && command.index == 0 {
|
||||
self.tail.modules[13].copy2d(&self.split, stream)?;
|
||||
}
|
||||
if command.asset == 19 && command.index == 0 {
|
||||
if (command.asset == 19 || command.asset == symbols::DAILY_ASSET) && command.index == 0 {
|
||||
self.ring.physical.modules[1]
|
||||
.as_ref()
|
||||
.ok_or(Error::ContextPoisoned)?
|
||||
|
||||
@@ -426,9 +426,19 @@ pub(super) const ASSETS: &[(&[u8], &[&CStr])] = &[
|
||||
c"chain_row_top_prob_kernel",
|
||||
],
|
||||
),
|
||||
// 22: sm120_attn_daily.ptx (claude/decode-sm120-switches), loaded only for the opt-in `LELEKA_SM120_ATTN_DAILY_MTP=1` (`DAILY_ASSET`); checked against its pin
|
||||
// (`original_verify::sm120::ATTN_DAILY`) before it is handed to the driver.
|
||||
(
|
||||
concat!(include_str!("sm120_attn_daily.ptx"), " | ||||