Manuscript Offprint
arXiv:2608.29093Titans-QFWP: A Regime-Aware Hybrid Quantum Fast Weight Programmer for Portfolio Optimization
Ming-Kai Hung
Dept. of Technology Application
and Human Resource Development
National Taiwan Normal University
Taipei, Taiwan
Jun-Hao Chen
Dept. of Bioenvironmental
Systems Engineering
National Taiwan University
Taipei, Taiwan
Yun-Cheng Tsai
PecuLab LLC
Seattle, WA, USA
Samuel Yen-Chi Chen
Wells Fargo
USA
Abstract—We propose Titans-QFWP, a hybrid reinforcement learning architecture integrating a Quantum Fast Weight Programmer with Titans-style memory (Persistence, Surprise, and Forgetting) for adaptive portfolio optimization. To address high-dimensional market features, we introduce an enhanced A3C framework with Hungarian-aligned K-means clustering and scaled log-return rewards. Evaluated on 468 S&P 500 stocks under an Equal-Parameter-Count (EPC) benchmark with approximately 3,000 trainable parameters, Titans-QFWP achieves strong performance (median ARR 0.4260, Calmar 8.5504, IR 0.8427). Ablation results reveal that quantum gating fundamentally reshapes memory component roles, with Persistence supporting drawdown control, Surprise contributing to return generation, and Forgetting providing additional stabilization. By stabilizing these quantum representations, the model enables defensive allocation during market drawdowns while preserving upside potential.
Index Terms—Deep Reinforcement Learning, Fast Weight Programmer, Portfolio Optimization, Quantum Machine Learning, Regime-Aware Architecture
I. INTRODUCTION
Financial markets are inherently time-varying [1] and non-stationary [2], driven by regime shifts and secular changes [3] that undermine traditional portfolio optimization [4], [5]. Deep Reinforcement Learning (DRL) addresses these challenges through sequential policy optimization [6]–[8], but it often struggles with high computational costs [9] and high-dimensional state spaces [10]. To manage such expansive spaces, static clustering is typically employed; however, it remains fundamentally incapable of capturing abrupt market transitions [11]. In the quantum domain, Variational Quantum Circuits (VQC) can exploit high-dimensional Hilbert spaces [12], yet they lack adaptability due to fixed parameterization [13]–[15]. Although the Quantum Fast Weight Programmer (QFWP) introduces dynamic weights [16], [17] to overcome this, its update mechanisms often degrade memory stability. To address these challenges, we propose a dynamically adaptive hybrid architecture with two key contributions:
-
Titans-QFWP Architecture. Upgrading the original Q-A3C [18], we replace the VQC with Titans-QFWP. This architecture integrates QFWP with Titans-style memory (Persistence, Surprise, Forgetting) [19].
-
Enhanced A3C Framework. We redesign the A3C reinforcement learning environment [18], incorporating Hungarian-aligned K-means clustering, a defensive cash action, and a scaled log-return reward [20].
A. State Representation and Temporal Alignment
Using a 60-day lookback, we rebalance every market days. For each asset at time , the 5- and 20-day moving averages and 20-day volatility of log-returns are cross-sectionally -scored to form (), and then partitioned into clusters via -means. To maintain temporal consistency, the Hungarian algorithm aligns centroids by minimizing drift:
To filter short-term market noise for the next time step, the matched centroids are smoothed with EMA ( ) via , initialized based on the 20-day log-return component . Each cluster yields five features: means for , relative size , and momentum dispersion . Concatenating these 5K features with three S&P 500 index features forms the 53-dimensional state (empty clusters zero-padded).
B. Portfolio Construction and Reward Function
At each 20-day step , let be the prior target weight vector and the compound gross return vector derived from daily log-returns . The drifted weights are calculated as , where denotes the element-wise multiplication. The new weights are then assigned following an inverse volatility strategy, , using the 60-day historical volatility vector . If the cash action
The views expressed in this article are those of the authors and do not represent the views of Wells Fargo. This article is for informational purposes only. Nothing contained in this article should be construed as investment advice. Wells Fargo makes no express or implied warranties and expressly disclaims all legal, tax, and accounting implications related to this article.
These authors contributed equally to this work.
Corresponding author.
Titans-QFWP Architecture (Hybrid Agent)

