In the domain of spectroscopy, miniaturization efforts often face significant challenges, particularly in achieving high spectral resolution and precise construction. Here, we introduce a computational spectrometer powered by a nonlinear photonic memristor with a WSe2 homojunction. This approach overcomes traditional limitations, such as constrained Fermi level tunability, persistent dark current, and limited photoresponse dimensionality through dynamic energy band modulation driven by palladium (Pd) ion migration. The critical role of Pd ion migration is thoroughly supported by first-principles calculations, numerical simulations, and experimental verification, demonstrating its effectiveness in enhancing device performance. Additionally, we integrate this dynamic modulation with a specialized nonlinear neural network tailored to address the memristor's inherent nonlinear photoresponse. This combination enables our spectrometer to achieve an exceptional peak wavelength accuracy of 0.18 nm and a spectral resolution of 2 nm within the 630-640 nm range. This development marks a significant advancement in the creation of compact, high-efficiency spectroscopic instruments and offers a versatile platform for applications across diverse material systems.
© 2025. The Author(s).