Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
run: |
python -m pytest tests/test_kv_cache_attention.py -v -k "not large and not gpu"

- name: Run WS2 Logprob Contract Tests (CPU-safe)
run: python -m pytest tests/test_logprob_contract.py -v

docs:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 8 additions & 0 deletions docs/design/runtime-dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ logical type, and the registry selects the first available backend for the curre
4. Cache successfully constructed operator instances.
5. Skip backends that already failed in the current process.

WS2 TP-aware logprob uses the stricter `KernelRegistry.get_logprob_op(contract)` path. In
addition to platform priority, this path requires a backend capability descriptor and checks
the requested role, dtype, TP/CP layout, padded-vs-real vocab masking, inactive-token
support, vocab-domain LSE export, and deterministic TP merge semantics. Incompatible
candidates produce explicit rejection reasons and are never used as an undeclared fallback.
The contract objects and their normative reduction semantics are documented in
`rl_engine.kernels.logprob_contract`.

## LogP Priority

| Platform | Priority |
Expand Down
14 changes: 14 additions & 0 deletions docs/operators/batch-invariant-logp.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ not compiled, instantiation fails and dispatch falls through to PyTorch native.
bf16/fp32 NPU tensors run the Ascend C kernel; anything else (e.g. fp16)
silently falls back to the native op.

### WS2 TP-aware dispatch

WS2 distributed callers use a separate contract-aware entry point,
`kernel_registry.get_logprob_op(contract)`. It validates explicit vocab-shard ownership,
padded-vs-real vocab metadata, active-token masking, and fixed `(max, sumexp)` merge
semantics before selecting a backend. Legacy `get_op("batch_invariant_logp")` behavior
remains unchanged.

The backends above are single-shard (TP=1) references and do not yet export vocab-domain
LSE or carry vocab-shard metadata, so they are declared incompatible with strict WS2
requests instead of being selected as a silent fallback. The Ascend backend is likewise
undeclared for WS2, so it is rejected with an explicit reason rather than silently
selected. The contract objects are documented in `rl_engine.kernels.logprob_contract`.

## Benchmarks

`benchmarks/benchmark_batch_invariant_logp.py` compares Native, Triton when
Expand Down
Loading