Skip to content

PE-US rebuild CLI import requires torch through microplex top-level import even when neural synthesis is unused #146

@anth-volk

Description

@anth-volk

Follow-up from the local PE-US rebuild smoke setup on macOS x86_64.

After the install blocker in #145, I tried a smoke-only workaround:

uv sync --extra policyengine --no-install-package torch
uv run --no-sync python -m microplex_us.pipelines.pe_us_data_rebuild_checkpoint --help

Running the help check outside the sandbox avoids the earlier Arrow/sklearn import stall, but the CLI still cannot import because microplex_us.__init__ imports microplex, and microplex.__init__ eagerly imports microplex.discrete, which imports torch:

Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "/Users/administrator/Documents/PolicyEngine/microplex-us/src/microplex_us/__init__.py", line 8, in <module>
    from microplex.targets import TargetSet, TargetSpec
  File "/Users/administrator/Documents/PolicyEngine/microplex-us/.venv/lib/python3.14/site-packages/microplex/__init__.py", line 63, in <module>
    from microplex.discrete import (
    ...<3 lines>...
    )
  File "/Users/administrator/Documents/PolicyEngine/microplex-us/.venv/lib/python3.14/site-packages/microplex/discrete.py", line 8, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

This means a canonical PE-US rebuild path that does not use neural synthesis still needs a working torch install just to expose the run module. On Intel macOS, #145 blocks the normal install because the locked torch==2.11.0 has no compatible wheel.

Likely fix belongs in core microplex: avoid eager top-level imports of torch-backed neural/discrete synthesis surfaces, or make the torch import lazy/optional so target/spec/calibration users can import without torch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions