Repository navigation
ci: add CI, release workflow and e2e tests; fix stale dependency pins - #70
Open
soroushdeimi wants to merge 47 commits into
Open
soroushdeimi wants to merge 47 commits into
soroushdeimi wants to merge 47 commits into
Conversation
Probe results (pytest -q on tests/, macOS arm64, uv venvs): pymonntorch 0.1.0 + torch 1.13.1: 47 failed, 87 passed, 100 errors pymonntorch 0.1.1 + torch 1.13.1: 47 failed, 87 passed, 100 errors pymonntorch 0.1.2 + torch 1.13.1: 41 failed, 93 passed, 100 errors pymonntorch 0.1.3 + torch 1.13.1: 224 passed, 10 errors pymonntorch 0.1.4 + torch 1.13.1: 234 passed pymonntorch 0.1.4 + torch 2.14.1: 234 passed Root cause: tests/conftest.py passes dtype= to Network, which only pymonntorch >= 0.1.4 accepts. 0.1.4 is the smallest fully-green version. sympy: pymonntorch imports it but does not declare it; torch 1.13.1 does not pull it in (torch 2.x does), so it must be listed explicitly. numpy<2: torch 1.13.1 with numpy 2.2.6 fails tests/test_voting.py::TestColumnVoting::test_partial_match_still_votes (1 failed, 233 passed); numpy 1.26.4 gives 234 passed. torch pin kept at 1.13.1: 0.1.4 passes with it on py3.8/3.9/3.10.
Runs on push to main, pull_request and workflow_dispatch. - lint: flake8 on conex and tests with the project config - test: matrix ubuntu-latest and macos-latest x python 3.8/3.9/3.10, fail-fast false, pip cache, pytest on tests/ - build: python -m build, twine check, install wheel in a fresh venv - ci-ok: single check that fails unless lint, test and build all succeed All six matrix cells have torch 1.13.1 wheels (checked on PyPI: cp38/39/310 x manylinux1_x86_64, macosx_10_9_x86_64, macosx_11_0_arm64).
Remove F841 (unused local) and F811 (redefinition) from the flake8 extend-ignore and fix each site with the smallest change: - dataset.py: drop duplicate `import torch` (F811) - active_dendrites.py: drop unused device/dtype (x2) and predicted_activation - grid_cells.py: drop unused n_cells in forward - predictive_coding.py: drop unused pred_dim (keep the parameter() call, which registers the key in used_attr_keys), unused dt/tau/alpha, and two unused cfg reads - sequence_memory.py: drop unused device Full suite still 234 passed; flake8 clean.
- test job now runs `pytest tests/ --ignore=tests/e2e -n auto` - new e2e job runs `pytest tests/e2e` on the same OS/python matrix; skips cleanly (exit 0) when tests/e2e does not exist yet - pytest-xdist installed in the workflow only (not requirements.txt); kept because the suite is 234 passed and identical across 3 local runs - ci-ok now needs lint, test, e2e and build actionlint clean.
On torch 1.13.1 (the CI pin) WeightInitializer crashes: it converts the weights to CSC (specs.py:189) then multiplies by scale (specs.py:198), and torch 1.x cannot multiply a CSC sparse tensor by a scalar. Branch on torch.__version__ inside the test: assert the RuntimeError on <2.0 and the sparse density on >=2.0. No skip/xfail.
Remove unused imports (TimeResolution, seed, Conv2dSTDP, Local2dSTDP), drop the unused 'n' binding, and wrap long lines / reword docstrings so 'flake8 tests/e2e' prints nothing. The library attribute 'I' (pymonntorch API name) gets a targeted noqa: E741.
Resolve E127/E128 continuation-line indents and an F841 unused variable, drop unused imports, and add a create_structure_from_dict test for the NeuronGroup branch.
Replace the two-line note about the unmerged shared conftest with a single line stating each file carries its own small network builder.
Add 4 end-to-end learning scenarios built from the public API that assert on what the networks learn, not a single function: - competitive STDP: Poisson input -> LIF+KWTA+homeostasis, per-pattern selectivity and weight-level preference, weights clipped to [0,1] - reward-modulated: Payoff + Dopamine + SimpleRSTDP, rewarded pattern's weights grow more than the unrewarded one's - dataset to network: Poisson-encoded SpikeNdDataset batches -> InputLayer -> readout, label-wise spike statistics and readout weight movement - reproducibility matrix: same seed bit-identical (torch.equal), different seed differs, each scenario run twice in-process Plus per-scenario failure/edge cases (zero input, saturated weights, wrong shapes). Inputs are Poisson-encoded so networks are stochastic and seed-dependent.
The selectivity was baked into a hand-biased 0.8/0.2 init, so the test stayed green when SimpleSTDP.compute_dw was broken. Start from an unbiased init (0.5 base + tiny seeded noise) and assert learning emerges as both LTP and LTD being active (some weights potentiate, some depress). This fails for a_plus=0 (no LTP) and for the LTD->LTP sign mutation (no LTD).
Raise a_plus and run more steps so the readout weight change is well above the 0.5 -> 0.52 noise floor (max |dw| 0.116-0.500 across seeds 0-4), and assert the direction per label: each label's active input channels potentiate. Fails when a_plus=0 (no potentiation).
Record the min/max observed across seeds 0-4 for the RSTDP rewarded growth (gA 0.219-0.257, gB 0.0) and the dataset readout change (max |dw| 0.116-0.500), so the thresholds are justified by a sweep, not a single seed.
Add a scenario using the Intensity2Latency encoder (the task asked for it): two intensity patterns drive a LIF readout over a time window. Assert the latency-coding property (a stronger intensity spikes sooner, one spike per channel) and that the readout weights learn from the encoded input.
Collaborator
|
Thank you for your interest in the Conex. This PR is huge in size. If I find the time I would review it. |
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.
Summary
Adds continuous integration, a tag-driven release workflow and an end-to-end test suite, and fixes the dependency pins that made the existing test suite fail.
Why the pins changed
requirements.txtpinnedpymonntorch==0.1.0, buttests/conftest.pybuildsNetwork(dtype=...), which that version rejects. With the old pins the existing suite gave 47 failed, 87 passed, 100 errors. I probed pymonntorch 0.1.0 to 0.1.4 withtorch==1.13.1:sympyis imported by pymonntorch but declared nowhere, so it is added.numpy<2is kept inrequirements.txtonly: torch 1.13.1 was built against the numpy 1.x C API, soTensor.numpy()fails under numpy 2.setup.pyleaves numpy uncapped.What is in this PR
.github/workflows/ci.yml): flake8, test matrix (ubuntu and macOS, Python 3.8 to 3.10), a separate e2e job, wheel build withtwine check, and oneCI OKjob to require in branch protection. Jobs run in parallel and superseded runs are cancelled..github/workflows/release.yml,scripts/check_release.py,docs/RELEASING.md): on av*tag it checks the tag againstsetup.pyandHISTORY.rst, runs the tests and the build in parallel, creates the GitHub release, and publishes to PyPI with trusted publishing (no stored token). A manual run can publish to TestPyPI. This replacespython-publish.yml. The pypa action is pinned by commit SHA.setup.cfgwith a note to tighten them as files are touched.tests/e2e/): per-module tests for neurons, synapses, layer and network behaviors and for the HTM, predictive coding, grid cell, voting,nnand helper code; scenario tests (competitive STDP from an unbiased init, reward-modulated STDP, dataset to readout, seeded reproducibility); pipeline tests (encoder to SDR to pooler to temporal memory to hierarchy, voting columns, grid cells with sequence memory, structure save/load round trip); and golden values generated bytests/e2e/golden/generate.pyfrom the library itself.Verification
Run on
torch==1.13.1,pymonntorch==0.1.4,numpy 1.26.4, Python 3.10:pytest tests: 718 passed (234 existing, 12 release script, 472 e2e); the e2e suite gives identical results on repeated runsflake8 conex tests: no outputactionlinton both workflows: cleanpython -m buildandtwine check: passed for the sdist and the wheelSimpleSTDP.compute_dw, or makingTemporalMemorynever predict)Line coverage of
conex/is 91% with the e2e tests.Not verified
pypiand atestpypienvironment and a trusted publisher set up once (seedocs/RELEASING.md).HISTORY.rsthas no version entries, socheck_release.py v0.1.5fails its history check until one is added.Existing library bugs found by the new tests (not fixed here)
OutputLayercallsNeuronGroupwith positional arguments in an order the current pymonntorch does not accept.One2OneRSTDPwith the default 2D weight broadcasts the one-to-one update over the rows; with a 1D weight it works. This is a usage question, not a crash.Sparse*STDPrules need a COO tensor, butWeightInitializerproduces CSC; on torch 1.x the sparse init raises "Expected result Tensor to be of format CSR". The e2e test asserts the real behaviour per torch major version.GridEraseMaskandGridCropMaskimporttorchvision, which does not import with torch 1.13.1.save_portsfails for a port whose behavior isNone, andbuild_portsis not the inverse ofsave_ports.