The Prophet ﷺ said, "Whoever fasts Ramadan out of faith and seeking reward will have his past sins forgiven."Abdullah bin Ahmad said, "My father said, 'I heard it four times from Sufyan. Once he said, "Whoever fasts Ramadan," and once he said, "Whoever stands in prayer." And whoever stands in prayer on Laylat al-Qadr out of faith and seeking reward will have his past sins forgiven.'"
عن النبي ﷺ: من صام رمضان إيمانا واحتسابا غفر له ما تقدم من ذنبه قال عبد الله بن أحمد: قال أبي: سمعته أربع مرات من سفيان، وقال مرة: من صام رمضان، وقال مرة: من قام، ومن قام ليلة القدر إيمانا واحتسابا غفر له ما تقدم من ذنبه.
Imam Ahmad narrated it (7280) from Sufyan (that is, Ibn Uyayna), from Zuhri, from Abu Salama, from Abu Hurairah, and he related it. Its chain is sahih. This hadith was narrated by a number of Sufyan's companions, among them Qutayba bin Saeed, Muhammad bin Abdullah bin Yazid, and Ishaq bin Ibrahim, all with the same wording. Nasai transmitted it from these narrators (2202, 2203). However, in Sunan al-Kubra of Nasai (2523), from Qutayba bin Saeed and Muhammad bin Abdullah bin Yazid, they said, Sufyan narrated to us, from Zuhri, from Abu Salama, from Abu Hurairah, from the Prophet ﷺ, who said, "Whoever stands in prayer during the month of Ramadan out of faith and in hope of reward will have his previous sins forgiven" in Qutayba's version, "and what comes after," "and whoever stands in prayer on Laylat al-Qadr out of faith and in hope of reward will have his previous sins forgiven" in Qutayba's version, "and what comes after."The addition of the phrase "and what comes after" is an irregular and objectionable addition. Ibn Abdul-Barr said in Tamhid (7/105), "The addition of 'and what comes after' is an objectionable addition." However, Ibn Hajar pointed out in Khisal Mukaffira (pp. 52–54) that Qutayba bin Saeed was not alone in transmitting this addition, but was rather corroborated by each of the following, Hamid bin Yahya Balkhi, as reported by Qasim bin Asbagh in his Musannaf, Hisham bin Ammar in his Fawaid, Yusuf bin Yaqub Najjahi, as reported by Abu Bakr Muqri in his Fawaid, and Husayn bin Hasan Marwazi in his Kitab al-Siyam -- end of quote.However, the majority of Sufyan's companions narrated it, and they are greater in number and more precise in their transmission, and they did not mention this addition. Among them are Imam Ahmad, as you have seen, and Ali bin Madini, as reported by Bukhari (2014), and Shafii and Humaydi, and Makhlad bin Khalid and Muhammad bin Ahmad bin Abu Khalaf. From these last two, Abu Dawud transmitted it (1372), and Amr bin Ali Fallas, as reported by Ibn Khuzayma (1894), and Abdul-Jabbar bin Ala and Saeed bin Abdul-Rahman Makhzumi together with Amr bin Ali, also with him (2199), and Ibn Muqri, as reported by Ibn Jarud (404), and Abu Khaythama, as reported by Abu Yaala (5960), and others too numerous to count.A group of narrators transmitted it from Zuhri, among them Malik, Aqeel bin Abu Khalid Ayli, Salih bin Kaysan, Muhammad bin Abdul-Rahman bin Abu Dhib, Uzai, and others, and they did not mention this addition. Ibn Hajar pointed to this by saying, "What is well known from Zuhri is without it." This indicates that this addition is shadh (anomalous) in the hadith of Abu Hurairah.Likewise, Hammad bin Salama was alone in transmitting this addition, from Muhammad bin Amr, from Abu Hurairah. Ahmad narrated it (9001) from Affan, from Hammad bin Salama. Tirmidhi (683), Ibn Majah (1326), Ibn Hibban (3682), and others narrated it through other routes from Muhammad bin Amr, and they did not mention in it "and what comes after."