Skip to content

Fit streaming retrains on the current window of stream items - #51

Merged
braceal merged 1 commit into
mainfrom
fix/stream-train-unbounded-history
Aug 11, 2026
Merged

Fit streaming retrains on the current window of stream items#51
braceal merged 1 commit into
mainfrom
fix/stream-train-unbounded-history

Conversation

@braceal

@braceal braceal commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Two problems in run_stream_train's handling of re-train data.

Contact maps were flattened across frames. Each streamed item carries a single frame's sparse contact map — np.concatenate([row, col]), so a variable-length 1-D array whose length depends on the number of contacts in that frame. The batch was combined with:

contact_maps = np.concatenate([x['contact_maps'] for x in items])

which concatenates every frame in the batch into one flat array, destroying frame boundaries before the data reaches model.fit. Replaced with an object array holding one entry per frame, matching the ragged layout ContactMapCollector produces elsewhere:

cmaps = np.array([x['contact_maps'] for x in items], dtype=object)

History grew without bound. Each batch was appended to contact_map_history / pcoord_history, which were never trimmed. Memory climbed for the life of the run, and every retrain re-consumed all data seen so far, so successive retrains got progressively slower.

Each retrain now fits on the current window of stream items only. How much history to retain is still an open question — the existing TODO is left in place.

Extracted from #40 so it can land on its own.

🤖 Generated with Claude Code

Two problems with the re-train data handling:

Each streamed item carries a single frame's sparse contact map, a
variable-length array of concatenated row and column indices.
np.concatenate flattened every frame in the batch into one array, so
frame boundaries were lost before the data reached model.fit. Build an
object array instead, one entry per frame, which is the ragged layout
the collector produces.

The batch was also appended to contact_map_history and pcoord_history,
which were never trimmed. Memory grew for the life of the run and every
retrain re-consumed all data seen so far, making successive retrains
progressively slower.

Fit on the current batch only. How much history to retain is still open
(see the existing TODO).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@braceal
braceal merged commit 5a42d19 into main Aug 11, 2026
@braceal
braceal deleted the fix/stream-train-unbounded-history branch August 11, 2026 22:01
@braceal braceal mentioned this pull request Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant