Repository navigation
Conversation
…r the model load lock (#4204)
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.
Summary
Fixes #4204.
_MODEL_LOAD_LOCKonly wrappedfrom_pretrained/from_quantized, so three other model-construction sites could still interleave transformers' process-globaltorch.set_default_dtypewindow (local_torch_dtype) with a concurrent load:BaseQModel.get_model_with_quantize— the save-side shell rebuild for a loaded quantized model (models/writer.py)_discover_compressed_tensors_module_schemes— the compressed-tensors dequant path (utils/model_dequant.py)build_blockfloat_model— the TT block-float_from_configpath (utils/tt_blockfloat_quant.py)What Changed
model_load_lock()inmodels/loader.py: a single accessor for the existingthreading.RLock. It is looked up at call time (not imported as a lock object) so every site shares one lock and tests can spy on it._serialized_model_loadnow enters the lock through that accessor.from_configundermodel_load_lock()together withsuspend_hf_weight_init().from_configand TT block-float_from_configtake the same lock.RLock, so the TT path called fromfrom_quantized(already locked) does not deadlock.tests/test_model_load_lock_4204.py:_MODEL_LOAD_LOCKwhilefrom_configruns;Tests
Pre-existing on the base commit and unrelated:
tests/test_tt_blockfloat_sequential.pyhas 2 failures (test_sequential_replay_uses_each_hybrid_layer_mask,test_sequential_replay_full_attention_context_unchanged) both before and after this change.Model Support / Module Plan
N/A — no new model types or registry entries.
Fixes #4204