TileOPs-Metax/scripts
Ang Gao a90c28c065
[Fix][Manifest] Keep UnaryOp dispatch visible to validator (#1708)
Fixes the unary-op manifest validation regression surfaced around #1707,
using the reviewer-preferred approach from this PR discussion.

## Summary
- Keep `UnaryOp.__init__` calling `dispatch_kernel(...)` directly, so
the S13 manifest rule remains simple and statically visible
- Replace the previous helper-call validator approach with explicit
unary customization hooks: `_build_kernel_instance(...)` and
`_resolve_output_dtype(...)`
- Let `LogicalNotFwdOp` override those hooks for the bool-storage path
while still exposing public `OUTPUT_DTYPE = torch.bool`
- Tighten `validate_manifest.py` source lookup so it locates the exact
class `__init__` AST node instead of relying on broader helper-call
traversal
- Update bool-like elementwise dtype coverage to assert
comparison/logical kernels expose `torch.bool` as their public output
dtype

## Problem
#1705 refactored unary elementwise setup so `UnaryOp.__init__` reached
`dispatch_kernel(...)` through `_prepare_unary_instance(...)`. That made
the runtime behavior work, but it broke the S13 manifest invariant: the
validator expects each op constructor to expose dispatch directly from
`__init__`.

The first version of this PR taught the validator to chase
`self.<helper>()` calls. After Ibuki's review, we changed direction
because that made the validator more permissive than the contract we
actually want. The better fix is to keep dispatch explicit in the op
constructor and move only the customization points into helpers.

Separately, op tests exposed that bool-like comparison/logical kernels
should advertise the public torch dtype (`torch.bool`) even when their
internal storage path uses an integer/uint8 representation.

## Fix
`UnaryOp.__init__` now performs the dispatch in place again:

- `_build_kernel_instance(...)` prepares the kernel instance
- `_resolve_output_dtype(...)` resolves the public output dtype
- `dispatch_kernel(kernel_map)` remains directly visible in `__init__`

`LogicalNotFwdOp` customizes the two hooks it actually needs instead of
routing the whole constructor through a dispatch helper. The manifest
validator no longer needs to follow arbitrary helper calls for S13, and
the regression test now rejects helper-only dispatch.

The bool-like elementwise dtype test now documents the public contract:
comparison and logical kernels expose `torch.bool`; any uint8/int
storage detail is internal to the implementation.

## Test plan
- [x] `pytest -q
tests/ops/test_elementwise_config_dtype.py::test_bool_like_elementwise_kernels_expose_torch_dtype_output`
- [x] `pytest -q
tests/test_validate_manifest.py::TestStrictParityC5Dispatch`
- [x] `python3 scripts/validate_manifest.py`
- [x] `python3 -m ruff check scripts/validate_manifest.py
tests/test_validate_manifest.py
tests/ops/test_elementwise_config_dtype.py`
- [x] `python3 -m py_compile scripts/validate_manifest.py`
- [x] `git diff --check`
2026-07-15 14:18:01 +08:00
..
ci [CI] retire run-local venv across CI; install via image-baked stack (#1606) 2026-06-24 13:22:59 +08:00
conftest_warmup.py [Refactor] Rename base modules to <module>_base.py convention (#950) 2026-04-13 18:13:32 +08:00
dep_hash.py [Fix][CI] Install external baseline libraries in nightly benchmarks (#673) 2026-03-26 15:06:45 +08:00
gpu_smoke_report.py [CI] Add gpu smoke workflow summary report (#764) 2026-04-02 17:23:37 +08:00
manifest_stats.py [Refactor][CI] retarget README badges to spec / bench coverage (#1470) 2026-05-15 17:41:52 +08:00
nightly_report.py [Bench] Add FA3/FlashInfer baselines across all attention benchmarks (#734) 2026-04-01 11:40:17 +08:00
test_node_delta.py [Test][Softmax] Add non-aligned edge-case shapes for softmax-family ops (#914) 2026-04-12 11:17:34 +08:00
validate_manifest.py [Fix][Manifest] Keep UnaryOp dispatch visible to validator (#1708) 2026-07-15 14:18:01 +08:00
warmup_kernel_cache.py [Fix][Benchmark] Add serial validation to correct noisy autotune configs (#773) 2026-04-03 13:27:42 +08:00