Skip to content

Fix the Samsung MobileBert test setup so it can run - #22550

Merged
shoumikhin merged 1 commit into
mainfrom
fix-samsung-mobilebert-finetune-test
Sep 4, 2026
Merged

Fix the Samsung MobileBert test setup so it can run#22550
shoumikhin merged 1 commit into
mainfrom
fix-samsung-mobilebert-finetune-test

Conversation

@shoumikhin

Copy link
Copy Markdown
Contributor

Summary

The Samsung model test job runs every test under backends/samsung/test/models. One of those tests, the MobileBert fine-tuning test, always errors out before it does any work:

ERROR: setUpClass (test_mobilebert_finetuning.Test_Milestone_MobileBertFinetune)
AttributeError: type object 'Test_Milestone_MobileBertFinetune' has no attribute 'model_cache_dir'

One error fails the whole job, so the other ten Samsung model tests passing does not help. The job only runs the tests when a Samsung device is available, which is why this looks like it comes and goes.

There were three separate problems stacked in the test setup, and each one was hidden behind the one before it:

  1. setUpClass read cls.model_cache_dir, which is not defined anywhere.
  2. It passed that value to patch_mobilebert_finetuning(), which takes no arguments. Python only checks the number of arguments when the call happens, so this could not be seen until the first problem was gone.
  3. The setup replaced load_tokenizer with a copy of itself that left out the model name, so AutoTokenizer.from_pretrained() had nothing to load.

The replacement tokenizer loader was the same as the real one except for the missing model name, so it could only ever do less than the real one. Removing the setup that installed it fixes all three problems at once and lets the test use the real loader. The test now has the same shape as the other ten tests in the same directory, which build a model and check it with no extra setup.

Test plan

Ran the real test collection and setup for this file before and after the change, with the heavy third party dependencies stubbed out so only the setup path was under test.

  • Before: reproduces the same AttributeError seen in CI, and never reaches the test body.
  • After: setup succeeds and the test body is reached.

Also checked that model_cache_dir, setUpClass and the now unused AutoTokenizer import are all gone, and that the file still compiles.

Copilot AI lite review requested due to automatic review settings September 4, 2026 04:12
@pytorch-bot

pytorch-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

As of commit 186f38a with merge base c65b23a (image):
💚 Looks good so far! There are no failures yet. 💚

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 Sep 4, 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The Samsung model test job runs every test under
backends/samsung/test/models. One of those tests, the MobileBert
fine-tuning test, always errors out before it does any work:

  ERROR: setUpClass (test_mobilebert_finetuning.Test_Milestone_MobileBertFinetune)
  AttributeError: type object 'Test_Milestone_MobileBertFinetune'
  has no attribute 'model_cache_dir'

That single error fails the whole job, which in turn holds back the
branch of known-good commits, so the other ten Samsung model tests
passing does not help.

There were three separate problems stacked in the test setup, and each
one was hidden behind the one before it:

1. setUpClass read cls.model_cache_dir, which is not defined anywhere.
2. It passed that value to patch_mobilebert_finetuning(), which takes no
   arguments. Python only checks this when the call happens, so it could
   not be seen until the first problem was gone.
3. The setup replaced load_tokenizer with a copy of itself that left out
   the model name, so AutoTokenizer.from_pretrained() had nothing to
   load.

The replacement tokenizer loader was the same as the real one except for
the missing model name, so it could only ever do less. Removing the
setup that installed it fixes all three problems at once and lets the
test use the real loader. The test now looks like the other ten tests in
the same directory, which build a model and check it with no extra
setup.

Test plan:
Ran the test collection and setup for the file before and after the
change with the heavy dependencies stubbed out. Before, it reproduces
the same AttributeError seen in CI and never reaches the test body.
After, setup succeeds and the test body is reached. Checked that
model_cache_dir, setUpClass and the unused AutoTokenizer import are all
gone, and that the file still compiles.
@shoumikhin
shoumikhin force-pushed the fix-samsung-mobilebert-finetune-test branch from 8b3027f to 186f38a Compare September 4, 2026 04:19
Copilot AI review requested due to automatic review settings September 4, 2026 04:19

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kirklandsign

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown

Claude finished @kirklandsign's task in 48s —— View job


Code Review — PR #22550

  • Read PR diff and changed file
  • Verify claims against the source (MobileBertFinetune)
  • Compare against sibling tests
  • Post review feedback

Verdict: LGTM. The change is correct, well-scoped, and the reasoning in the PR description holds up against the source.

What I checked

  1. cls.model_cache_dir was genuinely undefined. The removed setUpClass read cls.model_cache_dir, which is never set on the class or any base beyond unittest.TestCase — confirmed the AttributeError in CI is real and unavoidable.

  2. The arity bug is real. patch_mobilebert_finetuning() takes no parameters but was called as patch_mobilebert_finetuning(cls.model_cache_dir). As noted, this is only reachable once the attribute error is gone, so it was correctly identified as a stacked/hidden failure.

  3. The monkeypatch was strictly worse than the real loader. Comparing the removed _monkeypatch_load_tokenizer against the real method in examples/samsung/scripts/mobilebert_finetune.py:33-37:

    # removed patch — no model name
    AutoTokenizer.from_pretrained(do_lower_case=True)
    # real loader
    AutoTokenizer.from_pretrained("google/mobilebert-uncased", do_lower_case=True)

    The patch dropped the "google/mobilebert-uncased" positional arg, so from_pretrained had no model to load. Deleting the patch restores the real loader, which is the correct one. Good call removing it rather than "fixing" it to just re-add the model name — the patch had no remaining purpose.

  4. The remaining test matches its siblings. After the change, test_mobilebert_finetuning.py has the same build-model → SamsungTester → export/lower/compare shape as the other 10 tests in backends/samsung/test/models/ (e.g. test_mobilenet_v2.py), with no bespoke setup.

  5. Imports are clean. The now-unused from transformers import AutoTokenizer import was removed along with the patch; the remaining imports are all still used, and there's no leftover reference to _old_func / tearDownClass.

Minor observations (non-blocking, no change requested)

  • The kept test body calls get_finetune_mobilebert(None), which will download google/mobilebert-uncased and the SST-2 TSVs and run 5 fine-tuning epochs over the network. That's a pre-existing property of the test (this PR doesn't change it), and it only runs when a Samsung device is present, so it's out of scope here. Worth being aware of that this test is heavyweight/network-dependent by design.

Nothing to fix. Clean deletion that unblocks the whole Samsung model test job.
· branch fix-samsung-mobilebert-finetune-test

@shoumikhin

Copy link
Copy Markdown
Contributor Author

@kirklandsign stamp?

@shoumikhin
shoumikhin merged commit 89e108c into main Sep 4, 2026
199 checks passed
@shoumikhin
shoumikhin deleted the fix-samsung-mobilebert-finetune-test branch September 4, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: exynos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants