Repository navigation
Conversation
62f5adf to
3edb67d
Compare
| struct CacheStep { | ||
| layer: LayerId, | ||
| state: StepState, | ||
| // `Some` iff we're using block attention residuals. |
There was a problem hiding this comment.
the comment doesn't seem to match the code
There was a problem hiding this comment.
I think I was on drugs or something 🤠 . fixed
| reads, | ||
| starts_block, | ||
| message_gates, | ||
| read: <B::Kernels as Kernels>::AttnResReadKernel::new(context, data_type, data_type, 1) |
There was a problem hiding this comment.
all three call sites build the read kernel with query_count = 1 so maybe simplify the code given that?
There was a problem hiding this comment.
oh, you're right. That's there because of lalamo but lalamo has that to do the KQV projections in one, while I'm doing a loop because I'm storing them as three buffers, but that's actually worse for performance. Hopefully it's not too bad. I think I'll leave the query_count for now but also add a TODO with the fact that the buffers can just be merged.
There was a problem hiding this comment.
I just made the change to have everything in one buffer now.
| parameter_tree: &ParameterTree<'_, B>, | ||
| context: &B::Context, | ||
| ) -> Result<Self, ResidualNewError<B>> { | ||
| let rank = config.rank; |
There was a problem hiding this comment.
MessageGateConfig.linear_config doesn't seem to be read anywhere
There was a problem hiding this comment.
LinearConfig is an empty struct, it's that way everywhere, and it's never read anywhere 🤷
3edb67d to
37de35c
Compare
37de35c to
7e68170
Compare
909d3b4 to
816357a
Compare
816357a to
9375e1e
Compare
bd28c7d to
db19692
Compare
db19692 to
8117721
Compare
| // The Metal and Vulkan kernels keep every source's score in threadgroup memory until the softmax, so they | ||
| // need a fixed size. Their `MAX_SOURCES` must match this one (like `MAX_K` in `radix_top_k_small.rs`). 64 is | ||
| // arbitrary; raising it just uses more threadgroup memory. | ||
| pub const MAX_SOURCES: u32 = 64; |
There was a problem hiding this comment.
move to common/gpu_type.rs ?
| let start_index = start_index.unwrap(); | ||
| let slot_size = blocks.size() / self.schedule.block_source_capacity as usize; | ||
| let pass_range = start_index * slot_size..(*blocks_len + 1) * slot_size; |
There was a problem hiding this comment.
Could we move the block save and rewind into the residual module? will be easier for future fusion
| VARIANTS(ReadT, float, half, bfloat) | ||
| VARIANTS(T, float, half, bfloat) |
There was a problem hiding this comment.
Do our models really need all these types? same for all other kernels
| #define BLOCK_SIZE 1024 | ||
| // Must match `MAX_SOURCES` in `backends/common/kernel/attention_residual.rs`, which explains the limit. | ||
| constant uint MAX_SOURCES = 64; | ||
| #define MAX_QUERIES 3 |
|
|
||
| using namespace metal; | ||
|
|
||
| #define BLOCK_SIZE 1024 |
| VARIANTS(SourceT, float, half, bfloat) | ||
| VARIANTS(OutputT, float, half, bfloat) |
There was a problem hiding this comment.
probably don't need all these types?
support for block residuals. Changes include:
ResidualSteam<B>