Skip to content

feat(loader): preserve lazy native sources across replay and export - #3599

Merged
Qubitium merged 2 commits into
ModelCloud:mainfrom
tpurtell:upstream/19-lazy-source-replay-contracts-20261108
Nov 9, 2026
Merged

Qubitium merged 2 commits into
ModelCloud:mainfrom
tpurtell:upstream/19-lazy-source-replay-contracts-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Carry the model extension hooks, floatx source selection/reload, source tensor mappings, active-shard staging, concrete device materialization, safe replay cloning, and source config selectors used by the native model runners. Keep Dots3/Kimi registration in their later model layers.

This is layer 19/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3598. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream main.

Incremental change: 14 files, +1127/−42 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.

Flow and existing-code boundary

flowchart TD
    S0["_uses_auto_module_decoder"]
    S1["_convert_model_with_defuser"]
    S2["LazyTurtle"]
    M2_0["LazyTurtle.__init__"]
    M2_1["LazyTurtle.materialize_submodule"]
    M2_2["LazyTurtle.materialize_direct_meta_tensors"]
    S3["BaseQModel"]
    M3_0["BaseQModel.__init__"]
    M3_1["BaseQModel.prepare_dataset"]
    M3_2["BaseQModel.forward"]
    E["AttributeError, EnvironmentError, NotImplementedError, RuntimeError, TypeError, ValueError"]
    S2 -. "exposes" .-> M2_0
    S2 -. "exposes" .-> M2_1
    S2 -. "exposes" .-> M2_2
    S2 -->|"raises on rejected input/state"| E
    S3 -. "exposes" .-> M3_0
    S3 -. "exposes" .-> M3_1
    S3 -. "exposes" .-> M3_2
    S3 -->|"raises on rejected input/state"| E
    style E fill:#fee,stroke:#b22
Loading
Before this extraction layer Carried implementation
API absent in the previous stack layer (path/symbol checked) gptqmodel/models/auto.py:538: _uses_auto_module_decoder
Previous stack layer: gptqmodel/models/loader.py:535 gptqmodel/models/loader.py:535: _convert_model_with_defuser
Previous stack layer: gptqmodel/utils/structure.py:845 gptqmodel/utils/structure.py:846: LazyTurtle
Previous stack layer: gptqmodel/models/base.py:312 gptqmodel/models/base.py:312: BaseQModel

Committed reference: docs/lazy-source-replay-contracts.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.

Validation

Carried test files: tests/test_auto_module_decoder.py, tests/test_lazy_turtle_conversion_mapping.py, tests/test_lazy_turtle_materialize_map.py, tests/test_looper_helpers.py, tests/test_local_model_paths.py, tests/test_quantize_config_offload_tempdir.py

This packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.

tpurtell and others added 2 commits November 9, 2026 09:07
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
The layer-19 test set references DeepSeek V4 MTP mapping and GPTQ
_hessian_state, which land in later stack layers. Skip the whole conversion
mapping module when the symbol is absent and the two hessian-sharing tests.
@Qubitium
Qubitium force-pushed the upstream/19-lazy-source-replay-contracts-20261108 branch from 5733eae to 1047ee0 Compare November 9, 2026 09:08

@Qubitium Qubitium left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (layer 19)

Reviewed the incremental layer-19 commit (5733eae6d, 14 files, +1127/−42) after rebasing it onto current main (the branch was cumulative). The lazy-source replay contracts, conversion-map propagation, and export preservation are coherent. I pushed a test-only fix commit (1047ee0e1).

Fixed

  • tests/test_lazy_turtle_conversion_mapping.py imports deepseek_v4_mtp_checkpoint_mapping_reversed / deepseek_v4_mtp_module_tree, which do not exist in this layer or main; the module failed at collection. It now skips at module level when the symbol is absent.
  • tests/test_quantize_config_offload_tempdir.py has two tests that assert GPTQ._hessian_state, which lands in a later layer; both are skipped with a reason.

Verification

Changed suites: 76 passed, 3 skipped. ruff check clean on all 14 changed files.

Notes

  • The two DeepSeek V4 MTP mapping tests and the hessian-sharing tests should move to the layer that introduces their dependencies rather than staying skipped here.
  • The PR is now based on current main, so the cross-fork cumulative diff no longer applies; the effective change is the 14 files above.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:08
@Qubitium
Qubitium merged commit 49a072b into ModelCloud:main Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Review found auto decode could route a GPTQ checkpoint through source loading. #3713 now limits that bypass to native floatx sources.

Qubitium added a commit that referenced this pull request Nov 17, 2026
) (#4991)

Seven EXL3 tests carried an unconditional module-level
``pytest.mark.skip`` with "lands in a later stack layer" reasons from
#3592/#3594/#3599. That wiring landed long ago, so shipped code paths had
tests that pass but nobody ever ran.

- test_exl3_capture_frontier.py / test_exl3_error_ledger.py: drop the
  ``_processor_wiring_pending`` skip and its decorators; all four tests
  run and pass.
- test_quantize_config_offload_tempdir.py: drop two ``pytest.mark.skip``
  decorators; widen the two tiny ``nn.Linear(16, ...)`` layers to 128
  because EXL3 requires in_features to be a multiple of 128.
- kernels/test_kernel_compile_levels_quant.py: gate the Paro cases on
  ``awq_runtime_available()``/``awq_runtime_error()`` instead of
  ``CUDA_HOME`` plus an ``nvcc``-on-PATH probe, which misreported the
  runtime as available.
- Add tests/test_exl3_skip_reasons_4981.py, an AST guard that fails if
  any EXL3 test reintroduces an unconditional ``pytest.mark.skip``. A
  real precondition belongs in ``skipif`` with a precise reason.

The Machete JIT gate in test_machete_jit.py is deliberately left alone:
swapping the ``nvcc``-on-PATH probe for
``cuda_source_build_available()`` turns a skip into a failure on hosts
whose toolkit and headers disagree, which is worse than the status quo.

Fixes #4981
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