Does it count as a sin to discover that your prayers for the last many months were not valid due to impurity? Does the sin go away by making up the prayers after Ghusl?
As you did not know that your ritual purity was not valid when you performed your prayers, there is no sin on you if you had a valid reason of not knowing, but you need to redo those invalid prayers. After performing those prayers,no your responsibility will be clear.
'Wassalam.