Skip to content

test: add env-no-coreai and requires_coreai marker - #181

Open
dengqiaoyu wants to merge 1 commit into
apple:mainfrom
dengqiaoyu:u/qiaoyu_deng/make-coreai-deps-optional
Open

dengqiaoyu wants to merge 1 commit into
apple:mainfrom
dengqiaoyu:u/qiaoyu_deng/make-coreai-deps-optional

Conversation

@dengqiaoyu

Copy link
Copy Markdown
Contributor
  • Add make env-no-coreai, which sets up the default env without the coreai extra, and a linux-tests-no-coreai CI job that runs make env-no-coreai test
  • Add the requires_coreai marker in tests/config/plugin.py; marked tests skip at collection when coreai is not installed, while test files that import coreai at the top use pytest.importorskip("coreai")
  • Reword the Core AI export ImportError to name the coreai extra and ExportBackend.Torch


import pytest

pytest.importorskip("coreai")

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.

Why do we skip here?

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.

coreai_utils loads coreai at import time, so nothing in tests/coreai_utils/ can be imported without it. Adding it to the conftest of coreai_utils skips the entire directory.

Comment thread tests/export/conftest.py

import pytest

pytest.importorskip("coreai")

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.

Same -- Why do we skip here?

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.

Same as the reply above: almost all the tests under this directory need coreai packages. There are some tests that only need CoreML, but making them more fine-grained adds additional complexity; therefore, I just skip the entire directory. Export tests should only be run in the full venv with coreai.

- Add `make env-no-coreai`, which sets up the default env without the `coreai` extra, and a `linux-tests-no-coreai` CI job that runs `make env-no-coreai test`
- Add the `requires_coreai` marker in `tests/config/plugin.py`; marked tests skip at collection when coreai is not installed, while test files that import coreai at the top use `pytest.importorskip("coreai")`
- Reword the Core AI export `ImportError` to name the `coreai` extra and `ExportBackend.Torch`
error_message = (
"coreai-torch package is required for MLIR export. "
"Install it with: pip install coreai-torch"
"Core AI export needs the optional coreai and coreai-torch packages; install them "

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.

Should we also add a "requires CoreML" flag as well and change the venv to "make-env-no-coreai-no-coreml" (maybe not that long of a name but you get the point 😄 )

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.

That's a long name. I wonder if we should switch to something like "make env-basic" or "make env-core", and then the flag would become "require_extra_env". But this is not as intuitive as "make env-no-coreai" or "require_coreai".

from coreai_opt.quantization.spec.qparams_calculator import StaticQParamsCalculator
from coreai_opt.quantization.spec.range_calculator import MinMaxRangeCalculator

# torch.compile raises on a Python that torch doesn't support yet.

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.

Why is this a part of this PR?

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 2.14 currently doesn't support python 3.15 for torch.compile, see the its source code:

def check_if_dynamo_supported() -> None:
    if sys.version_info >= (3, 15):
        raise RuntimeError("Python 3.15+ not yet supported for torch.compile")
    elif sysconfig.get_config_var("Py_GIL_DISABLED") == 1 and sys.version_info < (
        3,
        13,
        3,
    ):
        raise RuntimeError(
            "torch.compile is not supported on Python < 3.13.3 built with GIL disabled. "
            "Please use Python 3.13.3+."
        )

@dengqiaoyu
dengqiaoyu force-pushed the u/qiaoyu_deng/make-coreai-deps-optional branch from f7d666e to 305ad79 Compare November 5, 2026 00:21

This branch has not been deployed

No deployments
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.

2 participants