Skip to content

test: relocate spec_decode_verify test into the collected suite#6

Merged
khosravipasha merged 1 commit into
prismfrom
test/spec-verify-relocate
Jul 14, 2026
Merged

test: relocate spec_decode_verify test into the collected suite#6
khosravipasha merged 1 commit into
prismfrom
test/spec-verify-relocate

Conversation

@bri-prism

Copy link
Copy Markdown

What

Move the spec_decode_verify validation out of the root-level test_spec_verify.py
script and into python/tests/test_fast.py as TestFast.test_spec_decode_verify,
and delete the root script.

Why

The script added in #5 sat at the repo root as a __main__ program. pytest does
not collect it (not test_-prefixed, not under python/tests/), so its coverage
never actually ran in CI — it was only runnable by hand. This folds the same
checks into the collected suite.

How

test_spec_decode_verify ports the script's coverage as assertions:

  • The hand-written cases (full-accept, mid-prefix mismatch, reject-all, K=1, and
    two batched shapes) across fp32/fp16/bf16.
  • Both execution paths: the default device (fused Metal kernel on a Metal build)
    and stream=mx.cpu (the op-composition fallback).
  • The 40-case seeded randomized sweep over prefix lengths, batch shapes, and
    corrected-token positions.
  • The target_logits.shape[1] != K + 1 rejection.

Verified the restructured harness matches the op's documented contract (greedy
argmax then prefix-match then commit) across all cases and the shape-rejection
using a reference stand-in; the underlying kernel/op is unchanged from #5.

No production code changes — test-only.

The spec_decode_verify validation lived in a root-level test_spec_verify.py
script that pytest does not collect, so it never ran in CI. Fold its coverage
into TestFast.test_spec_decode_verify (oracle-checked cases across
fp32/fp16/bf16, both the fused-kernel and cpu-composition paths, a randomized
sweep, and the bad-shape rejection) and drop the root script.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR relocates the spec_decode_verify validation from a non-collected root-level script into the pytest-collected Python test suite, ensuring the coverage runs in CI.

Changes:

  • Removed the root-level test_spec_verify.py standalone validation script.
  • Added test_spec_decode_verify to python/tests/test_fast.py, porting the oracle-based checks (hand cases, CPU fallback path, randomized sweep, and shape rejection) into unittest/pytest collection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test_spec_verify.py Deletes the uncollected root-level __main__ validation script.
python/tests/test_fast.py Adds a collected unit test covering mx.fast.spec_decode_verify behavior across dtypes/paths plus randomized and error-path coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@khosravipasha
khosravipasha merged commit 10b5fe4 into prism Jul 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants