Catalyzes an early step in riboflavin biosynthesis, the NAD(P)H-dependent reduction of the ribose side chain of 2,5-diamino-6-ribosylamino-4(3H)-pyrimidinone 5'-phosphate, yielding 2,5-diamino-6-ribitylamino-4(3H)-pyrimidinone 5'-phosphate. The beta anomer is the authentic substrate, and the alpha anomer can serve as substrate subsequent to spontaneous anomerization. NADPH and NADH function equally well as the reductants. Does not catalyze the reduction of 5-amino-6-(5-phospho-D-ribosylamino)uracil to 5-amino-6-(5-phospho-D-ribitylamino)uracil. 2,5-diamino-6-(1-D-ribitylamino)pyrimidin-4(3H)-one 5'-phosphate + NADP(+) = 2,5-diamino-6-(1-D-ribosylamino)pyrimidin-4(3H)-one 5'-phosphate + H(+) + NADPH 2,5-diamino-6-(1-D-ribitylamino)pyrimidin-4(3H)-one 5'-phosphate + NAD(+) = 2,5-diamino-6-(1-D-ribosylamino)pyrimidin-4(3H)-one 5'-phosphate + H(+) + NADH Cofactor biosynthesis; riboflavin biosynthesis. Homodimer. The protein sequence in PubMed:16730025 comes from protein expressed and processed in E.coli. Using chirally deuterated NADPH, the enzyme was shown to be A-type reductase catalyzing the transfer of deuterium from the 4(R) position of NADPH to the 1' (S) position of the substrate. Belongs to the HTP reductase family.