Cubit: Token Mixer with Kernel Ridge Regression
Anonymous authors
ICLR 2027
TL;DR. We propose Cubit with Kernel Ridge Regression to replace Transformer with Nadaraya-Watson Regression for better performance.
Abstract. Since its introduction in 2017, the Transformer has become one of the most widely adopted architectures in modern deep learning. Despite extensive efforts to improve positional encoding, attention mechanisms, and feed-forward networks, the core token-mixing mechanism in Transformers remains attention. In this work, we show that the attention module in Transformers can be interpreted as performing Nadaraya–Watson regression, where it computes similarities between tokens and aggregates the corresponding values accordingly. Motivated by this perspective, we propose Cubit, a potential next-generation architecture that leverages Kernel Ridge Regression (KRR), while the vanilla Transformer relies on Nadaraya-Watson regression. Specifically, Cubit modifies the classical attention computation by incorporating the closed-form solution of KRR, combining value aggregation through kernel similarities with normalization via the inverse of the kernel matrix. To improve the training stability, we further propose the Limited-Range Rescale (LRR), which rescales the value layer within a controlled range. We argue that Cubit, as a KRR-based architecture, provides a stronger mathematical foundation than the vanilla Transformer, whose attention mechanism corresponds to Nadaraya–Watson regression. We validate this claim through comprehensive experiments. The experimental results suggest that Cubit may exhibit stronger long-sequence modeling capability. In particular, its performance gain over the Transformer appears to increase as the training sequence length grows.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
ICLR 2027
Under review · 3 reviews · OpenReview
Updated 24 Nov 2026, 17:11 UTC.
- Rating
- 3/4
- Confidence
- 2/4
- Soundness
- 2/3
- Presentation
- 2/3
- Informativeness
- 2/3
Read review
Summary
This paper argues that softmax attention performs Nadaraya-Watson kernel regression and proposes Cubit, which replaces it with kernel ridge regression. Cubit keeps the standard query-key softmax weights but first transforms the values with the inverse of a regularized similarity matrix built from a separate key-like projection. Under causal masking, this reduces to a traingular solve. A learned, bounded per-token rescaling of the values (called as Limited-Range Rescale) stabilizes training. The authors train decoder-only models at 125M, 350M and 1.3B parameters on Arxiv, Books3 and FineWeb-Edu datasets with training sequence lengths from 512 to 8192 tokens. They compare against a standard Transformer and DeltaFormer and report consistently lower validation loss, typically by 0.02-0.04 below xthe Transformer, along with slightly higher average zero-shot accuracy on seven benchmarks including ARC, HellaSwag and PIQA. They claim the advantage grows with training sequence length, and they include ablations on the separate key projection and the rescaling as well as a local linear regression variant.
Strengths
-
The paper treats token mixing as a choice of regression estimator, which gives a principled reason to try a different aggregation rule and a way for comparing attention variants. The local linear regression variant in the appendix shows that this framing can produce more than one design. Cubit adds one triangular solve and a value rescaling to standard attention, so existing architectures can adopt it with little effort.
-
Under causal masking, the triangular structure keeps the method autoregressive without computing a separate matrix inverse for each position. Cubit improves on the Transformer in every reported experiment.
Weaknesses
-
The paper motivates Cubit with the guarantees of kernel ridge regression like explicit regularization, RKHS convergence rates and robustness to noise. Yet the implemented "kernel matrix" is a causally masked, row-normalized softmax matrix. That matrix is lower-triangular and therefore not symmetric, so it is not a Gram matrix of any kernel, and its quadratic form can be indefinite. It is invertible, which makes the triangular solve well defined, but no RKHS underlies it and the Representer theorem does not apply. The weighting uses a different query-key similarity from the matrix being inverted, and the ridge term starts at 1e-10, which is practically 0. The resulting operator, softmax attention over values transformed by an inverse of a triangular matrix with a per-token scale, closely resembles DeltaFormer, one of the baselines. One of the contributions claimed in the paper is a better replacement for attention. Without valid theory, the model used in experiments is an empirical variant of DeltaFormer, and the authors neither acknowledge nor analyze the differences.
-
The gains over the Transformer are small, typically 0.02-0.04 in validation loss. The major claim that the advantage of Cubit grows with sequence length, is not an overstatement. On both Arxiv and Books3, the gap between narrows from 0.021 to 0.0187 and 0.0346 to 0.0325 respectively. Figure 3 plots training loss rather than validation loss, which would have been more informative, The paper also reports no throughput, memory or wall-clock cost for the added triangular solve, so it is difficult to assess whether a small gain is a valid tradeoff.
Questions for the authors
- What are the training throughput, peak memory usage and wall-clock time of Cubit when compared to Transformer and DeltaFormer at 1024 and 8192 tokens? Does Cubit still win when the baselines receive the same FLOPs?
- Both DeltaFormer and Cubit apply softmax attention to values transformed by the inverse of a lower-triangular matrix. What exactly does Cubit compute that DeltaFormer does not? Can you show an ablation that gradually changes Cubit to DeltaFormer by small changes to the matrix and design?
- Can you report Figure 3 in validation loss rather than training loss?
- How does change in the course of training? Does it stay near 1e-10?
2 comments
Response to Reviewer dbzF(Part 2/2)
Q4: From DeltaFormer gradually to Cubit
A4: The following is from DeltaFormer to Cubit.
From DeltaFormer to Cubit
| Method | Formulation | 5k | 10k | 15k | 20k | 25k | 30k | 35k | 40k | 45k | 50k |
|---|---|---|---|---|---|---|---|---|---|---|---|
| DeltaFormer | and set diagnal value to be 1 | 4.1395 | 3.9361 | 3.8316 | 3.7734 | 3.7121 | 3.6482 | 3.6082 | 3.5724 | 3.5270 | 3.4705 |
| Cubit with shared R | 4.1432 | 3.9328 | 3.8313 | 3.7733 | 3.7134 | 3.6465 | 3.6058 | 3.5709 | 3.5227 | 3.4661 | |
| Cubit with Seperate R | 4.1357 | 3.9293 | 3.8258 | 3.7659 | 3.7052 | 3.6394 | 3.5995 | 3.5637 | 3.5176 | 3.4597 |
Q5: Can you report Figure 3 in validation loss rather than training loss?
A5: The following is the validation loss for Figure 3.
Diff Length Performance: Transformer VS Cubit
| Method | Length | 5k | 10k | 15k | 20k | 25k | 30k | 35k | 40k | 45k | 50k |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Transformer | 512 | 4.4865 | 4.2676 | 4.1182 | 4.0698 | 3.9963 | 3.9339 | 3.8610 | 3.8313 | 3.7778 | 3.7443 |
| Cubit | 512 | 4.4295 | 4.2254 | 4.0799 | 4.0319 | 3.9554 | 3.9003 | 3.8251 | 3.7961 | 3.7432 | 3.7110 |
| Transformer | 1024 | 4.1829 | 3.9666 | 3.8620 | 3.8012 | 3.7427 | 3.6778 | 3.6356 | 3.5973 | 3.5527 | 3.4960 |
| Cubit | 1024 | 4.1357 | 3.9293 | 3.8258 | 3.7659 | 3.7052 | 3.6394 | 3.5995 | 3.5637 | 3.5176 | 3.4597 |
| Transformer | 2048 | 3.9183 | 3.7805 | 3.6773 | 3.6389 | 3.5205 | 3.4631 | 3.4387 | 3.4006 | 3.3846 | 3.3673 |
| Cubit | 2048 | 3.8698 | 3.7385 | 3.6343 | 3.5967 | 3.4779 | 3.4199 | 3.3947 | 3.3584 | 3.3433 | 3.3265 |
| Transformer | 4096 | 3.7455 | 3.6394 | 3.5440 | 3.4668 | 3.4235 | 3.3919 | 3.3094 | 3.3154 | 3.3114 | 3.2985 |
| Cubit | 4096 | 3.6788 | 3.5776 | 3.4832 | 3.4050 | 3.3669 | 3.3352 | 3.2524 | 3.2578 | 3.2555 | 3.2430 |
| Transformer | 8192 | 3.6338 | 3.4524 | 3.4260 | 3.3345 | 3.3409 | 3.2739 | 3.2439 | 3.1980 | 3.2179 | 3.1942 |
| Cubit | 8192 | 3.5675 | 3.3904 | 3.3640 | 3.2743 | 3.2818 | 3.2160 | 3.1850 | 3.1412 | 3.1598 | 3.1366 |
Diff Length Performance: Deltaformer VS Cubit
| Method | Length | 5k | 10k | 15k | 20k | 25k | 30k | 35k | 40k | 45k | 50k |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Deltaformer | 512 | 4.4390 | 4.2357 | 4.0901 | 4.0457 | 3.9694 | 3.9128 | 3.8391 | 3.8092 | 3.7563 | 3.7242 |
| Cubit | 512 | 4.4295 | 4.2254 | 4.0799 | 4.0319 | 3.9554 | 3.9003 | 3.8251 | 3.7961 | 3.7432 | 3.7110 |
| Deltaformer | 1024 | 4.1395 | 3.9361 | 3.8316 | 3.7734 | 3.7121 | 3.6482 | 3.6082 | 3.5724 | 3.5270 | 3.4705 |
| Cubit | 1024 | 4.1357 | 3.9293 | 3.8258 | 3.7659 | 3.7052 | 3.6394 | 3.5995 | 3.5637 | 3.5176 | 3.4597 |
| Deltaformer | 2048 | 3.8834 | 3.7550 | 3.6485 | 3.6120 | 3.4937 | 3.4354 | 3.4131 | 3.3751 | 3.3601 | 3.3405 |
| Cubit | 2048 | 3.8698 | 3.7385 | 3.6343 | 3.5967 | 3.4779 | 3.4199 | 3.3947 | 3.3584 | 3.3433 | 3.3265 |
| Deltaformer | 4096 | 3.6973 | 3.5991 | 3.5061 | 3.4282 | 3.3847 | 3.3556 | 3.2732 | 3.2798 | 3.2796 | 3.2657 |
| Cubit | 4096 | 3.6788 | 3.5776 | 3.4832 | 3.4050 | 3.3669 | 3.3352 | 3.2524 | 3.2578 | 3.2555 | 3.2430 |
| Deltaformer | 8192 | 3.5919 | 3.4161 | 3.3918 | 3.2997 | 3.3082 | 3.2412 | 3.2113 | 3.1655 | 3.1854 | 3.1615 |
| Cubit | 8192 | 3.5675 | 3.3904 | 3.3640 | 3.2743 | 3.2818 | 3.2160 | 3.1850 | 3.1412 | 3.1598 | 3.1366 |
Q6: How does change in the course of training? Does it stay near 1e-10?
A6: Because we use key normalziation, softmax and RoPE, the inverse matrix condition number is relatively very small and so that solution is stable and the could be very small. If the condition number is very large, we have to increase it.
- Rating
- 2/4
- Confidence
- 2/4
- Soundness
- 2/3
- Presentation
- 3/3
- Informativeness
- 2/3
Read review
Summary
Cubit proposes a KRR-inspired token mixer that transforms values through a regularized matrix solve before attention aggregation, together with Limited-Range Rescale (LRR). Experiments evaluate language modeling and downstream performance across multiple datasets and model sizes.
Strengths
- The regression perspective motivates a concrete architectural modification. I find this an interesting design direction, whose empirical value does not depend on exact equivalence to classical KRR.
- Reported validation-loss improvements span several settings, with additional three-seed results in the appendix. The reference-sharing and no-LRR ablations also help examine the proposed components.
Weaknesses
- The relationship between the theoretical motivation and the implemented causal operator needs clarification. One-sided normalization, masked row-wise softmax, and triangular solving generally differ from classical symmetric KRR. Exact equivalence is not necessary for the architectural contribution to be useful, but the paper should distinguish the regression analogy from properties actually established for its implementation. My concern is whether the claimed theoretical advantages survive these modifications.
- The attribution of the gains could be clearer. The no-LRR ablation examines the effect of removing LRR from Cubit, but does not by itself establish whether the matrix solve provides an advantage over a baseline equipped with comparable rescaling. It would be helpful to clarify whether such a control is included or applicable. Comparisons with and without LRR for both architectures would help distinguish the contribution of the solve, the rescaling, and their interaction.
- The practical quality–cost trade-off remains unclear. Average downstream gains over Transformer are approximately 0.18–0.53 percentage points, but corresponding throughput, memory, and incremental decoding comparisons are missing. The additional validation-loss statistics are useful, but do not establish the uncertainty of these downstream differences. Consequently, the evidence for a practical advantage remains limited.
Questions for the authors
- Which KRR-derived properties hold for the implemented causal operator? If an optimization interpretation is central to the theoretical claims, what objective does this operator optimize?
- Can LRR be applied comparably to the Transformer baseline, and is this control included in the experiments? What do the existing ablations establish about the separate contributions of the matrix solve and LRR?
- At matched training compute, how does Cubit compare with Transformer and DeltaFormer in quality? Please also clarify training throughput, memory use, incremental decoding performance, and the variability of the key downstream gains.
3 comments
Response to Reviewer fHBa(Part 1/3)
Dear Reviewer fHBa,
Thank you for the comment, we will address the concerns below.
Q1: The theoretical motivation is insufficiently connected to the provided causal implementation. One-sided normalization, masked row-wise softmax, and triangular solving generally differ from classical symmetric KRR. The claimed theoretical advantages therefore require justification for the implemented operator or more limited claims.
A1: We will explain the one-sided normalization, softmax normalization and trigular solve.
one sided normalization We could apply both query and key normalization to Cubit. The following is the comparsion.
Actually, according our training Cubit with even large scale model experience (e.g. 15B), it is better to normalize both query and key to a fixed norm (e.g. )。 Attention: We normalize as , without any learnable scale. If a learnable scale is still desired, use a scalar rather than a vector of shape ; the latter may cause the diagonal entry not to be the largest one, thereby increasing the condition number.
Cubit Performance with RBF kernel, following strict KRR definition, with 1.3B model size and GBS 16
| Formulation | 5K | 10K | 15K | 20K | 25K | 30K | 35K | 40K | 45K | 50K |
|---|---|---|---|---|---|---|---|---|---|---|
| 4.1986 | 3.9526 | 3.8667 | 3.7418 | 3.6367 | 3.5844 | 3.5102 | 3.5080 | 3.3986 | 3.4005 | |
| 4.1872 | 3.9424 | 3.8591 | 3.7340 | 3.6322 | 3.5794 | 3.5113 | 3.5050 | 3.3957 | 3.3978 |
Softmax Normalization We have tried to apply RBF kernel (strictly follow the KRR), but the performance is worse than Softmax for the final step. We still dot not know the reason, and we sincere hope that if anyone could help solve this problem.
Cubit Performance with RBF kernel, following strict KRR definition, with 1.3B model size and GBS 16
| Kernel(QK) | Kernel(KK) | 5K | 10K | 15K | 20K | 25K | 30K | 35K | 40K | 45K | 50K |
|---|---|---|---|---|---|---|---|---|---|---|---|
| RBF | RBF | 4.1640 | 3.9327 | 3.8540 | 3.7338 | 3.6322 | 3.5773 | 3.5052 | 3.5035 | 3.3951 | 3.3987 |
| Softmax | Softmax | 4.1872 | 3.9424 | 3.8591 | 3.7340 | 3.6322 | 3.5794 | 3.5113 | 3.5050 | 3.3957 | 3.3978 |
The implementation of Softmax
T, B, H, D = query_layer.shape
key_layer_copy = key_layer
query_layer = query_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
key_layer = key_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
value_layer = value_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
beta = (0.5 + self.beta_ga) * F.sigmoid(
self.b_proj(hidden_states).reshape(T, B, H, 1).permute(1, 2, 0, 3)) + 0.5 + self.alpha_zeros
k2 = key_layer_copy.reshape(T * B, H, -1)
k2 = k2.reshape(T, B, H, -1)
k2_k = (k2 / torch.norm(k2, dim=-1, keepdim=True, p=2) * math.sqrt(D)).reshape(T, B, H, -1)
query_k = (query_layer / torch.norm(query_layer, dim=-1, keepdim=True, p=2) * math.sqrt(D))
k2 = (k2).permute(1, 2, 0, 3)
k2_k = k2_k.permute(1, 2, 0, 3)
k2_k = k2_k
atten_score = torch.matmul(query_k / math.sqrt(D), (k2_k).transpose(-2, -1))
atten_score = atten_score
W = self.scale_mask_softmax(atten_score, attention_mask)
atten_score = torch.matmul(k2_k / math.sqrt(D), (k2_k).transpose(-2, -1))
atten_score = atten_score
A = self.scale_mask_softmax(atten_score, attention_mask)
with torch.cuda.amp.autocast(dtype=torch.float32):
# solve(A, b)
value_layer = torch.linalg.solve_triangular(A.float(), (value_layer * beta).float(),
upper=False)
value_layer = value_layer.to(hidden_states.dtype)
context_layer = torch.einsum('bhij,bhjd->bhid', W, value_layer)
context_layer = context_layer.reshape(B, H, T, D).permute(2, 0, 1, 3).reshape(T, B, H * D)
Response to Reviewer fHBa(Part 2/3)
The implementation of RBF
def rbf_similarity_sqrt(Q, K, gamma=1.0, eps=1e-8):
"""
Compute the RBF kernel similarity matrix.
Args:
Q: (T_q, d) query matrix
K: (T_k, d) key matrix
gamma: kernel width parameter (gamma > 0)
eps: small constant for numerical stability (guard against negative zero)
Returns:
S: (T_q, T_k) similarity matrix, S[i,j] = exp(-gamma * ||Q[i] - K[j]||^2)
"""
# Method 1: use torch.cdist (recommended)
dist_sq = torch.cdist(Q, K, p=2) # (T_q, T_k)
# dist_sq = torch.cdist(Q, K, p=2)
dist_sq = dist_sq**2
dist_sq = dist_sq / (math.sqrt(16 * Q.shape[-1]))
# Avoid negative zero (theoretically impossible, but possible due to floating-point error)
dist_sq = torch.clamp(dist_sq, min=0.0)
S = torch.exp(-gamma * dist_sq)
return S
T, B, H, D = query_layer.shape
key_layer_copy = key_layer
query_layer = query_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
key_layer = key_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
value_layer = value_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
beta = (0.5 + self.beta_ga) * F.sigmoid(
self.b_proj(hidden_states).reshape(T, B, H, 1).permute(1, 2, 0, 3)) + 0.5 + self.alpha_zeros
k2 = key_layer_copy.reshape(T * B, H, -1)
k2 = k2.reshape(T, B, H, -1)
k2_k = (k2 / torch.norm(k2, dim=-1, keepdim=True, p=2) * math.sqrt(D)).reshape(T, B, H, -1)
query_k= (query_layer / torch.norm(query_layer, dim=-1, keepdim=True, p=2) * math.sqrt(D))
k2 = (k2).permute(1, 2, 0, 3)
k2_k = k2_k.permute(1, 2, 0, 3)
k2_k=k2_k
W = rbf_similarity_sqrt(query_k.reshape(B * H, T, -1), k2_k.reshape(B * H, T, -1))
W = torch.tril(W)
W = W.reshape(B, H, T, -1)
A = rbf_similarity_sqrt(k2_k.reshape(B * H, T, -1), k2_k.reshape(B * H, T, -1))
A = torch.tril(A)
A = A.reshape(B, H, T, -1)
with torch.cuda.amp.autocast(dtype=torch.float32):
# solve(A, b)
value_layer = torch.linalg.solve_triangular(A.float(), (value_layer * beta).float(),
upper=False)
value_layer = value_layer.to(hidden_states.dtype)
context_layer = torch.einsum('bhij,bhjd->bhid', W, value_layer)
context_layer = context_layer.reshape(B, H, T, D).permute(2, 0, 1, 3).reshape(T, B, H * D)
Solve trigular We apply the Cubit to train Large Language Model so that we apply casual mask. If we use it to image classification, we should remove the mask and solve the whole matrix, but that needs O(N^3) time cost.
Response to Reviewer fHBa(Part 3/3)
Q2: The practical quality–cost trade-off remains unclear.
The following is the time cost and memory cost.
| Method | Cost | Length 512 | Length 1024 | Length 2048 | Length 4096 | Length 8192 |
|---|---|---|---|---|---|---|
| Transformer | Time Cost (ms) | 326.3 | 352.0 | 445.3 | 790.7 | 2078.3 |
| Memory Cost (MB) | 7352.0 | 7552.0 | 8774.0 | 15980.0 | 39368.0 | |
| DeltaFormer | Time Cost (ms) | 459.6 | 567.3 | 823.0 | 1766.0 | 5307.0 |
| Memory Cost (MB) | 7352.0 | 7868.0 | 9542.0 | 19052.0 | 51704.0 | |
| Cubit | Time Cost (ms) | 468.2 | 575.8 | 835.3 | 1761.7 | 5274.5 |
| Memory Cost (MB) | 7352.0 | 7448.0 | 9578.0 | 20180.0 | 51656.0 |
Q3: What objective does the implemented causal operator optimize, and which KRR properties hold for it?
A3: We use casual operator because the current large scale model is decoder-only so that we add the casual mask, and you could remove it if you apply it to image classification and so on, but that needs O(N^3) time cost. The KRR properties hold for Cubit: when q=, the KRR/Cubit returns so that long context performance is betteer
The text model erros are related to associate recall. When , we may need the perfect
=
With the context length increase, the will decreases, suggests that the the needed will be difficult to be retrive. If the context is sufficient long, the retrived value is only noise
For KRR, we have th following
.
- Rating
- 2/4
- Confidence
- 3/4
- Soundness
- 2/3
- Presentation
- 2/3
- Informativeness
- 2/3
Read review
Summary
Cubit replaces the usual attention value aggregation with a kernel-ridge-regression-inspired token mixer. It builds an additional reference similarity matrix from projected token features, adds a learned ridge parameter, and solves a causal triangular linear system for transformed values before applying ordinary query-key attention. A learned limited-range rescaling (LRR) multiplies the values entering that system. The paper motivates this as moving from a Nadaraya-Watson view of attention to a more regularized KRR view, and argues that the change should help as context length grows. The experiments compare Cubit with a Transformer and DeltaFormer on Arxiv, Books3, and FineWeb-Edu language modeling, using 125M, 350M, and 1.3B parameter settings. The paper also shows a growing training-loss gap up to length 8,192 and ablates the extra reference projection and LRR. On seven zero-shot tasks, Cubit has the highest mean in each of the three reported model/token-budget settings, although those mean differences are much smaller than the language-modeling loss differences: for example, 51.78 versus 51.53 for the Transformer at 1.3B/10B tokens.
Strengths
-
The empirical pattern is reasonably consistent. Cubit is ahead of both listed baselines on Arxiv, Books3, and FineWeb validation loss at the reported endpoints, and the advantage persists at 350M and 1.3B rather than appearing only at the smallest scale. The comparison at 1,024 tokens with a doubled batch is a useful attempt to separate longer sequences from simply processing more tokens. Appendix J adds a three-seed FineWeb table, which is better than relying only on a single favorable run.
-
I also appreciate that the ablations look at two quite different pieces of the design. The shared-reference variant still beats the Transformer in the FineWeb plot, suggesting the result is not solely an extra projection's parameter count. Removing LRR changes the final 125M FineWeb loss from 3.4597 to 3.4645, so LRR helps, but the bulk of the gain over the 3.4960 Transformer comes from the underlying mixer. That is a more informative result than a single full-model comparison.
Weaknesses
-
The KRR justification does not cleanly match the operation actually implemented. Classical KRR uses a symmetric positive-semidefinite Gram matrix built from one kernel, whereas the supplied code forms the matrix to be inverted by row-wise softmax of reference-feature similarities with a causal mask and then adds a diagonal ridge term. This is generally not a symmetric Gram matrix; the separate query-key attention matrix used afterward is another learned similarity altogether. The paper itself first invokes a common feature map and then relaxes it to distinct query and key projections. That may define a useful mixer, but it is not enough to carry over KRR's convergence, regularization, or boundary-effect arguments. A careful derivation of what estimator the implemented causal solve represents is needed to sustain the main conceptual claim.
-
The evidence for a practical long-context advantage is incomplete. The block includes a triangular solve in addition to ordinary attention, yet there are no matched throughput, memory, FLOP, or inference-latency results, even at the 8,192-token setting where the paper emphasizes a larger loss gap. Figure 3 plots training loss differences at longer lengths; it does not directly test long-range retrieval or held-out quality at lengths beyond training. The downstream improvements are modest (the seven-task mean is only 0.25 points above the Transformer at 1.3B/10B tokens), and the paper gives no uncertainty for those task means. The appendix implementation also refers to self.lrr and self.casual_mask although the constructor defines self.LRR and self.causal_mask; if this is the intended reproducibility code, it would not run as printed. None of this negates the observed loss improvement, but it weakens the claim of a scalable next-generation replacement.
Questions for the authors
Can the authors specify the exact matrix solved in the experiments, including how the causal softmax is applied, and explain which of the stated KRR properties still hold for that generally nonsymmetric matrix? In particular, is there an ablation using a bona fide positive-semidefinite reference Gram matrix, or a more modest interpretation of the current operation that the authors can justify mathematically?
What are training tokens per second, peak memory, and autoregressive decoding latency for Cubit and both baselines at matched hardware and lengths 1,024, 4,096, and 8,192? A held-out long-context test, rather than only training-loss curves, would also materially change my view of the long-sequence claim. Please clarify whether the code in Appendix K is the code used for the experiments and correct the attribute-name inconsistencies if so.
3 comments
Response to Reviewer Hkte (Part 1/3)
Dear Reviewer Hkte,
Thank you for the comment. We will address the concerns below.
Q1: The KRR justification does not cleanly match the operation actually implemented, with softmax kernel and reference projection.
A1: We have clearly presented the performance of RBF kernel and shared reference projection (K=R) in Figure 5, where the performance is worse。
Cubit Performance with RBF kernel, following strict KRR definition, with 1.3B model size and GBS 16
| Kernel(QK) | Kernel(KK) | 5K | 10K | 15K | 20K | 25K | 30K | 35K | 40K | 45K | 50K |
|---|---|---|---|---|---|---|---|---|---|---|---|
| RBF | RBF | 4.1640 | 3.9327 | 3.8540 | 3.7338 | 3.6322 | 3.5773 | 3.5052 | 3.5035 | 3.3951 | 3.3987 |
| Softmax | Softmax | 4.1872 | 3.9424 | 3.8591 | 3.7340 | 3.6322 | 3.5794 | 3.5113 | 3.5050 | 3.3957 | 3.3978 |
Cubit Performance with Shared Reference Matrix (K=R) in Figure 5
| Method | 5k | 10k | 15k | 20k | 25k | 30k | 35k | 40k | 45k | 50k |
|---|---|---|---|---|---|---|---|---|---|---|
| Share R(K=R) | 4.1432 | 3.9328 | 3.8313 | 3.7733 | 3.7134 | 3.6465 | 3.6058 | 3.5709 | 3.5227 | 3.4661 |
| Seperate R(K!=R) | 4.1357 | 3.9293 | 3.8258 | 3.7659 | 3.7052 | 3.6394 | 3.5995 | 3.5637 | 3.5176 | 3.4597 |
Q2: The evidence for a practical long-context advantage is incomplete. And the implementation question.
A2: We further provide the Multi Query Associate Recal evaluation performance.
| Method | 1024 | 2048 | 8192 | Average |
|---|---|---|---|---|
| Hyena | 88.17 | 47.68 | 33.43 | 56.42 |
| Mamba | 97.89 | 98.27 | 88.74 | 94.96 |
| Mamba2 | 98.20 | 98.21 | 98.32 | 98.24 |
| RWKV-7 | 98.34 | 98.52 | 98.13 | 98.38 |
| Gated DeltaNet | 98.29 | 98.48 | 98.98 | 98.58 |
| Transformer | 98.65 | 98.90 | 98.77 | 98.77 |
| Cubit | 98.88 | 99.10 | 99.39 | 99.12 |
The detailed implementation, with input hiddden states .
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
def scale_mask_softmax(
atten_score: torch.Tensor,
attention_mask: torch.Tensor = None,
scale: float = None,
mask_value: float = -1e4,
) -> torch.Tensor:
"""
Scale + mask + softmax.
Convention: in `attention_mask`, 1 / True means KEEP, 0 / False means MASK.
Args:
atten_score: [..., T, T] raw scores (unscaled)
attention_mask: [..., T, T] or any broadcastable shape
- bool: True = keep, False = mask
- 0/1 value: 1 = keep, 0 = mask
scale: scaling factor, caller passes 1/sqrt(D)
mask_value: negative value filled at masked positions
(exp() ~ 0 in fp32, avoids -inf -> NaN)
Returns:
softmax result of shape [..., T, T]
"""
if scale is not None:
atten_score = atten_score * scale
if attention_mask is not None:
if attention_mask.dtype == torch.bool:
keep = attention_mask
else:
# 0/1 numeric mask -> bool
keep = attention_mask.to(torch.bool)
# 1 keep -> unchanged; 0 mask -> fill with mask_value
atten_score = atten_score.masked_fill(~keep, mask_value)
return torch.softmax(atten_score, dim=-1)
Response to Reviewer Hkte (Part 2/3)
class Cubit(nn.Module):
def __init__(
self,
hidden_size: int,
num_heads: int,
head_dim: int = None,
alpha_zeros: float = 0.0,
beta_ga: float = 1.0,
ga_norm: float = 1.0,
attention_dropout: float = 0.0,
mask_value: float = -1e4,
):
super().__init__()
self.hidden_size = hidden_size
self.num_heads = num_heads
self.head_dim = head_dim or hidden_size // num_heads
self.mask_value = mask_value
self.alpha_zeros = nn.Parameter(torch.tensor(alpha_zeros))
self.beta_ga = nn.Parameter(torch.tensor(beta_ga))
self.ga_norm = nn.Parameter(torch.tensor(ga_norm))
self.b_proj = nn.Linear(hidden_size, num_heads, bias=False)
self.dropout = nn.Dropout(attention_dropout)
def forward(
self,
hidden_states,
query_layer,
key_layer,
value_layer,
attention_mask=None, # [B*H, T, T] or [B, 1, T, T]; 1/True = keep
):
"""
Args:
hidden_states: [T, B, C]
query_layer / key_layer / value_layer: [T, B, H, D]
attention_mask: 1/True = keep, 0/False = mask
Returns:
context_layer: [T, B, H*D]
"""
T, B, H, D = query_layer.shape
dtype = hidden_states.dtype
# ---------- 1. reshape to [B*H, T, D] ----------
key_layer_copy = key_layer
q = query_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
k = key_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
v = value_layer.reshape(T, B, H, -1).permute(1, 2, 0, 3) # [B*H, T, D]
# ---------- 2. beta gating ----------
beta = (0.5 + self.beta_ga) * torch.sigmoid(
self.b_proj(hidden_states).reshape(T, B, H, 1).permute(1, 2, 0, 3)
) + 0.5 + self.alpha_zeros # [B*H, T, 1]
# ---------- 3. normalized k2 to make the condition number better ----------
k2 = key_layer_copy.reshape(T * B, H, -1).reshape(T, B, H, -1)
k2_k = k2 / torch.norm(k2, dim=-1, keepdim=True, p=2) * math.sqrt(D)
k2_k = k2_k.reshape(T, B, H, -1).permute(1, 2, 0, 3) * self.ga_norm
k2 = k2.permute(1, 2, 0, 3) # [B*H, T, D]
# ---------- 4. atten_score + custom scale_mask_softmax ----------
scale = 1.0 / math.sqrt(D)
atten_score = torch.matmul(q, k.transpose(-2, -1)) # [B*H, T, T]
A = scale_mask_softmax(
atten_score,
attention_mask=attention_mask,
scale=scale,
mask_value=self.mask_value,
) # [B*H, T, T]
# ---------- 5. triangular solve: value = solve(A, beta * v) ----------
with torch.cuda.amp.autocast(dtype=torch.float32):
v_solved = torch.linalg.solve_triangular(
A.float(), (v * beta).float(), upper=False
)
v_solved = v_solved.to(dtype) # [B*H, T, D]
# ---------- 6. SDPA attention (q x k2) ----------
if attention_mask is not None:
sdpa_mask = attention_mask.to(torch.bool)
else:
sdpa_mask = None
context_layer = F.scaled_dot_product_attention(
q, k2, v_solved, attn_mask=sdpa_mask
)
context_layer = self.dropout(context_layer) # [B*H, T, D]
# ---------- 7. restore to [T, B, H*D] ----------
context_layer = context_layer.reshape(B, H, T, D) \
.permute(2, 0, 1, 3) \
.reshape(T, B, H * D)
return context_layer
Response to Reviewer Hkte (Part 3/3)
Q3: Can the authors specify the exact matrix solved in the experiments, including how the causal softmax is applied, and explain which of the stated KRR properties still hold for that generally nonsymmetric matrix?
A3: For KRR, if q=, then we will have . This is still guaranteed so that the long-range retrival performance is better .
The text model erros are related to associate recall. When , we may need the perfect
=
With the context length increase, the will decreases, suggests that the the needed will be difficult to be retrive. If the context is sufficient long, the retrived value is only noise
For KRR, we have th following
.
Therefore, when , we cold perfect have , whatever the hidden size, hidden dimen and so on. The long context ability is only bounded by the computation precous
Q4: The time cost and memory cost
A4: The following is the time cost and memory cost.
| Method | Cost | Length 512 | Length 1024 | Length 2048 | Length 4096 | Length 8192 |
|---|---|---|---|---|---|---|
| Transformer | Time Cost (ms) | 326.3 | 352.0 | 445.3 | 790.7 | 2078.3 |
| Memory Cost (MB) | 7352.0 | 7552.0 | 8774.0 | 15980.0 | 39368.0 | |
| DeltaFormer | Time Cost (ms) | 459.6 | 567.3 | 823.0 | 1766.0 | 5307.0 |
| Memory Cost (MB) | 7352.0 | 7868.0 | 9542.0 | 19052.0 | 51704.0 | |
| Cubit | Time Cost (ms) | 468.2 | 575.8 | 835.3 | 1761.7 | 5274.5 |
| Memory Cost (MB) | 7352.0 | 7448.0 | 9578.0 | 20180.0 | 51656.0 |
Q5: The implementation code
A5: We have provided the implementation code in A2.
Comments on the paper
1 comment
Response to All Reviewer
Dear Reviewers,
We address the common concerns below.
Q1: The KRR properies for Cubit and the connection to long context performance (Reviewer Hkte, dbzF)
A1: When q=, the KRR/Cubit will return , while Transformer(Nadaraya-Watson Regression) not.
The text model erros are related to associate recall. When , we may need the perfect
=
With the context length increase, the will decreases, suggests that the the needed will be difficult to be retrive. If the context is sufficient long, the retrived value is only noise
For KRR, we have th following
.
Q2: The time cost and memory cost (Reviewer Hkte,fHBa, dbzF)
A2: The following is the time cost and memory cost.
| Method | Cost | Length 512 | Length 1024 | Length 2048 | Length 4096 | Length 8192 |
|---|---|---|---|---|---|---|
| Transformer | Time Cost (ms) | 326.3 | 352.0 | 445.3 | 790.7 | 2078.3 |
| Memory Cost (MB) | 7352.0 | 7552.0 | 8774.0 | 15980.0 | 39368.0 | |
| DeltaFormer | Time Cost (ms) | 459.6 | 567.3 | 823.0 | 1766.0 | 5307.0 |
| Memory Cost (MB) | 7352.0 | 7868.0 | 9542.0 | 19052.0 | 51704.0 | |
| Cubit | Time Cost (ms) | 468.2 | 575.8 | 835.3 | 1761.7 | 5274.5 |
| Memory Cost (MB) | 7352.0 | 7448.0 | 9578.0 | 20180.0 | 51656.0 |
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Response to Reviewer dbzF(Part 1/2)
Dear Reviewer dbzF,
Thank you for the support. We will address the concerns below.
Q1: Without valid theory, the model used in experiments is an empirical variant of DeltaFormer, and the authors neither acknowledge nor analyze the differences.
A1: The following is the difference between Deltaformer and Cubit.
Difference motivation The DeltaFormer also discusses how to use the inverse matrix to improve the performance, so that we can discuss the difference here. First, the motivation is different. The DeltaFormer is motivated by combining DeltaNet and Transformer, while the Cubit is motivated by the Kernel Ridge Regression.
Different Implementaion The implementation is different, as the DeltaFormer uses two different embeddings w and k to construct the inverse matrix, while Cubit suggests that we have to use one specific embedding (e.g., only k or only r) so that the matrix is invertible.
The diagonal value process Motivated by DeltaNet, the DeltaFormer sets the diagonal value to 1 to calculate the inverse matrix, while the Cubit can be sure that there exists an inverse matrix so that the diagonal value does not necessarily have to be 1. Such an error may gradually increase with the sequence length increase (empirically validated in Figure 3)
When q=ki, the KRR/Cubit will return vi, while Transformer(Nadaraya-Watson Regression) not.
The text model erros are related to associate recall. When q=ki, we may need the perfect vi
Transformer=NW(q=kt,k,v)=kernel(kt,kt)+∑j=tkernel(kt,kj)kernel(kt,kt)vt+∑i=tkernel(kt,kt)+∑j=tkernel(kt,kj)kernel(kt,ki)vi
With the context length increase, the kernel(kt,kt)+∑j=tkernel(kt,kj)kernel(kt,kt) will decreases, suggests that the the needed vt will be difficult to be retrive. If the context is sufficient long, the retrived value is only noise
For KRR, we have th following
KRR(q=kt,k,v)=(qk)(kkT)−1v=(ktk)(kkT)v=vt.
Q2: The gains over the Transformer are small, typically 0.02-0.04 in validation loss.
A2: For language modeling, the 0.04 loss is actually a large loss gain. For example, DeltaNet Gated Attention performance gain is only 0.018 loss gain compared to Transformer++ for 1.3B in Table 1 [1]
Reference:
[1] Yang, S., Wang, B., Zhang, Y., Shen, Y., & Kim, Y. (2024). Parallelizing linear transformers with the delta rule over sequence length. Advances in neural information processing systems, 37, 115491-115522.
Q3: The time cost
A3: The following is the time cost.