Skip to content

Add packaging metadata, CI, and unit tests for steering logic - #17

Open
piyushbag wants to merge 1 commit into
NousResearch:mainfrom
piyushbag:packaging-ci-tests
Open

Add packaging metadata, CI, and unit tests for steering logic#17
piyushbag wants to merge 1 commit into
NousResearch:mainfrom
piyushbag:packaging-ci-tests

Conversation

@piyushbag

Copy link
Copy Markdown

Problem

The repository ships a minimal pyproject.toml alongside a legacy setup.py, and has no automated tests or CI:

  • pyproject.toml declares only name and version. It lists no runtime dependencies, so pip install neural-steering produces an environment where import neuron_steer.core fails (no torch, transformers, or accelerate).
  • setup.py duplicates name/version already present in the PEP 621 [project] table. On pip resolvers that fall back to the legacy setup.py develop path, pip install -e . fails outright.
  • There is no test suite and no CI, so regressions in the core steering/selection logic are not caught.

Approach

Packaging (pyproject.toml, remove setup.py):

  • Declare runtime dependencies (torch, transformers, accelerate), requires-python, description, readme, license, and project URLs so a plain install yields a working environment.
  • Add an optional test extra (pytest) and a testpaths config.
  • Remove the redundant setup.py and consolidate on pyproject.toml, which also fixes the legacy setup.py develop failure.

Tests (tests/test_steering.py, CPU-only, no model download):

  • Steering multiplier logic in steer_neurons: multiplier=0.0 ablates only the circuit neurons (others untouched), 1.0 is a no-op baseline, >1.0 amplifies, and hooks are removed on context exit. Verified against a small stand-in module matching the model.layers[i].mlp.down_proj path that steer_neurons hooks.
  • select_circuit: top-k, cumulative-threshold, and empty-input behavior.

CI (.github/workflows/ci.yml):

  • Runs on push and PR across Python 3.9 and 3.11: installs CPU torch, editable-installs the package, runs an import smoke check on the public API, and runs pytest.

How this differs from the other open PRs

This PR intentionally touches a non-overlapping set of files:

No file in this PR (pyproject.toml, setup.py, .github/workflows/ci.yml, tests/) is modified by any of #11#15, so it can merge cleanly alongside them.

Test plan

pip install --index-url https://download.pytorch.org/whl/cpu "torch>=2.0"
pip install -e . --no-deps
pip install pytest
python -c "import neuron_steer.core as c; [getattr(c, n) for n in ('NeuronSteerer','Circuit','NeuronIdx','steer_neurons','select_circuit','compute_attribution')]"
pytest -q

Local run: 6 passed.

Consolidate packaging into pyproject.toml and add test coverage plus
continuous integration.

Packaging:
- Declare runtime dependencies (torch, transformers, accelerate),
  requires-python, description, readme, license, and project URLs in
  pyproject.toml so `pip install neural-steering` installs a working
  environment instead of a bare package with no dependencies.
- Add an optional `test` extra (pytest) and a pytest testpaths config.
- Remove the redundant setup.py. It duplicated name/version already in
  the PEP 621 [project] table, and its legacy `setup.py develop` path
  made `pip install -e .` fail on pip resolvers that fall back to it.

Tests (tests/test_steering.py):
- Cover the steering multiplier logic in steer_neurons against a small
  CPU-only stand-in model: multiplier=0.0 ablates only circuit neurons,
  1.0 is a no-op baseline, >1.0 amplifies, and hooks are removed on exit.
- Cover select_circuit top-k, cumulative-threshold, and empty-input
  behavior. All tests are CPU-only and require no model download.

CI (.github/workflows/ci.yml):
- Run on push and pull_request across Python 3.9 and 3.11.
- Install CPU torch, editable-install the package, run an import smoke
  check on the public API, and run pytest.
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