Skip to content

fix(eora): keep zeroed eigenspace out of leading SVD columns - #6671

Merged
Qubitium merged 1 commit into
mainfrom
fix/eora-svd-leading-zero-columns
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/eora-svd-leading-zero-columns

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

EoRA quantization aborts on GB10 (aarch64) inside the float32 SVD.
eora_compute_lora zeroes eigenvalues below the numerical-rank cutoff, and
because eigh sorts ascending, those zeroed columns are at the front of the
matrix passed to torch.linalg.svd. PyTorch's aarch64 build links NVIDIA NVPL
LAPACK, whose sgesdd aborts on leading all-zero columns (SLASCL parameter number 4 had an illegal value) and then SIGBUS/heap corruption. This is the
crash behind the GB10 failures of the #5354 and #4307 test files.

No issue number: this was found by a GB10 regression sweep, not filed upstream.

What Changed

  • eora_compute_lora now moves the retained eigenspace columns to the front of
    the SVD input and applies the same column permutation to
    scaling_matrix_inv. The permutation is mathematically neutral; on the
    9-mode control used by the regression, a float64 run of the old and new
    layouts produces a bit-identical B @ A.
  • Added a subprocess regression in tests/test_eora.py that reproduces the
    64x64 rank-9 layout, so the native abort is reported as a failed exit status
    instead of taking pytest down.

No API or behavior change beyond the SVD input layout.

Tests

# Branch (GB10, CPU)
PYTHONPATH=$PWD /root/gptqmodel-work/venv/bin/python -P -m pytest -q \
  -p no:cacheprovider -p no:xdist \
  tests/test_eora.py tests/test_eora_repeat_save_5354.py \
  tests/test_generator_calibration_4307.py
# 15 passed

# Branch, related EoRA family
PYTHONPATH=$PWD /root/gptqmodel-work/venv/bin/python -P -m pytest -q \
  -p no:cacheprovider -p no:xdist \
  tests/test_eora_calibration_rows_5719.py tests/test_eora_merge.py
# 9 passed, 1 skipped (CUDA-only test)

# Branch lint
bash format/check.sh
# ruff 0.14.2; All checks passed!

Red evidence on origin/main (0127a0313) with the same interpreter, no xdist:

python -P -X faulthandler -m pytest -q -s \
  -p no:cacheprovider -p no:xdist tests/test_eora_repeat_save_5354.py
# exit 1 after 1 passed: "STOP 1" /
# "** On entry to SLASCL parameter number 4 had an illegal value"

python -P -X faulthandler -m pytest -q -s \
  -p no:cacheprovider -p no:xdist tests/test_generator_calibration_4307.py
# exit 139 (SIGSEGV) after 1 passed: same SLASCL abort

python -P -m pytest -q -p no:cacheprovider -p no:xdist \
  tests/test_eora.py::test_eora_compute_lora_handles_leading_zero_columns
# 1 failed: child exited 1 with SLASCL parameter number 4

On GB10, the new regression passes on the branch and fails on main with the
native SLASCL abort, not an assertion about implementation details.

Numerical Validation

Method: captured the real w_wq_delta and covariance from a Qwen2.5-0.5B
EoRA run (same 8 wikitext texts, bits=4/g128, Lora(rank=8)) for 12 modules.
All variants were applied to the same captured inputs:

  • ref: old layout, float64 SVD.
  • main: old layout, float32 SVD (the pre-fix path).
  • branch: current permutation, float32 SVD.
  • slice: variant 2, removes the zeroed eigen-columns before the SVD and
    maps the reduced right singular vectors back through scaling_matrix_inv.

Metrics are against ref; relF is ||X - ref||_F / ||ref||_F.

layer retained sigma9/sigma8 main max main relF branch max branch relF slice max slice relF
0.mlp.down_proj 675 0.986956 2.313e-06 1.550e-04 2.368e-06 2.222e-04 2.378e-06 1.823e-04
0.self_attn.q_proj 406 0.965155 1.165e-05 1.193e-04 8.980e-06 9.355e-05 7.529e-06 8.921e-05
3.mlp.up_proj 574 0.943511 3.706e-06 3.155e-05 2.875e-06 1.198e-04 2.841e-06 1.044e-04
5.self_attn.o_proj 510 0.990296 5.335e-06 1.849e-04 1.800e-06 1.357e-04 2.489e-06 1.358e-04
8.mlp.gate_proj 645 0.985993 4.575e-06 1.501e-04 9.828e-06 2.083e-04 6.087e-06 1.900e-04
10.mlp.down_proj 1008 0.999256 2.250e-05 2.489e-03 1.389e-05 1.639e-03 7.454e-05 8.262e-03
12.self_attn.k_proj 638 0.958932 4.286e-07 2.784e-05 6.274e-07 3.425e-05 4.298e-07 2.750e-05
15.self_attn.v_proj 591 0.989121 3.132e-07 3.396e-05 3.346e-07 3.141e-05 4.763e-07 5.582e-05
18.mlp.up_proj 556 0.980322 1.554e-06 1.131e-04 1.465e-06 1.361e-04 1.356e-06 1.474e-04
20.self_attn.q_proj 545 0.988451 5.022e-06 3.544e-04 8.741e-06 6.329e-04 2.957e-06 2.195e-04
22.mlp.gate_proj 562 0.979907 3.628e-06 9.714e-05 6.164e-06 1.595e-04 7.750e-06 1.982e-04
23.mlp.down_proj 129 0.970235 8.568e-07 1.207e-04 5.264e-07 1.318e-04 1.940e-07 3.368e-05

