There is a tradition from Imam Ja'far as-Sadiq (a.s.) in the book Al Kafi (Section on Penal Code), that:
One day Ali (a.s.) was sitting with his companions when a man approached and said "O Chief of the Believers, I have committed sodomy with a boy, please purify me (impose legal penalty upon me) Ali (a.s.) told him, "Go home, you may have had some misunderstanding."
The next day the man returned and repeated his confession and requested for penalty. Ali (a.s.) said,
"Go home, you may not be in your sense right now."
He went away only to return the third time and repeat his confession and again asked for punishment.
At last when he came for the fourth time, Ali (a.s.) said,
"The Holy Prophet (s.a.w.s.) has prescribed three methods of dealing with the situation, you may choose any one of the three deaths - by having the arms and feet tied and thrown from the cliff, being beheaded or being burnt alive."
He said, "O, Ali (a.s.) which is the worst of these methods?" Imam replied, "Burning alive." "Then I choose this death." said the man. By permission of Ali (a.s.), he stood and prayed two rakaat prayer and then said, "O Allah ! A sin was committed by me of which You are well aware. Then I had the fear of this sin, I came to the Successor of your Prophet and requested him to purify me. He gave me a choice of three deaths. I chose the most dreadful death. I pray to you to consider this penalty as the expiation of my sin and do not burn me in the fire of Hell which is ignited by you."
Then he got up weeping and jumped into the pit into which the fire had been lit. He sat in the fire and the fire engulfed him from all the sides. Ali (a.s.) began to weep, upon seeing this condition and the other companions were also in tears.
Ali (a.s.) said, "Arise, the one who has caused the angels of the earth and the sky to weep. Allah has certainly accepted your repentance. Get up but never approach the sin that you have committed."
It so happened that the man came out of the fire unscathed. The fire could not burn the one who repented.
Remarkable Points
It is commonly agreed by the Mujtahids that if a person confesses four times but repents before the execution of sentence, the Judge has the authority either to impose penalty or cancel it. The above report also indicates that the Imam (a.s.) did not pursue the sentence. However, the sentence cannot be cancelled after the testimony of four just witnesses.
The Mother, Sister and Daughter of the Sodomist
It must be known that if a man commits sodomy with a boy (that he penetrates his anus), the mother, sister and daughter of the boy becomes Haraam for this man forever. That is, this man could never lawfully marry the mother, sister or daughter of this boy.
source : GREATER SINS by Ayatullah-ul-Uzma Sayed Abdul Husain Dastghaib Shirazi (r.a.)