Skip to content

Arm backend: Seed tests before collection#20183

Merged
zingo merged 1 commit into
pytorch:mainfrom
zingo:Arm-backend-Seed-tests-before-collection
Jun 11, 2026
Merged

Arm backend: Seed tests before collection#20183
zingo merged 1 commit into
pytorch:mainfrom
zingo:Arm-backend-Seed-tests-before-collection

Conversation

@zingo

@zingo zingo commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Seed the Arm test RNG during pytest configuration so module-level random inputs are deterministic before test collection imports model test modules. Keep the per-test seeding fixture for reproducible test execution.

This will make tests behave less random and hopefully fix some flakeynes in testing/CI.

For example test_dl3_arm.py failes about 5% of the time before this fix due to it getting non seeded random numbers.

cc @digantdesai @freddan80 @per @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

Seed the Arm test RNG during pytest configuration so module-level
random inputs are deterministic before test collection imports model
test modules. Keep the per-test seeding fixture for reproducible test
execution.

This will make tests behave less random and hopefully fix some
flakeynes in testing/CI.

For example test_dl3_arm.py failes about 5% of the time before
this fix due to it getting non seeded random numbers.

Signed-off-by: Zingo Andersen <Zingo.Andersen@arm.com>
Change-Id: I7fa266477cfcb80e5e41bef075a6bf850a6d622a
Copilot AI review requested due to automatic review settings June 10, 2026 14:48
@zingo
zingo requested a review from digantdesai as a code owner June 10, 2026 14:48
@zingo zingo added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: arm Changes to the ARM backend delegate labels Jun 10, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20183

Note: Links to docs will display an error until the docs builds have been completed.

❌ 4 New Failures, 2 Unclassified Failures

As of commit 5c3e595 with merge base 10bc51e (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 10, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Seeds the Arm backend test RNG earlier in the pytest lifecycle (during pytest_configure) so that module-level random/Torch-generated inputs are deterministic during test module import/collection, while keeping the per-test autouse seeding for reproducible execution.

Changes:

  • Call the random seeding logic from pytest_configure to ensure deterministic behavior before test collection imports modules.
  • Refactor the existing autouse seeding fixture to delegate to a shared _set_random_seed() helper.
  • Adjust seed-printing to differentiate RANDOM vs fixed-seed output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 89 to +93
if seed_env == "RANDOM":
random.seed() # reset seed, in case any other test has fiddled with it
seed = random.randint(0, 2**32 - 1) # nosec B311 - non-crypto seed for tests
torch.manual_seed(seed)
print(f" ARM_TEST_SEED=RANDOM using:{seed} ", end=" ")
@zingo
zingo force-pushed the Arm-backend-Seed-tests-before-collection branch from 0ab0ddc to 5c3e595 Compare June 11, 2026 06:50
Copilot AI review requested due to automatic review settings June 11, 2026 06:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines 89 to +93
if seed_env == "RANDOM":
random.seed() # reset seed, in case any other test has fiddled with it
seed = random.randint(0, 2**32 - 1) # nosec B311 - non-crypto seed for tests
torch.manual_seed(seed)
print(f" ARM_TEST_SEED=RANDOM using:{seed} ", end=" ")
@zingo
zingo merged commit 6795a41 into pytorch:main Jun 11, 2026
954 of 974 checks passed
@zingo
zingo deleted the Arm-backend-Seed-tests-before-collection branch June 15, 2026 12:29
@Gasoonjia Gasoonjia mentioned this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants