Skip to content

docs: propose typed quantization configs and component lifecycles - #3457

Open
Qubitium wants to merge 20 commits into
mainfrom
docs/component-quantization-plan
Open

Qubitium wants to merge 20 commits into
mainfrom
docs/component-quantization-plan

Conversation

@Qubitium

@Qubitium Qubitium commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

GPT-QModel's flat quantization config overloads bits, group size and format across increasingly different methods. Its global lifecycle also cannot express independently selected sub-models with different quantization programs, data roles, source histories and hardware placement. This proposal combines typed method/weight/scale-solver configs with the existing component composer and method-owned lifecycles, retaining explicit numerical dependencies, serial/concurrent composition and bounded execution.

Planning only, revision 0.14. Keep this PR in draft for iterative discussion. No runtime implementation or quantization experiments are included. Backward compatibility is explicitly discouraged.

Related to #2928; this proposal does not resolve that issue.

What Changed

  • Add a small BaseQuantizeConfig, shallow concrete method configs, typed weight partitions/formats, and optional ScaledWeight.scale_solver. Numeric width, scale groups, storage blocks, vectors, codec geometry and solver tiles have separate meanings.
  • Integrate this recipe layer with Quantize, Language, Vision, QDataSet, scoped Rules, existing placement and ModelArtifact. There is one compiler and override model.
  • Separate method/scale fitting from output layout/container and final encoded payload metadata. Use method, type, format and Config naming consistently.
  • Update the examples and schemas across the proposal and link it from the README. Preserve argument-order serial execution, explicit Parallel, calibration lineage, and independent evaluation after saving.
  • Synchronize the branch with current main to restore its lint wrapper. The resulting PR diff contains only documentation; no numerical or runtime behavior changes.

Authoring model

Quantize(a, b) is serial in argument order. In this example language completes before vision:

run = (
    Quantize(
        Language(GPTQConfig()).Use(textData),
        Vision(GPTQConfig()).Use(visionData),
        model=model,
    )
    .Default(parallel=DataParallel(devices=[0, 1]))
    .MoE(
        routing=MoERouting.bypass,
        parallel=DataParallel(devices=[2, 3]),
    )
    .Run()
)

textData and visionData are caller-provided QDataSet objects. Binding model= permits .Run(); an unbound job can use .Run(model). Use dispatches datasets, explicit DataBindings, and registered recipe extensions without exposing lifecycle stages.

Concurrent component quantization requires an explicit group:

job = Quantize(
    Parallel(
        Language(GPTQConfig()).Use(textData),
        Vision(GPTQConfig()).Use(visionData),
    ),
    model=model,
).Default(parallel=DataParallel(devices=[0, 1, 2, 3]))

run = job.Run()

Parallel(...) requests an admitted concurrent schedule and joins all branch results. Unsupported methods, producer dependencies, write conflicts, or resources that permit only wholly serial execution cause a concrete error. The compiler does not silently reorder or serialize the whole group, switch teacher/context policies, or refit another component.

DataParallel distributes samples within the applicable lifecycle; TensorParallel partitions a logical model computation. Neither makes components concurrent. Device lists infer worker counts; optional Local(...) contexts carry budgets, custom maps, and NUMA policies. Advanced combined layouts retain explicit data/tensor axes. The method resolves its own execution profile; common authoring needs no stage IDs, repeated counts, or enforcement flags.

Typed recipe configuration

For symmetric GPTQ INT4, groups of 128, natural column order and weight-MSE scale search:

config = GPTQConfig(
    weights=GroupWeights(
        format=IntFormat(bits=4, symmetric=True),
        axis="in_features",
        size=128,
        scale_solver=LpScaleSolverConfig(p=2),
    ),
    solver=GPTQSolverConfig(order="natural"),
)
job = Quantize(
    Language(config).Use(calibration),
    model=model,
    export=ExportConfig(layout="gptq_v2", container="safetensors"),
)

These signatures are proposed. LpScaleSolverConfig is a new design name for weight-error scale search, not an existing class; the audited implementation uses MSEConfig(norm=2.0). MinMaxScaleSolverConfig() disables clipping search while retaining scales. Natural order leaves GPTQ's calibration-derived Hessian error feedback active. Output-MSE is a separate potential capability requiring an implementation.

Concrete configs own weights, optional activations and method procedure. Data, targets and devices retain their existing composer/action owners. ExportConfig declares layout/container constraints before fitting; weights.format is the sole numerical representation selector. The final manifest contains QuantizedModelSpec / EncodedModuleSpec with realized scales, group assignments, codebooks and auxiliary payloads; loaders do not rerun recipe solvers.

Defaults, data, and numerical semantics

Defaults belong to the composed action. Resolution is method defaults → composer defaults → component defaults → composer MoE settings → component MoE settings, with explicit nested scope inheritance. Omitted fields inherit; an execution configuration replaces its mode and device pool atomically. MoE overrides apply to mapped routed-expert work without expanding selected writes. Shared experts, dense vision, and draft owners retain their own contracts.

