Skip to content

Fix module tree isolation and dynamic config caching - #3101

Merged
Qubitium merged 5 commits into
mainfrom
fix/isolate-module-tree-dynamic-cache
Sep 24, 2026
Merged

Qubitium merged 5 commits into
mainfrom
fix/isolate-module-tree-dynamic-cache

Conversation

@ZX-ModelCloud

@ZX-ModelCloud ZX-ModelCloud commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • keep class-level module tree declarations unchanged and give each model instance an immutable effective tree
  • route GPTQ, AWQ, shared-input, and MoE runtime planning through the instance tree
  • replace unbounded id-based dynamic config caches with ordered content fingerprints and bounded LRU caches
  • track nested dynamic config mutations so cached resolutions are invalidated safely
  • add regression coverage for unknown architecture load order, GPTQ/AWQ overrides, mixed dense/MoE trees, cache sharing, mutation, and eviction
  • add concise comments around the new isolation and caching mechanisms

Testing

  • pytest -q tests/qcfg tests/module_tree/test_module_tree_variants.py tests/module_tree/test_moe_flag_parsing.py tests/module_tree/test_auto_detect.py tests/test_requant_embed_lm_head.py
  • 95 passed

Comment thread gptqmodel/quantization/config.py Fixed
Comment thread gptqmodel/quantization/config.py Fixed
Comment thread gptqmodel/quantization/config.py Fixed
@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator Author

PR Review
PR: #3101
Reviewed head SHA: 9cea297
Result: findings

Findings:

  1. Severity: medium
    File and line: gptqmodel/models/base.py:478
    Rationale: Auto-detected trees now exist only on the BaseQModel instance, but the standard from_quantized path plans the model before creating that instance: loader.py calls cls.extract_layers_node(), cls.get_base_modules(), and cls.simple_layer_modules() at lines 1631-1647. For an unknown architecture, cls.module_tree therefore remains None, simple_layer_modules is empty, and the loader filters every candidate module before make_quant. This also regresses a same-process reload that previously worked after an earlier instance populated the class tree.
    Action: Resolve and bind an effective tree locally in from_quantized before those class-level planning calls, or create an instance/tree-bound planning object first; add a fresh-process quantized-load regression for an auto-detected architecture.
  2. Severity: medium
    File and line: gptqmodel/quantization/config.py:1959
    Rationale: The content-keyed global override cache returns its mutable cached dictionary directly. Because equal dynamic configurations intentionally share the same fingerprint, mutating a dictionary or nested container returned by cfg_a.dynamic_get(module) or cfg_a.dynamic_get(module, key) silently changes later results for cfg_b even though cfg_b.dynamic is unchanged. The cache can therefore cross-contaminate otherwise independent configs.
    Action: Keep cached override payloads immutable or return a defensive deep copy for mutable results on both cache hits and newly resolved matches; add a regression with two equal configs that mutates a result from one and verifies the other is unchanged.

@ZX-ModelCloud

ZX-ModelCloud commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Implemented the two valid follow-ups from the previous review.

  1. Auto-detected module trees are now resolved and bound before from_quantized class-level planning, and the same effective tree is passed to the final instance. Added a regression covering a fresh unknown-architecture quantized-load planning path.
  2. Dynamic override cache results are now defensively deep-copied on both cache hits and new matches, including nested values, so equal configs cannot cross-contaminate through caller mutation. Added a regression for independent equal configs.

Commit: f2e6dda

@ZX-ModelCloud
ZX-ModelCloud marked this pull request as ready for review September 24, 2026 12:15
@Qubitium
Qubitium merged commit 34223e6 into main Sep 24, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/isolate-module-tree-dynamic-cache branch September 24, 2026 12:50
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.

2 participants