Fig. 1. System architecture of the hybrid Titans-QFWP agent integrated with the Enhanced A3C continuous-reward portfolio simulation environment.
is chosen, . Rebalancing to these target weights at a cost rate yields a net survival fraction , which is solved by successive substitution: . With the gross portfolio return , the net realized return is given by . To ensure stability, the reward floors this return at and scales it by 100, treated as a hyperparameter:
C. Titans-QFWP Architecture and Optimization
As illustrated in Fig. 1, the policy fuses Titans-style memory with the Quantum Fast-Weight Programmer (QFWP). First, we apply two tanh activations to compress the state into an encoded vector ( ). This is augmented by a trainable matrix ( ) through an attention mechanism. The attention weights are computed as with , yielding the augmented representation:
A slow-program layer projects to ( ). From , three parallel softmax heads generate layer , qubit , and axis for Pauli ) distributions, whose normalized outer product forms the Surprise Tensor , where and . Conditioned on , learned sigmoid gates for memory retention ( ), momentum ( ), and surprise theta ( ) dictate the evolution of fast-weight memory from :
To serve as valid rotation angles, the raw memory is bounded via to parameterize the variational quantum circuit. Starting from uniform superposition , a feature encoding layer precedes layers of CNOT entanglers and parameterized rotations . Finally, the output state yields the expectation vector , composed of the Pauli-Z expectation values for each qubit. This vector is subsequently processed through a ReLU activation function to generate actor and critic heads for cluster selection, with the constituent stocks weighted by inverse volatility.
III. EXPERIMENTAL SETUP
Dataset. Daily log-returns of S&P 500 stocks (Jan. 2015–Apr. 2026) are used. Assets with more than 10% missing observations are excluded, yielding 468 stocks. All features are constructed using only the information available at time t. The data are divided into 2,262 training days (2015-01-06 to 2023-12-29), 252 validation days (2024-01-02 to 2024-12-31), and 332 test days (2025-01-02 to 2026-04-30).
Equal-Parameter-Count (EPC) Benchmark. For fair comparison, all 11 architectures are limited to approximately 3,000 trainable parameters. Inspired by Titans (Memory-as-Context) [19], our proposed Titans-QFWP (Full) is evaluated alongside its variants (allocations detailed in Table I).
IV. EXPERIMENTAL RESULTS AND DISCUSSION
A. Overall Analysis
Results over 10 random seeds (1–10), reported as median [IQR] in Table II, are compared with the market benchmark
TABLE I PARAMETER CONFIGURATION FOR THE EPC BENCHMARK.
| Architecture | Total | Quantum | Classical |
|---|---|---|---|
| Classical Architectures | |||
| Titans (Memory-as-Context) | 2,997 | 0 | 2,997 |
| FWP | 3,000 | 0 | 3,000 |
| Titans-FWP (Full) | 2,999 | 0 | 2,999 |
| Titans-FWP (-Forgetting) | 2,990 | 0 | 2,990 |
| Titans-FWP (-Persistence) | 2,931 | 0 | 2,931 |
| Titans-FWP (-Surprise) | 2,981 | 0 | 2,981 |
| Quantum Architectures | |||
| QFWP | 3,001 | 261 | 2,740 |
| Titans-QFWP (Full) | 3,000 | 1,253 | 1,747 |
| Titans-QFWP (-Forgetting) | 2,991 | 1,253 | 1,738 |
| Titans-QFWP (-Persistence) | 2,932 | 1,253 | 1,679 |
| Titans-QFWP (-Surprise) | 2,982 | 1,253 | 1,729 |
(S&P 500 Buy & Hold). Titans-QFWP (Full) achieves higher Annualized Rate of Return (ARR; 0.4260 vs. 0.2528), Calmar Ratio (Calmar; 8.5504 vs. 7.1638), and the highest Information Ratio (IR; 0.8427). In contrast, the market benchmark exhibits lower Maximum Drawdown (MDD; -0.0353) and higher Sortino Ratio (Sortino; 8.5405), partly due to the exclusion of transaction costs. These results demonstrate that Titans-QFWP effectively captures market trends under the strong bull-market regime.
B. Ablation Diagnostics
-
Classical Ablation (Titans-FWP): In classical variants (Table III), removing Surprise produces the largest degradation in ARR, Sortino, Calmar, and IR. Removing Forgetting results in the largest deterioration in MDD. Removing Persistence leads to smaller performance changes across most metrics.
-
Quantum Ablation (Titans-QFWP): In quantum variants (Table IV), removing Persistence causes the largest degradation in the median MDD, Sortino, and Calmar, while removing Surprise leads to the lowest median ARR and IR. These patterns suggest that quantum gating alters memory roles, with greater expressive capacity favoring Persistence over Forgetting for representation preservation.
C. Portfolio Dynamics and Asset Selection
As shown in Fig. 2 (Seed 1), Titans-QFWP achieves a cumulative return of , slightly outperforming the S&P 500 , driven by allocations to higher-return clusters (e.g., Clusters 7 and 9). The model adaptively reallocates to cash during market downturns.
Averaged across 10 seeds (1–10), the top-20 selected stocks exhibit concentrated outperformance in technology subsectors, including data storage, optical networking, photonics, and memory semiconductors (Fig. 3). Measured by active return (excess simple return over the S&P 500), WDC and CIEN outperform the benchmark at every time step, with peak active returns of +42.7% and +51.6%. In addition, COHR, LITE, and MU also contribute substantial excess returns.
V. LIMITATIONS
Limitations include survivorship bias, a short out-of-sample period, seed variability, simplified transaction costs, and eval- uation of quantum components using lightning.qubit quantum simulation. Risk-adjusted metrics are reported descriptively rather than as statistically conclusive evidence.

Fig. 2. Dynamic cluster selection of Titans-QFWP vs. the S&P 500 index.

Fig. 3. Top-20 selected stocks of Titans-QFWP vs. the S&P 500 index.
VI. CONCLUSION
Integrating QFWP with Titans-style memory provides a robust framework for addressing market non-stationarity. Crucially, the expressive capacity of quantum gating fundamentally alters learning dynamics: it shifts the mechanism of representation preservation, relying more on Persistence rather than Forgetting for drawdown control. Although frictionless passive benchmarks exhibit a marginal downside advantage during bull markets, Titans-QFWP mitigates this through regime-aware allocation, dynamically transitioning between defensive and high-performing asset clusters. These findings illustrate how quantum-classical memory architectures reorganize representation learning, advancing adaptive financial reinforcement learning.
REFERENCES
[1] A. M. Ozbayoglu, M. U. Gudelek, and O. B. Sezer, “Deep learning for financial applications: A survey,” Applied Soft Computing, vol. 93, p. 106384, 2020.
[2] J. D. Hamilton, “A new approach to the economic analysis of nonstationary time series and the business cycle,” Econometrica: Journal of the Econometric Society, vol. 57, no. 2, pp. 357–384, 1989.
[3] A. Ang and A. Timmermann, “Regime changes and financial markets,” Annual Review of Financial Economics, vol. 4, no. 1, pp. 313–337, 2012.
[4] F. J. Fabozzi, H. M. Markowitz, and F. Gupta, “Portfolio selection,” in Handbook of finance. John Wiley & Sons, 2008, vol. 2, pp. 3–13.
[5] M. Lopez de Prado, “Building diversified portfolios that outperform out-of-sample,” The Journal of Portfolio Management, vol. 42, no. 4, pp. 59–69, 2016.
TABLE II
S&P 500 OUT-OF-SAMPLE PERFORMANCE ACROSS ASSET ALLOCATION BASELINES (MEDIAN [IQR], SEEDS 1–10).
| Architecture | ARR | MDD | Sortino | Calmar | IR | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Market Benchmark | ||||||||||
| S&P 500 (Buy & Hold) | 0.2528 | -0.0353 | 8.5405 | 7.1638 | N/A | |||||
| Baseline & Classical Architectures | ||||||||||
| Titans (Memory-as-Context) | 0.2557 | [0.2649] | -0.0512 | [0.0355] | 3.3645 | [4.4568] | 3.9077 | [7.2651] | 0.1374 | [1.8125] |
| FWP | 0.3423 | [0.1904] | -0.0918 | [0.1046] | 3.3498 | [6.1209] | 3.9429 | [7.7964] | 0.4447 | [1.3117] |
| Titans-FWP (Full) | 0.3175 | [0.2013] | -0.0606 | [0.0648] | 4.9382 | [3.6665] | 6.2776 | [5.6673] | 0.3891 | [0.9531] |
| Titans-FWP (-Forgetting) | 0.2752 | [0.1713] | -0.0790 | [0.0453] | 3.5281 | [3.4122] | 3.4519 | [4.0856] | 0.1993 | [1.0045] |
| Titans-FWP (-Persistence) | 0.2841 | [0.2500] | -0.0702 | [0.0540] | 4.1309 | [2.8475] | 4.5385 | [3.4245] | 0.1927 | [1.2757] |
| Titans-FWP (-Surprise) | 0.1907 | [0.1834] | -0.0774 | [0.0731] | 2.8587 | [3.8253] | 2.5238 | [6.5771] | -0.4547 | [1.1375] |
| Quantum Architectures | ||||||||||
| QFWP | 0.1806 | [0.1437] | -0.1017 | [0.0887] | 1.8849 | [1.1011] | 1.5299 | [2.2969] | -0.4002 | [0.8815] |
| Titans-QFWP (Full) | 0.4260 | [0.4197] | -0.0500 | [0.0212] | 6.9018 | [6.5930] | 8.5504 | [6.0697] | 0.8427 | [1.3992] |
| Titans-QFWP (-Forgetting) | 0.1965 | [0.1276] | -0.0520 | [0.0415] | 3.0186 | [1.3646] | 3.3316 | [2.0293] | -0.3887 | [0.9337] |
| Titans-QFWP (-Persistence) | 0.1929 | [0.1297] | -0.1010 | [0.0400] | 2.0905 | [1.1939] | 2.1663 | [1.7055] | -0.3136 | [0.6757] |
| Titans-QFWP (-Surprise) | 0.1586 | [0.1749] | -0.0782 | [0.0318] | 2.6949 | [1.5092] | 2.3728 | [1.3064] | -0.5138 | [1.1810] |
TABLE III
PERFORMANCE METRICS FOR TITANS-FWP ABLATION VARIANTS (MEDIAN [IQR], SEEDS 1–10).
| Architecture | ARR | MDD | Sortino | Calmar | IR | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Classical Ablation Study: Titans-FWP | ||||||||||
| FWP (Baseline) | 0.3423 | [0.1904] | -0.0918 | [0.1046] | 3.3498 | [6.1209] | 3.9429 | [7.7964] | 0.4447 | [1.3117] |
| Titans-FWP (Full) | 0.3175 | [0.2013] | -0.0606 | [0.0648] | 4.9382 | [3.6665] | 6.2776 | [5.6673] | 0.3891 | [0.9531] |
| Titans-FWP (-Forgetting) | 0.2752 | [0.1713] | -0.0790 | [0.0453] | 3.5281 | [3.4122] | 3.4519 | [4.0856] | 0.1993 | [1.0045] |
| Titans-FWP (-Persistence) | 0.2841 | [0.2500] | -0.0702 | [0.0540] | 4.1309 | [2.8475] | 4.5385 | [3.4245] | 0.1927 | [1.2757] |
| Titans-FWP (-Surprise) | 0.1907 | [0.1834] | -0.0774 | [0.0731] | 2.8587 | [3.8253] | 2.5238 | [6.5771] | -0.4547 | [1.1375] |
TABLE IV
PERFORMANCE METRICS FOR TITANS-QFWP ABLATION VARIANTS (MEDIAN [IQR], SEEDS 1–10).
| Architecture | ARR | MDD | Sortino | Calmar | IR | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Quantum Ablation Study: Titans-QFWP | ||||||||||
| QFWP (Baseline) | 0.1806 | [0.1437] | -0.1017 | [0.0887] | 1.8849 | [1.1011] | 1.5299 | [2.2969] | -0.4002 | [0.8815] |
| Titans-QFWP (Full) | 0.4260 | [0.4197] | -0.0500 | [0.0212] | 6.9018 | [6.5930] | 8.5504 | [6.0697] | 0.8427 | [1.3992] |
| Titans-QFWP (-Forgetting) | 0.1965 | [0.1276] | -0.0520 | [0.0415] | 3.0186 | [1.3646] | 3.3316 | [2.0293] | -0.3887 | [0.9337] |
| Titans-QFWP (-Persistence) | 0.1929 | [0.1297] | -0.1010 | [0.0400] | 2.0905 | [1.1939] | 2.1663 | [1.7055] | -0.3136 | [0.6757] |
| Titans-QFWP (-Surprise) | 0.1586 | [0.1749] | -0.0782 | [0.0318] | 2.6949 | [1.5092] | 2.3728 | [1.3064] | -0.5138 | [1.1810] |
[6] D. Cao, Y. Liu, Y. Wang, Q. Zhang, and W. Hu, “Deep reinforcement learning in power systems resilience: A review,” IEEE Transactions on Reliability, vol. 74, no. 4, pp. 5356–5370, 2025.
[7] K. Arulkumaran, M. P. Deisenroth, M. Brundage, and A. A. Bharath, "Deep reinforcement learning: A brief survey," IEEE Signal Processing Magazine, vol. 34, no. 6, pp. 26–38, 2017.
[8] P. Henderson, R. Islam, P. Bachman, J. Pineau, D. Precup, and D. Meger, "Deep reinforcement learning that matters," in Proceedings of the 32nd AAAI Conference on Artificial Intelligence. AAAI Press, 2018, pp. 3207–3214.
[9] V. Mnih, A. P. Badia, M. Mirza, A. Graves, T. Lillicrap, T. Harley, D. Silver, and K. Kavukcuoglu, “Asynchronous Methods for Deep Reinforcement Learning,” in 33rd International Conference on Machine Learning (ICML). PMLR, 2016, pp. 1928–1937.
[10] H. Yang, X.-Y. Liu, S. Zhong, and A. Walid, “Deep reinforcement learning for automated stock trading: An ensemble strategy,” in 1st ACM International Conference on AI in Finance (ICAIF), 2020, pp. 1–8.
[11] S. Aghabozorgi, A. S. Shirkhorshidi, and T. Y. Wah, “Time-series clustering—a decade review,” Information Systems, vol. 53, pp. 16–38, 2015.
[12] M. Schuld and N. Killoran, “Quantum machine learning in feature Hilbert spaces,” Physical Review Letters, vol. 122, no. 4, p. 040504, 2019.
[13] K. Bharti, A. Cervera-Lierta, T. H. Kyaw, T. Haug, S. Alperin-Lea, A. Anand, M. Degroote, H. Heimonen, J. S. Kottmann, T. Menke, W.-K. Mok, S. Sim, L.-C. Kwek, and A. Aspuru-Guzik, "Noisy intermediate-scale quantum algorithms," Reviews of Modern
Physics, vol. 94, no. 1, p. 015004, 2022. [Online]. Available: https://doi.org/10.1103/RevModPhys.94.015004
[14] M. Cerezo, A. Arrasmith, R. Babbush, S. C. Benjamin, S. Endo, K. Fujii, J. R. McClean, K. Mitarai, X. Yuan, L. Cincio, and P. J. Coles, “Variational quantum algorithms,” Nature Reviews Physics, vol. 3, no. 9, pp. 625–644, 2021. [Online]. Available: https://doi.org/10.1038/s42254-021-00348-9
[15] A. Peruzzo, J. McClean, P. Shadbolt, M.-H. Yung, X.-Q. Zhou, P. J. Love, A. Aspuru-Guzik, and J. L. O'Brien, "A variational eigenvalue solver on a photonic quantum processor," Nature communications, vol. 5, no. 1, p. 4213, 2014.
[16] S. Y. C. Chen, “Learning to program variational quantum circuits with fast weights,” in 2024 International Joint Conference on Neural Networks (IJCNN). IEEE, 2024, pp. 1–9.
[17] J.-H. Chen, M.-K. Hung, Y.-C. Tsai, and S. Y.-C. Chen, “Batched training for QLSTM vs. QFWP: A system-oriented approach to EPC-aware RMSE-DA,” in IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE, 2026.
[18] Y.-K. Liu, Y.-C. Tsai, and S. Y.-C. Chen, “Q-A3C : Quantum reinforcement learning with time-series dynamic clustering for adaptive ETF stock selection,” in IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE, 2026, pp. 22012–22016.
[19] A. Behrouz, P. Zhong, and V. Mirrokni, “Titans: Learning to memorize at test time,” arXiv preprint arXiv:2501.00663, 2025.
[20] Z. Jiang, D. Xu, and J. Liang, “A deep reinforcement learning framework for the financial portfolio management problem,” arXiv preprint arXiv:1706.10059, 2017.