[Models] Improve iteration over layers (#19497)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
# limitations under the License.
|
||||
"""Inference-only GPTBigCode model compatible with HuggingFace weights."""
|
||||
from collections.abc import Iterable
|
||||
from itertools import islice
|
||||
from typing import Optional, Union
|
||||
|
||||
import torch
|
||||
@@ -246,7 +247,7 @@ class GPTBigCodeModel(nn.Module):
|
||||
else:
|
||||
hidden_states = intermediate_tensors["hidden_states"]
|
||||
|
||||
for layer in self.h[self.start_layer:self.end_layer]:
|
||||
for layer in islice(self.h, self.start_layer, self.end_layer):
|
||||
hidden_states = layer(hidden_states)
|
||||
|
||||
if not get_pp_group().is_last_rank:
|
||||
|
||||
Reference in New Issue
Block a user