MoERouting.native is the default. Explicit bypass supplies the declared calibration stream to selected experts without normal top-k filtering for coverage. This changes observation provenance and requires method/adapter support. Data-parallel bypass merges each expert's contributions through the proper reducer; assigning different experts to different GPUs is separate task/expert placement. Bypass cannot widen a last-ten write query, reuse native routed statistics, or persist in normal saved inference. Temporary state is restored on failure/cancellation as well as success.

Component data attachment does not isolate modality pipelines. Compatible calibration routes reach downstream consumers, so language observes image-conditioned inputs alongside its text corpus. Named role bindings intentionally replace inference for those roles; training, validation, selection, and adapter sources are not copied into arbitrary roles. Final evaluation data stays outside quantization.

Serial order preserves each method's source/candidate/teacher policy. A supported local text-first fit can use the existing vision revision, then report its calibration context changed after vision is updated. A policy requiring newly quantized vision before language instead rejects that order. Parallel cannot silently choose an independent frozen-source experiment to avoid a dependency. Explicit refinement remains a separate declared policy.

Targets default to Target.AUTO. Language, Vision, and registered scopes use versioned model mappings; names and dataset types cannot widen selected writes. DynamicModuleTargeting().experts(type="routed").last(10, per="moe_layer", order_by="expert_id") resolves global IDs before sharding. Packed selections require an explicit source descriptor and are recorded as requantization; decoded released values are never mislabeled original dense weights.

Documents

  • Typed configuration and representation: inventory of 11 method values and 12 concrete configs at 35987dfb, typed partitions/formats/scale solvers, GPTQ INT4 example, canonical schema, recipe/result/artifact separation, alternatives and 16 acceptance cases. This supplements the older lifecycle audit, including NF12 and load-only TT contracts.
  • Component composer: preferred Quantize, scoped Language/Vision recipes, typed Use, serial argument order, explicit Parallel, Default/MoE precedence, model binding, and Run.
  • Main design: ownership, source/teacher roles, method-owned programs, phased coordination, context changes, transactional publication, and acceptance criteria.
  • Method lifecycle inventory: all nine METHOD entries and ten concrete configurations at 536b7f9b, including native/data-free paths, GSQ, GPTAQ/FOEM, EoRA, auxiliary operations, and MLX.
  • 2026 architecture audit: 34 family/pattern groups; the October 27 survey plus the October 29 Engram inspection. Structural expressibility, adapter support, and measured quality are separate claims.
  • Parallel execution: independent tasks, data/tensor/hybrid execution, reducers, partitions, shared resource reservations, failure/resume, and complete shard publication.
  • Device placement: dense/layer/expert/module maps, separate storage/execution/fitting, stage buffers, CPU/NUMA allocation and affinity, and physical resource accounting across actions.
  • API and advanced graph contracts: direct calls, composer lowering, immutable graphs, targets, recipe registry, serialized plans, and independent evaluation after saving.
  • Data contract: inheritable QDataSet, automatic routes and downstream consumers, lifecycle roles, preparation, streaming, splits, and committed cursor provenance. Audit at 6d90aa19 includes 32 preparation overrides.
  • DeepSeek V4.1 Flash mock: pinned vision-first composer with the last ten routed experts per main language layer, explicit released-FP4 source, automatic image/text observations, GPU/NUMA maps, and DS1–DS8 targets.

DeepSeek acceptance target

The pinned deepseek-ai/DeepSeek-V4.1-Flash-1017 mock now uses Quantize(Vision(...), Language(...)), preserving vision-first serial order. Its main language query selects expert IDs 374–383 in each of 40 layers: 400 groups and 1,200 logical gate/up/down projections. The explicit fitting source remains bounded decoding of released FP4 values.

Component defaults retain the requested hardware maps: vision on GPU 0; dense language groups by layer on GPUs 0/1; full routed forward banks by expert ID on GPUs 2/3; selected fits distributed five per GPU per layer; Engram table backing and lookup workers assigned independently to NUMA nodes/cores. These are conditional adapter/backend acceptance targets, not evidence of current support or a claim that four unspecified GPUs suffice. The mock retains native routing; a bypass variant is a distinct numerical experiment.

All scopes share one physical resource ledger. Live outputs retain storage reservations after worker completion; transfers reserve destinations before releasing sources. Hard maps, aliases, coupled numerical groups, and CPU allocation requirements remain constraints after defaults resolve.

Saving and independent evaluation

Compilation resolves metadata without consuming data or executing the model. Quantization requires no final evaluation suite. Successful saving returns a pinned ModelArtifact; optional evaluation then loads the committed representation with fresh state and independent resources:

resolved = job.Compile()
run = model.run(resolved)
artifact = run.save("quantized-model")
report = artifact.evaluate(suite=held_out_suite, data=held_out_data)

Evaluation reports are separate artifacts. Failure/retry cannot alter quantization/save success or trigger fitting. Intrinsic optimization validation and selection remain inside their method programs.

Tests

  • Ten design documents plus README links; no source, runtime, kernel or quantization-math changes in the final PR diff.
  • All 46 Python examples, four YAML examples and the canonical JSON example parse.
  • Mermaid 11.12.0 parses all 19 diagrams. Visual rendering was not exercised.
  • Checked 128 relative links/anchors, 90 reference-link uses and 49 pinned repository source links.
  • AST/schema checks reject obsolete flat method constructors, encoding fields, Options-suffixed classes and kind discriminators in proposed examples.
  • Acceptance registers are sequential: V1–V44, D1–D26, QD1–QD19, P1–P18 and DS1–DS8.
  • Whitespace and the repository's strict Ruff gate pass:
git diff --check origin/main...HEAD
bash format/check.sh
# ruff 0.14.2: All checks passed!

Unit tests are not applicable to this documentation-only design proposal. No runtime conformance tests, quantization-quality experiments or performance benchmarks accompany it. Syntax and contract checks do not establish executable support.

Review Requirements

  • Reviewed the changed authoring, ordering, override, data, placement, routing, persistence, and lowering contracts across the ten documents.
  • Kept APIs/schema examples explicitly proposed and used the existing docs/ location.
  • Preserved method-owned lifecycles, packed inference storage, source lineage, and save/evaluation separation.
  • Kept capability claims separate from source facts and validation results.

Kernel Accuracy Requirements

Not applicable: no quantization math, packer, or inference kernel changes.

Open Decisions

Before implementation, agree on initial method/architecture/backend profiles, admission of concurrent component groups, enforcement of NUMA placement, bypass semantics for coupled methods, continuation guarantees, and budgeted quality/cost experiments. The decision register also tracks scope defaults, data conveniences, recipe extension compatibility, independent evaluation conventions, native scale-policy admission, per-format decode/payload schemas, and the initial typed-config defaults/capability matrix.

Link to Devin session: https://app.devin.ai/sessions/82f18f3ae8544e468f280b6aa44fe583
Open in Devin Desktop: https://app.devin.ai/desktop/session/82f18f3ae8544e468f280b6aa44fe583?variant=devin
Requested by: @Qubitium

@Qubitium Qubitium changed the title docs: draft component and phased quantization design docs: draft component quantization and method lifecycle design Oct 27, 2026
@Qubitium Qubitium changed the title docs: draft component quantization and method lifecycle design docs: draft composable multimodal quantization and parallel lifecycles Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed head e1dc9db3d9dbd9b856de5a7880c3f8782373e7eb against its base. No actionable correctness findings identified in this pass.

I checked the nine-document proposal for consistency around serial versus concurrent component execution, source/candidate provenance, downstream calibration routing and exact role overrides, scoped writes/defaults, physical resource accounting, continuation/publication, and save/evaluation separation. The DeepSeek example preserves vision-first order, explicit decoded FP4 source lineage, and global expert selection before placement.

Independent document checks passed: all 41 Python examples and 4 YAML examples parse; all 116 relative links resolve; all 90 reference-link uses have definitions; git diff --check is clean.

This is a review of the proposed contracts, not runtime qualification or approval to implement them. No quantization, accelerator, concurrency, or performance tests were run; external architecture citations were not comprehensively re-audited.

@devin-ai-integration devin-ai-integration Bot changed the title docs: draft composable multimodal quantization and parallel lifecycles docs: propose typed quantization configs and component lifecycles Nov 13, 2026
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Reviewed head e49f8eba43324b22c3b1dcc41b9060b30e159aa0 against base d063e31387567bb8634a4d3e714dcc37fc7ceb04 in a clean checkout. The final diff contains only documentation.

One low-priority consistency finding:

No other actionable correctness findings identified in this pass. I checked the ten-document proposal's ordering, overrides, data roles/routing, source lineage, ownership, physical resource accounting, continuation/publication, and save/evaluation contracts.

Independent document checks passed: all 46 Python examples, four YAML examples, and the JSON example parse; all 128 relative links/anchors resolve; all 90 reference-link uses have definitions; git diff --check is clean.

This reviews proposed contracts, not runtime qualification. No quantization, accelerator, concurrency, or performance tests were run. Mermaid rendering/parsing and the external architecture citations were not independently revalidated in this pass.

@Qubitium

Copy link
Copy Markdown
Collaborator Author

Merge conflict resolved — merged origin/main (9f0b0c67f), PR is now MERGEABLE.

Only README.md conflicted: main rewrote the docs-links section (quantization guide + support matrix) while this branch added a 300-line section pointing at the new design docs. Resolved by keeping main's structure verbatim and appending only this PR's pointer:

For proposed API changes, see the component quantization design and typed configuration proposal. These are design documents; the proposed interfaces are not implemented.

Diff against main is now exactly the 10 new design docs plus that one README paragraph.

@Qubitium
Qubitium marked this pull request as ready for review November 19, 2026 03:20
@Qubitium
Qubitium marked this pull request as draft November 19, 2026 11:36
@Qubitium
Qubitium marked this pull request as ready for review November 20, 2026 01:06
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.

1 participant