Repository navigation
Fix Q-GaLore quantization of single-sign groups - #10841
danielhanchen merged 4 commits into
Conversation
1cf562c to
f71616c
Compare
f71616c to
c5b8b09
Compare
|
Confirmed this hits unsloth/optimizers/q_galore_projector.py where a group with no sign change gets a zero point clamped outside its own range and collapses to a single value, and including zero in both quantizers is the right fix. Will get this reviewed. |
… allow Two changes to the new job. Run it across three bitsandbytes versions instead of one. pyproject.toml allows `bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0` with no upper bound, and `Optimizer2State.__init__` is not signature-stable across that range: 0.50.0 removed `percentile_clipping` and `block_wise`, so positions 10 and 11 became `max_unorm` and `skip_zeros`. A job pinned to a single version tests one point of that range. The matrix picks the three that differ: 0.45.5 the floor, and the version 8 pyproject extras hard-pin 0.49.2 last release with percentile_clipping / block_wise 0.50.2 first release without them, and the first with CPU optimizer kernels Drop `--confcutdir=tests/utils`. tests/conftest.py is the GPU-free harness, and this file loads unsloth/optimizers/*.py through importlib specs rather than importing the unsloth package, so it neither needs the spoof nor is disturbed by it. Checked both ways: 42 passed with the repo conftest, 42 passed without. The flag made this the only job in the repo running under a different conftest boundary, for no effect.
|
Reviewed and verified on hardware. The bug is real, the fix is correct, and I measured no regression anywhere. I pushed one change to the branch, to the workflow only. What happens before and afterThe quantizer is AWQ's
End to end,
A relative error of 1.0 means the gradient is entirely destroyed. Note the random rows: the ordinary path gets slightly better, not worse. Does it break anythingNo. I swept 132 round-trip cases, the cartesian product of 11 input shapes (all positive near zero, all positive far from zero, all negative, constant positive, constant negative, all zero, mixed sign, mixed asymmetric, tiny magnitudes, large magnitudes, single value) x Zero cases get worse on either device. Stochastic rounding stays unbiased over 4000 seeded draws. On the alternative fixThe other way to make the scale and the zero point agree is to stop clamping the zero point. I checked, and it is the worse option. The cost is real but bounded and it is strictly an improvement over what is there. A narrow group far from zero, What I pushedTwo changes to Dropped Added a bitsandbytes version axis, One merge note: all three add an identical Approach is right, fix is right. Good catch on a bug that silently zeroed the projection. |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…their own (#10898) #10841 added .github/workflows/q-galore-tests.yml to give tests/utils/test_q_galore.py a home, because `Repo tests (CPU)` passes --ignore=tests/utils and the file therefore ran in no job at all. A whole workflow is the wrong shape for that. This drops it and adds the file to the Bucket-A list in consolidated-tests-ci.yml, which exists for exactly this case: CPU-runnable tests that live inside the --ignore'd directories. Added in both places that list has to stay in sync, the collect-only sanity step and the Bucket-A pytest step. That job already installs bitsandbytes>=0.45, so the optimizer tests resolve the same way they did in the standalone workflow. The deleted workflow ran pytest with --confcutdir=tests/utils. Nothing needs it: test_q_galore.py loads unsloth/optimizers/*.py through importlib specs rather than importing the unsloth package, so the GPU-spoof conftest neither helps nor hinders it. Checked, 34 passed under the repo conftest, which is how the Bucket-A job runs it. Also corrected the Bucket-A count in the header comment and the summary echo. Both said 21; the list held 23 before this change and 24 after.
Q-GaLore can erase constant projection vectors and clip single-sign groups: INT4 quantization turns
[1, 2]into[1, 1].Cause: The scale excludes zero, but the zero point is clamped to the unsigned integer range.
Fix: Include zero in both quantizers' ranges.
Test:
python -m pytest --confcutdir=tests/utils tests/utils/test_q_galore.py -q: 10 failed / 24 passed before, 34 passed after. Covers INT4/INT8, deterministic/stochastic rounding, grouped quantization, and a rank-one gradient round trip.A dedicated CPU job now runs this previously excluded file with Python 3.12, torch 2.10.0 and bitsandbytes 0.50.2. Core/Backend failures also occur on unchanged main.