Transformer Architecture Internals · Problem 5 of 7
Implement grouped-query attention with configurable KV heads plus a KV cache for incremental decoding.
Implement the function/class skeleton in the editor. Any correct approach is accepted.
import torch
import torch.nn as nn
import torch.nn.functional as F
class GQA(nn.Module):
def __init__(self, d_model, n_heads, n_kv_heads):
raise NotImplementedError
def forward(self, x, cache=None):
raise NotImplementedErrorReady when you are
Submit your solution and a structured review appears here — verdict, score, and concrete feedback. Any correct approach passes.
Implement grouped-query attention with configurable KV heads plus a KV cache for incremental decoding.
Implement the function/class skeleton in the editor. Any correct approach is accepted.