Skip to content

Commit be8c379

Browse files
committed
style(prism): normalize baseline formatting
1 parent 9edf693 commit be8c379

48 files changed

Lines changed: 494 additions & 334 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/tiny-1m/architecture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, dim: int, n_heads: int) -> None:
4545
self.dim = dim
4646
self.n_heads = n_heads
4747
self.head_dim = dim // n_heads
48-
self.scale = self.head_dim ** -0.5
48+
self.scale = self.head_dim**-0.5
4949
self.qkv = nn.Linear(dim, dim * 3, bias=False)
5050
self.proj = nn.Linear(dim, dim, bias=False)
5151

scripts/mission/launch.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,7 @@ def _reconstruct_dispute_via_api(
617617
(
618618
u
619619
for u in units
620-
if u.get("work_unit_id") == sid
621-
or str(u.get("work_unit_id", "")).startswith(sid)
620+
if u.get("work_unit_id") == sid or str(u.get("work_unit_id", "")).startswith(sid)
622621
),
623622
None,
624623
)
@@ -645,8 +644,7 @@ def _reconstruct_dispute_via_api(
645644
f"outcome={audit.get('outcome')}"
646645
)
647646
print(
648-
f" (c) prism submission status={submission.get('status')} "
649-
f"no_live_score={ok_invalidated}"
647+
f" (c) prism submission status={submission.get('status')} no_live_score={ok_invalidated}"
650648
)
651649
print(f" (d) fault worker={fault['worker_id']} visible on API+CLI={ok_fault_both}")
652650
passed = ok_disputed and ok_audit and ok_invalidated and ok_fault_both

scripts/mission/legacy_smoke.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ def run(workdir: Path) -> bool:
253253
f"assigned_validator_hotkey={row['assigned_validator_hotkey']}"
254254
)
255255
assigned_to_validator = (
256-
row["assigned_validator_hotkey"] == validator_hk
257-
and row["required_capability"] == "gpu"
256+
row["assigned_validator_hotkey"] == validator_hk and row["required_capability"] == "gpu"
258257
)
259258
worker_regs = h._count("worker_registrations")
260259
worker_asgn = h._count("worker_assignments")

src/prism_challenge/admission.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ async def count_active_workers(settings: PrismSettings, hotkey: str) -> int | No
6666
ACTIVE_WORKERS_PATH, params={"hotkey": hotkey}, headers=headers
6767
)
6868
except httpx.HTTPError as exc:
69-
logger.warning(
70-
"admission master query failed (%s); failing closed", type(exc).__name__
71-
)
69+
logger.warning("admission master query failed (%s); failing closed", type(exc).__name__)
7270
return None
7371
if response.status_code >= 400:
74-
logger.warning(
75-
"admission master returned HTTP %s; failing closed", response.status_code
76-
)
72+
logger.warning("admission master returned HTTP %s; failing closed", response.status_code)
7773
return None
7874
try:
7975
payload = response.json()

