Implement multi-query attention with separate query heads, shared key-value heads, optional masking, and output projection.