Skip to content

Add OSS regression test for GDN channelwise_gated_delta_rule chunked-prefill NaN (#21439) - #21439

Merged
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
YIWENX14:export-D113943464
Jul 29, 2026
Merged

Add OSS regression test for GDN channelwise_gated_delta_rule chunked-prefill NaN (#21439)#21439
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
YIWENX14:export-D113943464

Conversation

@YIWENX14

@YIWENX14 YIWENX14 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary:

Adds an OSS unit test that guards the GDN2 chunked-prefill overflow NaN fixed
in D113866825. The fused torch.ops.llama.channelwise_gated_delta_rule
chunked-prefill kernel (op_sdpa.cpp) forms eg_inv = exp(-cumsum(log decay))
per CHUNK_SIZE (32) tokens; for tiny positive decay the within-chunk cumulative
-log(decay) exceeds the float expf overflow limit (~88.7), so eg_inv
overflows to +inf and eg * eg_inv becomes 0 * inf = NaN, poisoning the
whole head's output. The channelwise_gated_delta_rule_chunked_is_safe guard
routes such inputs to the exact (numerically stable) recurrence.

test_channelwise_gated_delta_rule_prefill_tiny_decay_is_finite builds a
prefill (T=64 > CHUNK_SIZE) input with tiny positive decay (1e-12) and asserts
the op output and final_state are finite and match the token-by-token
reference. Without the guard the isfinite assertions fail.

Reviewed By: JakeStevens

Differential Revision: D113943464

@pytorch-bot

pytorch-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21439

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures

As of commit de35da7 with merge base 2a64e2d (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 28, 2026
@meta-codesync

meta-codesync Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@YIWENX14 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113943464.

@YIWENX14

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot Bot added the release notes: none Do not include this in the release notes label Jul 28, 2026
@meta-codesync meta-codesync Bot changed the title Add OSS regression test for GDN channelwise_gated_delta_rule chunked-prefill NaN Add OSS regression test for GDN channelwise_gated_delta_rule chunked-prefill NaN (#21439) Jul 28, 2026
YIWENX14 added a commit to YIWENX14/executorch that referenced this pull request Jul 28, 2026
…prefill NaN (pytorch#21439)

Summary:

Adds an OSS unit test that guards the GDN2 chunked-prefill overflow NaN fixed
in D113866825. The fused `torch.ops.llama.channelwise_gated_delta_rule`
chunked-prefill kernel (`op_sdpa.cpp`) forms `eg_inv = exp(-cumsum(log decay))`
per CHUNK_SIZE (32) tokens; for tiny positive decay the within-chunk cumulative
`-log(decay)` exceeds the float `expf` overflow limit (~88.7), so `eg_inv`
overflows to `+inf` and `eg * eg_inv` becomes `0 * inf = NaN`, poisoning the
whole head's output. The `channelwise_gated_delta_rule_chunked_is_safe` guard
routes such inputs to the exact (numerically stable) recurrence.

`test_channelwise_gated_delta_rule_prefill_tiny_decay_is_finite` builds a
prefill (T=64 > CHUNK_SIZE) input with tiny positive decay (1e-12) and asserts
the op output and final_state are finite and match the token-by-token
reference. Without the guard the `isfinite` assertions fail.

Reviewed By: JakeStevens

Differential Revision: D113943464
@YIWENX14
YIWENX14 force-pushed the export-D113943464 branch from 7ccaf51 to 3e90b91 Compare July 28, 2026 20:20
…prefill NaN (pytorch#21439)

Summary:

Adds an OSS unit test that guards the GDN2 chunked-prefill overflow NaN fixed
in D113866825. The fused `torch.ops.llama.channelwise_gated_delta_rule`
chunked-prefill kernel (`op_sdpa.cpp`) forms `eg_inv = exp(-cumsum(log decay))`
per CHUNK_SIZE (32) tokens; for tiny positive decay the within-chunk cumulative
`-log(decay)` exceeds the float `expf` overflow limit (~88.7), so `eg_inv`
overflows to `+inf` and `eg * eg_inv` becomes `0 * inf = NaN`, poisoning the
whole head's output. The `channelwise_gated_delta_rule_chunked_is_safe` guard
routes such inputs to the exact (numerically stable) recurrence.

`test_channelwise_gated_delta_rule_prefill_tiny_decay_is_finite` builds a
prefill (T=64 > CHUNK_SIZE) input with tiny positive decay (1e-12) and asserts
the op output and final_state are finite and match the token-by-token
reference. Without the guard the `isfinite` assertions fail.

Reviewed By: JakeStevens

Differential Revision: D113943464
@YIWENX14
YIWENX14 force-pushed the export-D113943464 branch from 3e90b91 to de35da7 Compare July 28, 2026 21:29
@YIWENX14
YIWENX14 requested review from JakeStevens and billmguo July 28, 2026 21:35
@meta-codesync
meta-codesync Bot merged commit 94c6c88 into pytorch:main Jul 29, 2026
182 of 186 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants