Skip to content

Commit 969adfe

Browse files
physicsrobclaude
andcommitted
Ruff migration: ruff format (mechanical)
f-string interior spacing and assert/paren reflow relative to black. No content changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 20a4f84 commit 969adfe

78 files changed

Lines changed: 444 additions & 460 deletions

File tree

Some content is hidden

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

examples/calculator_advanced.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ def subtract_digit_seqs(
222222
embedding,
223223
seq1,
224224
seq2,
225-
status_of=lambda a, b: (
226-
_GENERATE if a < b else _PROPAGATE if a == b else _KILL
227-
),
225+
status_of=lambda a, b: _GENERATE if a < b else _PROPAGATE if a == b else _KILL,
228226
digit_of=lambda a, b, borrow: (a - b - borrow) % 10,
229227
)
230228

scripts/calculator_layer_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def collect_cell(impl_name: str, n: int) -> dict:
141141
if hasattr(impl, "compiled_layers"):
142142
row["layers_extrapolated"] = impl.compiled_layers(n, d_hidden=D_HIDDEN)
143143
print(
144-
f"[{impl_name} n={n}] build refused: " f"{row['build_error'][:80]}",
144+
f"[{impl_name} n={n}] build refused: {row['build_error'][:80]}",
145145
flush=True,
146146
)
147147
return row

scripts/clip_sweep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ def gaps(writes):
7575
n = len(ag)
7676
print(
7777
f"\nAGGREGATE over all angles: n={n} min={ag[0]} "
78-
f"median={statistics.median(ag):.0f} p95={ag[int(0.95*n)]} "
79-
f"p99={ag[int(0.99*n)]} max={ag[-1]}"
78+
f"median={statistics.median(ag):.0f} p95={ag[int(0.95 * n)]} "
79+
f"p99={ag[int(0.99 * n)]} max={ag[-1]}"
8080
)

