-
Notifications
You must be signed in to change notification settings - Fork 1
fix: structural issue batch — bounded reads, oracle coherence, protocol comparison, vLLM percentiles #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: structural issue batch — bounded reads, oracle coherence, protocol comparison, vLLM percentiles #293
Changes from all commits
4e243b4
4252a68
dd9148c
f2133ac
02646ca
0486592
17e945a
b4d6734
39cb8cc
529aefb
7d3ef1b
9cf4a3f
cd57b18
0a221bf
7aeb3c6
d79dd8e
e6ba710
6c19bc1
6ebc992
4762de6
2ee72e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| import math | ||
| import warnings | ||
| from typing import Any, cast | ||
| from typing import Any, Literal, cast | ||
|
|
||
| import numpy as np | ||
| from scipy.stats import bootstrap, spearmanr | ||
|
|
@@ -29,6 +29,17 @@ | |
|
|
||
|
|
||
| class ScalingRecipes(RecipeContext): | ||
| @staticmethod | ||
| def _input_identity( | ||
| integer_value: object, | ||
| floating_value: object, | ||
| ) -> tuple[float | None, Literal["integer", "floating"] | None]: | ||
| if integer_value is not None: | ||
| return float(cast(Any, integer_value)), "integer" | ||
| if floating_value is not None: | ||
| return float(cast(Any, floating_value)), "floating" | ||
| return None, None | ||
|
|
||
| def scaling( | ||
| self, | ||
| experiment_id: str, | ||
|
|
@@ -106,22 +117,25 @@ def scaling( | |
| ).fetchone() | ||
| assert complete_row is not None | ||
| trial_groups: dict[ | ||
| tuple[str, str, str | None, float | None, str, str], | ||
| tuple[ | ||
| str, | ||
| str, | ||
| str | None, | ||
| float | None, | ||
| Literal["integer", "floating"] | None, | ||
| str, | ||
| str, | ||
| ], | ||
| list[float], | ||
| ] = {} | ||
| for row in rows: | ||
| input_value = ( | ||
| float(row[3]) | ||
| if row[3] is not None | ||
| else float(row[4]) | ||
| if row[4] is not None | ||
| else None | ||
| ) | ||
| input_value, input_kind = self._input_identity(row[3], row[4]) | ||
| key = ( | ||
| str(row[0]), | ||
| str(row[1]), | ||
| str(row[2]) if row[2] is not None else None, | ||
| input_value, | ||
| input_kind, | ||
| str(row[7]), | ||
| str(row[5]), | ||
| ) | ||
|
|
@@ -133,6 +147,7 @@ def scaling( | |
| variant, | ||
| block_id, | ||
| input_value, | ||
| input_kind, | ||
| unit, | ||
| environment_id, | ||
| ), values in sorted(trial_groups.items()): | ||
|
|
@@ -143,6 +158,7 @@ def scaling( | |
| variant=variant, | ||
| block_id=block_id, | ||
| input_value=input_value, | ||
| input_kind=input_kind, | ||
| median=median, | ||
| dispersion=float(np.median(np.abs(np.asarray(values) - median))), | ||
| unit=unit, | ||
|
|
@@ -151,18 +167,18 @@ def scaling( | |
| ) | ||
| ) | ||
| point_groups: dict[ | ||
| tuple[str, float | None, str], | ||
| tuple[str, float | None, Literal["integer", "floating"] | None, str], | ||
| list[ScalingTrialSummary], | ||
| ] = {} | ||
| for trial in trials: | ||
| point_groups.setdefault( | ||
| (trial.variant, trial.input_value, trial.unit), | ||
| (trial.variant, trial.input_value, trial.input_kind, trial.unit), | ||
| [], | ||
| ).append(trial) | ||
| points_list: list[ScalingPoint] = [] | ||
| for (variant, input_value, unit), group in sorted( | ||
| for (variant, input_value, input_kind, unit), group in sorted( | ||
| point_groups.items(), | ||
| key=lambda item: (item[0][0], item[0][1] or -math.inf), | ||
| key=lambda item: (item[0][0], item[0][1] or -math.inf, item[0][2] or ""), | ||
| ): | ||
| trial_medians = np.asarray( | ||
| [trial.median for trial in group], | ||
|
|
@@ -180,6 +196,7 @@ def scaling( | |
| variant=variant, | ||
| block_id=next(iter(block_ids)) if len(block_ids) == 1 else None, | ||
| input_value=input_value, | ||
| input_kind=input_kind, | ||
|
morluto marked this conversation as resolved.
|
||
| value=median, | ||
| dispersion=dispersion, | ||
| confidence_interval=( | ||
|
|
@@ -218,6 +235,27 @@ def scaling( | |
| warnings.append( | ||
| "Some variants have no numeric input value and were excluded from fits." | ||
| ) | ||
| input_kinds_by_variant: dict[str, set[Literal["integer", "floating"]]] = {} | ||
| for point in points: | ||
| if ( | ||
| point.input_value is not None | ||
| and point.input_value > 0 | ||
| and math.isfinite(point.input_value) | ||
| and math.isfinite(point.value) | ||
| and point.input_kind is not None | ||
| ): | ||
| input_kinds_by_variant.setdefault(point.variant, set()).add(point.input_kind) | ||
| mixed_input_kind_variants = { | ||
| variant | ||
| for variant, input_kinds in input_kinds_by_variant.items() | ||
| if input_kinds == {"integer", "floating"} | ||
| } | ||
| if mixed_input_kind_variants: | ||
| warnings.append( | ||
| "Fits were excluded for variants with mixed integer and floating scaling inputs: " | ||
| + ", ".join(sorted(mixed_input_kind_variants)) | ||
| + "." | ||
| ) | ||
| environment_stable = all(point.environment_count == 1 for point in points) | ||
| if not environment_stable: | ||
| warnings.append("Environment identity varies within at least one scaling point.") | ||
|
|
@@ -294,6 +332,8 @@ def _scaling_fits( | |
| ] | ||
| if len(numeric) < 3 or len({point.input_value for point in numeric}) < 2: | ||
| continue | ||
| if {point.input_kind for point in numeric} == {"integer", "floating"}: | ||
| continue | ||
| x = np.asarray([point.input_value for point in numeric], dtype=float) | ||
| y = np.asarray([point.value for point in numeric], dtype=float) | ||
| candidates = { | ||
|
|
@@ -403,20 +443,16 @@ def _correlated_hotspots( | |
| int | None, | ||
| str, | ||
| str, | ||
| Literal["integer", "floating"], | ||
| float, | ||
| ], | ||
| float, | ||
| ] = {} | ||
| for row in rows: | ||
| input_value = ( | ||
| float(cast(Any, row[2])) | ||
| if row[2] is not None | ||
| else float(cast(Any, row[3])) | ||
| if row[3] is not None | ||
| else None | ||
| ) | ||
| input_value, input_kind = self._input_identity(row[2], row[3]) | ||
| if input_value is None or not math.isfinite(input_value): | ||
| continue | ||
| assert input_kind is not None | ||
| key = ( | ||
| str(row[0]), | ||
| str(row[1]), | ||
|
|
@@ -426,6 +462,7 @@ def _correlated_hotspots( | |
| int(cast(Any, row[7])) if row[7] is not None else None, | ||
| str(row[8]), | ||
| str(row[9]), | ||
| input_kind, | ||
| input_value, | ||
| ) | ||
| per_trial[key] = per_trial.get(key, 0.0) + float(cast(Any, row[10])) | ||
|
|
@@ -442,6 +479,7 @@ def _correlated_hotspots( | |
| line, | ||
| metric, | ||
| unit, | ||
| _input_kind, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a scaling experiment mixes integer and floating inputs, AGENTS.md reference: AGENTS.md:L46-L49 Useful? React with 👍 / 👎. |
||
| input_value, | ||
| ), value in per_trial.items(): | ||
| groups.setdefault( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.