From 24cd0a042e8f14f206e5dc66eb00431eab5fc5a7 Mon Sep 17 00:00:00 2001 From: Jane Xu Date: Tue, 28 Nov 2023 13:17:20 -0800 Subject: [PATCH] Update base for Update on "[BE][SparseAdam] cleaner way to verify no sparse params" Context: https://github.com/pytorch/pytorch/pull/47724 fixed the problem that SparseAdam could not handle generators by using the `list(...)` construct. However, this meant that SparseAdam deviated from other optimizers in that it could _accept_ a raw Tensors/Parameter vs requiring a container of them. This is not really a big deal. So why this PR? I do think this PR is cleaner. It uses the fact that the Optimizer parent class already containerizes parameters into parameter groups, so we could reuse that here by calling `super().__init__` first and then filter the param_groups after. This change would also make SparseAdam consistent with the rest of our optimizers in that only containerized params are accepted, which technically is BC breaking but would be minor, I believe. [ghstack-poisoned]