algo_cfg#

What each calibration algorithm reads, writes and assumes.

Classes

AlgoCapabilities

What one calibration algorithm reads, writes and assumes.

Functions

capabilities_for

Capabilities of algo, read off its calibrate-mode descriptor.

class AlgoCapabilities#

Bases: object

What one calibration algorithm reads, writes and assumes.

__init__(writes_whole_module, refines, requires=frozenset({}), may_write=frozenset({}), invalid_if_present=frozenset({}), scopable=True)#
Parameters:
  • writes_whole_module (bool)

  • refines (Literal['weight', 'input', 'both'])

  • requires (frozenset[str])

  • may_write (frozenset[str])

  • invalid_if_present (frozenset[str])

  • scopable (bool)

Return type:

None

invalid_if_present: frozenset[str] = frozenset({})#

awq_lite folds a scale into the weight assuming an unsmoothed start, so it conflicts with pre_quant_scale.

Type:

Tokens whose presence makes this algorithm incorrect

may_write: frozenset[str] = frozenset({})#

it may write fewer on a given model (smoothquant only touches INT8 layers), never more. Over-declaring is safe for conflict detection and unsafe for the hand-off, which is why the hand-off also checks coverage.

Type:

Tokens this may write. An upper bound

refines: Literal['weight', 'input', 'both']#

weight-side algorithms also seed input amax via an internal max_calibrate, which may_write records.

Type:

Role this algorithm improves. Narrower than what it writes

requires: frozenset[str] = frozenset({})#

Tokens this algorithm reads. weight and acts are ambient, so never counted. Not a precondition: every algorithm listing weight_amax also seeds its own via an internal max_calibrate, so an algorithm run on its own is fine.

scopable: bool = True#

Can be restricted to a scope, i.e. threads the should_process write-mask through everything it writes. False forces whole-model scope; the compiler rejects the rest.

writes_whole_module: bool#

Writes every quantizer of each linear it touches, not one quantizer at a time.

WRITABLE_TOKENS = frozenset({'input_amax', 'pre_quant_scale', 'weight', 'weight_amax'})#

over-reporting conflicts is the safe direction.

Type:

Conservative default for an algorithm that declares nothing

capabilities_for(algo, cfg=None)#

Capabilities of algo, read off its calibrate-mode descriptor.

Parameters:
  • algo (str | None)

  • cfg (dict | None)

Return type:

AlgoCapabilities | None