Repository navigation
Conversation
…mport Accelerate dispatch, stale guards Regressions found by re-auditing the accelerate removal (#6471): - Importing gptqmodel hid Accelerate from all of Transformers, so `TrainingArguments`/`Trainer` raised "requires accelerate" even with it installed (PEFT fine-tuning of GPT-QModel models broke). The isolation now executes only `transformers.trainer` / `transformers.training_args` with the real flag via a scoped import hook; loading, placement, generation and `load_adapter` stay isolated. - A plain-Transformers load that imports gptqmodel late (Optimum imports it inside the GPTQ quantizer, after `device_map` was accepted) got dispatched by Accelerate and then half-initialized by the bridge, which only understands weight_loader hooks. `hf_gptqmodel_post_init` now refuses Accelerate hooks with a pointer to `GPTQModel.load(placement=...)` (strict everywhere). - OSTQuant's lazy-shell guard still read `turtle_model`; it never fired. - Three unchanged tests still used LazyTurtle's private interface or a deleted test file. Cleanup: dead preexisting-hook plumbing in utils/offload.py (its setter went in #6494), unused `_split_dim_cache_key`, and stale docs/comments that still described Accelerate dispatch or LazyTurtle names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #6473 / #6494 (tracking: #6471). It comes from re-auditing the accelerate removal for completeness and regressions.
Regressions fixed
transformers.Trainerbroke in any process that importsgptqmodel, even with Accelerate installed (TrainingArgumentsraised "requires accelerate"). This also broke the PEFT fine-tuning workflow indocs/peft.md._accelerate_isolationpatchedis_accelerate_availablefor all of Transformers.transformers.trainerandtransformers.training_argswith the real flag.generate,load_adapter(integrations.peft) and the quantizers stay isolated.from_pretrained(device_map=...)still raises after the Trainer is imported (pinned by the test).gptqmodelfirst gets past Transformers'device_mapcheck, because Optimum importsgptqmodelonly inside the GPTQ quantizer. Accelerate then dispatched the model, and the HF bridge mishandled Accelerate's hooks: it only understandsweight_loaderhooks, so disk-offloaded layers raised and CPU-offloaded Marlin layers were treated as resident.hf_gptqmodel_post_initnow refuses Accelerate-owned hooks with a clear message pointing toGPTQModel.load(placement=...). This applies "strict everywhere" regardless of import order.owner.turtle_model, so it never fired. It now readscheckpoint_source.aff56aa1a):test_embedding_save_lifecycle.pyandtest_module_replacement_generation_config_5387.py: their fixtures mimicked LazyTurtle's private_weight_map/model_local_path; they now useCheckpointSource'sweight_map/root.test_loader_double_contract_4941.pystill required a double from a test file deleted in Remove accelerate: explicit WeightLoader for weight loading, placement and offload (#6471) #6473.Cleanup
utils/offload.py: remove the preexisting-hook take/restore plumbing; its setter was removed in Delete the dead hook-based offload machinery (#6471) #6494, so it was always a no-op.weight_loader/plan.py: remove the unreferenced_split_dim_cache_key.weight-loader.md,peft.md,hf-interop.md§6,loader-quantized-redirect.md,fp8-save-offload.md,calibration-replay.md,tenstorrent.md, the isolation docstring, bridge comments inutils/model.py, theimporter.pydocstring, and thelogger.pyregion label.max_memoryremedy string inimporter.py, becausetest_default_device_mixed_capability_4705.pyasserts on it.flowchart TD A[import gptqmodel] --> B[is_accelerate_available = False for Transformers] B --> C{module being imported} C -- transformers.trainer / training_args --> D[exec with real flag: Trainer gets Accelerator] C -- modeling_utils / generation / integrations.accelerate / peft / quantizers --> E[isolated: device_map raises, hooks = weight_loader] F[plain Transformers, gptqmodel imported late by Optimum] --> G[Accelerate dispatches] G --> H[hf_gptqmodel_post_init] H --> I[ValueError: use GPTQModel.load placement=]Validation (targeted only)
mainand pass here:test_accelerate_isolation.py::test_transformers_trainer_still_trains_in_a_gptqmodel_process[gptqmodel_first|trainer_first]test_hf_bridge_refuses_accelerate_dispatch.pytest_ostquant_config.py::test_ostquant_refuses_a_lazy_checkpoint_shellaff56aa1a,mainand this branch):mainhad 3 regressions againstaff56aa1a;aff56aa1a.main(environmental: no AVX512-BF16, nooptimum).Also measured (no change needed)
056beb477eab3ff9is bit-identical to before Remove accelerate: explicit WeightLoader for weight loading, placement and offload (#6471) #6473.aff56aa1avsmain:🤖 Generated with Claude Code