Skip to content

Commit d3167f2

Browse files
authored
Merge pull request #65 from interscript/fix/remove-duplicate-tiny-spec
style: ruff debt from the direct-pushed mounts commit
2 parents e9f55ef + b91113d commit d3167f2

7 files changed

Lines changed: 30 additions & 17 deletions

File tree

‎src/api/inference.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
.env({"IMAGE_REV": "6"})
2727
.add_local_dir(str(Path(__file__).resolve().parent.parent), "/root/interscript-ml", copy=True)
2828
# deterministic mounts for the index-driven resolver + the index itself
29-
.add_local_file(str(Path(__file__).resolve().parent / "model_resolution.py"), "/root/model_resolution.py")
29+
.add_local_file(
30+
str(Path(__file__).resolve().parent / "model_resolution.py"),
31+
"/root/model_resolution.py",
32+
)
3033
.add_local_file(str(_REPO_ROOT / "models.yaml"), "/root/models.yaml")
3134
)
3235

‎src/api/model_resolution.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
from __future__ import annotations
1515

16-
import yaml
1716
from pathlib import Path
1817

18+
import yaml
19+
1920

2021
def load_index(path: str | Path = "models.yaml") -> dict:
2122
with open(path, encoding="utf-8") as fh:

‎src/gpu/modal_distill.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ def probe_pkm_gates(spec_id: str = "ara-diac-small-pkm") -> dict:
16171617
raise RuntimeError(f"no step checkpoints under {out_root}")
16181618

16191619
_ensure_src_path()
1620-
from gpu.pkm import ProductKeyMemory, inject_pkm
1620+
from gpu.pkm import inject_pkm
16211621

16221622
student = AutoModelForSeq2SeqLM.from_pretrained(spec["student_init"])
16231623
inject_pkm(student, **spec["pkm"])

‎src/gpu/muon.py‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,27 @@ def __init__(self, params, lr: float = 0.01, momentum: float = 0.95,
4141
weight_decay: float = 0.0) -> None:
4242
super().__init__(
4343
list(params),
44-
dict(lr=lr, momentum=momentum, nesterov=nesterov,
45-
ns_steps=ns_steps, weight_decay=weight_decay, adamw=False),
44+
{
45+
"lr": lr,
46+
"momentum": momentum,
47+
"nesterov": nesterov,
48+
"ns_steps": ns_steps,
49+
"weight_decay": weight_decay,
50+
"adamw": False,
51+
},
4652
)
4753

4854
def add_adamw_group(self, params, lr: float = 1e-4, betas=(0.9, 0.999),
4955
weight_decay: float = 0.0) -> None:
5056
"""Embedding-like parameters: standard AdamW math, shared
5157
scheduler (the cosine scales every group's lr)."""
52-
self.add_param_group(dict(params=list(params), lr=lr, betas=tuple(betas),
53-
weight_decay=weight_decay, adamw=True))
58+
self.add_param_group({
59+
"params": list(params),
60+
"lr": lr,
61+
"betas": tuple(betas),
62+
"weight_decay": weight_decay,
63+
"adamw": True,
64+
})
5465

5566
@torch.no_grad()
5667
def step(self, closure=None): # noqa: ARG002

‎src/imf/parity.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,8 @@ def run_margin_analysis(model, zip_path, pairs, max_len: int = 256) -> MarginRep
277277
def write_margin_report(report: MarginReport, out_path: Path | str) -> Path:
278278
"""Emit the margin analysis as JSON next to a release zip (diagnostic
279279
artifact; the release gate remains the CER parity block)."""
280-
from dataclasses import asdict
281-
282280
import json
281+
from dataclasses import asdict
283282

284283
out_path = Path(out_path)
285284
out_path.parent.mkdir(parents=True, exist_ok=True)

‎tests/test_decode_guard.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ def __init__(self):
2222
self.step = 0
2323

2424
def get_outputs(self):
25-
class O:
25+
class Out:
2626
def __init__(self, name):
2727
self.name = name
2828

29-
return [O("logits"), O("present_k"), O("present_v")]
29+
return [Out("logits"), Out("present_k"), Out("present_v")]
3030

3131
def get_inputs(self):
32-
class I:
32+
class In:
3333
def __init__(self, name, shape, typ="tensor(float)"):
3434
self.name = name
3535
self.shape = shape
3636
self.type = typ
3737

3838
return [
39-
I("input_ids", [1, "seq"]),
40-
I("encoder_hidden_states", [1, "seq", 4]),
41-
I("past_k", [1, 4, "past", 8]),
42-
I("past_v", [1, 4, "past", 8]),
39+
In("input_ids", [1, "seq"]),
40+
In("encoder_hidden_states", [1, "seq", 4]),
41+
In("past_k", [1, 4, "past", 8]),
42+
In("past_v", [1, 4, "past", 8]),
4343
]
4444

4545
def run(self, _, feeds):

‎tests/test_imf_parity.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
make_fixture_checkpoint,
2424
)
2525
from imf.parity import ( # noqa: E402
26-
MarginReport,
2726
ParityReport,
2827
_margin_stats,
2928
run_margin_analysis,

0 commit comments

Comments
 (0)