Skip to content

fix(utils): resolve test model paths lazily - #1568

Open
EazyReal wants to merge 1 commit into
areal-project:mainfrom
EazyReal:fix/lazy-testing-model-paths
Open

fix(utils): resolve test model paths lazily#1568
EazyReal wants to merge 1 commit into
areal-project:mainfrom
EazyReal:fix/lazy-testing-model-paths

Conversation

@EazyReal

@EazyReal EazyReal commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

Importing tests.utils imports areal.utils.testing_utils, whose module-level model registries previously resolved every configured path immediately. On machines without the shared model directory, importing or collecting a CPU test could therefore call snapshot_download for unrelated dense and 30–35B MoE fixtures before pytest evaluated GPU and slow-test skips.

Keep the existing read-only mapping interface while resolving and caching only requested model keys. VLM parameterization now passes the mapping and key to an indirect fixture, so model resolution happens only after pytest skip evaluation.

Related Issue

No existing issue found. This is a narrow import-side-effect regression with executable coverage included here.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • ♻️ Refactoring
  • ⚡ Performance improvement
  • ✅ Test coverage improvement

Verification

  • HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 python -m pytest -q tests/test_testing_utils.py tests/experimental/openai/test_concat_prompt.py — 10 passed
  • Empty-cache offline collection of tests/test_megatron_engine_vlm_distributed.py — 14 tests collected with no cache writes
  • Empty-cache offline CPU execution of the VLM module — 14 tests skipped with no cache writes
  • pre-commit run --all-files — passed

GPU and distributed VLM execution were not run because the test machine has no GPU. The affected invariant is import and collection behavior before those tests execute.

Checklist

  • I have read the Contributing Guide
  • Pre-commit hooks pass (pre-commit run --all-files)
  • Relevant tests pass; new tests added for new functionality
  • Documentation updated (not applicable)
  • Branch is up to date with main
  • Self-reviewed via the repository review workflow
  • This PR was created by a coding agent via the repository PR workflow
  • This PR is a breaking change

Breaking Change Details (if applicable):

None.

Additional Context

The dense, MoE, and combined registries retain their existing key lookup behavior for __getitem__ and iteration. Iteration and length inspection remain download-free; the first lookup of a key resolves it once and caches the result. Because Mapping.get() is implemented in terms of __getitem__, calling .get() on these registries now also triggers lazy resolution (and a possible download) on first access, rather than returning an already-resolved value the way it did when these were plain dicts.

Importing shared testing utilities should not download every configured
model before pytest can apply GPU and slow-test skips. Preserve the
registry mapping interface while resolving and caching only requested
keys.

Key changes:
- replace eager model path registries with lazy mappings
- defer VLM model lookup to fixture setup after skip evaluation
- cover offline import, collection, and per-key caching behavior
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@EazyReal

Copy link
Copy Markdown
Contributor Author

This fixes an eager-resolution bug in areal/utils/testing_utils.py: importing the test model-path registries calls snapshot_download for every configured fixture, including three 30-35B MoE models, before pytest can apply GPU/slow skips — and that eager resolution is still present verbatim on current main. The PR is mergeable, no review threads are open, and it ships a dedicated regression test (tests/test_testing_utils.py) with green CI. @sitabulaixizawaluduo could you review when you have a chance?

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.

1 participant