MambaFormer-TPEF: a hybrid state space-transformer framework with two-stage peak enhancement for ultra-long sequence photovoltaic power forecasting Authors: Jiayu Zou, Xixiu Wu, Qingyong Zhang, Zirui Shao Published: 2026 ABSTRACT AbstractReliable ultra-long-horizon photovoltaic (PV) power forecasting is essential for ensuring grid stability and optimizing energy storage dispatch under high renewable penetration. However, existing paradigms struggle with the efficiency—accuracy paradox in long-range modeling and the systematic peak underestimation inherent in mean squared error (MSE) optimization. This paper proposes MambaFormer-TPEF, a synergistic forecasting framework that reconciles global sequence scanning with local feature refinement. Specifically, we develop a MambaSeq2Seq architecture to achieve O(L) linear complexity for 720-h historical inputs, coupled with attention mechanisms to capture fine-grained fluctuations. To rectify systematic peak bias, a two-stage peak enhancement strategy decouples peak magnitude regression from timing classification using heterogeneous tree-based experts. Furthermore, a meta-learning-based multi-level ensemble fusion (MLEF) framework is introduced to facilitate scenario-adaptive optimal weighting. Validated on real-world datasets for a 168-h prediction horizon, MambaFormer-TPEF achieves state-of-the-art performance with a mean absolute error (MAE) of 0.5521 and a root mean square error (RMSE) of 33.90 kW. Notably, it delivers an 8.15% improvement in over leading benchmarks and significantly reduces peak prediction bias from −22.1 to −1.5%. This framework provides a scalable and robust solution for next-generation microgrid energy management systems, effectively bridging the gap between high-dimensional sequence modeling and real-time operational requirements.Keywords: Photovoltaic power forecasting, Long-horizon time series forecasting, Mamba, Hybrid transformer architecture, Meta-learning-based ensemble learningSubject terms: Energy science and technology, Engineering, Mathematics and computing Introduction Against the backdrop of global efforts to address climate change and accelerate the energy transition, PV power generation has emerged as a cornerstone of clean energy systems and is experiencing unprecedented growth in installed capacity. According to the International Energy Agency (IEA), global annual PV installations surpassed 400 GW for the first time in 2023, while cumulative installed capacity has exceeded 1.5 TW. Projections further indicate that by 2030, photovoltaic power may contribute more than 25% of total global electricity generation1. Despite this remarkable expansion, the large-scale integration of PV generation into power systems remains highly challenging. Owing to its inherent intermittency, volatility, and weather dependence, PV generation can introduce considerable uncertainty into system operation, directly affecting supply–demand balance, frequency regulation, and the secure operation of modern power grids2. Against this background, accurate PV power forecasting is indispensable for practical grid dispatching and electricity market operations. While short-term forecasting is important for real-time control, system operators and market participants are increasingly demanding reliable ultra-long-horizon forecasts covering the coming days or even weeks3. Such long-term forecasts play a critical role in grid scheduling, energy storage optimization, maintenance planning, and participation in electricity spot markets. For example, weekly dispatch planning requires system operators to determine the start-up and shut-down schedules of thermal power units and to coordinate reservoir management for hydropower several days in advance. In this context, even relatively small forecasting errors may lead to substantial economic losses, such as higher dispatch costs and increased curtailment of renewable energy. However, ultra-long-horizon PV forecasting presents unique technical challenges. To produce reliable forecasts, models must typically process extended historical observation windows—often spanning 30 days (720 hours)—in order to capture the evolution of weather patterns and their cumulative effects on power output4. Based on these long-term dependencies, the model must further infer the PV generation trajectory over a future horizon of up to 7 days (168 h). Therefore, effectively modeling temporal dependencies that span multiple time scales remains a fundamental and open challenge in the field of energy informatics. Despite the remarkable progress of deep learning in time series forecasting, existing approaches still encounter fundamental challenges when applied to ultra-long-horizon PV power forecasting. The first challenge is balancing efficiency and accuracy in long-range temporal modeling. RNN-based models such as LSTM5 and GRU6 perform well in short-term forecasting, but their sequential structure and gradient degradation limit their effectiveness on long sequences7. Transformer models improve long-range dependency modeling through self-attention8, but their quadratic complexity leads to high computational cost for long inputs and may cause overfitting when PV data are limited. Our experiments also show that standard Transformers can perform poorly in this task. In contrast, SSMs represented by Mamba9 offer linear complexity O(L) and are more suitable for ultra-long sequences, but they are still less effective in capturing fine-grained local interactions. Therefore, a key question is whether the efficiency of Mamba and the local modeling ability of Transformers can be combined in a unified framework. The second challenge is the systematic bias in peak power prediction. Deep learning models trained with mean squared error often regress toward conditional means, producing a peak-smoothing effect and underestimating daytime peak power10. For example, our results show that a standalone Mamba model yields a peak bias of . This issue is particularly critical for power system security assessment and is difficult to address through loss function redesign alone. Therefore, an important question is whether models with stronger extreme-value modeling ability can be integrated with deep learning methods to capture long-term trends while correcting peak deviations. The third challenge lies in the limited flexibility of conventional ensemble fusion strategies. Traditional ensemble methods usually adopt simple averaging or fixed weights, without considering that model performance varies across different scenarios, such as clear versus cloudy weather or peak versus off-peak periods11. As a result, the complementary strengths of heterogeneous models cannot be fully utilized. This leads to another important question: can a dynamic and scenario-aware fusion mechanism be designed to adaptively assign model weights according to the current input context? To address these challenges, this paper proposes the MambaFormer-TPEF framework, with the following key contributions: A hybrid Mamba–transformer sequence-to-sequence architecture (MambaSeq2Seq) is proposed to reconcile computational efficiency and predictive accuracy. Mamba modules efficiently extract global temporal patterns from 720-hour historical sequences with linear complexity, while Transformer modules refine local feature interactions. The decoder further establishes explicit input–output connections via cross-attention, enabling global awareness and local sensitivity within a predominantly linear-complexity framework. A hybrid Mamba–transformer sequence-to-sequence architecture (MambaSeq2Seq) is proposed to reconcile computational efficiency and predictive accuracy. Mamba modules efficiently extract global temporal patterns from 720-hour historical sequences with linear complexity, while Transformer modules refine local feature interactions. The decoder further establishes explicit input–output connections via cross-attention, enabling global awareness and local sensitivity within a predominantly linear-complexity framework. A two-stage peak enhancement strategy is developed to explicitly decouple extreme-value prediction. Peak forecasting is decomposed into peak magnitude regression and peak timing classification, which are handled by heterogeneous LightGBM and XGBoost expert modules using 569 engineered statistical features. This strategy effectively complements deep learning models and reduces peak bias from to , with a 13.3% reduction in peak RMSE. A two-stage peak enhancement strategy is developed to explicitly decouple extreme-value prediction. Peak forecasting is decomposed into peak magnitude regression and peak timing classification, which are handled by heterogeneous LightGBM and XGBoost expert modules using 569 engineered statistical features. This strategy effectively complements deep learning models and reduces peak bias from to , with a 13.3% reduction in peak RMSE. A dynamic confidence-aware MLEF framework is introduced based on meta-learning. The proposed framework adaptively assigns time-varying confidence weights according to input characteristics and historical model performance, enabling scenario-aware optimal fusion. This dynamic strategy improves forecasting performance by 8.15% in terms of compared with the best single model. A dynamic confidence-aware MLEF framework is introduced based on meta-learning. The proposed framework adaptively assigns time-varying confidence weights according to input characteristics and historical model performance, enabling scenario-aware optimal fusion. This dynamic strategy improves forecasting performance by 8.15% in terms of compared with the best single model. This paper is organized as follows. “Related work” reviews related work on deep learning for sequence forecasting, Mamba, and hybrid ensemble strategies. “Methodology” presents the proposed MambaFormer-TPEF framework in detail. “Results” reports experimental results and ablation studies, followed by discussion in “Discussion” and concluding remarks in “Conclusion”. Related work PV power forecasting has evolved from physics-based modeling and statistical learning toward data-driven deep learning approaches. With advances in data acquisition, data-driven methods have become dominant by avoiding explicit physical parameter modeling. This section looks at related work from three angles: deep learning for sequence forecasting, Mamba, and ensemble learning. It highlights their limitations in ultra-long-horizon PV forecasting and shows why this study is needed. Deep learning-based pv power sequence forecasting Over the past decade, deep learning has progressively replaced traditional statistical approaches—such as ARIMA and support vector machines—and has become the dominant paradigm for PV power forecasting, primarily due to its ability to model complex nonlinear relationships directly from data12. Recurrent neural networks (RNNs) and their variants have been widely adopted for time series prediction. Long short-term memory (LSTM) networks mitigate the vanishing gradient problem through gated mechanisms and have long served as a cornerstone for sequential modeling5. In PV forecasting applications, bidirectional LSTM models have been employed for day-ahead prediction to better capture intraday power fluctuations13, while the integration of meteorological variables further improves predictive accuracy14. Gated recurrent units (GRUs) simplify the LSTM architecture while maintaining comparable performance6. Extensions that incorporate attention mechanisms into GRU-based models have shown clear advantages in short-term PV forecasting tasks15. Despite these successes, RNN-based approaches fundamentally rely on sequential computation, which limits training efficiency. Moreover, theoretical analyses indicate that learning long-range dependencies remains difficult when sequence lengths become excessively long, due to persistent gradient degradation7. The introduction of the Transformer architecture marked a significant departure from recurrent modeling by enabling direct dependency modeling through self-attention8. This design effectively alleviates the long-range dependency bottleneck of RNNs. However, the quadratic computational complexity O(L) of self-attention introduces substantial computational overhead for long input sequences. To address this issue, a number of efficient Transformer variants have been proposed, including Informer16, Autoformer17, and PatchTST18. In the context of PV forecasting, Transformers have been combined with convolutional networks or extended to spatiotemporal architectures to extract multi-scale patterns19,20. Nevertheless, recent studies report that under certain long-horizon settings, simple linear models can outperform more sophisticated Transformer variants, particularly when training data are limited21. This observation suggests that large-capacity attention-based models may suffer from overfitting and reduced robustness in ultra-long-horizon PV forecasting scenarios. Taken together, existing deep learning approaches face a persistent efficiency–accuracy trade-off. RNN-based models are constrained by sequential computation and gradient degradation, whereas Transformer-based models are limited by quadratic complexity. This dilemma becomes especially pronounced in ultra-long-horizon PV forecasting tasks involving input sequences spanning hundreds of hours. State space models and efficient long-sequence modeling State space models (SSMs),represented by Mamba, provide a way to balance efficiency and long-range modeling. Classical Mamba describe system dynamics through linear recursive formulations22, but their integration into modern deep learning frameworks is hindered by numerical instability and limited capacity to model input-dependent dynamics. The HiPPO framework addresses numerical stability by enabling efficient and stable compression of long-term historical information23. Structured SSMs, such as S4, represent a major step forward by imposing structured constraints on state matrices and leveraging fast Fourier transforms to achieve complexity24. These models have demonstrated strong performance on long-range sequence benchmarks, in some cases surpassing Transformer-based approaches. Subsequent research has explored both further efficiency improvements and architectural refinements, including models such as DSS25, S526, and hybrid designs that alternate state space layers with attention mechanisms27. Mamba represents the most recent advancement in this line of work. By introducing selective scanning mechanisms, Mamba enables input-dependent parameter adaptation and relaxes the linear time-invariant assumption inherent to traditional SSMs9. With linear computational complexity O(L), Mamba combines recurrent-style inference with parallelizable training and has demonstrated strong performance in both natural language processing and time series forecasting9. Despite these advantages, pure SSM-based models remain less effective than attention mechanisms in capturing fine-grained local interactions and abrupt nonlinear changes28. Recent studies have therefore explored hybrid architectures that interleave Mamba with attention layers29. However, the application of such hybrid designs to ultra-long-horizon PV power forecasting has received little attention. How to effectively combine global sequence modeling with local refinement in this context remains a central question addressed in this work. Ensemble learning and extreme-value optimization strategies The inherent complexity of PV power generation makes it difficult for a single model to capture all relevant patterns, which has motivated the widespread use of ensemble learning to improve robustness. Traditional ensemble methods, including random forests30, XGBoost31, and LightGBM32, perform well on structured data and have been successfully applied to PV forecasting, particularly when combined with meteorological features. More recently, ensembles of deep learning models have been investigated, such as hybrid CNN–LSTM architectures33 and conditional ensemble strategies based on weather classification34. Although these approaches improve performance, they suffer from two fundamental limitations. First, ensemble weights are typically static and fail to adapt to changing operating conditions across different time periods or scenarios. Second, models trained with mean squared error objectives exhibit a pronounced peak-smoothing effect, leading to systematic underestimation of daytime peak power10,35. While tree-based models are well suited for nonlinear regression and extreme-value modeling, they lack the ability to capture temporal dependencies36. Existing extreme-value optimization strategies include asymmetric loss functions, post-processing correction techniques, and hierarchical forecasting schemes37,38. Furthermore, recent studies have demonstrated that combining multiple lightweight models through stacking or hybrid ensemble techniques can significantly improve prediction performance for short- and medium-term horizons with moderate computational overhead. For instance, stacking-based frameworks utilizing secondary feature extraction have shown marked improvements in accuracy39, while hybrid models integrating Variational Mode Decomposition (VMD) with feature selection effectively capture multi-scale power fluctuations40. However, these methods either show limited effectiveness in ultra-long-horizon settings or compromise temporal consistency. Furthermore, as highlighted in a recent systematic review41, robust forecasting is now recognized as a critical backbone for advanced microgrid energy management systems (EMS). Effectively integrating high-fidelity predictive signals with operational scheduling and real-time control is essential for managing the inherent stochasticity of renewable energy, yet achieving such integration in complex, resource-constrained environments remains a significant hurdle. Developing a unified framework that preserves temporal structure while accurately modeling extreme values therefore remains an open challenge. In summary, existing PV forecasting methods exhibit complementary strengths but also clear limitations. RNN-based models are effective in capturing short-term and local temporal variations, yet their sequential computation and gradient degradation make them less suitable for ultra-long historical sequences. Transformer-based models improve long-range dependency modeling through global attention, but their quadratic complexity often leads to high computational cost and potential overfitting on limited PV datasets. SSM-based models, represented by Mamba, offer a more efficient alternative for long-sequence modeling, although their ability to characterize sharp local fluctuations and peak-value deviations remains limited. Ensemble-based methods can enhance robustness by combining heterogeneous predictors, but they often lack a unified mechanism to simultaneously model long-range dependencies and adapt to scenario-specific forecasting characteristics. In view of these limitations, current research lacks an integrated framework that simultaneously supports linear-complexity modeling of ultra-long historical sequences, corrects systematic peak bias, and adaptively fuses heterogeneous models based on scenario-specific characteristics. The proposed MambaFormer-TPEF framework is designed to address these gaps. Methodology Problem formulation and dataset This section outlines a clear method for predicting ultra-long photovoltaic power sequences. It details the dataset used, defines the feature space, and describes the preprocessing strategy. Figure 1 shows the technical layout of the MambaFormer-TPEF framework. This framework combines the linear complexity modeling of the Mamba state space model with the cross-time step attention of the Transformer. It creates a prediction system that takes 720-hour inputs to generate 168-hour outputs. The process includes raw data collection, preprocessing, feature engineering, two-stage multi-model training, and SHapley Additive exPlanations (SHAP)-based interpretability analysis. Schematic overview of the proposed MambaFormer-TPEF framework for ultra-long-sequence photovoltaic power forecasting (720 –168 h). The framework adopts a hybrid MambaFormer encoder–decoder architecture and incorporates a two-stage prediction strategy with dynamic ensemble learning and SHAP-based interpretability. Mathematical statement The PV power forecasting task considered in this study is formulated as a multi-step Seq2Seq regression problem. At discrete time steps , the system observes a multivariate feature vector , constructed by concatenating temporal features, while the prediction target is the inverter active power output . Given a historical observation window of length L and a prediction horizon of length H, the learning objective is to estimate a parameterized mapping function such that where denotes the historical input sequence, and represents the predicted output sequence. The symbol denotes the set of learnable model parameters. In this work, we adopt a challenging ultra-long-sequence forecasting configuration. Specifically, the input sequence length is set to hours (corresponding to 30 days), and the prediction horizon is set to hours (corresponding to 7 days). The feature dimension is , consisting of 16 electrical features and 9 temporal features, with a temporal resolution of 1 hour. This setting requires the model to effectively capture long-range temporal dependencies spanning multiple weeks, while simultaneously producing accurate hour-level forecasts over an entire week. Model optimization is performed by minimizing the cumulative discrepancy between the predicted and ground-truth sequences. Taking the mean squared error (MSE) loss as an example, the optimization objective is defined as where N denotes the number of training samples. To avoid information leakage, all experiments strictly follow a chronological split of the dataset into training, validation, and testing sets. Evaluation metrics include both overall performance indicators (, RMSE, and MAE) and horizon-specific metrics at different forecast lead times (1 h, 24 h, 72 h, and 168 h). In particular, performance at longer horizons ( h) is emphasized to assess the model’s ability to capture long-term temporal dependencies. The problem formulation is flexible and covers many sequence modeling techniques. These techniques include: tree-based models, recurrent neural networks (RNNs), Transformer-based architectures, and the state-space-model-based Mamba framework adopted in this study. Dataset overview The dataset for this study is derived from the NIST Campus Photovoltaic (PV) Arrays and Weather Station Data Sets, released by the National Institute of Standards and Technology (NIST), USA. It covers continuous measurements from 2015 to 2018. This multi-year coverage provides a diverse range of atmospheric conditions and long-term climatic variations, which serves as a rigorous foundation for testing the model’s robustness against different weather regimes. To ensure high-fidelity modeling, we specifically utilized the 270-kW ground-mounted system data, integrating multi-modal meteorological variables: Global Horizontal Irradiance (GHI), Direct Normal Irradiance (DNI), Diffuse Horizontal Irradiance (DHI), ambient temperature, and wind speed, all captured via research-grade sensors at 1-minute resolution. The dataset includes PV power output and 16 unique electrical measurement variables sampled at 1-second and 1-minute intervals. For this work, we selected data from 2016 as our primary benchmark. The observation period encompasses 366 days, resulting in 8,784 hourly observations. By encompassing a complete annual cycle, this subset exposes the model to significant seasonality, including drastic shifts in solar zenith angles and varying day-night durations. To ensure data integrity, a rigorous preprocessing pipeline was applied: (i) missing values were addressed using linear interpolation for short gaps (< 30 min) and mean imputation for extended outages; (ii) a nighttime filtering threshold was set at a solar zenith angle and irradiance to prevent the model from learning trivial zero-patterns; and (iii) Min-Max scaling was employed to normalize all features to the range [0, 1]. Detailed definitions of the features can be found in the “Appendix”. Dataset partitioning strategy To ensure a fair evaluation of model performance and to prevent data leakage, a strict time-ordered data splitting strategy is adopted in this study. The dataset is partitioned as follows: Training set: data collected from January to October 2016, comprising 13,729 samples, are used for model training. Training set: data collected from January to October 2016, comprising 13,729 samples, are used for model training. Validation set: approximately 10% of the training data (about 1,500 samples) are reserved for validation and used for early stopping and hyperparameter tuning. Validation set: approximately 10% of the training data (about 1,500 samples) are reserved for validation and used for early stopping and hyperparameter tuning. Test set: data collected from November to December 2016, consisting of 3,505 samples, are used exclusively for final performance evaluation. Test set: data collected from November to December 2016, consisting of 3,505 samples, are used exclusively for final performance evaluation. All splits strictly respect the chronological order of the time series to ensure that future information is not used during model training or validation (Table 1). Table 1Statistical characteristics of the target variable InvPAC_kW_Avg.StatisticValueMinimum0.00 kWMaximum257.10 kWMean40.56 kWMedian0.00 kWStd. dev.64.40 kWZero ratio50.1% Statistical characteristics of the target variable InvPAC_kW_Avg. Target variable statistics The target variable in this study is the inverter AC active power, denoted as InvPAC_kW_Avg. As shown in the table, the target variable exhibits a highly skewed distribution, with approximately half of the observations taking zero values, corresponding to nighttime periods without power generation. This property poses a significant challenge for accurate peak power forecasting, as conventional loss functions tend to favor conservative mean predictions, which may lead to systematic underestimation of daytime peak values. Feature engineering The dataset contains 16 original electrical features, primarily related to inverter power output and other electrical variables, covering multiple aspects of photovoltaic system operation. These features include measurements of voltage, current, frequency, and power readings at different measurement points. Specifically, the electrical features correspond to monitoring channels associated with array-side DC/AC power, energy metering, environmental sensing, and array reference module temperature provided by the NIST PV array system. All features fall within the category of electrical observations recorded by the array, inverter, and metering devices. Detailed descriptions of all original electrical features are provided in the Appendix. Temporal features Photovoltaic power generation shows periodic patterns at different scales. These include daily cycles (day-night alternation), weekly cycles (weekend vs. weekday operations), and annual cycles (seasonal changes in solar angle). This study adds 9 time-derived features to the original 16 electrical features. This brings the total to 25 features. These temporal features help the model understand the order and structure of time. They also reduce the negative effects of seasonal changes on performance. The details of the mathematical formulations and encoding methods for these features are in the Appendix. Proposed MambaFormer-TPEF architecture Overall pipeline To tackle the challenges associated with long-horizon photovoltaic power forecasting, this study introduces MambaFormer-TPEF, a multi-model ensemble framework that integrates state-space sequence modeling, tree-based peak enhancement, and dynamic fusion strategies. The framework’s architecture is specifically designed to support the real-time scheduling and control requirements of microgrid energy management systems42. An overview of the proposed framework is illustrated in Fig. 2. Overall architecture of the proposed MambaFormer-TPEF framework. The MambaFormer-TPEF architecture is organized into three hierarchical components: a base learner layer, a fusion layer, and an output layer. At the base learner layer, multi-scale input features—including historical power generation, and temporal encodings—are processed through two parallel branches. The first branch comprises four sequence-to-sequence models, namely Mamba-Transformer, LSTM, Transformer, and GRU. These models are designed to capture temporal dynamics and generate continuous power trajectories over the prediction horizon. In parallel, the second branch focuses on peak-oriented regression through tree-based models, specifically hybrid Mamba-XGBoost and Mamba-LightGBM architectures. In this branch, deep representations extracted by the Mamba backbone are used as inputs to enhance the accuracy of peak power prediction. The fusion layer implements a two-stage ensemble strategy. In the first stage, a model quality filtering mechanism removes underperforming base learners based on validation performance, ensuring that only reliable predictions are retained. In the second stage, a dynamic confidence-weighted aggregation module adaptively assigns weights to the remaining models according to their historical performance across different time scales and power ranges. This design allows the framework to exploit the complementary strengths of heterogeneous models: sequence-to-sequence architectures effectively capture smooth temporal evolution, while tree-based hybrids exhibit superior performance in peak regions. Finally, the output layer produces the long-horizon power forecasting results and incorporates a SHAP analysis module to quantify feature importance. This additional interpretability component improves the transparency and credibility of the model’s predictions (Fig. 3). Encoder–decoder architecture of the proposed MambaSeq2Seq model. MambaFormer-TPEF forecasting procedure. MambaSeq2Seq sequence-to-sequence model As the core backbone of the proposed framework, this study designs a hybrid Mamba–Transformer sequence-to-sequence model, referred to as MambaSeq2Seq. The proposed MambaSeq2Seq model adopts an encoder–decoder architecture. The encoder processes the input sequence and extracts latent representations, while the decoder generates the future power sequence conditioned on the encoded information. Let denote the input sequence. The encoder maps to a hidden representation via a Mamba-based block: The decoder interacts with the encoder output through a cross-attention mechanism and produces the decoder hidden states: The cross-attention operation is formulated as where , , and denote the query, key, and value matrices, respectively, and is the key dimension. Within the encoder, the MambaBlock combines state-space modeling with residual normalization: A Transformer block is further applied to refine local temporal patterns: Finally, the output layer employs a multilayer perceptron (MLP) to generate the prediction: The predicted sequence is used as the final photovoltaic power forecasting output. Mamba–transformer hybrid regression model As illustrated in Fig. 4, the Mamba–transformer hybrid module serves as a core building block of both the encoder and decoder. The module adopts a parallel integration strategy to combine the complementary modeling capabilities of Mamba and Transformer layers. Architecture of the Mamba–transformer hybrid encoder for peak regression and feature extraction. In each hybrid block, a MambaBlock is first applied to model long-range temporal dependencies with linear computational complexity. Specifically, for the lth layer, the Mamba update is expressed as This operation establishes a global temporal context through state-space recurrence, providing long-term memory representations for subsequent processing. Following the MambaBlock, a standard TransformerBlock is employed to refine local temporal interactions via multi-head self-attention: The attention mechanism complements the state-space modeling by enhancing nonlinear feature interactions across different time positions. The encoder and decoder adopt an alternating stacking strategy in the form of Mamba Transformer Mamba Transformer. This hybrid design allows shallow Mamba layers to efficiently capture coarse long-range dependencies, while deeper Transformer layers progressively refine feature correlations. Compared with pure Mamba or pure Transformer architectures, the proposed hybrid structure achieves a favorable balance between computational efficiency and expressive capacity. Baseline models (LSTM/GRU/transformer) To comprehensively evaluate the effectiveness of the proposed MambaFormer-TPEF framework, three representative deep learning baseline models are implemented, including Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), and Transformer. All baseline models adopt a Seq2Seq architecture and are trained under identical experimental settings to ensure a fair comparison. TransformerSeq2Seq model The Transformer baseline employs a standard encoder–decoder architecture based on multi-head self-attention. The encoder extracts contextual representations from the input sequence, while the decoder generates future power values through masked self-attention and encoder–decoder cross-attention. An overview of the TransformerSeq2Seq architecture is shown in Fig. 5. Despite its strong global modeling capability, the quadratic computational complexity of self-attention limits its efficiency for ultra-long sequences. Encoder–decoder architecture of the TransformerSeq2Seq baseline model. LSTMSeq2Seq model The LSTM baseline consists of an LSTM encoder and an autoregressive LSTM decoder. The encoder summarizes the input sequence into its final hidden state, which is used to initialize the decoder for multi-step prediction. Teacher forcing is applied during training to improve convergence stability. The overall architecture of the LSTMSeq2Seq model is illustrated in Fig. 6. While LSTM effectively mitigates the vanishing gradient problem, its sequential computation limits parallelism and scalability. Encoder–decoder architecture of the LSTMSeq2Seq baseline model. GRUSeq2Seq model The GRU baseline follows a similar Seq2Seq structure to LSTM but replaces memory cells with gated recurrent units. By reducing the number of gating mechanisms, GRU achieves lower computational complexity and faster training. The architecture of the GRUSeq2Seq model is shown in Fig. 7. However, the simplified gating structure may limit its ability to model long-range dependencies in ultra-long forecasting tasks. Encoder–decoder architecture of the GRUSeq2Seq baseline model. To ensure experimental fairness, all baseline models are configured with the same hidden dimension, number of layers, optimizer settings, and training strategy as the proposed framework. Tree-based peak enhancement Deep sequence models optimized with global loss functions often exhibit peak-smoothing behavior, which may lead to systematic underestimation of extreme photovoltaic power values. To alleviate this issue, a tree-based peak enhancement module is introduced to explicitly model peak power characteristics and complement sequence-based predictions. The peak enhancement task is formulated as a daily peak regression problem. For each day, the maximum hourly power value is defined as where denotes the power output at hour h. The model is trained to minimize the mean squared error between predicted and observed daily peak values. To focus on peak-relevant temporal patterns, the time index corresponding to the daily maximum power is extracted and mapped to a fixed-length representation. Based on this representation, gradient boosting tree models, including LightGBM and XGBoost, are employed to capture nonlinear feature interactions associated with peak generation. These tree-based models are well suited for extreme-value regression due to their robustness to feature scaling and ability to model heterogeneous feature importance. During inference, the predicted daily peak values are injected back into the hourly prediction sequence. Peak power estimates are assigned at the identified peak time indices, while the remaining time steps are smoothly interpolated and merged with the original sequence-based predictions. The resulting peak-enhanced sequence is subsequently used as a high-confidence auxiliary signal in the dynamic fusion stage of the proposed framework. Architecture configurations and dimensionality To consolidate the structural details of the proposed MambaFormer-TPEF, Table 2 summarizes the specific layer configurations and the transformation of data dimensions throughout the forecasting pipeline. This overview ensures the mathematical transparency and reproducibility of the hybrid architecture. Table 2Summary of data dimensions and model layers.Processing part / layerInput dimensionOutput dimensionInput Embedding ()(B, 720, 25)(B, 720, 128)Mamba Blocks (, 4 Layers)(B, 720, 128)(B, 720, 128)Hybrid Attention (8 Heads)(B, 720, 128)(B, 720, 128)Linear Output Projection(B, 720, 128)(B, 168, 1)TPEF Statistical Features(B, 720, 1)(B, 3375)Tree-based Peak Experts(B, 3375)(B, 168, 1)MLEF Dynamic Integration(B, 168, 1) Summary of data dimensions and model layers. MLEF ensemble framework The MLEF framework constitutes a core component of the proposed MambaFormer-TPEF architecture. By integrating dynamic weighting, quality filtering, and nonlinear aggregation mechanisms, MLEF aims to achieve robust and adaptive combination of heterogeneous base learners, thereby improving both forecasting accuracy and generalization performance. Dynamic weighting Conventional ensemble methods often rely on fixed or static weights, which fail to account for the varying performance of different models across input conditions. In contrast, MLEF adopts an input-adaptive dynamic weighting strategy that assigns confidence-aware weights to base learners according to the current forecasting context. Given a set of base learners and input features , the dynamic weighting function produces non-negative weights: The weighting function is learned using a meta-learner implemented with LightGBM. Its input includes the original features, base model predictions, and deep latent representations, enabling context-aware weight allocation. After training, SHAP-based analysis is employed to interpret the contribution of each base learner and to enhance the transparency of the weighting mechanism. To prevent excessive weight concentration, an entropy-based regularization term is introduced: where denotes the entropy of the weight distribution and controls the regularization strength. Quality filtering Quality filtering serves as a pre-ensemble step to identify and remove unreliable base learners. Each model is evaluated on a validation set using multiple performance criteria, including overall accuracy and peak-related errors. Models that consistently underperform or exhibit large relative degradation are excluded from subsequent fusion, ensuring that only high-quality predictors participate in the ensemble. Aggregation algorithm After quality filtering, the retained base learners are combined using a nonlinear aggregation strategy. The aggregation function is implemented with LightGBM and takes as input the base predictions, latent feature representations, and summary statistics that characterize prediction uncertainty and inter-model diversity. This design enables the ensemble to capture complex interactions among models and to adaptively emphasize complementary predictors under different operating conditions. The final ensemble output is obtained after aggregating the filtered predictions and is used as the overall forecasting result. Training and optimization This section describes the training strategy and optimization settings of the proposed Mamba-MLEF framework, including the loss function design, optimizer configuration, regularization methods, and learning rate scheduling. Loss function The mean squared error (MSE) is adopted as the primary training objective due to its effectiveness and smooth optimization properties in regression tasks: where N denotes the number of training samples and H is the prediction horizon. Although MSE provides stable global optimization, it often leads to peak-smoothing effects in long-horizon forecasting. To mitigate this issue, a peak-aware loss is introduced to explicitly emphasize extreme-value accuracy43: where corresponds to the standard MSE term, penalizes peak magnitude errors, and constrains peak timing deviations. The coefficients , , and control the relative importance of each component. Optimizer and regularization Model training is performed using the AdamW optimizer44, which decouples weight decay from gradient-based parameter updates and improves training stability. The parameter update rules follow the standard AdamW formulation with , , and . To prevent overfitting, regularization and dropout are jointly employed. The overall objective function is defined as Dropout is applied to different network components with rates of 0.1 for Mamba and Transformer layers, and 0.2 for the MLP output layer. Learning rate scheduling A cosine annealing learning rate schedule with linear warm-up is adopted to improve convergence stability and avoid premature optimization45. During the warm-up stage, the learning rate increases linearly: After warm-up, the learning rate decays following a cosine schedule: This scheduling strategy effectively reduces training oscillations and enhances overall optimization stability. Hyperparameter summary Table 3 summarizes the hyperparameter configuration of the proposed MambaFormer-MLEF framework. These hyperparameters cover the model architecture, training process, and MLEF ensemble settings, ensuring stable and efficient model optimization. Table 3Hyperparameter configuration of the MambaFormer-MLEF framework.CategoryHyperparameterSymbolValueArchitectureHidden dimension128Mamba layers / state dim. / conv. kernel2 / 16 / 4Transformer layers / attention heads2 / 4FFN dimension512MLP hidden dimensions[256, 128]TrainingBatch size / max epochs64 / 100Learning rate (initial / minimum) / Weight decay / dropout / 0.1Gradient clipping / warm-up steps1.0 / 500Early stopping patienceP15MLEF ensembleBase learners / quality threshold6 / 0.30LightGBM estimators / depth / leaves–500 / 6 / 31LightGBM learning rate / reg.0.05 / 1.0DataInput / output sequence length96 / 96Train / validation / test split–70% / 15% / 15% Hyperparameter configuration of the MambaFormer-MLEF framework. Experimental environment See Table 4. Table 4Experimental environment and implementation details.ItemSettingGPUNVIDIA RTX 3090 (24GB)FrameworkPyTorch 2.1.0, CUDA 12.1Random seed42AccelerationDeep models on GPU; LightGBM on CPU (multi-threaded)Training timeMamba–transformer: 45 min / 100 epochsLSTM/GRU: 30 min / 100 epochsLightGBM ensemble: 5 min Experimental environment and implementation details. Evaluation metrics To thoroughly evaluate the performance of photovoltaic power forecasting models, this study uses a range of complementary evaluation metrics. This comprehensive evaluation is especially important for long-term forecasting tasks, where accurately estimating peaks and maintaining consistency over time are crucial for effective grid operation (Table 5 ). Table 5Evaluation metrics used in this study.GroupMetricPurposeOverallRMSE, MAEOverall point forecasting accuracyMAPERelative error with respect to magnitudeGoodness of fit and explained varianceNRMSENormalized error for cross-setting comparisonSkill score (SS)Improvement over a reference baselinePeak-specificPeak RMSE, Peak MAEAccuracy within peak intervalsRelative peak error (RPE)Degree of systematic peak under- or over-estimationPeak capture rate (PCR)Recall of peak eventsPeak precision (PP)Control of false peak alarmsPeak timing error (PTE)Temporal deviation of peak occurrencePeak magnitude error (PME)Deviation of peak power valuesMulti-horizonSequence RMSEAggregated error over the full forecasting horizonStep-wise RMSEError at individual forecast stepsError growth rate (EGR)Error accumulation along the horizonPICP, PINAWCoverage and sharpness of prediction intervalsWinkler scoreJoint assessment of interval width and coveragePearson correlationLinear correlation with ground truthDTW distanceRobustness to temporal misalignment Evaluation metrics used in this study. Model interpretability and ablation study To enhance the transparency of the proposed Mamba–transformer framework and quantify the contribution of individual components, SHAP-based interpretability analysis and systematic ablation experiments are conducted. The former provides feature-level explanations for model predictions, while the latter evaluates the effectiveness of key architectural modules. SHAP-based interpretability analysis SHAP is adopted to quantify the contribution of each input feature to the model prediction based on cooperative game theory46. For an input feature vector , the SHAP value represents the marginal contribution of feature to the prediction. SHAP satisfies the additive attribution property: where denotes the expected model output over the training data. For tree-based components in the proposed framework, SHAP values are computed using the TreeExplainer algorithm47, which exploits tree structures to achieve exact and efficient attribution. For ensemble predictions, SHAP values are aggregated across all base learners to obtain unified feature importance estimates. Global feature importance is quantified using the mean absolute SHAP value: where S denotes the set of sampled instances. For cross-feature comparison, importance scores are normalized as Visualization and consistency analysis SHAP summary plots and force plots are employed to visualize feature contributions at both global and instance levels48. To evaluate the consistency of feature importance rankings across different models, Spearman rank correlation is adopted as a non-parametric measure of rank agreement49: where and denote the ranking positions of feature i in two models. A higher correlation indicates stronger agreement in feature attribution. Ablation study design Ablation studies are conducted to systematically evaluate the effectiveness of individual components in the proposed Mamba–Transformer framework. By selectively removing or modifying architectural modules, loss terms, and ensemble strategies, the contribution of each design choice is quantitatively assessed. All ablation experiments are performed under identical training settings to ensure fair comparison. Architecture ablation Architecture ablation experiments are designed to investigate the necessity and complementarity of the Mamba–Transformer hybrid structure. Specifically, variants are constructed by isolating Mamba or Transformer components, adjusting network depth, and altering encoder–decoder assignments. The configurations are summarized in Table 6. Table 6Architecture ablation configurations.VariantConfigurationParamsPurposeA12-layer Mamba encoder + 2-layer transformer decoder2.3MComplete hybrid architecture (baseline)A24-layer Mamba encoder with linear prediction head2.1MVerify standalone capability of MambaA34-layer Transformer encoder–decoder2.5MEvaluate performance without MambaA41-layer Mamba + 1-layer transformer1.2MTest minimum hybrid depth necessityA53-layer Mamba + 3-layer transformer3.5MExamine performance saturationA6Transformer encoder + Mamba decoder2.4MValidate encoder–decoder role assignmentA72-layer BiLSTM encoder + 2-layer GRU decoder2.0MTraditional recurrent baselineA83-layer 1D CNN + 2-layer LSTM2.2MHybrid conventional architecture Architecture ablation configurations. Loss function ablation Loss ablation experiments are conducted to analyze how different objective designs influence model optimization and peak prediction behavior. By selectively removing robustness, peak-awareness, or dynamic weighting terms, the necessity of each loss component is evaluated. The tested configurations are summarized in Table 7. Table 7Loss function ablation configurations.VariantLoss functionPurposeL1 Full lossComplete composite loss (baseline)L2 MSE-onlyTest whether a plain objective is sufficientL3 Robust lossIsolate the contribution of robustnessL4 Peak-weightedEvaluate peak-aware optimizationL5 MAE-only-type objective comparisonL6 Dynamic weightingAssess dynamic loss re-weightingL7 Quantile loss (median regression)Additional robustness against outliers Loss function ablation configurations. Ensemble strategy ablation This ablation study evaluates the contribution of individual components in the proposed MLEF ensemble, including quality filtering, dynamic weighting, and nonlinear aggregation. The evaluated strategies are summarized in Table 8. Table 8Ensemble strategy ablation configurations.VariantStrategyPurposeE1 full MLEFQuality filtering + LightGBM dynamic weighting + deep feature fusionComplete framework (baseline)E2 no-filterAll base learners + LightGBM aggregationVerify the necessity of quality filteringE3 simple averageEqual weighting, Lower-bound ensemble baselineE4 weighted averageInverse validation RMSE weightingCompare against heuristic weightingE5 linear stackingLinear regression meta-learnerTest whether nonlinear aggregation is neededE6 NN stacking2-layer MLP meta-learner (e.g., [128, 64])Deep stacking comparisonE7 best singleSelect the best base learner on the validation setQuantify the gain brought by ensemblingE8 no-DeepFeaturesAggregator without latent representations Evaluate contribution of deep features Ensemble strategy ablation configurations. Results Feature correlation analysis Figure 8 illustrates the Pearson correlation structure among electrical and time-derived features. Strong positive correlations are observed within the electrical feature group, particularly among the three-phase inverter currents (InvIa_Avg, InvIb_Avg, InvIc_Avg), with correlation coefficients exceeding 0.99, indicating a high degree of phase balance. Correlation heatmap of photovoltaic system features, including electrical variables and time-derived features. The inverter AC active power (InvPAC_kW_Avg) is highly correlated with the DC input power (InvPDC_kW_Avg, ), consistent with the inverter power conversion process. Power variables exhibit stronger correlations with current measurements () than with voltage-related features (–0.85), suggesting that short-term power fluctuations are primarily driven by current dynamics. In contrast, voltage fault indicators show weak correlations with normal operating variables. Time-derived features display clear internal correlations reflecting diurnal and weekly periodicities. The sinusoidal hour encoding (hour_sin) is moderately correlated with daily encoding (day_sin, ), while weekday-related features remain largely independent of daily cycles. The daytime indicator (is_daytime) shows strong consistency with continuous hour encodings (). Cross-correlations between electrical and temporal features are generally weak (mostly ), indicating that temporal encodings provide complementary rather than redundant information to electrical measurements. These results support the joint use of electrical states and time-derived features in long-horizon photovoltaic power forecasting. Overall performance comparison Primary results Table 9 compares the overall forecasting performance of different models under the 720-hour input and 168-hour prediction setting. Table 9Overall performance comparison under the 720-h input and 168-hour prediction setting.ModelMAE (kW)RMSE (kW)MAPE (%)RankMLEF (ours)1149.2119.2333.900.552158.421XGBoost_Peak1252.4618.9535.390.511757.682Mamba1255.2818.8635.430.510557.343LightGBM_Peak1265.2219.0835.570.506758.014GRU1425.0620.2737.750.444661.555LSTM1511.6623.3938.880.410871.086Transformer2709.2043.8052.05133.147Significant values are in bold. Overall performance comparison under the 720-h input and 168-hour prediction setting. Significant values are in bold. The proposed MLEF framework achieves the best overall performance across most evaluation metrics, ranking first among all competing methods. In particular, MLEF attains an score of 0.5521 and an RMSE of 33.90 kW, outperforming the strongest single model (Mamba) by 8.15% in RMSE and 4.32% in . Among individual sequence models, Mamba shows clear advantages over conventional recurrent architectures, achieving an of 0.5105 compared with 0.4108 for LSTM and 0.4446 for GRU. In contrast, the Transformer performs poorly in this long-horizon setting (). Tree-based peak-oriented models, including XGBoost_Peak and LightGBM_Peak, remain competitive with values of 0.5117 and 0.5067, respectively. By integrating sequence models and tree-based predictors, MLEF further improves overall accuracy. MAPE values are relatively high for all models due to low-power nighttime periods; therefore, and RMSE provide more reliable indicators of predictive performance in this task. Architecture comparison To evaluate architectural design choices, multiple Mamba variants were examined by adjusting model width (), depth (), and state-space dimension (). Unless stated otherwise, the default configuration is used as the reference. As shown in Table 10, performance gains are consistently accompanied by increased computational cost. Mamba-Large achieves the highest accuracy (), but requires more than twice the training time of the default model. Increasing depth alone (Mamba-Deep) provides only marginal improvement, indicating limited benefit from deeper architectures in this setting. Table 10Comparison of Mamba architecture variants.Architecture variantRMSE (kW)Time (s/epoch)Mamba-Large2566641238.4535.190.5172142.3Mamba (default)1284161255.2835.430.510568.5Mamba-Small64281289.6735.910.497135.2Mamba-Wide2564161242.1135.240.515898.7Mamba-Deep1288161246.3335.300.5142128.6 Comparison of Mamba architecture variants. By contrast, widening the model proves more effective. Mamba-Wide improves by 1.04% over the default configuration with a moderate increase in training time, suggesting that representational width contributes more to long-sequence modeling than additional layers. Meanwhile, Mamba-Small retains most of the predictive performance while substantially reducing both parameters and training cost, highlighting the efficiency of the architecture. Balancing accuracy and efficiency, the default configuration (, ) is selected as the backbone of MLEF. Additional analysis shows that enlarging the state-space dimension yields limited benefit, as a 16-dimensional state space already captures the dominant temporal dynamics. Quantitatively, the proposed MambaFormer model maintains a relatively compact parameter size of approximately 2.3M, which is significantly smaller than many large-scale Transformer variants. This low parameter count reduces memory occupancy, making the framework compatible with hardware environments ranging from high-performance GPUs to standard industrial servers. Peak power prediction analysis Peak magnitude accuracy Peak magnitude accuracy is a critical metric in photovoltaic power forecasting, as it directly affects grid dispatch decisions and energy storage capacity planning. In this subsection, peak prediction performance is evaluated from three complementary perspectives: error magnitude, systematic bias, and temporal localization accuracy. Figure 9 provides a comprehensive comparison across different models. As shown in Fig. 9a, MLEF achieves the lowest peak RMSE among all methods, indicating superior accuracy in peak magnitude estimation. In contrast, the Mamba-based model exhibits substantially higher peak RMSE, suggesting limited capability in capturing extreme power fluctuations. Peak power prediction performance comparison across different models. (a) Peak value RMSE, representing error magnitude in peak power estimation. (b) Peak value bias, indicating systematic under- or over-estimation relative to ground truth. (c) Peak time ±1 h accuracy, measuring temporal precision of peak occurrence prediction. Systematic bias distributions are illustrated in Fig. 9b. Deep learning models show pronounced over- or under-estimation tendencies, with bias magnitudes ranging from 10.2% to 22.1%, whereas tree-based and ensemble models maintain significantly smaller bias levels (1.4%–4.3%). This discrepancy highlights fundamental differences in peak modeling behavior between sequence-based neural networks and feature-driven methods. Temporal prediction accuracy is reported in Fig. 9c, measured as the proportion of samples whose predicted peak time deviates from the ground truth by no more than one hour. MLEF attains the highest peak-time accuracy at 75.5%, demonstrating that the proposed ensemble strategy improves not only peak amplitude estimation but also temporal localization reliability. Prediction quality visualization Figure 10 provides a visual comparison between predicted and ground-truth power sequences under complex temporal patterns. Clear differences in tracking behavior can be observed across models, particularly during rapid power ramps and peak transitions. Visualization of predicted versus ground-truth power sequences under complex temporal dynamics. From top to bottom: Mamba, LSTM, GRU, and MLEF. The comparison highlights differences in amplitude tracking, peak preservation, and temporal alignment across models. Sequence-based baselines exhibit noticeable amplitude attenuation and temporal misalignment, leading to underestimation of sharp peaks and delayed responses. While recurrent models capture the general periodic structure, their predictions tend to smooth extreme variations, resulting in reduced peak fidelity. By contrast, MLEF demonstrates closer alignment with the ground truth across both amplitude and timing. Peak values are more accurately preserved, and transitions are tracked with reduced lag, indicating improved responsiveness to abrupt power fluctuations. This visualization further confirms that the proposed ensemble framework enhances dynamic consistency and peak representation in time-series forecasting. Multi-horizon forecasting performance Multi-horizon forecasting stability is a critical requirement for practical photovoltaic power prediction, as short-term accuracy and long-term robustness must be jointly considered. Figure 11 illustrates the performance degradation of different models across increasing prediction horizons. Unlike Transformer-based architectures, Mamba’s O(L) linear complexity ensures superior computational efficiency and scalability for such extended sequence modeling. Performance degradation curves across different prediction horizons. The figure compares the stability of forecasting accuracy as the prediction horizon increases, highlighting differences in degradation behavior among models. As the forecasting horizon extends, most baselines exhibit clear performance decay, though at markedly different rates. Recurrent models demonstrate strong short-term responsiveness but suffer from rapid degradation at longer horizons, indicating limited robustness to error accumulation. In contrast, state-space–based modeling enables Mamba to maintain relatively stable performance over extended horizons, albeit at a lower absolute accuracy level. This characteristic allows Mamba to preserve predictive fidelity much more effectively than standard recurrent benchmarks as the horizon increases. By integrating complementary strengths from multiple architectures, MLEF achieves the most balanced degradation profile. Its performance remains consistently superior across all horizons, outperforming state-of-the-art published models in overall and peak capture. This reflects an effective trade-off between short-term precision and long-term stability. These results confirm that the proposed ensemble strategy enhances robustness in multi-horizon forecasting scenarios where both immediate accuracy and sustained reliability are required. Ablation studies To evaluate the contribution of key design choices in MLEF, ablation studies are conducted with a focus on input sequence length and ensemble strategy. This investigation serves as a sensitivity analytics to identify the optimal temporal context and the framework’s robustness boundaries. Figure 12 illustrates the effect of input length on forecasting performance. Sensitivity results confirm that 720h (30 days) is the optimal window for capturing monthly seasonal cycles. Decreasing the horizon to 360h leads to a 10.2% drop in for MLEF due to insufficient seasonal context, while extending it to 1080h causes a sharp decline ( drops to 0.136) as excessive historical noise overpowers the signal. This suggests that overly extended contexts increase modeling difficulty for sequence-based architectures. By contrast, MLEF exhibits improved robustness, maintaining more stable performance under varying input settings. Input length ablation study across different forecasting models. The figure illustrates the impact of input sequence length on prediction accuracy, highlighting the robustness of MLEF under varying temporal contexts. The effectiveness of the ensemble strategy is further examined by comparing different weighting mechanisms. Results indicate that adaptive weighting consistently outperforms fixed or uniform period-based strategies by 1.3% in . This confirms that the ensemble design plays a critical role in mitigating performance fluctuations and balancing short-term precision with long-term stability. Interpretability analysis To provide insight into the predictive behavior of the proposed framework, SHAP-based feature importance analysis is performed on the tree-based peak predictors, namely :contentReference[oaicite:0]index=0 and :contentReference[oaicite:1]index=1. Figure 13 compares the global feature importance patterns of the two models. Both predictors consistently emphasize temporal and periodic features, confirming their dominant role in peak power estimation. Despite this shared emphasis, the importance distributions exhibit complementary characteristics, suggesting that different aspects of the underlying dynamics are captured by each model. This complementarity provides qualitative support for the ensemble design adopted in MLEF. Comparison of global feature importance derived from SHAP analysis for LightGBM and XGBoost peak predictors. The two models exhibit both consistent and complementary importance patterns, indicating that distinct aspects of temporal and system dynamics are captured. To further examine the global contribution patterns, Fig. 14 presents the SHAP summary plot of the LightGBM peak predictor. The distribution highlights the combined effects of temporal encoding and system-state features on prediction outcomes, indicating that peak estimation is driven by both seasonal structure and short-term system dynamics rather than isolated variables. SHAP summary plot for the LightGBM peak predictor. Each point represents the contribution of a feature to the prediction, illustrating the distribution and relative influence of key features across the dataset. Additional SHAP-based analyses, including detailed feature rankings and individual prediction breakdowns, are provided in the Supplementary Material for completeness. Discussion This study investigates long-horizon photovoltaic power forecasting from three complementary perspectives. First, the advantages of the hybrid MambaFormer-TPEF framework in long-sequence modeling are analyzed. Second, the role and limitations of the proposed peak-enhancement strategy are discussed. Finally, the constraints of the current study are examined, together with potential directions for future research. Synergistic effects of the hybrid architecture The experimental results show that combining Mamba and Transformer architectures offers clear benefits for long-term forecasting tasks. Mamba-based models are robust for long predictions but struggle with short-term accuracy. In contrast, Transformer models excel at capturing local patterns but quickly lose performance as the prediction horizon increases. The hybrid architecture effectively combines these strengths. From a modeling view, Mamba’s state-space formulation supports stable temporal representation. It helps reduce error accumulation over long sequences, especially with slowly changing or periodic data. Furthermore, the O(L) complexity of Mamba ensures superior scalability over Transformers, enabling the efficient processing of longer sequences or higher-frequency data from various sites. On the other hand, the self-attention mechanism in Transformers focuses on important local patterns, which is crucial for modeling quick power changes. By arranging these components together, the hybrid framework improves both short-term accuracy and long-term stability. This synergy shows up in both accuracy gains and less performance drop across prediction horizons. Compared to recurrent models, the hybrid model has a much flatter degradation curve, indicating that combining state-space dynamics and attention mechanisms creates a more balanced approach for long-sequence photovoltaic forecasting. Mechanism and applicability of the peak-enhancement strategy The peak-enhancement strategy is key for improving the reliability of extreme power event predictions. This is crucial for grid dispatch and energy storage planning. By focusing on peak-related errors during optimization, the strategy reduces systematic underestimation and improves the timing of peak occurrences. Functionally, the enhancement mechanism shifts model capacity toward high-impact samples often missed in standard loss methods. This is especially useful during rapid irradiance changes, like cloud transients, where peak deviations add significant operational risk. Beyond technical metrics, the economic implications of this strategy are profound. By reducing the peak power bias from -22.1% to -1.5%, the framework directly mitigates “imbalance charges” imposed by grid operators for generation deviations. Furthermore, accurate long-horizon peak forecasting allows for more precise Unit Commitment and hydropower coordination several days in advance, potentially saving substantial costs associated with the emergency start-up of backup thermal units. In the context of microgrid energy management, high-fidelity peak prediction ensures that energy storage systems pre-allocate sufficient capacity, thereby minimizing renewable energy curtailment and maximizing the overall return on investment for distributed energy assets. However, the peak-enhancement strategy isn’t suitable for all situations. In cases where peak events are rare or unclear, too much focus can create bias toward these patterns and lower overall performance. Thus, the strategy should be seen as a task-specific optimization tool, effective depending on the distribution of the forecasting target. Limitations and future directions The proposed MambaFormer-TPEF framework offers a solid solution for long-horizon PV power forecasting, yet several challenges and limitations must be addressed to enhance its practical utility in diverse operational environments. First, while the framework demonstrates strong performance on the benchmark datasets, its cross-site generalization remains a primary challenge. The impact of local factors such as complex terrain, air quality, and micro-climatic variations on model behavior requires further validation across broader geographical contexts. Second, although the MLEF module is designed to adaptively handle shifts in statistical properties—such as seasonal transitions and varying degrees of intermittency—the model still faces the “cold-start” problem in scenarios with poor historical data quality. Third, despite the O(L) linear scaling of Mamba during inference, the multi-model ensemble architecture involves a relatively high memory footprint during the training phase, which may pose challenges for rapid retraining on resource-constrained industrial servers. Finally, the current study primarily focuses on point forecasting, which provides limited information regarding the inherent stochasticity and uncertainty of renewable energy required for risk-aware grid operations. To address these limitations, future research will pursue three key avenues. (i) Probabilistic Forecasting: We aim to extend the framework to generate predictive intervals or full probability distributions using techniques such as Quantile Regression or Gaussian Processes, providing a robust measure of uncertainty for power system operators. (ii) Lightweight Deployment: Further optimization through model compression, knowledge distillation, and hardware-aware acceleration will be explored to facilitate deployment on edge devices and embedded controllers. (iii) Physics-Informed Hybrid Modeling: By integrating physical constraints, such as solar zenith angle dynamics and photovoltaic thermal models, into the Mamba-based state-space representation, we expect to further improve the model’s robustness and explainability across different climatic regions. This work offers a solid solution for long-horizon photovoltaic power forecasting. Future research will aim at cross-site generalization, probabilistic forecasting, and lightweight deployment to improve practical utility. Conclusion This study tackles three main challenges in long-horizon photovoltaic power forecasting, including the efficiency–accuracy trade-off in ultra-long sequence modeling, systematic underestimation of peak values, and the robustness of ensemble fusion under varied operating conditions. To address these challenges, a hybrid forecasting framework, termed MambaFormer-TPEF, is proposed. First, a hybrid sequence modeling architecture is developed by combining state-space modeling with attention mechanisms, enabling the joint modeling of global temporal dependencies and local pattern variations. The state-space component efficiently handles long historical sequences, while the attention module sharpens short-term representations. Experimental results show that the proposed architecture exhibits a long-horizon performance decay of only 4.0%, in contrast to 36.7% and 35.8% observed for LSTM and GRU, respectively, demonstrating substantially improved robustness in long-sequence forecasting tasks. Second, a dual-stage peak-enhancement strategy is introduced to mitigate the common peak underestimation issue in deep learning–based forecasts. By decoupling peak magnitude estimation and peak timing identification into two complementary subtasks and incorporating tree-based expert models, the proposed strategy reduces peak bias from to and decreases peak RMSE by 13.3%. SHAP-based analysis further reveals the complementary feature preferences of the expert models, providing interpretable evidence for the effectiveness of the peak-enhancement mechanism. Third, a multi-layer ensemble fusion framework (MLEF) is proposed to enable scenario-adaptive dynamic weighting among base predictors. Compared with simple averaging and fixed weighting strategies, MLEF learns the relationship between input features and model performance, allowing confidence weights to be adjusted automatically under different weather conditions. This adaptive strategy enhances forecasting stability and robustness across multiple prediction horizons. In ultra-long sequence forecasting tasks with 720-hour inputs and 168-hour prediction horizons, the proposed MambaFormer-TPEF framework achieves an score of 0.5521 and an RMSE of 33.90 kW, corresponding to relative improvements of 8.15% and 4.32%, respectively, over strong baseline models. These results confirm the effectiveness of integrating state-space modeling, attention mechanisms, tree-based peak enhancement, and adaptive ensemble fusion for photovoltaic power forecasting. Overall, this work provides a scalable and adaptable solution for long-horizon time-series prediction. The proposed framework and associated strategies are not limited to photovoltaic power forecasting and can be extended to other energy prediction tasks, such as wind power and load forecasting. Future research will focus on cross-site generalization, probabilistic forecasting, and lightweight deployment to further enhance practical applicability. Appendix A: Feature engineering and preprocessing The photovoltaic power forecasting dataset used in this study contains a large number of raw electrical measurements from photovoltaic arrays and weather stations, together with derived temporal features. This appendix provides detailed descriptions of the raw electrical features and the temporal encoding features adopted in the experiments. A.1 Raw electrical features Table 11 summarizes the 16 raw electrical features included in the dataset. These features cover a wide range of inverter- and meter-level electrical parameters, including power output, voltage, current, and frequency, and provide essential information for modeling the operational behavior of photovoltaic systems. Table 11Raw electrical features used in this study.SymbolFeature nameTypeUnitValue rangeDescription InvPAC_kW_AvgContinuouskW0–207Inverter AC output power (target variable) InvVb_AvgContinuousV270–276Inverter phase-B voltage InvIa_AvgContinuousA0–252Inverter phase-A current InvIb_AvgContinuousA0–251Inverter phase-B current InvIc_AvgContinuousA0–252Inverter phase-C current InvFreq_AvgContinuousHz60.1–60.2Inverter output frequency InvPDC_kW_AvgContinuouskW0–227Inverter DC input power InvOpStatus_AvgBinary/int flag–0–5Inverter operation status flag InvVoltageFault_MaxBinary/int flag–0–0Inverter voltage fault indicator PwrMtrIa_AvgContinuousA0–255Power meter phase-A current PwrMtrIb_AvgContinuousA0–254Power meter phase-B current PwrMtrFreq_AvgContinuousHz60–60Power meter frequency PwrMtrPhaseRev_AvgBinary/int flag–0–0Power meter phase sequence reversal flag PwrMtrVa_AvgContinuousV270–274Power meter phase-A voltage Battery_A_AvgContinuousA–0.024Battery current Qloss_Ah_MaxContinuousAh0–0.001Cumulative charge loss Raw electrical features used in this study. A.2 Temporal derived features To explicitly model temporal periodicity, multiple time-derived features are constructed from timestamp information, including hour of day, day of week, month, and day of year. As summarized in Table 12, sine–cosine encodings are employed to represent cyclical temporal patterns, together with a binary daytime indicator to capture diurnal activity. Table 12Temporal derived features and encoding formulas.SymbolFeature nameTypeRangeEncoding FORMULADescription hour_sinContinuous Sine encoding of hour-of-day hour_cosContinuous Cosine encoding of hour-of-day weekday_sinContinuous Sine encoding of day-of-week weekday_cosContinuous Cosine encoding of day-of-week month_sinContinuous Sine encoding of month month_cosContinuous Cosine encoding of month day_of_year_sinContinuous Sine encoding of day-of-year day_of_year_cosContinuous Cosine encoding of day-of-year is_daytimeBinary Daytime indicator flag Temporal derived features and encoding formulas. Appendix B: Additional SHAP-based interpretability results See Figs. 15, 16 and 17. SHAP summary plot for the XGBoost peak predictor. The distribution illustrates the global contribution patterns of key features across all samples. Example waterfall plot illustrating the individual prediction breakdown for the LightGBM peak predictor. Feature contributions are shown relative to the baseline prediction. Example waterfall plot illustrating the individual prediction breakdown for the XGBoost peak predictor. The plot highlights differences in feature attribution compared with LightGBM. Author contributions J.Z.: Conceptualization, Methodology, Software, Validation, Writing—original draft. X.W.: Supervision, Project administration, Funding acquisition, Writing—review & editing. Q.Z.: Data curation, Formal analysis, Visualization. Z.S.: Investigation, Resources, Writing—review & editing. Data availability The NIST Campus Photovoltaic (PV) Arrays and Weather Station Data Sets used in this study are publicly available through the U.S. Government’s open data portal at https://catalog.data.gov/dataset/nist-campus-photovoltaic-pv-arrays-and-weather-station-data-sets-05b4d. The processed datasets and code implementations will be made available upon reasonable request to the corresponding author (Xixiu Wu, wuxixiu@whut.edu.cn). Code availability The source code of MambaFormer-TPEF is publicly available on GitHub: https://github.com/zoujiayu-123/MambaFormer-TPEF The repository provides the implementation of the proposed method and related documentation for public use. Declarations Competing interests The authors declare no competing interests. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. References Associated Data Data Availability Statement The NIST Campus Photovoltaic (PV) Arrays and Weather Station Data Sets used in this study are publicly available through the U.S. Government’s open data portal at https://catalog.data.gov/dataset/nist-campus-photovoltaic-pv-arrays-and-weather-station-data-sets-05b4d. The processed datasets and code implementations will be made available upon reasonable request to the corresponding author (Xixiu Wu, wuxixiu@whut.edu.cn). The source code of MambaFormer-TPEF is publicly available on GitHub: https://github.com/zoujiayu-123/MambaFormer-TPEF The repository provides the implementation of the proposed method and related documentation for public use.