Add packaging metadata, CI, and unit tests for steering logic - #17
Open
piyushbag wants to merge 1 commit into
Open
Add packaging metadata, CI, and unit tests for steering logic#17piyushbag wants to merge 1 commit into
piyushbag wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The repository ships a minimal
pyproject.tomlalongside a legacysetup.py, and has no automated tests or CI:pyproject.tomldeclares onlynameandversion. It lists no runtime dependencies, sopip install neural-steeringproduces an environment whereimport neuron_steer.corefails (notorch,transformers, oraccelerate).setup.pyduplicatesname/versionalready present in the PEP 621[project]table. On pip resolvers that fall back to the legacysetup.py developpath,pip install -e .fails outright.Approach
Packaging (
pyproject.toml, removesetup.py):torch,transformers,accelerate),requires-python,description,readme,license, and project URLs so a plain install yields a working environment.testextra (pytest) and atestpathsconfig.setup.pyand consolidate onpyproject.toml, which also fixes the legacysetup.py developfailure.Tests (
tests/test_steering.py, CPU-only, no model download):steer_neurons:multiplier=0.0ablates only the circuit neurons (others untouched),1.0is a no-op baseline,>1.0amplifies, and hooks are removed on context exit. Verified against a small stand-in module matching themodel.layers[i].mlp.down_projpath thatsteer_neuronshooks.select_circuit: top-k, cumulative-threshold, and empty-input behavior.CI (
.github/workflows/ci.yml):torch, editable-installs the package, runs an import smoke check on the public API, and runspytest.How this differs from the other open PRs
This PR intentionally touches a non-overlapping set of files:
apply_surgery.py,stress_test.py,canonical_indices.json, README).neuron_steer/__init__.py(public API re-export). This PR does not touch__init__.py; the tests import fromneuron_steer.coreso they pass with or without Fix ImportError: export public API from neuron_steer/__init__.py #12 merged, and are complementary to it.examples/interactive_demo.py.experiments/steering_comparison.py.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
Local run: 6 passed.