Skip to main content

PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION

PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION

ASL pseudocode

The complete ASL owner is shown directly below.

// PTO-UNIT: {"id":"PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION","surface":"arch","classification":["profile","reference-quantization"],"depends_on":["PTO-ARCH-PROFILE-REFERENCE-PROFILE","PTO-TILE-MODEL-NUMERIC-FORMATS"]}pure func ReferencePowerOfTwo(exponent: integer {-149..127}) => realbegin    var result: real = 1.0;    if exponent > 0 then        for step = 1 to exponent looplimit 127 do            result = result * 2.0;        end;    elsif exponent < 0 then        for step = 1 to -exponent looplimit 149 do            result = result / 2.0;        end;    end;    return result;end;
pure func ReferenceFP32FiniteValue(value: bits(32)) => realbegin    let exponent = UInt(value[30:23]);    let fraction = UInt(value[22:0]);    assert exponent != 255;    var magnitude: real = 0.0;    if exponent == 0 then        magnitude = Real(fraction) * ReferencePowerOfTwo(-149);    else        let significand = Real(0x800000 + fraction) / Real(0x800000);        magnitude = significand * ReferencePowerOfTwo(            (exponent - 127) as integer {-126..127});    end;    if value[31] == '1' then return -magnitude; end;    return magnitude;end;
pure func ReferenceIntegerValue(value: Word,                                data_type: TileDataType) => integerbegin    let normalized = NormalizeTileInteger(value, data_type);    if TileDataTypeIsSigned(data_type) then return SInt(normalized); end;    return UInt(normalized);end;
func ReferenceFP32FiniteEncoding(    value: real,    rounding_mode: NumericRoundingMode) => (Word, bits(5))begin    if value == 0.0 then return (Zeros{PTO_XLEN}, Zeros{5}); end;    let negative = value < 0.0;    var normalized = if negative then -value else value;    var exponent: integer {-149..128} = 0;    for step = 1 to 128 looplimit 128 do        if normalized >= 2.0 && exponent < 128 then            normalized = normalized / 2.0;            exponent = (exponent + 1) as integer {-149..128};        end;    end;    for step = 1 to 149 looplimit 149 do        if normalized < 1.0 && exponent > -149 then            normalized = normalized * 2.0;            exponent = (exponent - 1) as integer {-149..128};        end;    end;
    let sign = if negative then 0x80000000 else 0;    if exponent > 127 then        return (            Zeros{PTO_XLEN} + sign + 0x7f800000,            Zeros{5} + 0x14);    end;
    if exponent < -126 then        let scaled = value / ReferencePowerOfTwo(-149);        let rounded = FloatingToInteger(scaled, rounding_mode);        let magnitude = if rounded < 0 then -rounded else rounded;        if magnitude == 0 then            return (Zeros{PTO_XLEN} + sign, Zeros{5} + 0x18);        end;        return (            Zeros{PTO_XLEN} + sign + magnitude,            if Real(rounded) == scaled then Zeros{5}            else Zeros{5} + 0x18);    end;
    let scaled = if negative then        -(normalized * Real(0x800000))        else normalized * Real(0x800000);    let rounded = FloatingToInteger(scaled, rounding_mode);    var magnitude = if rounded < 0 then -rounded else rounded;    var encoded_exponent = exponent + 127;    if magnitude == 0x1000000 then        magnitude = 0x800000;        encoded_exponent =            (encoded_exponent + 1) as integer {-22..255};    end;    if encoded_exponent >= 255 then        return (            Zeros{PTO_XLEN} + sign + 0x7f800000,            Zeros{5} + 0x14);    end;    let fraction = magnitude - 0x800000;    return (        Zeros{PTO_XLEN} + sign + encoded_exponent * 0x800000 + fraction,        if Real(rounded) == scaled then Zeros{5} else Zeros{5} + 0x10);end;
implementation func TileProfileQuantize(value: Word, scale: Word,                                         zero_point: Word,                                         source_type: TileDataType,                                         destination_type: TileDataType,                                         control: NumericExecutionControl)                                         => (Word, bits(5))begin    assert source_type == TileDataType_FP32;    assert destination_type == TileDataType_S8 ||           destination_type == TileDataType_U8;    let source_class = TileNumericValueClass(source_type, value);    let scale_class = TileNumericValueClass(TileDataType_FP32, scale);    assert !NumericValueClassIsNaN(scale_class);    assert !NumericValueClassIsInfinity(scale_class);    assert !NumericValueClassIsZero(scale_class);    let minimum = ReferenceIntegerValue(        TileIntegerMinimum(destination_type), destination_type);    let maximum = ReferenceIntegerValue(        TileIntegerMaximum(destination_type), destination_type);    if NumericValueClassIsNaN(source_class) then        return (Zeros{PTO_XLEN}, Zeros{5} + 1);    elsif NumericValueClassIsInfinity(source_class) then        let saturated = if value[31] == '1' then minimum else maximum;        return (            NormalizeTileInteger(                Zeros{PTO_XLEN} + saturated,                destination_type),            Zeros{5} + 0x14);    end;    let affine = ReferenceFP32FiniteValue(value[31:0]) *        ReferenceFP32FiniteValue(scale[31:0]) +        Real(ReferenceIntegerValue(zero_point, destination_type));    let rounded = FloatingToInteger(affine, control.rounding_mode);    var selected = rounded;    let flags = if Real(rounded) == affine then Zeros{5}        else Zeros{5} + 0x10;    if control.saturating then        if selected < minimum then selected = minimum;        elsif selected > maximum then selected = maximum;        end;    end;    return (        NormalizeTileInteger(Zeros{PTO_XLEN} + selected, destination_type),        flags);end;
implementation func TileProfileDequantize(value: Word, scale: Word,                                           zero_point: Word,                                           source_type: TileDataType,                                           destination_type: TileDataType,                                           control: NumericExecutionControl)                                           => (Word, bits(5))begin    assert source_type == TileDataType_S8 ||           source_type == TileDataType_U8;    assert destination_type == TileDataType_FP32;    let scale_class = TileNumericValueClass(TileDataType_FP32, scale);    assert !NumericValueClassIsNaN(scale_class);    assert !NumericValueClassIsInfinity(scale_class);    assert !NumericValueClassIsZero(scale_class);    let source_value = ReferenceIntegerValue(value, source_type);    let zero_value = ReferenceIntegerValue(zero_point, source_type);    let dequantized = Real(source_value - zero_value) *        ReferenceFP32FiniteValue(scale[31:0]);    return ReferenceFP32FiniteEncoding(        dequantized,        control.rounding_mode);end;

Architecture behavior

purpose scope

Purpose and scope

This unit supplies deterministic PTO v0 reference implementations for FP32 finite conversion, affine quantization to S8 or U8, and dequantization back to FP32.

concepts state

Value helpers

  • ReferencePowerOfTwo constructs powers from exponent -149 through 127.
  • ReferenceFP32FiniteValue decodes finite FP32 sign, exponent, and fraction into a real value.
  • ReferenceIntegerValue normalizes a Tile integer and interprets it with the source type's signedness.
  • ReferenceFP32FiniteEncoding performs the inverse finite encoding with status.
rules interactions

Quantize and dequantize

TileProfileQuantize accepts FP32 input and S8 or U8 output. It checks that the FP32 scale is finite and nonzero, computes source * scale + zero_point, rounds under the selected mode, and optionally clamps to the destination range.

TileProfileDequantize accepts S8 or U8 input and FP32 output. It computes (source - zero_point) * scale and returns the reference FP32 encoding.

boundaries

Exceptional and profile boundaries

Quantizing NaN produces zero with NV; infinity selects the signed integer endpoint with overflow/inexact status. The scale may not be NaN, infinite, or zero. These are PTO v0 implementation functions, so other named profiles require their own reviewed definitions.

example usage

illustrative affine example

Use this example block only as a reading aid: apply the rules above, then confirm the result in the normative ASL owner. It does not add an architectural contract.

Related owners

  • Reference profile supplies common numeric policy such as rounding selection.
  • Tile numeric formats classify encodings; matrix quantization reuses these reference helpers for broader formats.

NDF clauses

Bodies come from owning ASL. Dragging or buttons change only this page-session view order.

No NDF clause is attached to this unit.

Evidence index

10 matching entries

