DSGD implementation