NumPy allowed · plain Python earns 10 bonus points
Q · Kᵀ / √d scores normalized with softmax
Merge two partitioned attention blocks using online softmax rescaling without materializing the full attention matrix.
Implement merge_online_softmax_blocks(block_maxes, block_sums, block_weights): given two blocks with max logits m_1, m_2, exponential sums l_1, l_2, and unnormalized output accumulators O_1, O_2, calculate new maximum m_new = max(m_1, m_2). Rescale factors alpha_1 = exp(m_1 - m_new) and alpha_2 = exp(m_2 - m_new). Compute merged sum l_new = alpha_1 * l_1 + alpha_2 * l_2 and output O_new = (alpha_1 * O_1 + alpha_2 * O_2) / l_new. Return dict with keys merged_max, merged_sum, and merged_output rounded to 4 decimals.
merge_online_softmax_blocks(block_maxes: list[float], block_sums: list[float], block_weights: list[list[float]]) -> dict[str, any]