src/prism_challenge/evaluator/benchmarks/official.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ class NeedleScoringConfig(BaseModel):
9191
@model_validator(mode="after")
9292
def weights_sum_to_one(self) -> NeedleScoringConfig:
9393
total = (
94-
self.exact_match_weight
95-
+ self.contains_answer_weight
96-
+ self.normalized_position_weight
94+
self.exact_match_weight + self.contains_answer_weight + self.normalized_position_weight
9795
)
9896
if abs(total - 1.0) > 1e-6:
9997
raise ValueError(f"needle scoring weights must sum to 1.0, got {total:.6f}")
@@ -217,9 +215,7 @@ def parse_official_benchmark_outputs(
217215
parsed_scores = list(parse_lm_eval_output(lm_payload))
218216
parsed_scores.append(parse_needle_output(needle_payload, needle_spec))
219217
benchmark_scores = {score.benchmark_key: score.score for score in parsed_scores}
220-
missing = tuple(
221-
key for key in OFFICIAL_BENCHMARK_SCORE_KEYS if key not in benchmark_scores
222-
)
218+
missing = tuple(key for key in OFFICIAL_BENCHMARK_SCORE_KEYS if key not in benchmark_scores)
223219
errors = tuple(f"missing benchmark result: {key}" for key in missing)
224220
return BenchmarkParseResult(
225221
benchmark_scores=benchmark_scores,
@@ -301,8 +297,7 @@ def _parse_task_group(
301297
if metric is None:
302298
raise ValueError(f"{task_id} result missing supported metrics {preferred_metrics}")
303299
values = [
304-
_require_float(result[metric], f"{task_id}.{metric}")
305-
for result in task_results.values()
300+
_require_float(result[metric], f"{task_id}.{metric}") for result in task_results.values()
306301
]
307302
stderr = _average_stderr(task_results, metric)
308303
return ParsedBenchmarkScore(
@@ -315,9 +310,7 @@ def _parse_task_group(
315310
)
316311

317312

318-
def _matching_task_results(
319-
results: dict[str, Any], task_id: str
320-
) -> dict[str, dict[str, Any]]:
313+
def _matching_task_results(results: dict[str, Any], task_id: str) -> dict[str, dict[str, Any]]:
321314
matches: dict[str, dict[str, Any]] = {}
322315
for key, value in results.items():
323316
if key == task_id or key.startswith(f"{task_id}_"):

src/prism_challenge/evaluator/components.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ def _top_level_functions(content: str, path: str) -> set[str]:
309309
f"submission contract violation: cannot parse {path} ({exc.msg})"
310310
) from exc
311311
return {
312-
node.name
313-
for node in tree.body
314-
if isinstance(node, ast.FunctionDef | ast.AsyncFunctionDef)
312+
node.name for node in tree.body if isinstance(node, ast.FunctionDef | ast.AsyncFunctionDef)
315313
}
316314

317315

src/prism_challenge/evaluator/cpu_test_mode.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ def stage_tiny_train_data(root: Path | str, *, lines: int = 64) -> Path:
9999
data_dir.mkdir(parents=True, exist_ok=True)
100100
shard = data_dir / "train-00000.jsonl"
101101
if not shard.exists():
102-
shard.write_text(
103-
"".join(_SHARD_LINE.format(i=i) for i in range(lines)), encoding="utf-8"
104-
)
102+
shard.write_text("".join(_SHARD_LINE.format(i=i) for i in range(lines)), encoding="utf-8")
105103
return data_dir
106104

107105

src/prism_challenge/evaluator/data_prep.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def _load(self) -> object:
6363
try:
6464
import tiktoken
6565
except ImportError as exc: # pragma: no cover - exercised only without tiktoken
66-
raise LockedDatasetError(
67-
"tiktoken is required for the gpt2 token counter"
68-
) from exc
66+
raise LockedDatasetError("tiktoken is required for the gpt2 token counter") from exc
6967
self._encoding = tiktoken.get_encoding("gpt2")
7068
return self._encoding
7169

src/prism_challenge/evaluator/dataset.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def partition_bucket(doc_id: str) -> int:
6363
def bucket_to_split(bucket: int) -> str:
6464
"""Map a partition bucket to its split using the fixed/pinned boundaries."""
6565
if not 0 <= bucket < PARTITION_MODULUS:
66-
raise LockedDatasetError(
67-
f"partition bucket {bucket} out of range [0, {PARTITION_MODULUS})"
68-
)
66+
raise LockedDatasetError(f"partition bucket {bucket} out of range [0, {PARTITION_MODULUS})")
6967
for split, (low, high) in PARTITION_BUCKETS.items():
7068
if low <= bucket <= high:
7169
return split
@@ -171,9 +169,7 @@ def to_dict(self) -> dict[str, Any]:
171169
"partition": self.partition,
172170
"tokenizer": dict(self.tokenizer),
173171
"splits": {
174-
name: self.splits[name].to_dict()
175-
for name in LOCKED_SPLITS
176-
if name in self.splits
172+
name: self.splits[name].to_dict() for name in LOCKED_SPLITS if name in self.splits
177173
},
178174
}
179175

@@ -319,8 +315,7 @@ def verify_locked_manifest(
319315
actual = hashlib.sha256(data).hexdigest()
320316
if actual != shard.sha256:
321317
problems.append(
322-
f"sha256 mismatch for {shard.path}: "
323-
f"manifest {shard.sha256} != on-disk {actual}"
318+
f"sha256 mismatch for {shard.path}: manifest {shard.sha256} != on-disk {actual}"
324319
)
325320
if len(data) != shard.bytes:
326321
problems.append(
@@ -345,9 +340,7 @@ def verify_locked_manifest_or_raise(
345340
) -> None:
346341
problems = verify_locked_manifest(root, manifest, splits=splits)
347342
if problems:
348-
raise LockedDatasetError(
349-
"locked dataset integrity check failed: " + "; ".join(problems)
350-
)
343+
raise LockedDatasetError("locked dataset integrity check failed: " + "; ".join(problems))
351344

352345

353346
def locked_shard_paths(manifest: LockedManifest, split: str) -> list[str]:
@@ -405,9 +398,7 @@ def iter_locked_documents(root: Path | str, split: str) -> Iterator[LockedDocume
405398
doc_id = str(record["id"])
406399
text = record["text"]
407400
except (json.JSONDecodeError, KeyError, TypeError) as exc:
408-
raise LockedDatasetError(
409-
f"malformed locked shard line {rel}:{offset}"
410-
) from exc
401+
raise LockedDatasetError(f"malformed locked shard line {rel}:{offset}") from exc
411402
if not isinstance(text, str):
412403
raise LockedDatasetError(f"locked shard line {rel}:{offset} has non-string text")
413404
yield LockedDocument(doc_id=doc_id, text=text, shard=rel, offset=offset, index=index)

src/prism_challenge/evaluator/distributed_contract.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ def _is_rank0_test(test: ast.AST) -> bool:
272272
return any(_is_rank0_test(value) for value in test.values)
273273
if isinstance(test, ast.Compare) and len(test.ops) == 1 and isinstance(test.ops[0], ast.Eq):
274274
left, right = test.left, test.comparators[0]
275-
return (_is_rank_ref(left) and _is_zero(right)) or (
276-
_is_rank_ref(right) and _is_zero(left)
277-
)
275+
return (_is_rank_ref(left) and _is_zero(right)) or (_is_rank_ref(right) and _is_zero(left))
278276
return False
279277

280278

0 commit comments

Comments
 (0)