Skip to content

fix: make auto_docstring import-time performance test robust to timing noise. - #48149

Open
deepresearcher08 wants to merge 3 commits into
huggingface:mainfrom
deepresearcher08:fix/flaky-auto-docstring-import-time-test
Open

fix: make auto_docstring import-time performance test robust to timing noise.#48149
deepresearcher08 wants to merge 3 commits into
huggingface:mainfrom
deepresearcher08:fix/flaky-auto-docstring-import-time-test

Conversation

@deepresearcher08

@deepresearcher08 deepresearcher08 commented Aug 20, 2026

Copy link
Copy Markdown

CI

What does this PR do?

-tests/utils/test_auto_docstring.py

  • Switched from time.perf_counter() to time.process_time() to prevent inflation of measurement from the co-tenant scheduling noise.
  • Use min() over 10 iterations instead of median() over 5, the minimum is the sample least contaminated by unrelated system activity.
  • Replace the percentage-of-import-time ratio with an absolute per-module CPU budget (100 ms/module), so filesystem/bytecode-cache I/O in the denominator leaves the metric entirely and the bound is portable across hardware.
  • Removed the now-unused statistics import.

For validation, I ran the test 8x locally (Python 3.11, torch CPU, pytest): per-module auto_docstring cost measured 5.3-6.7 ms against the 100 ms budget, giving ~15-20x headroom with a spread under 1.5 ms (vs the old ratio's ~15-point spread). Full test files collect cleanly (9 tests).

Fixes #48145

Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. These often are low-quality, or fix extremely minor issues that occur rarely or never in practice.
As a result, we're instituting a rule that first-time contributors should not use code agents to submit PRs or issues.
We'd also ask autonomous "OpenClaw"-like agents not to open any PRs or issues.

Issues/PRs from first-time contributors that violate this rule will probably just be closed without review, and we
might block you, especially if you open more than one or appear to be deliberately ignoring this. We especially do not
want new contributors to jump in on random issues to contribute an agent-written fix. This creates lots of noise
for reviewers and other users and will almost certainly get you blocked.

For more information, please read CONTRIBUTING.md.

  • (First-time contributors only): I confirm that this PR description and code is not written by an LLM or code agent

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline and the
    Pull Request checks?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case. Link to issue
  • Did you make sure to update the documentation with your changes according to the guidelines?
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@deepresearcher08
deepresearcher08 force-pushed the fix/flaky-auto-docstring-import-time-test branch from 2c2daec to 46b8b2c Compare August 21, 2026 12:39
@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 32479139741:2
Result: success | Jobs: 3 | Tests: 33 | Failures: 0 | Duration: 2m 19s

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.

Flaky: test_auto_docstring_import_time_upper_bound asserts a timing ratio whose noise exceeds its margin

2 participants