The Prophet ﷺ said, "Whoever fasts Ramadan..." In Qutayba's version of the hadith, the Prophet ﷺ said, "Whoever stands in prayer during the month of Ramadan out of faith and seeking reward, his previous sins will be forgiven, and whoever stands in prayer on Laylat al-Qadr out of faith and seeking reward, his previous sins will be forgiven."
أخبرنا قتيبة ومحمد بن عبد الله بن يزيد قالا حدثنا سفيان عن الزهري عن أبي سلمة
عن النبي ﷺ قال من صام رمضان وفي حديث قتيبة أن النبي ﷺ قال من قام شهر رمضان إيمانا واحتسابا غفر له ما تقدم من ذنبه ومن قام ليلة القدر إيمانا واحتسابا غفر له ما تقدم من ذنبه
Bukhari narrated it in "The Virtue of Laylat al-Qadr," chapter on the virtue of Laylat al-Qadr, hadith 2014, from the hadith of Sufyan bin Uyayna with this same wording. It is also found in Kubra, hadith 2512, with the addition, "and what came after."