Executable evidence2
  • PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION compiles as an independent normative unit
    1. surfaceARCH
    2. ownerPTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
    3. categorySTATIC-INVARIANT
    4. case001
    Show exact test source
    Sources and references
    Complete stable ID
    PTO-AVS-ARCH-PROFILE-REFERENCE-QUANTIZATION-STATIC-001
    Path
    tests/asl/arch/profile/reference-quantization/arch-static-reference-quantization-contract-001.asl
    Kind / role
    static-invariant
    Pass condition
    the complete model and this unit's static invariant compile
    SHA-256
    e5859faec80b723cccc8cd21c068ad1cd6ce6ba79c1ba1d9bf22e6365113487d
    Open exact source ↗ for PTO-AVS-ARCH-PROFILE-REFERENCE-QUANTIZATION-STATIC-001
  • The reference quantization profile converts representative FP32 and integer values without changing their encodings
    1. surfaceARCH
    2. ownerPTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
    3. categoryEXECUTION
    4. case001
    Show exact test source
    Sources and references
    Complete stable ID
    PTO-AVS-ARCH-REFERENCE-QUANTIZATION-001
    Path
    tests/asl/arch/profile/reference-quantization/arch-exec-reference-quantization-001.asl
    Kind / role
    execution
    Pass condition
    FP32 one and two decode exactly, FP32 one re-encodes exactly with no flags, and signed integer normalization preserves minus one
    SHA-256
    77a1aeec8c6b63e08c22aca602ea197a22a51320e033721fa531bdfbb1046fea
    Open exact source ↗ for PTO-AVS-ARCH-REFERENCE-QUANTIZATION-001
Commit-scoped evidence5
  • spec/evidence/release-traceability-readiness.json · closedPTO-EVIDENCE-RELEASE-TRACEABILITY
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-TRACEABILITY
    Path
    spec/evidence/release-traceability-readiness.json
    Kind / role
    ASL/NDF/documentation/AVS traceability
    SHA-256
    c7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3e
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-TRACEABILITY
  • spec/evidence/instruction-contract-closure.json · closedPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
    Path
    spec/evidence/instruction-contract-closure.json
    Kind / role
    mnemonic and encoding contract closure
    SHA-256
    3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106a
    Open exact source ↗ for PTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSURE
  • spec/evidence/architecture-readiness.json · openPTO-EVIDENCE-ARCHITECTURE-READINESS
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-ARCHITECTURE-READINESS
    Path
    spec/evidence/architecture-readiness.json
    Kind / role
    architecture maturity and blockers
    SHA-256
    4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004
    Open exact source ↗ for PTO-EVIDENCE-ARCHITECTURE-READINESS
  • spec/evidence/release-gate-readiness.json · ready-for-exact-head-verificationPTO-EVIDENCE-RELEASE-GATE-READINESS
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-GATE-READINESS
    Path
    spec/evidence/release-gate-readiness.json
    Kind / role
    exact-head gate readiness
    SHA-256
    a0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-GATE-READINESS
  • spec/release-manifest.json · draftPTO-EVIDENCE-RELEASE-MANIFEST
    Sources and references
    Complete stable ID
    PTO-EVIDENCE-RELEASE-MANIFEST
    Path
    spec/release-manifest.json
    Kind / role
    release content and encoding fingerprints
    SHA-256
    1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8
    Open exact source ↗ for PTO-EVIDENCE-RELEASE-MANIFEST
Decision history3
  • PTO v0 concrete reference profile · accepted
    1. decision recordADR
    2. case0005

    Decision record

    Loading ADR-0005…

    Sources and references
    Complete stable ID
    ADR-0005
    Path
    docs/status/decisions/0005-pto-v0-concrete-reference-profile.md
    Affected units
    PTO-ARCH-PROFILE-APPLICABILITY, PTO-ARCH-PROFILE-E8M0-CONVERSION, PTO-ARCH-PROFILE-EXTENSION-FIRST-USE, PTO-ARCH-PROFILE-MATRIX-POSTPROCESS, PTO-ARCH-PROFILE-MATRIX-QUANTIZATION, PTO-ARCH-PROFILE-REFERENCE-PROFILE, PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION, PTO-ARCH-PROFILE-RESET, PTO-ARCH-PROFILE-TRAP-CONTEXT-RECOVERY
    Affected NDF
    PTO-ARCH-EXTENSION-FIRST-USE-PROFILE-001, PTO-MATRIX-POSTPROCESS-BITEXACT-001, PTO-MATRIX-QUANT-BITEXACT-001, PTO-TCVT-E8M0-PROFILE-001
    SHA-256
    a83528c2fc744cc120c2a0a32c82410059638ea88936fa65ac0eb36a0274d87c
    Open exact decision source ↗ for ADR-0005
  • Numeric profile identity and bounded variation framework · accepted
    1. decision recordADR
    2. case0037

    Decision record

    Loading ADR-0037…

    Sources and references
    Complete stable ID
    ADR-0037
    Path
    docs/status/decisions/0037-numeric-profile-identity-and-variation-framework.md
    Affected units
    PTO-ARCH-PROFILE-APPLICABILITY, PTO-ARCH-PROFILE-E8M0-CONVERSION, PTO-ARCH-PROFILE-MATRIX-POSTPROCESS, PTO-ARCH-PROFILE-MATRIX-QUANTIZATION, PTO-ARCH-PROFILE-REFERENCE-PROFILE, PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
    Affected NDF
    PTO-MATRIX-POSTPROCESS-BITEXACT-001, PTO-MATRIX-QUANT-BITEXACT-001, PTO-TCVT-E8M0-PROFILE-001
    SHA-256
    b09efd36ccfc7258d1743c974f42b875ead42137c503f576a12f471f65b52e30
    Open exact decision source ↗ for ADR-0037
  • Numeric variation-point ownership · accepted
    1. decision recordADR
    2. case0042

    Decision record

    Loading ADR-0042…

    Sources and references
    Complete stable ID
    ADR-0042
    Path
    docs/status/decisions/0042-numeric-variation-point-ownership.md
    Affected units
    PTO-ARCH-PROFILE-APPLICABILITY, PTO-ARCH-PROFILE-E8M0-CONVERSION, PTO-ARCH-PROFILE-MATRIX-POSTPROCESS, PTO-ARCH-PROFILE-MATRIX-QUANTIZATION, PTO-ARCH-PROFILE-REFERENCE-PROFILE, PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
    Affected NDF
    PTO-MATRIX-POSTPROCESS-BITEXACT-001, PTO-MATRIX-QUANT-BITEXACT-001, PTO-TCVT-E8M0-PROFILE-001
    SHA-256
    f25df23306837e4199f6b7c03f70de853a693fdc6435c65ead57b2a174076081
    Open exact decision source ↗ for ADR-0042

Unit metadata

Open 4 generated metadata fields
id
PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION
surface
arch
classification
[
  "profile",
  "reference-quantization"
]
depends_on
[
  "PTO-ARCH-PROFILE-REFERENCE-PROFILE",
  "PTO-TILE-MODEL-NUMERIC-FORMATS"
]
Open generated traceability record
{
  "classification": [
    "profile",
    "reference-quantization"
  ],
  "documentation": "docs/arch/profile/reference-quantization.md",
  "id": "PTO-ARCH-PROFILE-REFERENCE-QUANTIZATION",
  "mnemonic": null,
  "readiness_subjects": [
    "ADR-0005",
    "ADR-0037",
    "ADR-0042"
  ],
  "semantic_tests": [
    "PTO-AVS-ARCH-REFERENCE-QUANTIZATION-001"
  ],
  "source": "asl/arch/profile/reference-quantization.asl",
  "surface": "arch",
  "tests": [
    "PTO-AVS-ARCH-PROFILE-REFERENCE-QUANTIZATION-STATIC-001",
    "PTO-AVS-ARCH-REFERENCE-QUANTIZATION-001"
  ]
}

Sources and release identity

Show commit, paths, hashes, version, and canonical owners
Release
0.58.5 · Release candidate
Commit
7dc8b7e5b121d2b2499a2273bebff29e2cd86812
ASL SHA-256
e82820dc13f89142aa0448c4435f6cbd53d4eb0b85c05e63a887452c186d9aef
Generated documentation
docs/arch/profile/reference-quantization.md · embedded in this page
Documentation SHA-256
4f53abb7b8d600f9defac146883eab1ea29c72a369f2f879c4451646bb4c15b6

Exact owners