Skip to content

feat(step5): carry bounded native core and MTP calibration - #3612

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/32-step5-native-calibration-20261108
Nov 9, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/32-step5-native-calibration-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Carry native Step-5 source/reference loading, bounded fused-expert reads, actual-row covariance products, functional indexer W input observation without extra GEMMs, explicit stage replay, and MTP alignment. Preserve the reviewed source config instead of mutating its document.

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

Incremental change: 4 files, +890/−0 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["Step5BF16Source"]
    M0_0["Step5BF16Source.__init__"]
    M0_1["Step5BF16Source.materialize_block"]
    M0_2["Step5BF16Source.load_block"]
    S1["capture_inputs"]
    S2["staged_forward"]
    S3["load_mtp"]
    E["ValueError"]
    S0 -. "exposes" .-> M0_0
    S0 -. "exposes" .-> M0_1
    S0 -. "exposes" .-> M0_2
    S0 -->|"raises on rejected input/state"| E
    S1 -->|"raises on rejected input/state"| E
    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/utils/step5_core.py:148: Step5BF16Source
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/step5_core.py:380: capture_inputs
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/step5_core.py:372: staged_forward
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/step5_core.py:498: load_mtp

Committed reference: docs/step5-native-calibration.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_step5_core.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.

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.
@Qubitium
Qubitium force-pushed the upstream/32-step5-native-calibration-20261108 branch from 9ff6e90 to a832519 Compare November 9, 2026 09:56

@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.

Reviewed against current main.

The Step-5 adapter adds loading/observation boundaries without reimplementing attention, which is the right split:

  • step5_core pins the revision, reuses the GLM core capture_linear_input/reconstruct_projection/validate_projection, and adds only the Step-5 Hessian and projection stages.
  • accumulate_hessian_fp32 validates square FP32 storage, an integer 1..128 product bound, finite floating activations with a matching last dimension, and accumulates addmm_ in bounded chunks. DenseRawHessian.add increments count only after the accumulation succeeds, so invalid observations cannot inflate the dense sample count (covered by the parameterized tests).
  • quantize_projection keeps the same fresh-Hessian/geometry/metric validation as the GLM path while allowing the Step-5 K4/K5/K6 rates.
  • Tests cover unsafe/non-integer product bounds, non-incrementing invalid observations, FP32-storage enforcement, and the bounded product behavior.

Cleanup only: unused imports, import ordering, dict(...) → literals, and semicolon-split lines in the test harness.

Validation: ruff check clean; pytest tests/test_step5_core.py reports 36 passed.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:56
@Qubitium
Qubitium merged commit d616018 into ModelCloud:main Nov 9, 2026
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