Skip to content

test(tier3): time the masking linearity check on equal work - #717

Merged
chrisknvidia merged 2 commits into
mainfrom
test/deflake-masking-linearity
Nov 17, 2026
Merged

chrisknvidia merged 2 commits into
mainfrom
test/deflake-masking-linearity

Conversation

@chrisknvidia

@chrisknvidia chrisknvidia commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

test_masking_escaped_again_stays_linear_on_adversarial_input[markers-and-escaped-quotes] failed on the Python 3.14 job of #690's CI run with 0.911 < 16 * 0.052 + 0.05 while the other 36,501 tests passed, and passed again on the neighbouring runs of main.

The test timed one 25k-character mask against one 250k-character mask (thread CPU time, fastest of three) and bounded the ratio at 16x. Under pytest -n auto the workers share the runner's cores, so a 50 ms reading often finds an idle moment that a 900 ms one never does: the ratio grows with the load, not with the text. Locally every parametrised unit sits at 10.0x.

This changes the measurement in the shared _masking_seconds helper: the large text masked whole is timed against the same text masked in large // small pieces, each side as one block of CPU time, fastest of three, interleaved. Both sides now do the same work, so runner load slows them alike, while a step quadratic in the text still takes about twice as long whole. _grows_linearly keeps its margin as whole < 1.6 * in_pieces + 0.05, which is the old 16 * small bound expressed on equal work. The two other tests that use the helper measure the same way, and their assertions now report the two timings on failure.

Test-only change; no CHANGELOG entry.

Verification

  • pytest tests/tier3/test_security_finding_evidence.py: 1121 passed, plain and with two more pytest processes plus eight memory-bandwidth hogs running alongside (wall time 4x slower, no failures). Whole/pieces measured 0.97–1.01 for the failing unit.

  • With a quadratic step injected into _masked_spans (a read.count per kept piece), the named test fails on every marker-bearing unit at a ratio of about 5; injecting it on only every sixth piece, which roughly doubles the whole-text time, still fails markers and markers-and-escaped-quotes.

  • test_the_linear_growth_bound_rejects_reading_each_run_again still passes both ways (linear accepted, the patched quadratic reading rejected).

  • The 28 linearity tests take about 36 s locally instead of 21 s, since the pieces side now does as much work as the whole.

  • make lint clean.

  • I am familiar with the Contributing Guidelines

  • Added or updated focused tests

  • Updated documentation for user-visible changes (none)

  • Ran make lint

  • Ran make test for the changed file

  • Ran make build (test-only change)

  • Did not add credentials, private datasets, or proprietary benchmark content

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Devin Review

The adversarial-input linearity tests timed one 25k-character mask
against one 250k-character mask and bounded the ratio. Under
`pytest -n auto` the workers share the runner's cores, so a 50 ms
reading often finds an idle moment that a 900 ms one never does, and
the ratio grows with the load rather than with the text: on Python
3.14 the markers-and-escaped-quotes case measured 17.6x against the
16x bound while every unit is at 10.0x locally.

Time the large text masked whole against the same text masked in
pieces, each side as one block of CPU time, fastest of three. Both
sides do the same work, so load slows them alike, while a step
quadratic in the text still takes about twice as long whole. The
bound keeps its margin: whole < 1.6 * in_pieces + 0.05. The two
other tests that share the helper measure the same way.

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
devin-ai-integration[bot]

This comment was marked as resolved.

The judge evidence linearity test imports _masking_seconds, which now
returns the time to mask the text in ten pieces and the time to mask it
whole. The judge test still applied the old 16 * small + 0.05 bound to
that pair. Linear masking now gives a ratio near 1 and quadratic masking
a ratio near 10, so the old bound accepted quadratic growth.

Use the shared _grows_linearly bound (1.6 * in_pieces + 0.05), which is
the old 16x bound scaled to the new measurement, and add a test of that
bound on a simulated clock that tells linear from quadratic masking.

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@chrisknvidia
chrisknvidia merged commit d2cb138 into main Nov 17, 2026
23 checks passed
@chrisknvidia
chrisknvidia deleted the test/deflake-masking-linearity branch November 17, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant