feat: add GRU transition model for latent-space dynamics prediction (OP#363)#3
Open
sahreen-haider wants to merge 7 commits into
Open
feat: add GRU transition model for latent-space dynamics prediction (OP#363)#3sahreen-haider wants to merge 7 commits into
sahreen-haider wants to merge 7 commits into
Conversation
6 tasks
ChinarCypher
approved these changes
Jul 6, 2026
ChinarCypher
left a comment
Collaborator
There was a problem hiding this comment.
The overall integration looks great. It will be great if we can consider one smoke test that runs the real encoder (even on a tiny input) so we are not exclusively testing against FakeEncoder. Can we also confirm if the GRU hidden state is intended to persist across env steps within an episode and reset on done (tests mention carry-over).
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
Implements a GRU-based transition model that predicts the next JEPA latent state
given the current latent and the action taken. This closes the loop between
perception (DINO ViT encoder) and planning by learning vessel dynamics directly
in latent space. Includes a full unit + smoke test suite and supporting fixes.
Changes
New:
models/transition_model.pyGRUTransitionModel: single-layer GRU operating on(z_t ‖ a_t)→z_t+1init_hidden()for clean batch-compatible zero-state initialisationmain.pyGRUTransitionModeleach step after env interaction(
[speed·cos(hdg), speed·sin(hdg)]) instead of the previous[speed, 0]z_t+1norm in the step printout for a quick sanity checkenv/maritime_env.pyget_vessel_state()returning(speed, heading_deg)for latent augmentationconfig.yamldevice: mps→device: cudaperception/waste_detector.pyimport numpy as nputils/checkpoint.pyweights_only=Truetotorch.loadto suppress PyTorch's upcomingsecurity default change
New:
tests/— full test suite (52 tests, 0 failures)tests/test_transition_model.pyinit_hidden, hidden state propagation, determinism, backward passtests/test_maritime_env.pyget_vessel_state, speed formula, heading wrap [0–360), step contract, done conditionstests/test_jepa_world_model.pytests/test_smoke.pypytest.iniadded withtestpaths = testsandpythonpath = .tests/conftest.pystubstimmat the module level to work around atorchvisionbinary mismatch (torchvision::nmsoperator missing atregistration time); individual fixtures monkeypatch
timm.create_modelto return a lightweight
FakeEncoderreturning the correctVISUAL_DIMdocs/gru_training_data_requirements.md(untracked — see note).npzstorage format, normalisation, episode-level splits, MSE trainingloss, and real-vessel telemetry pipeline for future fine-tuning
Notes
checkpoints/should be added to.gitignore— currently untracked butnot ignored,
.pthfiles will appear as untracked after any rundocs/is excluded by.gitignore; remove that line if the datarequirements doc should be versioned with the code
Test plan
python -m pytest tests/ -v)main.pyend-to-end on a CUDA machine; confirmz_t+1 normlogs a non-zero value each step
checkpoints/on episode endOP#363