Repository navigation
Commit 4de6bb7
Fix integration test: remove dropped
`test_qwen35_deltanet_single_layer_parity` fails on transformers 5.x
because `Qwen3_5GatedDeltaNet.forward()` no longer accepts
`cache_position`, and `has_previous_state` is no longer implicitly set
when assigning cache states directly.
## Changes
- **Remove `cache_position` kwarg** — dropped from the HF forward
signature in transformers 5.x; decode vs. prefill mode is now determined
solely via `cache_params.has_previous_state(layer_idx)`.
- **Explicitly set `cache.layers[0].has_previous_state = True`** — in
the old API this flag was implicitly set when `conv_states` was assigned
directly on the layer; in 5.x it is a plain `bool` defaulting to `False`
and only set via `update_conv_state()`. The test bypasses that method,
so the flag must be set manually to put the forward into decode mode and
consume the pre-filled states.
```python
# Before
cache.layers[0].recurrent_states = torch.from_numpy(rec_np).float()
# has_previous_state is True once conv_states[0] is set ← no longer true
hf_output = hf_dn(
hidden_states=...,
cache_params=cache,
cache_position=torch.tensor([conv_kernel - 1]), # ← TypeError in 5.x
).numpy()
# After
cache.layers[0].recurrent_states = torch.from_numpy(rec_np).float()
cache.layers[0].has_previous_state = True # explicit in 5.x
hf_output = hf_dn(
hidden_states=...,
cache_params=cache,
).numpy()
```
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: justinchuby <[email protected]>cache_position kwarg from Qwen3_5GatedDeltaNet.forward() (#229)1 parent e73e0a5 commit 4de6bb7
1 file changed
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3929 | 3929 | | |
3930 | 3930 | | |
3931 | 3931 | | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
3932 | 3935 | | |
3933 | | - | |
3934 | | - | |
3935 | | - | |
3936 | | - | |
3937 | | - | |
3938 | | - | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
3939 | 3941 | | |
3940 | 3942 | | |
3941 | 3943 | | |
3942 | 3944 | | |
3943 | 3945 | | |
3944 | | - | |
3945 | 3946 | | |
3946 | 3947 | | |
3947 | 3948 | | |
| |||
0 commit comments