You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once WS1 operator implementations and ground-truth paths (#108, #145–#151) are largely in place, remaining work is no longer “write another op.” It is to close contract axes, path consistency, cross-op backward audit, and the end-to-end exit gate before WS2.
This issue is the unified description and acceptance entry point for that closing work. Execution is owned by four existing issues:
“Aligned” is meaningless without a pinned dtype set. RL training runs in BF16; FP32 is the tolerance / gold reference. The dtype axis must be locked first, or each op validates under a different set and chain-level guarantees are empty.
Rollout uses decode; training uses prefill. The same token can get different logprobs under different reduction orders. Decode must be covered explicitly—not only via chunked-prefill.
Forward alignment is not enough. Gradient reductions that drift with batch shape break training. Backward must be a first-class tested property.
All ops green ≠ full chain invariant. Drift appears at op boundaries, dtype handoffs, and chunked-prefill / padding interactions. [WS1] Chain integration test (WS1 exit gate) #150 is the real WS1 exit gate.
Sole definition of “aligned”
All pass/fail decisions use only the #108 harness and tolerance_contract.json (extended by #154). No private threshold tables.
The contract must distinguish four judgments:
Judgment
Meaning
forward_accuracy
Candidate vs strict FP32 / reference
forward_invariance
Same-dtype output invariance across batch / layout / path configs
gradient_accuracy
Candidate VJP/grad vs reference
gradient_invariance
Same-dtype gradient invariance across equivalent configs
Gradient thresholds must not silently inherit forward thresholds.
Goals
Finalize the dtype axis of the numerical contract so every WS1 op validates against the same pinned set.
Prove prefill ↔ decode (including generate-then-re-score) numerical consistency on the KV-cache path.
Make batch-invariant backward a reusable harness property required for every WS1 op.
Merged implementation · registered reference/candidate · forward compliant with #154 · backward compliant with #153 where applicable · unresolved failures have a linked blocker
Workstream 4 — #150 Chain integration test (WS1 exit gate)
Assignees:@maxiaosong1124@EthanZero2Hero@Flink-ddd Suggested duration: 1–1.5 weeks (assembly + sweep + diagnostic + CI; buffer for cross-op boundary drift) Close condition: All hard deps green with handoff-matrix evidence — last WS1 issue to close
Scope
Assemble all WS1 ops into one end-to-end forward + backward pass and assert invariance across the config matrix.
Standard Transformer forward topology (CI tiny model may shrink layers/hidden size, but topology and semantics must not be cut):
token embedding
→ RMSNorm → Q/K/V → QK-Norm (if required by fixed model) → RoPE
→ attention → out proj → residual
→ RMSNorm → MLP gate/up → SwiGLU → down → residual
→ final RMSNorm → LM head → selected logprob → masked loss
Config sweep:
Axis
Comparison
batch
1 vs N
chunked-prefill
on vs off
padding
multiple layouts
packing
packed vs unpacked where supported
dtype
#154 pinned set (BF16 e2e minimum; FP32 reference path)
Planned PRs
ID
Description
150-PR1
Pin fixed workload manifest + topology-correct BI forward chain
150-PR2
Full backward through the same chain
150-PR3
batch / chunked-prefill / padding / packing sweep
150-PR4
First-drift diagnostic (max abs/rel + first failing op)
150-PR5
CI small model + GPU/backend provenance as WS1 regression gate
Gate report must include: requested_backend / actual_backend, device/CC, dtype, model/workload ID, seed, config transform, fallback reason, max abs/rel, first failing layer/op. Silent fallback to reference = fail (unless the contract explicitly permits and labels it). A CPU-only green run cannot certify the GPU WS1 gate.
Hard dependencies (all required before closing #150)
#108 harness + contract (including #154 dtype axis)
#145 RMSNorm #146 GEMM #147 Attn #148 Logprob
#149 RoPE/elementwise #151 Embedding + LM head
#152 KV prefill/decode
#153 bwd harness + each op bwd green
└──→ #150 EXIT
Summary
Once WS1 operator implementations and ground-truth paths (#108, #145–#151) are largely in place, remaining work is no longer “write another op.” It is to close contract axes, path consistency, cross-op backward audit, and the end-to-end exit gate before WS2.
This issue is the unified description and acceptance entry point for that closing work. Execution is owned by four existing issues:
Background and motivation
Sole definition of “aligned”
All pass/fail decisions use only the #108 harness and
tolerance_contract.json(extended by #154). No private threshold tables.The contract must distinguish four judgments:
forward_accuracyforward_invariancegradient_accuracygradient_invarianceGradient thresholds must not silently inherit forward thresholds.
Goals
Non-goals (explicitly out of scope)
Ownership boundary
Per-row readiness for the #150 gate:
Merged implementation · registered reference/candidate · forward compliant with #154 · backward compliant with #153 where applicable · unresolved failures have a linked blocker
Dependencies and execution order
Close dependency:
Live status lives only in
ws1-handoff-matrix.md. When a row flips green/red, leave a short comment on #202 and #150 with an evidence link.Workstream 1 — #154 dtype coverage (blocking pin)
Assignees: @Flink-ddd @maxiaosong1124 @EthanZero2Hero
Suggested duration: 2–4 days · 3–5 small PRs
Scope
Planned PRs
tolerance_contract.jsonfour judgments + per-dtype rowscheck_operator.pyuse the same dtype setAcceptance
Repo docking
rl_engine/kernels/gtest/tolerance_contract.jsonrl_engine/kernels/gtest/tolerance.pytests/test_tolerance_contract.pyWorkstream 2 — #152 KV-cache path consistency
Assignee: @zhangj1an
Related PR: #178 (WIP)
Suggested duration: ~1 week (including #178 close-out + generate-rescore + CI smoke)
Scope
Ensure prefill and decode produce the same reductions for the same effective context:
Stateful validation levels
Planned PRs
Acceptance
Repo docking
rl_engine/kernels/ops/pytorch/attention/kv_cache.py(Level A only)tests/test_kv_cache_attention.pyrl_engine/testing/kv_consistency.py(B1 entry point)Workstream 3 — #153 Backward-pass consistency
Assignees: @maxiaosong1124 @EthanZero2Hero @Flink-ddd
Suggested duration: 1–1.5 weeks (harness / audit / matrix / CI; kernel fixes tracked under #145–#151)
Scope
Make batch-invariant backward a required, tested property of every WS1 op:
gradient_*rows)dx/dweight/dW…) uses a fixed, batch-shape-independent order — noatomicAddin backwarddweight→ GEMMdW/dX→ attention bwd → embedding-grad scatter → remaining opsLogical-workload identity (must hold before comparison)
(sample_id, token_position)before comparePlanned PRs
atomicAdd/ fixed-order rule (docs + checklist + optional guards)Target harness API:
Acceptance
atomicAddor shape-dependent accumulation in backwardRepo docking
rl_engine/kernels/gtest/op_checks.py(check_grad→ cross batch-config invariance)operator_specs.pygrad_input_namestolerance_contract.jsongradient_*rowsWorkstream 4 — #150 Chain integration test (WS1 exit gate)
Assignees: @maxiaosong1124 @EthanZero2Hero @Flink-ddd
Suggested duration: 1–1.5 weeks (assembly + sweep + diagnostic + CI; buffer for cross-op boundary drift)
Close condition: All hard deps green with handoff-matrix evidence — last WS1 issue to close
Scope
Assemble all WS1 ops into one end-to-end forward + backward pass and assert invariance across the config matrix.
Standard Transformer forward topology (CI tiny model may shrink layers/hidden size, but topology and semantics must not be cut):
Config sweep:
Planned PRs
Suggested entry points:
python scripts/ws1_chain_gate.py --model tiny-bi-transformer --dtype bfloat16 --seed 0 # or pytest tests/test_ws1_chain_integration.py -qGate report must include:
requested_backend/actual_backend, device/CC, dtype, model/workload ID, seed, config transform, fallback reason, max abs/rel, first failing layer/op.Silent fallback to reference = fail (unless the contract explicitly permits and labels it). A CPU-only green run cannot certify the GPU WS1 gate.
Hard dependencies (all required before closing #150)
Acceptance
Suggested schedule
Parallelism notes:
Cross-issue Definition of Done
#154
#152
#153
atomicAdd/ no shape-dependent bwd accumulation#150
Risks and external phrasing