-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[https://nvbugs/6506920][fix] Add stderr, stderr_margin_sigmas fields to HypothesisTestingParams…
#16858
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
[https://nvbugs/6506920][fix] Add stderr, stderr_margin_sigmas fields to HypothesisTestingParams…
#16858
Changes from all commits
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 |
|---|---|---|
|
|
@@ -69,6 +69,9 @@ def compute_threshold(num_samples: int, | |
| return ref_accuracy - z_alpha * scale | ||
|
|
||
|
|
||
| STDERR_MARGIN_SIGMAS = 2.0 | ||
|
|
||
|
|
||
| @dataclass(slots=True) | ||
| class HypothesisTestingParams: | ||
| ref_accuracy: float | ||
|
|
@@ -78,10 +81,19 @@ class HypothesisTestingParams: | |
| beta: float = 0.2 | ||
| sigma: float = 50.0 | ||
| higher_is_better: bool = True | ||
| # lm-eval-style per-metric stderr. When set, ref_accuracy is treated as an | ||
| # anchor and the strict floor is offset by STDERR_MARGIN_SIGMAS * stderr so | ||
| # single-run noise does not trip the outer assertion (nvbugs/6506920). | ||
| stderr: Optional[float] = None | ||
| ref_accuracy_anchor: float = field(init=False) | ||
| theta: float = field(init=False) | ||
| threshold: float = field(init=False) | ||
|
|
||
| def __post_init__(self) -> None: | ||
| self.ref_accuracy_anchor = self.ref_accuracy | ||
| if self.stderr is not None and self.stderr > 0: | ||
| sign = -1 if self.higher_is_better else 1 | ||
| self.ref_accuracy += sign * STDERR_MARGIN_SIGMAS * self.stderr | ||
|
Comment on lines
+87
to
+96
Contributor
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Reject invalid Negative or NaN values fail the 🤖 Prompt for AI Agents |
||
| self.theta = compute_theta(self.num_samples, | ||
| sigma=self.sigma, | ||
| alpha=self.alpha, | ||
|
|
@@ -95,6 +107,13 @@ def __post_init__(self) -> None: | |
|
|
||
| def report(self, accuracy: Optional[float] = None) -> str: | ||
| metric_name = self.metric_name.upper() | ||
| if self.stderr is not None and self.stderr > 0: | ||
| stderr_line = ( | ||
| f"\nAnchor {self.metric_name}: {self.ref_accuracy_anchor:.3f}" | ||
| f" (adjusted by {STDERR_MARGIN_SIGMAS:.1f}sigma * stderr={self.stderr:.3f})" | ||
| ) | ||
| else: | ||
| stderr_line = "" | ||
| report = f"""=========================================================== | ||
| = {metric_name} HYPOTHESIS TESTING | ||
| =========================================================== | ||
|
|
@@ -104,7 +123,7 @@ def report(self, accuracy: Optional[float] = None) -> str: | |
| #Samples: {self.num_samples} | ||
| Higher is better: {self.higher_is_better} | ||
| Theta (Minimum detectable effect): {self.theta:.3f} | ||
| Reference {self.metric_name}: {self.ref_accuracy:.3f} | ||
| Reference {self.metric_name}: {self.ref_accuracy:.3f}{stderr_line} | ||
| Threshold: {self.threshold:.3f} | ||
| ===========================================================""" | ||
| if accuracy is not None: | ||
|
|
@@ -190,7 +209,8 @@ def get_hypothesis_testing_params(self, | |
| sigma=entry.get("sigma", self.SIGMA), | ||
| num_samples=entry.get("num_samples", self.NUM_SAMPLES), | ||
| higher_is_better=entry.get("higher_is_better", | ||
| self.HIGHER_IS_BETTER)) | ||
| self.HIGHER_IS_BETTER), | ||
| stderr=entry.get("stderr")) | ||
|
|
||
| def evaluate(self, | ||
| llm: Union[PyTorchLLM, AutoDeployLLM], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Implement the advertised
stderr_margin_sigmasparameter.The PR contract describes
stderr_margin_sigmasas configurable, but this class only exposes the hard-codedSTDERR_MARGIN_SIGMAS = 2.0; reference entries cannot select another margin.Suggested fix
class HypothesisTestingParams: stderr: Optional[float] = None + stderr_margin_sigmas: float = STDERR_MARGIN_SIGMAS def __post_init__(self) -> None: self.ref_accuracy_anchor = self.ref_accuracy if self.stderr is not None and self.stderr > 0: sign = -1 if self.higher_is_better else 1 - self.ref_accuracy += sign * STDERR_MARGIN_SIGMAS * self.stderr + self.ref_accuracy += sign * self.stderr_margin_sigmas * self.stderrAlso forward
entry.get("stderr_margin_sigmas", STDERR_MARGIN_SIGMAS)fromget_hypothesis_testing_params().Based on the PR objectives,
stderr_margin_sigmasis part of the intendedHypothesisTestingParamsAPI.Also applies to: 84-96, 204-213
🤖 Prompt for AI Agents