Skip to content

test(autograd): cover chained reshape and Qwen LoRA gradients - #6

Merged
BESTTOOLBOX merged 2 commits into
Edge-Intelligence-Lab:codex/fix-reshape-double-gradfrom
AndyLu666:codex/reshape-gradient-regressions
Oct 15, 2026
Merged

BESTTOOLBOX merged 2 commits into
Edge-Intelligence-Lab:codex/fix-reshape-double-gradfrom
AndyLu666:codex/reshape-gradient-regressions

Conversation

@AndyLu666

Copy link
Copy Markdown
Contributor

Adds regression coverage for the duplicate ops::reshape backward registration reported in #5, on top of Johnny's fix in #4.

This is a stacked PR targeting codex/fix-reshape-double-grad at 00c8059001eea3bed37695374ccbc67e748c562d. The diff contains tests and their CMake entries only; the runtime fix remains Johnny's commit. After #4 merges, this PR can be retargeted to its destination branch.

  • Covers 15 analytic cases: chained reshape, residual branches, legitimate repeated inputs, transpose followed by reshape, frozen inputs, and LoRA A/B gradients.
  • Checks every element of all 16 LoRA tensors (448 elements) in a small two-layer Qwen model against two central finite differences, with nonzero A/B, finite-value and layout checks.
  • Registers both tests for the new autograd engine. No model downloads, pretrained weights or additional dependencies are required.

Validation on macOS:

  • Release with warnings-as-errors enabled, BLAS disabled: 31/31 CTests pass, including LoRAStepAlignment.
  • BLAS enabled with assertions retained: 31/31 CTests pass, using the current SDK's ACCELERATE_NEW_LAPACK interface and the repository's default warnings-as-errors OFF setting.
  • Restoring only the old duplicate registration in an isolated copy makes all three targeted tests fail: 9 analytic cases, 446/448 Qwen gradient elements, and the original LoRAStepAlignment mismatch (max_abs_diff=0.30073). All 160 Qwen forward logits remain identical.
cmake -S operator -B build_release -DCMAKE_BUILD_TYPE=Release -DOPERATORS_WARNINGS_AS_ERRORS=ON
cmake --build build_release -j4
ctest --test-dir build_release --output-on-failure

cmake -S operator -B build_blas -DCMAKE_BUILD_TYPE=Release -DUSE_BLAS=ON -DOPERATORS_WARNINGS_AS_ERRORS=OFF -DCMAKE_CXX_FLAGS=-DACCELERATE_NEW_LAPACK -DCMAKE_CXX_FLAGS_RELEASE='-O3 -UNDEBUG'
cmake --build build_blas -j4
ctest --test-dir build_blas --output-on-failure

Existing build limitation: BLAS ON plus warnings-as-errors still fails on unused fallback helpers in the unchanged ops.cpp; the old SDK interface also emits deprecation diagnostics. This PR does not change those unrelated functions or claim that strict BLAS combination passes. Android/SDK CI results will be reported separately from the local C++ checks.

@BESTTOOLBOX
BESTTOOLBOX merged commit 6d8d53d into Edge-Intelligence-Lab:codex/fix-reshape-double-grad Oct 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants