Repository navigation
test(tier3): time the masking linearity check on equal work - #717
Merged
Merged
Conversation
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>
chrisknvidia
requested review from
mosheabr,
rmalani-nv and
rng1995
as code owners
November 17, 2026 02:39
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 with0.911 < 16 * 0.052 + 0.05while the other 36,501 tests passed, and passed again on the neighbouring runs ofmain.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 autothe 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_secondshelper: the large text masked whole is timed against the same text masked inlarge // smallpieces, 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_linearlykeeps its margin aswhole < 1.6 * in_pieces + 0.05, which is the old16 * smallbound 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(aread.countper 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 failsmarkersandmarkers-and-escaped-quotes.test_the_linear_growth_bound_rejects_reading_each_run_againstill 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 lintclean.I am familiar with the Contributing Guidelines
Added or updated focused tests
Updated documentation for user-visible changes (none)
Ran
make lintRan
make testfor the changed fileRan
make build(test-only change)Did not add credentials, private datasets, or proprietary benchmark content
Release Impact
CHANGELOG.md