Fix EinopsError in wall-to-wall example due to incorrect tensor shapes #376
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.
Problem
The wall-to-wall example notebook was failing with an EinopsError when trying to run the Clay model encoder:
Root Cause
The issue was in how time and location tensors were being constructed for multiple timesteps. The notebook was using
np.hstack()to combine lists of tuples, which created 1D tensors instead of the required 2D tensors with proper batch dimensions:Where:
week_normandhour_normwere lists of 12 tuples each (24 values total)hstackflattened everything into a single 1D array of 48 values[B, D]where B=12 (batch size) and D=4 (normalized values)Solution
Fixed tensor creation in the wall-to-wall notebook by replacing
np.hstack()withnp.column_stack():Corrected inconsistent documentation across the codebase where comments incorrectly stated time/latlon tensors have shape
[B, 2]when they actually have shape[B, 4].Result
The fix ensures proper tensor shapes:
[12, 4]containing(week_sin, week_cos, hour_sin, hour_cos)for each sample[12, 4]containing(lat_sin, lat_cos, lon_sin, lon_cos)for each sample[12, 8]which matches the model's expectation for the einops operationUsers can now successfully run the wall-to-wall example without encountering the EinopsError.
Files Changed
docs/tutorials/wall-to-wall.ipynb: Fixed tensor creationclaymodel/model.py: Updated tensor shape commentsclaymodel/finetune/embedder/factory.py: Updated tensor shape commentsclaymodel/finetune/regression/factory.py: Updated tensor shape commentsclaymodel/finetune/segment/factory.py: Updated tensor shape commentsFixes #[issue_number]
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.