Skip to content

[PT FE] Fix timm model filter selecting huge models, update timm to 1.0.30, support aten.meshgrid in FX - #38443

Merged
mvafin merged 25 commits into
openvinotoolkit:masterfrom
mvafin:pt-fe-timm-models-fix
Oct 1, 2026
Merged

mvafin merged 25 commits into
openvinotoolkit:masterfrom
mvafin:pt-fe-timm-models-fix

Conversation

@mvafin

@mvafin mvafin commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Details:

  • Nightly Scope1 has been crashing with runner OOM since [PT FE] Update timm models #33706. filter_timm sorted size tokens alphabetically (enormous < giant < ... < small) and didn't recognize 7b/so400m, so it picked the largest variants (e.g. vit_7b_dinov3, 26.9 GB). Several of these were loaded at the same time under -n 4.
  • filter_timm now keeps the smallest variant of each architecture. Size tokens are ordered by size, parameter counts and bare t/h sizes are recognized, and width-multiplier variants (resnetv2_50x3, resnext101_32x8d) are folded into their base architecture (they use the same ops).
  • timm updated to 1.0.30. timm_models is regenerated: 517 models, down from 532. The largest model is now 4.05 GB, and total weights drop from ~248 GB to ~108 GB. New failing models are marked xfail: iformer_* (numpy<2 load error) and gemma4_vit_167m* in export mode.
  • aten::meshgrid is now converted during translation for both TorchScript and FX. PrimListUnpackReplacer is still the fallback when the input list is unknown at that point. This fixes export mode for 9 new timm models and meshgrid outputs used directly by stack/cat/[i].
  • Nightly Scope2 fails because DunnBC22/efficientformer-l3-300-Brain_Tumors_Image_Classification was removed from HF Hub. That failure also skips the LLM, Detectron2 and Torchbench steps. The model is replaced with snap-research/efficientformer-l1-300.
  • LLM nightly test qwen3_compressed_tensors (cyankiwi/Qwen3.5-4B-AWQ-4bit, a multimodal checkpoint) is marked xfail. With the pinned transformers 5.5.3, AutoModelForCausalLM drops its quantization_config (fixed in 5.8, Fix: propagate quantization_config to text sub-config for composite models in AutoModelForCausalLM huggingface/transformers#45494). Newer versions still don't match the checkpoint's ignore list to the text-only module names, so linear_attn.in_proj_a/b are initialized randomly.
  • Torchbench: all models failed in install.py, which requires torchaudio. torchaudio was dropped from the requirements in [PT FE] Upgrade tests to torch 2.12 #36098 and doesn't support torch 2.14. The test removes torchaudio from torchbench's TORCH_DEPS, pins setuptools<81 for sdist builds (visdom needs pkg_resources), and sets PIP_USE_PEP517=1. With pip 24, legacy setup.py packages are built in the test venv, where the egg_info hook of kernels (installed for LLM tests) crashes against the older huggingface_hub installed by torchbench. The maml models' inputs, pickled with numpy<2, now load with numpy 2.
  • Scope1 failures that existed before this PR:
    • convit_tiny (trace): the model fills a cache on its first forward, so the test runs one warm-up forward first.
    • torchvision segmentation models (export): FX model outputs are now named after their dict keys, which for ExportedProgram are taken from out_spec. A key is skipped if it's ambiguous (one tensor under several keys, or the same key in several nested dicts) or matches the name of another graph node or input.
    • efficientvit_b0 (export): fixed by [PyTorch] Support exported grad-mode and autocast regions without decompositions #38396, now passes.
  • Documented how to run model hub tests with a model cache.
  • The nightly PyTorch Models Nightly Scope1/Scope2 tests jobs in ubuntu_22.yml now also run for PRs that change tests/model_hub_tests/pytorch, tests/model_hub_tests/models_hub_common or job_pytorch_models_tests.yml. The Smart_CI job checks the PR's changed files with git diff on the merge commit, without extra API calls. The jobs also run on manual dispatch with the new pytorch-models-nightly input. They use the same runner and settings as the nightly, and aren't part of Overall_Status, so a failure doesn't block merge. This PR runs them itself. Moved from [CI] Run nightly PyTorch model hub scopes on related PRs and on dispatch #38457.

Tickets:

  • N/A

AI Assistance:

  • AI assistance used: yes
  • AI analyzed the CI logs, implemented the changes and ran local validation (torch 2.14.0+cpu, timm 1.0.30):
    • New timm models and the timm models that use meshgrid: pass or xfail in trace and export mode.
    • test_models_list_complete: passes.
    • Full layer suites: 0 failures, with TorchScript (16533 passed) and with export (12969 passed, including the new dict output name tests).
    • Torchbench, convit, efficientvit and torchvision segmentation models: pass.
    • New efficientformer HF test: passes.

@mvafin
mvafin requested review from a team as code owners September 28, 2026 11:11
@mvafin
mvafin requested review from ValentinaKats, mmikolajcz and rkazants and removed request for a team September 28, 2026 11:11
@github-actions github-actions Bot added category: CI OpenVINO public CI category: docs OpenVINO documentation category: PyTorch FE OpenVINO PyTorch Frontend labels Sep 28, 2026
….meshgrid in FX

- Fix filter_timm size ordering (was alphabetical) and recognize parameter-count
  (7b, so400m), width-multiplier (50x3, 32x8d) and f/e size tokens, so the
  smallest variant of each architecture is selected. This removes multi-GB
  models that made the nightly runner run out of memory.
- Update timm to 1.0.30 and regenerate timm_models.
- Add FX translator for aten.meshgrid and enable meshgrid layer tests in export mode.
- Document how to run model hub tests and reuse the model cache.

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 review overview

🟡 Changes recommended

The filter still retains large one-letter iFormer size variants instead of selecting only the smallest model.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Reduces PyTorch timm nightly memory usage, updates timm, and adds FX support for aten.meshgrid.

Changes:

  • Improves timm model filtering and regenerates the model scope.
  • Adds shared meshgrid conversion with TorchScript/FX tests.
  • Documents model-hub testing and caching.
File Description
tests/​model_hub_tests/​pytorch/​timm_models Regenerates the timm model scope.
tests/​model_hub_tests/​pytorch/​test_timm.py Improves model-size filtering.
tests/​model_hub_tests/​pytorch/​envs/​timm.txt Updates timm to 1.0.30.
tests/​layer_tests/​pytorch_tests/​test_listunpack.py Adds FX meshgrid coverage.
src/​frontends/​pytorch/​src/​utils.hpp Declares shared meshgrid builder.
src/​frontends/​pytorch/​src/​utils.cpp Implements meshgrid decomposition.
src/​frontends/​pytorch/​src/​transforms/​prim_list_unpack_replacer.cpp Reuses shared decomposition.
src/​frontends/​pytorch/​src/​op/​meshgrid.cpp Converts known lists and supports FX.
src/​frontends/​pytorch/​src/​op_table.cpp Registers FX meshgrid overloads.
src/​frontends/​pytorch/​README.md Documents model-hub testing.
.github/​agents-prototype/​skills/​conversion-issues/​pytorch.md Links model-hub guidance.
.claude/​skills/​ov-update-pytorch-version/​SKILL.md Adds model-test and cache instructions.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Use one translator for TorchScript and FX. When the input list is known at
conversion, decompose meshgrid directly and return a list, otherwise keep
deferring to PrimListUnpackReplacer. Share the decomposition in build_meshgrid.
@mvafin
mvafin requested a review from evkotov September 28, 2026 12:58
Recognize t and h as size tokens when the name has no other size token, so
iformer_h/iformer_s fold into iformer_t and efficientnetv2_rw_s into
efficientnetv2_rw_t, while efficientnet_h_b5 and regnetz_040_h keep h as a
variant marker.

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 review overview

🔵 Needs a closer look

The large generated model-scope update and cross-path frontend conversion warrant final human validation.

Review effort: Balanced
Findings: None

Resolved since last review (1)

DunnBC22/efficientformer-l3-300-Brain_Tumors_Image_Classification was removed
from HF Hub, which fails the nightly scope2 HF Transformers step and skips the
LLM, Detectron2 and Torchbench steps after it. Use the original
snap-research/efficientformer-l1-300 checkpoint instead.
@mvafin
mvafin requested a review from a team as a code owner September 29, 2026 09:54
@github-actions github-actions Bot added the github_actions Pull requests that update GitHub Actions code label Sep 29, 2026
Nightly PyTorch Models Scope1/Scope2 jobs ran only on schedule. Also run them
for PRs that change PyTorch model hub tests (checked in the Smart_CI job) and
on workflow_dispatch with the pytorch-models-nightly input.
cyankiwi/Qwen3.5-4B-AWQ-4bit is a multimodal checkpoint. AutoModelForCausalLM
loads it with text_config, which has no quantization_config, so the model is
loaded unquantized and patch_quantized fails with 'Unknown quantization type: None'.
The multimodal checkpoint can't be loaded correctly via AutoModelForCausalLM:
transformers<5.8 drops its quantization_config, and newer versions still
don't match its ignore list to the text-only module names.

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 review overview

🔵 Needs a closer look

The combined frontend conversion, remote-model matrix, and nightly CI changes warrant final human review.

Review effort: Balanced
Findings: None

@mvafin
mvafin requested a review from a team as a code owner September 29, 2026 16:01
@github-actions github-actions Bot added the category: Python API OpenVINO Python bindings label Sep 29, 2026
@mryzhov
mryzhov requested a balanced review from Copilot September 30, 2026 08:04
@mvafin
mvafin requested a review from mryzhov September 30, 2026 08:05

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 High severity · 3 Medium severity

Open (5)

Comment thread .github/workflows/ubuntu_22.yml Resolved
Comment thread .github/workflows/ubuntu_22.yml Resolved
NodeVector reshapes;
auto const_neg_1 = v0::Constant::create(element::i32, Shape{1}, {-1});
auto const_1 = v0::Constant::create(element::i32, Shape{1}, {1});
for (size_t i = 0; i < inputs.size(); ++i) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

torch.meshgrid itself rejects inputs with rank > 1, so a valid model can't reach this decomposition with such inputs. Keeping it as is.

Comment on lines +45 to +49
os.environ["PIP_BUILD_CONSTRAINT"] = build_constraints
os.environ["PIP_CONSTRAINT"] = build_constraints
# build legacy setup.py packages in isolation, so setuptools plugins from the test env
# (e.g. kernels egg_info writer) are not loaded
os.environ["PIP_USE_PEP517"] = "1"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Torchbench tests run in a separate pytest invocation, which is the last step of the job, so these variables don't affect other tests. Keeping it simple.

Comment thread .github/workflows/ubuntu_22.yml Resolved
@mvafin
mvafin added this pull request to the merge queue Oct 1, 2026
# parameter count, e.g. "300m", "7b", "so400m"
param_count_pattern = re.compile(r"^(?:so)?(\d+)([mb])$")
# depth/cardinality x width multiplier, e.g. "50x1", "152x4", "32x8d"
width_multiplier_pattern = re.compile(r"^(\d+)x(\d+)d?$")

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.

[nitpick] This is brittle. width_multiplier_pattern = r"^(\d+)x(\d+)d?$" would misclassify a hypothetical NxN resolution token (e.g. 224x224) as a large width multiplier and skew size ranking. No such tokens exist in the current timm name set and test_models_list_complete validates the regenerated list, so impact is limited to test selection.

with open(deps_file) as f:
deps = f.read()
with open(deps_file, "w") as f:
f.write(deps.replace('"torchvision", "torchaudio"]', '"torchvision"]'))

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.

[nitpick] This is brittle. deps.replace('"torchvision", "torchaudio"]', '"torchvision"]') is mostly acceptable thanks to pinning of the torchbench commit.

Merged via the queue into openvinotoolkit:master with commit 13c4856 Oct 1, 2026
220 checks passed
@mvafin
mvafin deleted the pt-fe-timm-models-fix branch October 1, 2026 14:15
@mvafin mvafin added this to the 2026.5 milestone Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: CI OpenVINO public CI category: docs OpenVINO documentation category: Python API OpenVINO Python bindings category: PyTorch FE OpenVINO PyTorch Frontend github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants