This is a promising direction, and you're clearly thinking in the right ballpark—state-size generalization is one of the key frontiers for sequence modeling. But there are several critical issues that need to be addressed before this idea can reliably work at scale or generalize beyond training conditions.
Let’s unpack your proposal carefully.
1. State Size Generalization: What Does It Mean?
You're aiming to train models with a smaller internal state (e.g., number of keys in attention or hidden dimensionality), then deploy them with larger states. The core assumption here is that the model's function—its ability to process sequences and make decisions—is not tightly bound to the size of its internal representation. That’s a strong assumption, and it’s not clear whether it holds across all relevant tasks.
Critical issue: When you increase the effective memory (i.e., more keys or higher dimensionality), does the model retain the same behavior modulo scaling? Or does it fundamentally change how information is represented and processed?
For example:
- In standard attention, increasing the number of keys changes the softmax normalization, which affects gradient flow.
- In linear attention, changing the projection dimension alters the space in which inner products are computed, possibly invalidating learned patterns.
So even if you manage to train on small states, the functional mapping might not extrapolate well unless the architecture has some kind of compositional or invariant structure.
2. Random Key Attention: A Clever Trick, but With Hidden Costs
The idea of using random keys during training, and dynamically assigning or merging keys during inference, seems elegant—it allows for dynamic expansion of the key-value store. However, there are several potential pitfalls:
a) Key Assignment Ambiguity
When you write a new key, how do you decide which existing key to overwrite or merge with? Softmax-based assignment introduces smoothness but may lose specificity. Nearest neighbor approaches are brittle unless the key space is structured in a meaningful way.
If the keys are randomly initialized and not learned, how do they form a coherent basis for representing the input? You risk losing representational power unless the assignment mechanism itself learns to impose structure.
b) Gradient Flow Through Assignment
If the assignment depends on soft distances between incoming queries and stored keys, you’ll have gradients flowing through those distances. This creates a dependency between the current query and the entire key set, which could lead to instability when the key set grows.
As the number of keys increases, the influence of each individual key diminishes—this could cause vanishing gradients or poor signal propagation.
c) Dynamic Merging vs. Overwriting
Melding or overwriting introduces a kind of memory compression. But what guarantees do you have that the merged representations preserve the necessary information? Without a principled loss function guiding the merge, this becomes a heuristic step.
This is akin to vector quantization without commitment loss or reconstruction objective—there's no reason to believe the merged key retains the required information.
3. Linear Attention and State Expansion
You mention that similar ideas could apply to linear attention. That’s true in principle, but again, the devil is in the details.
In linear attention, the state is often a compressed representation (e.g., a matrix product of values and keys). If you fix the dimensionality during training, then expand it at inference time, you’re effectively changing the rank or expressivity of the system.
Critical issue: How do you ensure that the expanded projection matrices (or their implicit equivalents) maintain the learned relationships? For instance, if you project into a higher-dimensional space at inference, how do you initialize the extra dimensions? Randomly? Then you're back to the same problem as with random keys—lack of structure.
Even if you use learned projections, the extrapolation from low-rank to high-rank is non-trivial. Linear attention assumes certain linearity properties, but these may not hold under dimensional expansion unless the original model was trained with explicit invariance to such changes.
4. Generalization Across State Sizes: Architectural Constraints
There’s a deeper architectural question here: what parts of the model must remain fixed across state sizes, and what can vary?
For example:
- If you expand the number of keys, do you also expand the value vectors? The projection heads?
- Do feed-forward layers also scale with the state size? If not, they become bottlenecks.
Any component that doesn't scale with the state will eventually limit the benefit of increasing the state size.
Moreover, any learned parameters tied directly to the state (e.g., layer norms, gate functions, etc.) will now be mismatched if the state size changes. These mismatches can break the internal coordination between components.
5. Evaluation and Training Signal
Finally, how do you train a model to perform well at larger state sizes when it only sees smaller ones during training?
Unless you include some kind of meta-learning signal or auxiliary loss that encourages robustness to state size changes, the model has no incentive to learn a scalable internal logic.
Critical issue: There's no direct supervision for how the model should behave at larger state sizes. So even if you can technically expand the state, there's no guarantee the behavior generalizes meaningfully.
Summary of Challenges
| Challenge | Description |
|---|
| Function Stability | Does the model behave consistently when state size changes? |
| Key Assignment | How to assign or merge keys without losing representational fidelity? |
| Gradient Dynamics | Do gradients still propagate meaningfully when the key set expands? |
| Dimensional Extrapolation | Can linear attention or projection mechanisms generalize to higher dimensions? |
| Architectural Consistency | Which parts of the model must scale with state size, and how? |
| Training Signal | Is there an explicit incentive for the model to generalize across state sizes? |
Final Thought
Your intuition—that we should be able to train models at small scales and deploy them at large—is sound. But the path to achieving this requires confronting deep questions about invariance, modularity, and compositionality in neural architectures. Your approach touches on these issues, but the crux lies in ensuring that the learned representations and operations are independent of the specific state size used during training.
The essential difficulty is not just technical implementation—it's defining what it means for a model to generalize across different computational capacities while preserving its functional behavior.