Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
why1te
force-pushed
the
dsv4-p1-dev
branch
3 times, most recently
from
September 16, 2026 08:20
bbaa792 to
ccc7b1a
Compare
Signed-off-by: why1te <youngtingwang@gmail.com>
Keep the RMSNorm gain in FP32 as confirmed with the maintainer. Previously the BF16 storage path discarded gain bits before the operator's FP32 math. Implementation: - Change NormParams validation and seeded fixtures to FP32 gamma. - Read gamma through float pointers in CUDA forward and input-gradient kernels; update Triton dtype validation without changing reduction order. - Preserve BF16 activations, upstream gradients, normalized/residual outputs, and FP32 explicit dx/dgamma. Autograd returns BF16 x.grad and FP32 gamma.grad. - Update gtest/benchmark input generation and record benchmark gamma dtype. - Adapt direct callers to the oracle backward signature without x; keep provider/backend interfaces with explicit x through the reference adapter. - Add tests using gamma=1+2**-10 to detect premature BF16 rounding in both forward and backward, plus dtype validation and gradient-precision checks. Golden migration: - Regenerate the CPU-oracle manifest for the approved FP32 input contract. - Update 59 hashes: normalized outputs and gamma-dependent upstream gradients in five block fixtures, plus y/grad.dx in rms_edges. - Leave Sinkhorn-edge, residual, and dgamma hashes unchanged and retain strict manifest equality; no candidate output is used as a golden value. - The migration validation recorded in the original refresh commit rounded gamma through BF16 in a diagnostic process and reproduced the entire old manifest. No diagnostic rounding was added to production code or tests. H100 PCIe validation (PyTorch 2.8.0+cu128, Triton 3.4.0, CUDA 12.8): - uv run --no-sync python -m pytest tests/test_rmsnorm_residual.py tests/test_rmsnorm_residual_triton.py -q -rs: 28 passed in 7.89s. - uv run --no-sync python -m pytest tests/test_rmsnorm_residual_gamma_precision.py -q: 4 passed in 2.63s. - uv run --no-sync python -m pytest tests/test_p1_oracle.py tests/test_p1_provider.py tests/test_operator_inputs.py tests/test_kernel_registry.py -q: 77 passed in 2.16s, including the anchor. - check_operator.py for cuda and triton at T=16/D=4096 with --check-grad: both passed, zero reported errors, gamma gradient FP32. - check_p1.py for both providers: all boundaries byte-equal in all five cases. - Benchmark at T=32768/131072/262144, D=4096, 50 warmup/1000 iterations: both candidates byte-equal to the oracle before timing; CUDA combined speedup 1.27-1.31x versus torch-native on these measured workloads. Squashes the FP32 implementation and reviewed golden refresh into one atomic contract migration. The source tree is unchanged from 6b24500. Signed-off-by: why1te <youngtingwang@gmail.com>
Document public and explicit APIs, FP32 gamma and gradient boundaries, fixed-order arithmetic, backend dispatch, validation commands, H100 results, and rank-local limitations. Add the operator page to the documentation index and navigation. Validation: Python and shell example syntax, YAML navigation, and git diff checks passed. Full MkDocs build not run because MkDocs is not installed in the local environment. Signed-off-by: why1te <youngtingwang@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[DSv4][P1-5] rmsnorm_residual
Summary
Implements P1-5
rmsnorm_residualfrom #383, targetingdsv4-p1-dev. Adds CUDA/Triton forward and backward, autograd, registry fallback, and P1 providers.The operator returns RMS-normalized output plus a copy of the original input—not
RMSNorm(x + residual). Both backends pass bitwise oracle alignment and P1 acceptance on H100.Implementation
dx/dgamma. Autograd returns BF16x.gradand FP32gamma.grad.D=4096in production;D=128for fixtures;eps=1e-6.rsqrt(mean(x²) + eps),(x * r) * gamma, ascending FP32 reductions, and separate rounding. No atomic reductions, Split-K, or Stream-K. Residual copying does not change the reduction layout.Operator documentation:
docs/operators/rmsnorm-residual.md.Validation environment
Correctness / Tests
Coverage:
T={1,7,16},D={128,4096}; byte-equal forward/backward and saved state, edge values, strided inputs, repeatability, batch/padding invariance, both autograd branches, invalid inputs, and FP32 gamma rounding regressions.gtest
Both report
passed=True pass_rate=1.0000. Maximum absolute and relative errors are 0 for both outputs, BF16x.grad, and FP32gamma.grad.P1 acceptance
Both report
RESULT: PASS (all boundaries byte-equal)for all five cases:one_row,packed_t16,packed_t7_odd,fused_pre_norm, andmixer_frozen.Benchmarks
H100 PCIe,
D=4096, BF16 activations, FP32 gamma/explicit gradients; CUDA-event mean, eager execution, no CUDA Graphs. The script runs all three backends; both candidates pass pre-timing bitwise checks. CUDA versus torch-native forward + backward results:CUDA forward speedup is 1.62–1.63×; combined peak extra allocated memory is approximately 71.4% lower. Memory is the allocator peak above the live baseline, not total GPU usage. Torch-native uses vectorized reductions and is a performance baseline, not the fixed-order oracle. Results apply to these measured workloads.
Kernel PR checklist
Follow PR #204.
MHCProvidercheck_p1.pypassing result