Skip to content

[executorch][muse] Fix the DFlash final-block draft counts test - #24050

Merged
Gasoonjia merged 1 commit into
mainfrom
gasoonjia/fix-dflash-final-block-test
Oct 22, 2026
Merged

Gasoonjia merged 1 commit into
mainfrom
gasoonjia/fix-dflash-final-block-test

Conversation

@Gasoonjia

Copy link
Copy Markdown
Contributor

Stacked on #24047.

CudaDFlashNative.FinalWholeBlockFitsExactlyAndPreservesAllPrefillRows has failed in unittest-cuda-muse-glimmer-batching since #24043. It failed on that PR's own CI and on main at 8d9eec3:

cuda_dflash_native_test.cpp:612: Failure
Expected: (drained.draft_forwards - drain.draft_forwards) > (drained.static_draft_forwards - drain.static_draft_forwards), actual: 1 vs 1

The test expected the decode at position 78 to drain the 79 hidden rows through the dynamic draft before running the static draft. But run_target drains every owner it touches right after it appends hidden rows (added in #24042). So the 78-row prefill already drains down to the fresh context (32 in this fixture). The decode then holds at most one block (16) of rows and runs a single static draft. The dynamic forwards happen during the prefill, before the stats snapshot the test took.

This is a bug in the test's measurement window, not in the executor. The fix takes the first snapshot before the prefill and checks two things:

  • the prefill runs only dynamic draft forwards (at least one);
  • the decode runs exactly one draft forward, and it is static.

Test plan:

  • clang-format is clean on the changed lines.
  • No local GPU, so the test relies on CI: unittest-cuda-muse-glimmer-batching on this PR should pass.

@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 Oct 21, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Gasoonjia / name: gasoonjia (6e13047)

@Gasoonjia
Gasoonjia force-pushed the gasoonjia/fix-dflash-final-block-test branch from caf7d3a to 6e13047 Compare October 21, 2026 17:25
@Gasoonjia
Gasoonjia marked this pull request as ready for review October 22, 2026 05:56
@Gasoonjia
Gasoonjia added this pull request to stack #24077 October 22, 2026 07:28
@Gasoonjia
Gasoonjia force-pushed the gasoonjia/fix-dflash-final-block-test branch from 6e13047 to 7d911c2 Compare October 22, 2026 17:55
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Base automatically changed from gasoonjia/split-unittest-cuda to main October 22, 2026 21:07
CudaDFlashNative.FinalWholeBlockFitsExactlyAndPreservesAllPrefillRows has
failed in unittest-cuda-muse-glimmer-batching since #24043 added draft
forward count checks to it:

  Expected: (drained.draft_forwards - drain.draft_forwards) >
            (drained.static_draft_forwards - drain.static_draft_forwards),
  actual: 1 vs 1

The test expected the decode at position 78 to drain the 79 hidden rows
dynamically before the static draft. But run_target drains every owner
it touches right after appending hidden rows (#24042), so the 78-row
prefill already drains down to the fresh context (32). The decode then
holds at most one block of rows and takes a single static draft, and the
dynamic forwards fall before the window the test measured.

Measure from before the prefill instead: the prefill drains through
dynamic drafts only, and the decode runs exactly one static draft.
@Gasoonjia
Gasoonjia force-pushed the gasoonjia/fix-dflash-final-block-test branch from 7d911c2 to 03e2b91 Compare October 22, 2026 21:07
@Gasoonjia
Gasoonjia merged commit 08e033f into main Oct 22, 2026
268 of 270 checks passed
@Gasoonjia
Gasoonjia deleted the gasoonjia/fix-dflash-final-block-test branch October 22, 2026 21:10
Gasoonjia added a commit that referenced this pull request Oct 22, 2026
…r warnings (#24052)

Stacked on #24050.

Every CUDA method load that binds FQN weights next to an off-graph KV
cache printed one AOTI warning line per KV buffer:

```
[WARNING] Found constant or module state buffer or empty module state parameter __et_offgraph_kv_layer_0_k in model, but not provided by user!
```

The `unittest-cuda-muse-glimmer-batching` log contains 1672 of these
lines, out of 11650 lines total.

**Why it happens.** `CudaWeightCache::load` binds the weights with
`validate_full_update=true` and intentionally leaves the off-graph KV
buffers unbound, because the KV pool binds them later. AOTI's
full-update check (`assert_all_constants`) allows absent buffers, but it
writes a warning to stderr for each absent buffer on every load.

**Fix.**
- When the AOTI library exports
`AOTInductorModelContainerGetConstantType` and
`AOTInductorModelContainerGetConstantFromFolded`, ExecuTorch runs the
same completeness rule itself. Folded constants, buffers, tensor
constants, and empty parameters may be absent. Every other constant must
be bound, otherwise `load` fails with `InvalidProgram`.
- Binding then runs with `validate_full_update=false`. In AOTI that flag
only gates `assert_all_constants`, so nothing else about binding
changes.
- If the library does not export those two APIs, `load` keeps
`validate_full_update=true` as before.

Test plan:
- `g++ -fsyntax-only` on `cuda_weight_cache.cpp` and `cuda_backend.cpp`
against the CUDA 12.6 headers.
- CI: the CUDA unittest jobs and the muse-glimmer batching job should
pass, and their logs should no longer contain the `__et_offgraph_kv_`
warnings.

This branch was successfully deployed

1 active deployment
cadence — 03e2b91d Deployed Oct 22, 2026 by Gasoonjia via hifi-op-test / hifi4 #34407
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants