testintel: add missing test for AvgDown3D.forward (created by linxwang) - #1083
testintel: add missing test for AvgDown3D.forward (created by linxwang)#1083jiagaoxiang wants to merge 3 commits into
Conversation
Candidate cand:9cf47afdeacb6b6d0378129eb4bf01c2 at 2f01706.
|
Please revise the spatial/channel test before marking this PR ready. |
There was a problem hiding this comment.
🟡 Changes recommended
One of the new tests validates only output shape (not values), which leaves the core downsampling/reshaping semantics unverified.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new unit test module to exercise the previously untested AvgDown3D.forward path in the Wan VAE 2.2 implementation, focusing on temporal padding and grouped channel averaging behavior.
Changes:
- Introduces
tests/unit_tests/backends/diffusion/test_wan_vae_avgdown3d.pycovering: (1) grouped averaging without padding, (2) temporal left-padding to a multiple offactor_t, and (3) initialization-time channel-factor compatibility assertions. - Adds a basic shape check for spatial downsampling + channel regrouping.
File summaries
| File | Description |
|---|---|
| tests/unit_tests/backends/diffusion/test_wan_vae_avgdown3d.py | Adds new unit tests for AvgDown3D.forward, including temporal padding and grouped averaging scenarios. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def test_forward_downsamples_spatial_and_channel_dims(): | ||
| factor_t, factor_s = 1, 2 | ||
| in_channels, out_channels = 2, 4 | ||
| module = AvgDown3D(in_channels=in_channels, out_channels=out_channels, factor_t=factor_t, factor_s=factor_s) | ||
|
|
||
| b, t, h, w = 1, 2, 4, 4 | ||
| x = torch.randn(b, in_channels, t, h, w) | ||
| out = module(x) | ||
|
|
||
| assert out.shape == (b, out_channels, t, h // factor_s, w // factor_s) |
…rence Address review: compare full output against a hand-computed reference for factor_s=2 with in_channels != out_channels (deterministic torch.arange input), verifying spatial block grouping and channel/group mapping instead of only asserting output shape.
|
TestIntel PR Steward: Addressed @WangLingxun's review comment in
The existing temporal front-padding and non-divisible-constructor tests are unchanged, as requested. I verified the reference formula against the actual module logic with a standalone reshape/permute simulation before pushing, so this should be correct, but I don't have a torch environment in this sandbox to run pytest directly — please let CI (or a manual run) confirm. |
pre-commit's black hook wraps the AvgDown3D(...) constructor call in test_forward_downsamples_spatial_and_channel_dims onto multiple lines (line was too long). No behavior change.
|
TestIntel PR Steward: CI's @WangLingxun / Copilot: the underlying test-content change (full-tensor comparison against an independent reference instead of shape-only) is unchanged from my earlier reply — only formatting moved. |
There was a problem hiding this comment.
🟢 Approval recommended
The change is test-only and the added assertions correctly match the current AvgDown3D implementation semantics (padding, reshaping/permute order, and grouping).
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Superseded by same-repo PR #1096 (head |
This PR was created by linxwang via Test Gap Resolver.
No existing test in tests/unit_tests/backends/diffusion (or anywhere else in the repo) instantiates AvgDown3D or imports vae2_2.py at all; the pad->view->permute->view->view->mean sequence that implements grouped spatiotemporal average-downsampling, including the temporal padding branch (pad_t>0) and the group_size averaging when in_channelsfactor != out_channelsgroup_size trivially, is completely unexercised.
This PR adds a focused unit test for
AvgDown3D.forward; it does not change production code.