[codex] Harden federated longitudinal SuStaIn - #1
Draft
armaneshaghi wants to merge 4 commits into
Draft
Conversation
… guard - FederatedClient: memoise per-sequence stage-likelihood (bounded LRU keyed by the integer ordering). Pure function -> numerically exact; turns the repeated non-moving-subtype and revisited-candidate calls in the greedy sequence search into cache hits. - LongitudinalZscoreSustain: vectorise the monotone-path DP across subjects (grouped by visit count) instead of a per-subject Python loop. Same ops. - tests/test_regression_golden.py: pin exact pooled cross-sectional and longitudinal fit outputs (loglike + sequences) so optimisations cannot change the numerics. Verified unchanged after the optimisation. (Also includes incremental hardening: AbstractSustainData base + input validation for longitudinal data, aggregate subtype/stage summaries on the server/client, and a package-discovery test.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
@copilot review please |
Add longitudinal equivalence (full-scale 3-subtype, fed-long == pooled-long) and recovery numbers to RESULTS.md; note the hot-path optimisations are in and golden-verified exact (longitudinal handling + caching are no longer roadmap). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
Review (Claude) — reviewed & addressed, leaving for your final reviewVerdict: looks solid. CI ( Checked:
Addressed:
No outstanding issues from my side. Roadmap (non-blocking): federated MCMC uncertainty, federated K-selection, further sequence-search batching. Leaving open for your review — not merging. |
Collaborator
Author
|
I have reviewed this PR. The mathematical approach for the longitudinal path dynamic programming and the federated cache and aggregation is entirely sound. However, I discovered an incompatibility with Numpy 2.x (TypeErrors due to array-to-scalar casting) which breaks the tests. I've created PR #2 to fix these Numpy 2.x compatibility issues on this branch. Once PR #2 is merged into this branch, this PR is good to merge! |
* Fix numpy 2.0 scalar conversion errors * Extend numpy 2.x scalar fix to _perform_mcmc The EM candidate-generation fix (scalar event bounds + int conversion) was missing from the MCMC candidate-generation in _perform_mcmc: the same current_location[event] array bounds (lines ~392/399) and the array-valued move_event_to from global_rng.choice(...,1) feeding np.arange (~421). Apply the identical scalar-extraction so run_sustain_algorithm's MCMC uncertainty step is numpy-2.x-safe too. Behaviour-preserving (size-1 arrays -> scalars): suite + golden + a pooled MCMC smoke pass on numpy 1.24 and 2.0.2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Arman Eshaghi <armaneshaghi@Armans-MacBook-Pro.local> Co-authored-by: armaneshaghi <4290297+armaneshaghi@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
This review branch hardens the federated/longitudinal SuStaIn work added today. It includes Claude's exact hot-path optimisations and golden regression guard, plus review fixes for packaging and aggregate-only federation semantics.
Changes:
setup.pysopySuStaIn.federatedand experiment modules are included in real wheel/sdist installs.LongitudinalZscoreSustainfrom the top-levelpySuStaInpackage.LongitudinalZScoreSustainDataexplicitly satisfyAbstractSustainDataand validate visit/subject shapes.return_individual=Trueonly for local simulations/debugging.Review notes
The main issue I found in today's committed branch was packaging:
setup.pyonly listedpySuStaInandsim, so a normal package install would omit the new federated subpackage. I also thought the previous server-sidesubtype_and_stage()API conflicted with the aggregate-only privacy language because it returned row-level assignments to the server by default.Validation
.venv/bin/python -m pytest -q->8 passed, 1 skippedrg --files -g "*.py" | xargs -r .venv/bin/python -m py_compilegit diff --check