Skip to content

Commit 5297a60

Browse files
Ronald Tseronaldtse
authored andcommitted
style: drop unused loop vars in layer_drop_state
1 parent 163aedf commit 5297a60

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/gpu/modal_distill.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,19 @@ def src_depth(prefix):
152152
for prefix in ("encoder.", "decoder."):
153153
d_dst, d_src = depth(prefix), src_depth(prefix)
154154
kept = list(range(0, d_src, keep))[:d_dst] if d_dst < d_src else list(range(d_src))
155-
for name, tgt in narrow.items():
155+
for name in narrow:
156156
if not name.startswith(f"{prefix}block."):
157157
continue
158158
m = re.match(rf"{prefix}block\.(\d+)\.(.*)", name)
159159
src_name = f"{prefix}block.{kept[int(m.group(1))]}.{m.group(2)}"
160160
out[name] = pretrained[src_name].clone()
161-
for name, tgt in narrow.items():
161+
for name in narrow:
162162
if name in out:
163163
continue
164164
src = pretrained.get(name)
165-
out[name] = (src if src is not None else tgt).clone()
165+
if src is None:
166+
raise KeyError(name)
167+
out[name] = src.clone()
166168
return out
167169

168170
def _maybe_stitch(spec_id: str, spec: dict, student) -> None:

0 commit comments

Comments
 (0)