Skip to content

Rename the Python package npu_lora to npu_train; keep npu_lora as a deprecated alias - #47

Open
gspark-etri wants to merge 1 commit into
mainfrom
refactor/46-npu-train-package
Open

gspark-etri wants to merge 1 commit into
mainfrom
refactor/46-npu-train-package

Conversation

@gspark-etri

@gspark-etri gspark-etri commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Background

The repository is ai-computing/npu-train and trains with LoRA, full fine-tuning and MoE, but the Python package was still npu_lora. People run python3 -m npu_lora.<module> ... on shared hosts right now (for example npu_lora.moe_bench2, a script copied into the package directory), and some hosts have an editable install made before the rename, so the old name must keep working (#46).

Changes

  • git mv npu_lora npu_train. The package uses relative imports, so the modules are unchanged apart from docstrings/usage lines; k8s.py now mounts the ConfigMap at /opt/npu-lora/npu_train and runs python3 -m npu_train.cli; the Helm job runs npu_train.cli.
  • pyproject.toml: distribution npu-train; packages npu_train* and npu_lora*; CLI npu-train added, npu-lora kept; airm workload npu-lora now points at npu_train.airm:train. Helm install.pip installs npu-train @ git+....
  • npu_lora/__init__.py is a compatibility shim:
    • emits DeprecationWarning on import;
    • installs a meta-path finder: npu_lora.X resolves to the same module object as npu_train.X (one copy of every class/global; __spec__ stays npu_train.X), and runpy gets the code from it, so python -m npu_lora.X runs npu_train.X as __main__;
    • a module that exists only under npu_lora/ (an untracked script left there on a host, e.g. moe_bench2.py) is still found there and can import npu_lora.* / relative names;
    • if npu_train is not importable (editable install made before the rename maps only npu_lora), it appends the sibling directory to sys.path;
    • top-level names (npu_lora.LoRATrainer, __version__) come from npu_train.
  • tests/test_compat.py (new, 4 tests, each in a fresh interpreter): import + warning + module identity; python -m npu_lora.cli --help and python -m npu_lora.compare --help; a script inside npu_lora/ run with -m; an old-style editable finder that maps only npu_lora.
  • Imports in tests, README (EN/KO), docs/, ai-rm.yaml comment, scripts/vendor-into-lmd-top.sh (copies npu_train/*.py, destination assets/npu-lora unchanged) and the STATUS goal line use npu_train.

Verification

  • Checks / tests run: full CPU suite in a clean venv with this branch installed (pip install -e .; the host's old npu-lora editable install excluded so entry-point metadata comes from this branch).
  • Commands: CUDA_VISIBLE_DEVICES= python -m pytest -q tests
  • CI (cpu-tests, Python 3.11, CPU torch): 38 passed (run 39713975072).
  • Results: 38 passed in 182 s (34 existing + 4 new in test_compat.py). Python 3.10.12, torch 2.10.0+cu128 (CPU only, no NPU/GPU used), transformers 5.1.0.
    • In the shared user environment (old npu-lora 0.1.0 editable install still registered) the same run gives 37 passed, 1 failed: test_airm.py::test_registry_loads_runner sees the stale entry point npu_lora.airm:train. That is the installed metadata, not the code; it goes away after reinstalling (see below). CI installs fresh.
    • Mutation check: removing the sys.path fallback fails test_old_editable_install_mapping_only_npu_lora; removing the __spec__ restore fails test_import_old_name_is_same_module_and_warns.
  • Also checked: npu-train --help, npu-lora --help, python -m npu_lora.cli --help from outside the repo in the venv; npu_train.k8s.build(...) emits npu_train.cli and the /opt/npu-lora/npu_train mount; scripts/vendor-into-lmd-top.sh <tmpdir> copies the 17 modules. helm template not run (helm not installed on this host).
  • Sensitive-data check (check_sensitive.py): clean, no new findings.

Compatibility and limits

  • Kept on purpose (other systems depend on them; renaming them is a separate change): CLI command npu-lora, ai-rm workload name npu-lora, Prometheus metrics npu_lora_*, npu_lora_meta.json, NPU_LORA_RNGD* env vars, cache dir ~/.cache/npu-lora, Helm chart name/path deploy/helm/npu-lora, lmd-top vendoring path assets/npu-lora.
  • Not changed: experiment records and scripts under experiments/ (they document what was run; their python3 -m npu_lora.* commands keep working through the shim).
  • Existing hosts: after pulling, old commands keep working without reinstalling. To get the new metadata (entry point, npu-train command): pip uninstall -y npu-lora && pip install -e . (otherwise two distributions register the npu-lora command and workload).
  • DeprecationWarning follows Python's default filters: shown when npu_lora is imported from __main__ code or under pytest / -W default, hidden for python -m npu_lora.X.

Related Issue

Closes #46

Checklist

  • One purpose; unrelated formatting, dependency or API changes are in separate PRs
  • Required checks pass locally or in CI
  • No IPs, internal hostnames, tokens or site-specific paths (sensitive-data check run)
  • Docs updated (EN, and KO where the repository keeps both)
  • AI assistance stated, if used (written with Claude Code)

🤖 Generated with Claude Code

…eprecated alias (#46)

- git mv npu_lora npu_train; imports, Helm job, k8s manifest, vendor script, docs and tests use npu_train.
- pyproject: distribution npu-train, packages npu_train + npu_lora, CLI npu-train added next to npu-lora,
  airm workload npu-lora -> npu_train.airm:train.
- npu_lora/__init__.py: DeprecationWarning plus a meta-path finder that maps npu_lora.X to the same module
  object as npu_train.X, so `import npu_lora.X` and `python -m npu_lora.X` keep working; files that exist only
  under npu_lora/ still resolve there; falls back to the sibling directory for editable installs made before
  the rename.
- tests/test_compat.py covers these cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gspark-etri gspark-etri self-assigned this Oct 22, 2026
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.

Rename the Python package npu_lora to npu_train (keep npu_lora as a compatibility shim)

1 participant