Repository navigation
fix: zero turnover limit, CAE/SAE minibatch edge cases, attention with no neighbors or long lag - #56
Open
quantum-like wants to merge 5 commits into
Open
quantum-like wants to merge 5 commits into
quantum-like wants to merge 5 commits into
Conversation
A non-positive turnover cap replaced the target book with zeros, which liquidates an existing portfolio instead of forbidding trades. A zero cap now scales weight changes to the previous holdings, and a negative cap is rejected. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
Hidden beta networks skip one-row minibatches because BatchNorm cannot train on them. When every batch was a single row, fit still returned a converged model whose weights were the random initialization. That fit now fails instead of emitting an untrained beta surface. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
A configured batch size that left a one-row tail, or a single valid training row, crashed inside BatchNorm during training. Singleton tails are folded into the previous batch, and a one-row sample now raises a clear error before any update. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
A fully blocked adjacency row, or a node whose only neighbors are missing, produced NaN attention and NaN portfolio weights. Those queries now attend to themselves when present, and otherwise use a finite fallback. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
When the lag exceeded the window length, the history slice used a negative stop and either crashed or read the end of the same window. Lags that reach past the start of the window now see an empty history. Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
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.
Owning issue
Closes #55
Outcome
5 correctness fixes, one commit each, each with a focused test:
tests/test_financial_correctness.py::test_zero_turnover_limit_holds_the_previous_book,::test_negative_turnover_limit_is_rejected. (2a32358)converged=Truewhen hidden units were set and every minibatch had one row, so no step ran and the random initialization was returned. It now raises. The existing skip of a trailing singleton minibatch is unchanged. Test:tests/test_cae.py::test_cae_rejects_fits_that_never_update_parameters. (b0d261a)tests/test_sae.py::test_sae_trains_when_the_last_minibatch_would_be_a_single_row,::test_sae_rejects_a_single_training_row. (95557c0)tests/test_financial_correctness.py::test_graph_attention_stays_finite_when_a_node_has_no_neighbors,::test_graph_attention_ignores_a_masked_only_neighbor. (7312029)tests/test_financial_correctness.py::test_cross_attention_lag_longer_than_the_window_does_not_wrap. (077948a)Compatibility
A turnover limit of 0 now means "hold" rather than "liquidate", and invalid limits raise. Other changes affect only edge cases that previously crashed or produced NaN.
Verification
mainand passes with its fix)typassespytest tests/: 422 passed before, 431 passed after.ruffandtywere clean in the review environment.Documentation and release
No documentation changes. The behavior changes above may be worth a line in the next patch-release notes.
Amir