Skip to content

fix(tests): repair the unit-test suite after the Reactive_E2E refactor (#88)#94

Merged
riita10069 merged 2 commits into
autowarefoundation:mainfrom
gcordova10:fix/tests-after-reactive-refactor
Jun 28, 2026
Merged

fix(tests): repair the unit-test suite after the Reactive_E2E refactor (#88)#94
riita10069 merged 2 commits into
autowarefoundation:mainfrom
gcordova10:fix/tests-after-reactive-refactor

Conversation

@gcordova10

Copy link
Copy Markdown
Contributor

Summary

Closes #88. The #86 refactor (everything moved inside Reactive_E2E) changed the model's public contract, but the unit tests still asserted the old API, so make test was red. This PR brings the whole suite back in line with the refactored architecture and fixes two pre-existing source-level mypy errors that also kept CI red.

No production behaviour changes beyond two type-only annotations — this is a test-and-typing repair.

Root cause (what the refactor changed)

After #86:

  • AutoE2E is a thin wrapper around self.Reactive_E2E = ReactiveE2E(...); the Backbone, FeatureFusion, MapEncoder/MapBEVFusion, TemporalMemory and TrajectoryPlanner now live under Reactive_E2E.* (so parameter names are prefixed Reactive_E2E.).
  • AutoE2E.forward(...) returns only trajectory [B, num_timesteps*num_signals], in every mode. The old 3-tuple (loss/trajectory, ego_hidden, future_features) is gone.
  • The planner forward() is inference-only and returns just the trajectory (no ego_hidden); the per-planner compute_planner_loss was removed (the training objective lives in the training loop).
  • View fusion: only bev is registered now (FUSION_REGISTRY == {"bev"}); concat/cross_attn are gone. The fusion_mode kwarg was dropped from AutoE2E/ReactiveE2E (it is hard-wired to "bev" internally); FeatureFusion itself still accepts a fusion_mode arg.
  • The GRU planner was removed; PLANNER_REGISTRY == {flow_matching, bezier}. AutoE2E's default planner_mode is bezier. (Note: ReactiveE2E.__init__ still carries a stale planner_mode="gru" default that would raise if it were ever constructed directly with defaults — AutoE2E always passes bezier, so the live path is fine; flagging it as a latent source nit.)
  • The future_features output was removed from the forward path. FutureState is still constructed inside ReactiveE2E but is not called by forward, so it produces no output and receives no gradient.

The tests were written against all of the above, so they failed en masse (collection-time and assertion-time).

What changed, file by file

Test suite (adapted to the new contract):

  • conftest.py_build_model_with_mock_backbone patches model_components.reactive_e2e.Backbone (was auto_e2e.Backbone); always BEV at an 8×8 grid; model/full_model fixtures parametrised on ["bev"] only.
  • test_auto_e2e.pymodel(...) now returns a single trajectory; removed the ego_hidden/future_features shape tests; train-mode calls now return the trajectory (no 3-tuple); gradient/optimizer tests backward through a trajectory MSE and target Reactive_E2E.{Backbone,FeatureFusion,TrajectoryPlanner}, excluding the unused FutureState and the alpha-gated MapEncoder; num_views matrix is BEV-only.
  • test_view_fusion.py — read fused features via model.Reactive_E2E.{Backbone,FeatureFusion}; registry/BEV-specific tests unchanged.
  • test_feature_fusion.pyfusion_mode="concat""bev" (+ view_fusion_kwargs={"bev_h":8,"bev_w":8}).
  • test_map_encoder.py — single-trajectory return; paths via Reactive_E2E.{MapEncoder,MapBEVFusion}; gradient checks now drive a trajectory-MSE backward. cross_attn map fusion stays covered (it is still a valid map_fusion_mode).
  • test_history_encoder.py — single-trajectory return; Reactive_E2E.TemporalMemory; one_hz/no_memory paths verified via trajectory backward.
  • test_causal_reasoning.py — asserts the new single-trajectory contract; the (independent) CausalReasoningModule is exercised on a 256-d embedding since the planner's internal ego embedding is no longer surfaced.
  • test_bezier_planner.py — planner forward returns just the trajectory; removed tests for the deleted compute_planner_loss/trajectory_loss; default-planner test now asserts bezier (GRU removed); AutoE2E tests patch reactive_e2e.Backbone and use Reactive_E2E.TrajectoryPlanner.
  • test_trajectory_planning.py — Flow-Matching forward returns the trajectory; removed the compute_planner_loss end-to-end / wrong-shape tests and test_train_mode_requires_target (the forward no longer requires a target); gradient test backprops through the integrated trajectory; AutoE2E-with-FM tests use the single-trajectory contract; "interchangeable planners" now compares bezier vs flow_matching.
  • test_integration.pyTestRealArchitectureSmoke (runs in CI, is_pretrained=False) and the @integration tier adapted to the single-trajectory contract and Reactive_E2E.Backbone.

Source (type-only mypy fixes, no behaviour change):

  • losses/trajectory_loss.py — class-level annotations loss_fn: nn.Module / temporal_weights: torch.Tensor so mypy resolves them instead of nn.Module.__getattr__ -> Tensor | Module (which flagged self.loss_fn(...) as "Tensor not callable").
  • map_encoder/raster_map_encoder.py — bind timm's feature_info through Any to iterate it without a union-attr error.

Tests removed (and why)

Tests for features deleted by #86 were removed rather than left asserting dead behaviour: concat/cross_attn view fusion, the GRU planner, the planner compute_planner_loss/trajectory_loss, and the ego_hidden/future_features returns. Everything still present (BEV fusion, bezier + flow_matching planners, residual + cross_attn map fusion, temporal memory, the reasoning head) stays covered.

Testing

Run exactly as CI does:

ruff check                  # All checks passed
cd Model && mypy .          # Success: no issues found in 74 source files
pytest Model/tests          # 181 passed, 6 deselected

The 6 deselected are the @integration tier (real pretrained backbones), which Model/pytest.ini excludes from the default/CI run via -m "not integration and not e2e_data".

Notes

  • FutureState is still constructed inside ReactiveE2E but is not used by its forward, so it receives no gradient; the gradient-coverage tests exclude it intentionally (flagging in case it should be wired in or dropped).
  • Net diff is −172 lines (12 files, +317/−489) — mostly deleting expectations for removed features.

… WIP foundation)

Root-cause fix for the broken shared test infra after the Reactive_E2E refactor:
patch the backbone at its new home (model_components.reactive_e2e.Backbone, not
the removed auto_e2e.Backbone); always build BEV fusion (concat/cross_attn were
removed); default planner_mode='bezier' (GRU removed). Clears the 57 collection
ERRORS (fixture no longer crashes).

NOT a complete fix: ~73 test failures remain that are NOT mechanical — they need
team decisions: (a) the post-refactor AutoE2E.forward RETURN CONTRACT is
undefined (docstring says a 3-tuple, code returns 1-2 values); (b) many tests
reference FutureState/TemporalMemory which the WG is removing. Those require the
new contract to be defined first (see autowarefoundation#88 / 24-06 meeting).

Signed-off-by: GABRIELA CORDOVA <100548769@alumnos.uc3m.es>
…ation#88)

The autowarefoundation#86 refactor moved Backbone/FeatureFusion/MapEncoder/planner inside
Reactive_E2E and made AutoE2E.forward return ONLY the trajectory; it also
removed concat/cross_attn view fusion, the GRU planner, fusion_mode, the BEV
FutureState output and the per-planner compute_planner_loss. The tests still
asserted the old API, breaking CI.

Tests adapted to the new contract:
- AutoE2E.forward returns a single trajectory tensor (no (loss, ego_hidden,
  future) 3-tuple); submodules now live under Reactive_E2E.* — updated every
  unpacking, attribute path and gradient-group prefix (test_auto_e2e,
  test_map_encoder, test_history_encoder, test_causal_reasoning, test_integration).
- view fusion: concat/cross_attn -> bev (+ view_fusion_kwargs 8x8) in
  test_feature_fusion / test_view_fusion; FutureState excluded from
  gradient-coverage checks (instantiated but unused in the reactive forward).
- planners: forward returns just the trajectory; removed tests for the deleted
  compute_planner_loss / trajectory_loss and the GRU planner; default planner is
  now bezier; training-loss tests reframed as trajectory-MSE backprop checks
  (test_bezier_planner, test_trajectory_planning).
- map fusion cross_attn is still a valid map_fusion_mode and stays covered.
- patched model_components.reactive_e2e.Backbone (was auto_e2e.Backbone).

Two pre-existing source mypy errors fixed (type-only, no behaviour change):
class-level annotations on TrajectoryImitationLoss (loss_fn/temporal_weights)
and an Any binding for timm's feature_info in RasterizedMapEncoder.

CI green: ruff clean, mypy clean (74 files), pytest 181 passed / 6 deselected
(the @integration tier still requires real weights and is run separately).

Signed-off-by: GABRIELA CORDOVA <100548769@alumnos.uc3m.es>
@riita10069

Copy link
Copy Markdown
Collaborator

@gcordova10 I really appreciate your contributions!

@gcordova10 gcordova10 deleted the fix/tests-after-reactive-refactor branch June 30, 2026 15:30
riita10069 added a commit that referenced this pull request Jul 3, 2026
…params/fusion_mode)

Was doubly stale: fusion_mode was removed in #94 and camera_params is now gone
from forward. Use a PinholeProjection operator (or explicit pseudo), num_views=7
real cameras, and the current keyword forward signature.

Signed-off-by: riita10069 <ryota10069.tech5.jizi@gmail.com>
riita10069 added a commit that referenced this pull request Jul 3, 2026
…_modes

Was stale from #94 (fusion_mode loop over removed concat/cross_attn, 3-arg
forward) and now also from camera_params removal. Use a PinholeProjection
operator, pass map_input, num_views=7, and benchmark BEV only.

Signed-off-by: riita10069 <ryota10069.tech5.jizi@gmail.com>
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.

[Bug]: CI is broken because tests are for old architecture and need to be updated

2 participants