Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick] Support qat in sharding stage2 (#47169) #47240

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ def dtype_rank_params(self):
"""
if len(self._dtype_rank_params) == 0:
# Assign the parameters of each rank according to the type
for param in self._local_params:
trainable_params = list(
filter(lambda x: x.trainable, self._local_params))
for param in trainable_params:
if param.dtype not in self._dtype_rank_params.keys():
self._dtype_rank_params[param.dtype] = [
[] for _ in range(self.world_size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ def __init__(
# sharing stage 2 comm overlap flag
self._reduce_overlap = False

self._trainable_params = []
self._grad_reduced = []
self._trainable_param2rank = {}
self._trainable_param2align = {}
self._trainable_mask = list(map(_trainable, self._all_params))
self._trainable_params = list(
filter(lambda x: x.trainable, self._all_params))
self._trainable_mask = list(map(_trainable, self._trainable_params))
self._param_grads = []

# Set grad storage size & Display param sizes and model sizes
Expand Down Expand Up @@ -488,7 +489,7 @@ def _setup_use_grad_storage(self):

def _detect_train_change(self):
# Current trainable parameters
trainable_mask = list(map(_trainable, self._all_params))
trainable_mask = list(map(_trainable, self._trainable_params))

# Whether parameters trainability changed
trainability_changed = trainable_mask != self._trainable_mask
Expand Down