scripts/measure_op_noise.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,9 @@ def _target_ops() -> List[TargetOp]:
13081308
source_file=_ARITH_FILE,
13091309
input_specs={"x": 1},
13101310
build_graph=lambda nodes: mod_const(nodes["x"], divisor=7, max_value=100),
1311-
reference_fn=lambda inputs: inputs["x"]
1312-
- 7.0 * torch.floor(inputs["x"] / 7.0),
1311+
reference_fn=lambda inputs: (
1312+
inputs["x"] - 7.0 * torch.floor(inputs["x"] / 7.0)
1313+
),
13131314
distribution_names=("mod_integers_0_100_by7",),
13141315
notes=(
13151316
"Identity `x % d = x - d · thermometer_floor_div(x, d)`. "
@@ -1713,12 +1714,14 @@ def _target_ops() -> List[TargetOp]:
17131714
build_graph=lambda nodes: swiglu_ops.dynamic_extract(
17141715
nodes["table"], nodes["idx"], n_entries=4, d_fill=2
17151716
),
1716-
reference_fn=lambda inputs: inputs["table"]
1717-
.view(-1, 4, 2)[
1718-
torch.arange(inputs["table"].shape[0]),
1719-
inputs["idx"].flatten().long(),
1720-
]
1721-
.view(-1, 2),
1717+
reference_fn=lambda inputs: (
1718+
inputs["table"]
1719+
.view(-1, 4, 2)[
1720+
torch.arange(inputs["table"].shape[0]),
1721+
inputs["idx"].flatten().long(),
1722+
]
1723+
.view(-1, 2)
1724+
),
17221725
distribution_names=("dynamic_extract_int_idx_4x2",),
17231726
notes=(
17241727
"in_range one-hot → broadcast_select (zero-literal false "
@@ -1893,8 +1896,9 @@ def _target_ops() -> List[TargetOp]:
18931896
build_graph=lambda nodes: swiglu_ops.mod_const(
18941897
nodes["x"], divisor=7, max_value=100
18951898
),
1896-
reference_fn=lambda inputs: inputs["x"]
1897-
- 7.0 * torch.floor(inputs["x"] / 7.0),
1899+
reference_fn=lambda inputs: (
1900+
inputs["x"] - 7.0 * torch.floor(inputs["x"] / 7.0)
1901+
),
18981902
distribution_names=("mod_integers_0_100_by7",),
18991903
notes=(
19001904
"x − d·thermometer_floor_div(x, d) — linear hardware plus "
@@ -2150,8 +2154,7 @@ def render_markdown(data: Dict) -> str:
21502154
lines.append("## Summary")
21512155
lines.append("")
21522156
lines.append(
2153-
"| Op | Machine | Module | Max abs error | Max rel error "
2154-
"| Worst distribution |"
2157+
"| Op | Machine | Module | Max abs error | Max rel error | Worst distribution |"
21552158
)
21562159
lines.append("| --- | --- | --- | --- | --- | --- |")
21572160
for op in data["ops"]:

scripts/proto_rmsnorm_float_roundtrip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def run(d, eps=0.0, energy_scale=1.0, n_iter=200):
9595
bound = E * 2**-24 # half-ULP of E; the data energy must stay under this
9696
ok = "OK" if (err.max() == 0 and rms_spread == 0 and drift == 0) else "BIT-DRIFT"
9797
print(
98-
f" d={d:<5} b={d.bit_length()-1} cols={n_const} rms=2^{m} gain={gain:.2e} "
98+
f" d={d:<5} b={d.bit_length() - 1} cols={n_const} rms=2^{m} gain={gain:.2e} "
9999
f"eps={eps:g} scale={energy_scale:<5g} "
100-
f"Σdata²={data_energy:.2e}(<{bound:.1e}? {'y' if data_energy<bound else 'N'}) "
100+
f"Σdata²={data_energy:.2e}(<{bound:.1e}? {'y' if data_energy < bound else 'N'}) "
101101
f"rms_spread={rms_spread:.0e} max|Δ|={err.max():.0e} "
102102
f"drift@{n_iter}={drift:.0e} [{ok}]"
103103
)

scripts/proto_rmsnorm_identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def run_case(d, max_digits, prompt):
109109
else:
110110
verdict = "DRIFT"
111111
print(
112-
f" d={d:<5} b={d.bit_length()-1} cols={n_const} rms=2^{m} gain={gain:.2e} "
112+
f" d={d:<5} b={d.bit_length() - 1} cols={n_const} rms=2^{m} gain={gain:.2e} "
113113
f"layers={len(net.layers):3} free_cols={len(free):4} "
114114
f"rms_spread={rms_spread:.0e} max|Δ|={max_abs:.0e} "
115115
f"decode_ok={decode_ok} [{verdict}]"

scripts/rope_phase_readout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def single_cosine_end_resolution(n: int, margin: float = 0.1) -> None:
135135
dcos = abs(math.cos(p0) - math.cos(p1))
136136
print(
137137
f" single-cosine sep at {label:>14}: {dcos:.2e} "
138-
f"(uniform two-head sep would be ~{theta_half*gap*2:.2e})"
138+
f"(uniform two-head sep would be ~{theta_half * gap * 2:.2e})"
139139
)
140140

141141

scripts/rope_position_decode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def main() -> None:
215215
knots = n_breakpoints(radix, n_levels)
216216
print(
217217
f"{radix:>6} {n_levels:>7} {n_levels:>7} {knots:>7} "
218-
f"{str(exact):>7} {margin:>18.4f} {math.pi/radix:>10.4f}"
218+
f"{str(exact):>7} {margin:>18.4f} {math.pi / radix:>10.4f}"
219219
)
220220

221221
print("\nReadings:")

scripts/rope_recency_replay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def noisy(v, n_reads=1):
119119
theta_full = 2.0 * math.pi / MAX_POSITIONS
120120
c_min = _sigmoid_prime(G_M * math.cos(math.pi / 4)) * G_M * math.sin(math.pi / 4)
121121
ramp = (c_min * theta_full) * k # value-space, uniform slope
122-
out[f"octant_twohead(slope={c_min*theta_full:.1e}/tok)"] = (
122+
out[f"octant_twohead(slope={c_min * theta_full:.1e}/tok)"] = (
123123
noisy(ramp, n_reads=2),
124124
1.0,
125125
)

scripts/validate_multiply_2d_build_cost.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def main() -> None:
5656
print()
5757
print(
5858
"old generic path at this n built a (n², n²) = "
59-
f"({n_bp ** 2}, {n_bp ** 2}) float64 SVD U matrix "
60-
f"≈ {n_bp ** 4 * 8 / 1e9:.1f} GB → OOM"
59+
f"({n_bp**2}, {n_bp**2}) float64 SVD U matrix "
60+
f"≈ {n_bp**4 * 8 / 1e9:.1f} GB → OOM"
6161
)
6262
print()
6363

0 commit comments

Comments
 (0)