[LD] reusable GPU layer forward (ld::layer) with persistent per-layer state
- ld::layer (feature hip): LayerWeights (load_layer reads all attention + MoE
weights + learned depth-mix queries for a physical step ip), LayerState
(persistent KV cache + ShortConv history rings, new_state), Dims, and
layer_forward_swa — a complete SWA layer step composing the verified
microkernels with the exact Inkling deep-residual cadence:
ip==0: in0=attn_norm(cur); ip>0: in0=attn_norm(mix(blocks,cur,attn_query))
attention block -> asc; ip%block_size==0: snapshot cur->blocks, cur=asc
else cur+=asc
mlpin=mlp_norm(mix(blocks,cur,mlp_query)); MoE block; cur+=mlp_sconv(moeout)
The depth-block snapshots are owned by the caller (the forward residual
stream); experts loaded on demand (zero requantization).
- Refactored real_full_layer_end_to_end to drive the GPU side through
layer_forward_swa; the unchanged full CPU oracle still verifies it
(max_rel_err 6.6e-4, identical experts) AND asserts the ip=0 block snapshot.
This is the reusable foundation for the multi-layer forward.
Scope: SWA layers without loop controllers (prelude). Full-attn 3-query split,
loop controllers (gain/forget/down) and multi-pass bank rollback come next.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; real full layer via reusable fn PASS
(--features hip, --ignored).
This commit is contained in:
1 parent
25ffc820f8
commit
0929bde578
3 files changed
+230
-105
No files matched your search
@@ -17,6 +17,9 @@ pub mod inkling_graph;
|
||||
#[cfg(feature = "hip")]
|
||||
pub mod packer;
|
||||
|
||||
#[cfg(feature = "hip")]
|
||||
pub mod layer;
|
||||
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::os::unix::fs::FileExt;
|
||||
|
||||
Reference in new issue
Block a user