Repository navigation
Commit 6096273
authored
Skip the query/key head repeat for grouped value heads in gated DeltaNet (#49141)
* Skip the query/key head repeat for grouped value heads in gated DeltaNet
FLA's chunked and fused recurrent gated delta rule kernels accept fewer
query/key heads than value heads since 0.5.0, and the hub kernel does too.
The torch fallbacks now repeat query/key themselves, so the modeling code
only repeats when an older FLA is installed. This removes a query/key copy
and its backward reduction in every linear-attention layer of Qwen3-Next,
Qwen3.5, Qwen3.5-MoE, Qwen4-Exp and OLMo-Hybrid.
* Pass g and beta by keyword in test_gdn_chunked_matches_recurrent
FLA's fused recurrent kernel takes gk and gv between g and beta, so the
positional call fed beta into gk whenever FLA was installed. FLA's chunked
kernel also runs its dot products in TF32, so the tolerance follows the
backend.
* Name the FLA version check fla_needs_equal_qk_heads
* Always pass grouped query/key heads to the gated delta rule kernels
Drop the FLA version check and the layer-level repeat; the torch fallbacks
repeat query/key themselves when there are fewer of them.
* Add a helper for the gated delta rule test inputs
* Move the gated delta rule input helper into the model tester1 parent 70152d9 commit 6096273
9 files changed
Lines changed: 130 additions & 51 deletions
File tree
- src/transformers/models
- olmo_hybrid
- qwen3_5_moe
- qwen3_5
- qwen3_next
- qwen4_exp
- tests/models/qwen3_next
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | 401 | | |
407 | 402 | | |
408 | 403 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | 300 | | |
304 | 301 | | |
305 | 302 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
| |||
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
365 | | - | |
| 370 | + | |
366 | 371 | | |
367 | 372 | | |
368 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
369 | 379 | | |
370 | 380 | | |
371 | 381 | | |
| |||
558 | 568 | | |
559 | 569 | | |
560 | 570 | | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | 571 | | |
565 | 572 | | |
566 | 573 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments