Translation
(40) Prescribed Punishments (Kitab Al-Hudud)
كتاب الحدود
(16) Chapter: If an insane person steals or commits a crime that is subject to a had
(16) باب فِي الْمَجْنُونِ يَسْرِقُ أَوْ يُصِيبُ حَدًّا
Sunan Abi Dawud 4400 
A similar tradition has also been transmitted by al-A’mash through a different chain of narrators. He also said :
“... . Till he reaches puberty , and a lunatic till he is restored to consciousness.” ‘Umar then began to utter: Allah is most great.
حَدَّثَنَا يُوسُفُ بْنُ مُوسَى، حَدَّثَنَا وَكِيعٌ، عَنِ الأَعْمَشِ، نَحْوَهُ وَقَالَ أَيْضًا حَتَّى يَعْقِلَ ‏.‏ وَقَالَ وَعَنِ الْمَجْنُونِ حَتَّى يُفِيقَ ‏.‏ قَالَ فَجَعَلَ عُمَرُ يُكَبِّرُ ‏.‏
Grade :  Sahih (Al-Albani) صحيح  (الألباني)حكم :
Reference : Sunan Abi Dawud 4400
In-book reference : Book 40, Hadith 50
English translation : Book 39, Hadith 4386