Commit Graph

2 Commits

Author SHA1 Message Date
Cao Ying d81ec1f5ef
[Test][Softmax] Add non-aligned edge-case shapes for softmax-family ops (#914)
## Summary

Add targeted edge-case test shapes that exercise the M×N non-aligned
combination for softmax-family kernels, covering single-tile and
multi-tile (large-N) paths.

Closes #906

## Changes

**Tests** (`tests/ops/test_softmax.py`):
- 3 new shapes per fixture (SoftmaxFixture, LogSoftmaxFixture,
LogSumExpFixture):
  - `(33, 300)` fp32 — both M and N non-aligned, single-tile path
- `(33, 33000)` fp16 — both M and N non-aligned, multi-tile with masked
loads
  - `(33, 32768)` fp16 — non-aligned M with large-N tiled path

**Scripts** (`scripts/test_node_delta.py`):
- Fix base-ref collection: write temp file in original directory instead
of `/tmp/` so pytest can resolve project imports

**Foundry** (`.foundry/mold/pre-create-checks.md`):
- Add test node delta as pre-create check #3 (soft gate) with correct
`--base upstream/main` command

## Test plan

- [x] AC-1: All 126 tests pass (`pytest tests/ops/test_softmax.py`)
- [x] AC-2: New shapes exercise non-aligned M×N paths (single-tile and
multi-tile)

## Test node delta

```
File                         Base    HEAD    Delta
--------------------------------------------------
tests/ops/test_softmax.py     117     126       +9
--------------------------------------------------
TOTAL                         117     126       +9

Growth: +7.7%
```

Justification: 9 new `pytest.mark.full` nodes (3 shapes × 3 fixtures).
Each shape targets a distinct non-aligned code path not covered by
existing aligned shapes. No cross-dtype expansion (existing fixtures
already cover fp32/fp16/bf16 on aligned shapes; the non-aligned path
shares the same tiling/masked-load logic across fp16 and bf16).

## Follow-up

No follow-up issues or suggestions.

---------

Co-authored-by: Ibuki 🍃 — a wind born from Claude Opus <Ibuki-wind@users.noreply.github.com>
2026-04-12 11:17:34 +08:00
Cao Ying 20170a617d
[Chore][Testing] Add unit-test policy and test node growth detection script (#761)
## Summary

Define a unit-test policy for operator tests and provide a local script
(`scripts/test_node_delta.py`) that reports test node count delta for
touched files in a PR, making growth visible and justifiable.

Closes #760

## Changes

**M1 — Unit-test policy**
- Added Unit-Test Policy section to `docs/testing.md` covering: allowed
UT purposes, dtype risk class rule, shape coverage rule, manifest
separation, growth justification
- Added `.claude/rules/testing-budget.md` with concise agent-enforceable
version
- Verified policy is consistent with existing smoke/full tier system in
`tests/conftest.py`

**M2 — Growth-detection script**
- Created `scripts/test_node_delta.py` that compares test node counts
between current branch and main
- Added usage instructions to `docs/testing.md`
- Added note in `.claude/rules/testing-budget.md` about running script
and justifying growth

## Test plan

- [x] **AC-1-1**: docs/testing.md contains a Unit-Test Policy section
with dtype risk class, shape coverage, manifest separation, and growth
justification rules
- [x] **AC-1-2**: .claude/rules/testing-budget.md exists and is loadable
by Claude Code
- [x] **AC-1-3**: Policy does not contradict existing tier enforcement
in tests/conftest.py
- [x] **AC-2-1**: Script runs successfully on the current repo and
reports node counts for at least 3 existing test files
- [x] **AC-2-2**: Script correctly detects delta when a test file has
more nodes than its main branch version
- [x] **AC-2-3**: Script exits 0 regardless of delta (non-blocking)
- [x] **AC-2-4**: Script handles new test files (no main branch version)
without error
- [x] **AC-2-5**: docs/testing.md documents how to run the script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 12:08:16 +08:00