[Models] Improve iteration over layers (#19497)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import math
|
||||
from collections.abc import Iterable, Mapping, Sequence
|
||||
from dataclasses import dataclass
|
||||
from functools import cached_property, partial
|
||||
from itertools import islice
|
||||
from typing import Annotated, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
@@ -842,7 +843,7 @@ class MolmoModel(nn.Module, SupportsQuant):
|
||||
residual = intermediate_tensors["residual"]
|
||||
|
||||
# Apply blocks one-by-one.
|
||||
for layer in self.layers[self.start_layer:self.end_layer]:
|
||||
for layer in islice(self.layers, self.start_layer, self.end_layer):
|
||||
hidden_states, residual = layer(
|
||||
positions,
|
||||
hidden_states,
|
||||
|
||||
Reference in New Issue
Block a user