Skip to content

fix(eora): keep generated adapter tensors for repeated saves - #5446

Merged
Qubitium merged 1 commit into
mainfrom
fix/5354-eora-repeat-save
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/5354-eora-repeat-save

Conversation

@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator

Summary

Fixes #5354.

An EoRA-quantized model could be saved only once. _eora_save() exported the generated adapter and then deleted self.lora_results, the only in-memory copy. A second save() wrote the new base checkpoint and then failed at the hasattr(self, "lora_results") assertion, leaving the destination without an adapter.

What Changed

  • gptqmodel/models/writer.py: stop deleting lora_results after an adapter export. The EoRA pass stores CPU-resident A/B tensors on the model; they now live for the model's lifetime, so every save() re-exports the same payload with a destination-specific adapter_config.json.
  • gptqmodel/looper/eora_processor.py: document that the generated adapters are model-lifetime state.
  • tests/test_eora_repeat_save_5354.py: writer-level regression (two exports from one result map) and an end-to-end regression (quantize once, save twice to distinct base/adapter destinations, compare both adapter payloads, and reload both exports for logits parity).

The suggested staged/preflight export is not needed for this failure: the writer now always retains the payload it exports. Arbitrary adapter I/O failures are unchanged and out of scope.

Tests

Red (pre-fix, both new tests):

python -m pytest tests/test_eora_repeat_save_5354.py -q -ra
# 2 failed; both hit AssertionError at gptqmodel/models/writer.py:2047

Green (post-fix):

python -m pytest tests/test_eora_repeat_save_5354.py -q -ra
# 2 passed

python -m pytest tests/test_eora_repeat_save_5354.py tests/test_adapter_case_sensitive.py tests/test_adapter_scaling.py tests/test_save_kwargs_validation_4686.py tests/test_auto_adapter_generate.py -q -ra
# 30 passed

bash format/check.sh
# All checks passed!

No hardware-dependent skips: the regressions are deterministic and run on CPU.

Model Support / Module Plan

Not applicable: no model definitions, aliases, module plans, or fusion changes.

AWQ onboarding safety

Not applicable: no model/definition/AWQ changes.

Logic Flow Documentation

  • This change does not alter a major logic flow, or the required diagrams and docs page are included below.
  • New-flow Mermaid diagram(s) describe the shipped code using real symbol names.
  • The removed/replaced mechanism is shown or tabulated with file:line evidence.
  • Failure and ambiguity paths are marked and visually distinct from success.
  • A reference page under docs/ repeats the diagrams, titled for the mechanism, and is linked from README.md.

Diagram summary: local persistence-state fix. The EoRA export still runs at the same call site with the same inputs; only the post-export deletion of the payload is removed. No stage, selection order, dispatch, or failure-path decision changed.

Review Requirements

AI-assisted code is welcome. Open the PR as a draft. Mark it ready only after review and after GitHub confirms the pushed head has no conflicts with the current remote base.

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: no kernel or fusion changes.

Notes

The retained payload is the CPU adapter tensor set already produced by the EoRA pass, the same bytes previously exported. It is released with the model; there is no API, config, or checkpoint-layout change.

@ZX-ModelCloud
ZX-ModelCloud marked this pull request as ready for review November 19, 2026 05:46
@Qubitium
Qubitium merged commit 45ab52c into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/5354-eora-repeat-save branch November 19, 2026 06:11
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.

[BUG] Saving an EoRA-quantized model twice fails after writing the second base checkpoint

2 participants