Normalize only spatial predecessor phases; remove NumPy usage; preserve CPU statistics configuration; lazy-load Lightning exports - #229
Open
stephandooper wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Motivation
_compatible_predecessor_coordinatesthat applied remainder across the legacy (non-spatial) coordinate and could produce zero-divisor or lattice-mismatch issues for spatial branches.lightningare not installed by making convenience exports lazy.Description
_prev_statsto return a list of stats rather than a single entry and to stop traversal per-path. (_prev_stats,_compatible_predecessor_coordinates)_compatible_predecessor_coordinates)torch.repeat_interleaveandtorch.zeros) to remove thenumpyruntime dependency and keep tensors on the correct device.statistics_on_cpuis used by recordingoriginal_deviceand restoring it after CPU statistics gathering instead of unconditionally moving the model to CUDA. (_configure)LightningStreamingModuleandImageNetClassifierlazy imports via__getattr__to avoid import-time failures when optionallightning/torchvisionpackages are not installed. (lightstream/modules/__init__.py)Testing
Ran the focused predecessor tests with
pytest -q tests/test_scnn.py -k 'prev_stats or predecessor_coordinates'andpython -m compileall -q lightstream, which produced7 passedand successful byte-compilation respectively, confirming the zero-divisor / remainder cases are resolved.Ran the full test file with
pytest -q tests/test_scnn.py, which produced57 passed, 10 failed, 1 warning; none of the failures point to the predecessor collector including parameter/non-spatial branches or incorrectly rejecting valid legacy graphs, and stride metadata computed during statistics collection appears preserved.Remaining failures (grouped by exception and originating test locations) are:
AssertionErrorattests/test_scnn.py:694,tests/test_scnn.py:850, andtests/test_scnn.py:1074related to GeM saliency parity, mixed head mapping parity, and the reducer mask error-message contract.ValueErrorattests/test_scnn.py:866,tests/test_scnn.py:888, andtests/test_scnn.py:1085originating fromlightstream/core/reducer/base.py:420where converted reducers enter a legacy passthrough expecting a single tensor (multi-input reducer handling issue).RuntimeErrorattests/test_scnn.py:743indicating a backward replay / grad_fn mismatch for shared-parameter GeM reducers.AttributeErrorattests/test_scnn.py:129related to a test constructingStreamingCNNwith__new__then assigning modules beforeModule.__init__is called (test fixture limitation).ModuleNotFoundErrorattests/test_scnn.py:1193due to the test requiring optionaltorchvisionin the environment.Conclusion: the spatial-only remainder fix resolves the zero-divisor / lattice-normalization problems and the collector behaves as intended; the remaining failures point to reducer conversion/passthrough logic, backward-replay handling for shared parameters, and a couple of environment/fixture issues rather than regressions in spatial coordinate collection or stride metadata.
Codex Task