Main is slightly closest to the float64 reference on average (median relF
1.35e-4; branch 1.45e-4; slice 1.45e-4), but the branch is within float32 SVD
noise of main: the same-input main-vs-branch difference at the worst layer
(22.mlp.gate_proj) is 4.286e-6 max / 1.108e-4 relF. The saved-adapter
difference at that layer is 6.415e-3 max / 0.188 relF, i.e. propagation from
earlier near-degenerate subspace choices, not the layer's SVD error.
sigma9/sigma8 is 0.9435-0.9993 across the sample, so the rank-8 cutoff sits
in a near-degenerate pair; that is why a tiny basis change propagates.

The slice variant avoids the NVPL abort on the 64x64 rank-9 CPU repro (exit 0),
but it is not closer to the float64 reference and is worse on
10.mlp.down_proj (8.262e-3 relF vs 2.489e-3 main / 1.639e-3 branch), so it
was not chosen.

Seeded end-to-end quality check on GB10 GPU, Qwen2.5-0.5B-Instruct,
WikiText-2 test, fixed 512-token windows (80 windows, 40,880 scored tokens),
EoRA adapters loaded through GPTQModel.load:

Run WikiText-2 PPL
origin/main 21.8062
branch 21.8076

Difference: 0.0014 absolute / 0.0065% relative, equal within noise.

CPU/NVPL A/B: main aborts with SLASCL/exit 1 during EoRA quantization;
branch completes 168 adapters in 954.1 s. GPU quantization timings are 130.1 s
(main) and 130.6 s (branch).

Model Support / Module Plan

Not applicable: no model, alias, definition, module-plan, or fusion changes.

AWQ onboarding safety

Not applicable: no AWQ grouping, search, replay, or folding changes.

Logic Flow Documentation

This change does not alter a major logic flow or selection order. It only
reorders columns of the SVD input and the matching rows of
scaling_matrix_inv; the float64 control is bit-identical, so no diagram is
needed.

Review Requirements

I or an AI agent (such as Codex or Claude) have:

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable: this is EoRA host-side linear algebra, not a kernel. The SVD
layout was checked against a float64 reference on 12 real Qwen layers; the
branch is within float32 SVD noise of main, and WikiText-2 PPL is equal
(21.8076 vs 21.8062).

Notes

The proximate abort is in NVPL LAPACK. The fix avoids the degenerate
leading-zero-column layout in GPT-QModel's own SVD input rather than patching
the library. The branch is not measurably more accurate than main: main is
slightly closer to the float64 reference on average, but the branch's
same-input difference is within float32 SVD noise and WikiText-2 PPL is equal
within noise. The 6.4e-3 propagated adapter difference comes from the
near-degenerate sigma8/sigma9 pair at the rank-8 cutoff. The slice variant
avoids the abort but is not closer to the float64 reference, so it was
rejected. No x86 host was available for this run; the #5354/#4307 files passed
there before the sweep.

`eora_compute_lora` scales the eigendecomposition by sqrt(eigenvalue) and then runs a float32 SVD on the product. `eigh` sorts ascending, so every eigenvalue below the numerical-rank cutoff leaves an all-zero column at the front of the SVD input. PyTorch links NVPL LAPACK on aarch64 (GB10), whose `sgesdd` aborts on that layout ("SLASCL parameter number 4 had an illegal value", then SIGBUS/heap corruption), crashing EoRA quantization and the #5354/#4307 tests.

Move the retained eigenspace first before the SVD and apply the same column permutation to `scaling_matrix_inv`. The permutation leaves the singular values and the adapter unchanged (float64 control is bit-identical), while avoiding the all-zero leading columns. Add a subprocess regression that reproduces the 64x64 rank-9 layout so a native abort is reported as a failed exit status instead of taking pytest down.
@Qubitium
Qubitium force-pushed the fix/eora-svd-leading-zero-columns branch from f329321 to 91abcdf Compare December 1, 2026 17:26
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 17:45
@Qubitium
Qubitium merged commit b467cc3 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/eora-svd-leading-zero-columns branch December 1, 2026 17:46
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.

1 participant