Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
run: |
python -m pytest rl_engine/tests/test_dispatch.py -v
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest tests/test_attention_correctness.py -q -rs
python -m pytest tests/test_forward_invariance.py -q

- name: Run Attention Ground-Truth Tests (CPU-safe)
run: |
Expand Down
64 changes: 64 additions & 0 deletions docs/design/ws1-c3-269-closeout-evidence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# WS1 C3 (#269) closeout evidence

**Parent:** #266 · **Depends on:** #267 / #268 · **Scope:** shared forward harness only

## Acceptance map

| #269 criterion | Evidence |
| --- | --- |
| Accuracy and invariance separate | `ForwardInvarianceReport.accuracy_reports` and `invariance_reports` |
| Batch/chunk bitwise after logical unpadding | C1 `forward_invariance` resolver plus exact C2 logical-key validation |
| C2 transforms | `build_config_matrix`: fixed 2×2 matrix, permutation, packing, left/right padding |
| Diagnostics | tensor name, config pair, max/mean absolute error, max relative error |
| Backend provenance | profile, requested/actual backend, candidate/kernel id, device, CC, dtype, seed, fallback reason |
| Silent/cross-profile fallback | missing or mismatched provenance fails; CLI rejects candidate/profile mismatch |
| Selected-logprob smoke | C1 `max_abs_dlogp`, `approx_kl0`, and `clipfrac0` verdict |
| CUDA and Triton same schema | one API/CLI/report schema; both profile contracts are parametrically tested |
| No private thresholds | all tensor and aggregate thresholds resolve through the C1 contract |

CPU-safe contract regression:

```bash
python -m pytest -q \
tests/test_tolerance_contract.py \
tests/test_ws1_workload.py \
tests/test_forward_invariance.py \
tests/test_op_checks.py
```

Required-profile runtime examples (must run on CUDA hardware and must not be skipped):

```bash
python scripts/check_forward_invariance.py \
--op logp --candidate cuda \
--backend-profile cuda_bf16 --json

python scripts/check_forward_invariance.py \
--op batch_invariant_logp --candidate triton \
--backend-profile triton_cuda_bf16 --json
```

The CLI exits red when CUDA is unavailable, a candidate is absent, the C2 node is
`missing_required`, the compute capability cannot run a declared SM90 candidate, provenance
does not match the profile, or any accuracy/invariance/logprob verdict fails.

## Runtime verification

Verified on NVIDIA GeForce RTX 3060 Laptop GPU (`sm86`) with PyTorch 2.8.0+cu128:

| Gate | Result |
| --- | --- |
| Full pytest suite | `1524 passed, 121 skipped` |
| Full pre-commit | trailing whitespace, EOF, YAML, large-file, black, isort, flake8 passed |
| `cuda_bf16` / generic CUDA logp C3 matrix | passed; all invariance max-abs errors `0.0` |
| `triton_cuda_bf16` / Triton batch-invariant-logp C3 matrix | passed; all invariance max-abs errors `0.0` |
| CUDA operator accuracy check | passed, max absolute error `0.0287590` |
| Triton operator accuracy check | passed, max absolute error `9.536743e-07` |

The CUDA profile uses the manifest-declared generic CUDA logp candidate on SM86. No SM90
candidate or fallback path is claimed on this device.

## Parent boundary

This closes only C3. It supplies the report and canonicalization contract that C10 must reuse.
It does not claim the full-model, backward, KV-cache, or CI EXIT requirements of #266.
18 changes: 18 additions & 0 deletions rl_engine/kernels/gtest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 RL-Kernel Contributors

from .forward_invariance import (
AccuracyReport,
ConfigSpec,
ForwardInvarianceReport,
InvarianceReport,
LogprobSmokeResult,
TensorComparisonDetail,
assert_forward_batch_invariant,
build_config_matrix,
)
from .op_checks import CandidateSpec, OperatorCase, run_operator_suite
from .tolerance import (
BackendProvenance,
Expand All @@ -15,8 +25,16 @@
)

__all__ = [
"AccuracyReport",
"CandidateSpec",
"ConfigSpec",
"ForwardInvarianceReport",
"InvarianceReport",
"LogprobSmokeResult",
"OperatorCase",
"TensorComparisonDetail",
"assert_forward_batch_invariant",
"build_config_matrix",
"run_operator_suite",
"BackendProvenance",
"ContractError",
Expand Down
Loading