Summary
Audit and tighten the existing reinterpret_tile<NewDType>(src) API so it is a
zero-instruction, compiler-only Tile view rather than an implicit architectural
Tile-descriptor mutation.
The API already exists on linx, together with
docs/tileop-usage/reinterpret-tile.md. The current implementation changes the
view's public DType, and downstream Tile operations obtain the PTO datatype
encoding from that new type. This is broader than the currently accepted PTO
architecture contract and is the concrete mismatch reported in
PTO-ISA/pto-spec#162.
This issue requests an API-contract correction and implementation. It does not
authorize weakening the PTO ASL exact-dtype checks to a byte-width comparison.
Why this is needed
The failing pattern is:
// Runtime Tile descriptor after TCVT: BF16.
auto bits = reinterpret_tile<std::uint16_t>(bf16_tile); // emits no instruction
// The current API can make the consumer encode UINT16 even though the
// architectural Tile descriptor is still BF16.
TANDS(..., bits, ...);
// A later numeric consumer expects the original BF16 descriptor.
TMULS(..., bf16_tile, ...);
A zero-instruction C++ expression is not observable by hardware, gfrun, QEMU,
or the PTO ASL model. It therefore cannot silently relabel the architectural
Tile descriptor. Treating every same-width dtype as interchangeable would also
leave numeric interpretation, packed formats, scale-bearing formats, aliases,
definedness, and destination descriptor propagation unspecified.
Proposed API contract
1. reinterpret_tile is a non-owning compiler view
Keep the public spelling:
template <typename ViewDType, TileLike SourceTile>
[[nodiscard]] constexpr auto reinterpret_tile(SourceTile& source);
The returned view MUST:
- emit no PTO instruction, copy, conversion, memory access, or state update;
- reference the same underlying Tile storage and register identity;
- preserve location/role, shape, valid shape, layout, packing, padding,
compactness, TileSizeCode, and definedness;
- preserve the architectural/runtime backing descriptor dtype;
- reject rvalues so the non-owning view cannot outlive its source;
- remain Local-only until Shared handle and
B.IOS binding semantics are
separately designed.
The view type SHOULD expose both identities explicitly:
using ViewDType = NewDType; // compile-time API view
using BackingDType = typename Source::DType; // architectural descriptor
Do not represent these two meanings with one unqualified DType that every
consumer interprets as the architectural dtype. Add traits such as
is_reinterpreted_tile_view_v<T>, view_dtype_t<T>, backing_dtype_t<T>, and
an unwrap/accessor for the exact backing Tile as needed by consumers.
2. Compile-time legality
The first supported form MUST require:
- a named Local Tile lvalue;
- registered PTO source and view dtypes;
- equal element bit width;
- identical storage geometry and layout interpretation;
- no change to element count, TileSizeCode, shape, or physical bytes.
Equal bit width alone is not sufficient for all formats. Packed, scale-bearing,
or descriptor-sidecar formats MUST be rejected unless an accepted PTO contract
explicitly places the pair in a storage-compatible raw-carrier class.
Diagnostics MUST distinguish at least:
- unsupported target dtype;
- different element width;
- incompatible storage/layout class;
- Shared Tile not supported;
- consumer does not accept a reinterpret view;
- dangling/rvalue source.
3. Consumers opt in; generic Tile APIs do not
reinterpret_tile MUST NOT automatically make the view legal for every API
that accepts a Tile-shaped type.
Default numeric consumers—including arithmetic, matrix multiply, conversion,
comparison, reduction, and format/scale-sensitive operations—MUST use the
backing architectural dtype and MUST reject a cross-dtype reinterpret view
unless their accepted PTO contract explicitly says otherwise.
Raw-carrier consumers may opt in through a dedicated concept/trait. The initial
candidate family is the raw bitwise logical surface (TAND, TOR, TXOR and
their scalar forms), but the exact whitelist and legal dtype pairs MUST follow
the accepted resolution of PTO-SPEC #162. Do not infer eligibility from equal
width alone.
For an opted-in raw operation:
ViewDType controls only the API-level raw element grouping that the PTO
contract explicitly permits;
BackingDType remains the architectural descriptor identity;
- source shape/layout/definedness come from the backing Tile;
- writing through a view to the same backing Tile preserves its descriptor;
- a separately owned
Tile<NewDType> destination is an ordinary NewDType Tile,
not an implicit descriptor mutation of the source.
If PTO needs an operation that actually changes a live Tile descriptor without
numeric conversion, that must be a separate explicit architectural relabel or
bitcast operation. It is not part of this zero-instruction API.
4. Required API documentation
Update the reinterpret documentation to explain:
- compiler view versus architectural descriptor;
- reinterpret versus
TCVT numeric conversion;
- raw-carrier whitelist and rejected numeric consumers;
- lifetime and aliasing;
- supported dtype/layout classes;
- examples that produce no instruction;
- compile-time failure examples;
- the dependency on PTO-SPEC #162 for any expanded consumer surface.
Remove or replace examples that imply a reinterpreted view is automatically
valid for TMATMUL or other numeric operations.
Verification
Add tests that prove:
ViewDType changes while BackingDType, storage carrier, shape, layout,
TileSizeCode, identity, and bytes remain unchanged.
- Constructing the view emits no instruction in optimized target output.
- The accepted raw-carrier example emits exactly the intended consumer bundle
and no TCVT, copy, memory transfer, or hidden relabel operation.
- Numeric consumers reject cross-dtype views at compile time with actionable
diagnostics.
- Different-width, unregistered, incompatible packed/scale-bearing, Shared,
and rvalue sources fail at compile time.
- Aliased source/view access preserves one backing descriptor and has a
deterministic lifetime contract.
- CPU-sim/host compilation and Linx target compilation agree on the type
traits and negative gates.
- After PTO-SPEC #162 is accepted, one cross-model test uses the same compiled
consumer in gfrun and QEMU without weakening ASL dtype legality.
Acceptance criteria
- The API exposes compiler view dtype and architectural backing dtype as
distinct concepts.
- A zero-instruction reinterpret cannot silently change runtime descriptor
state.
- Generic numeric operations cannot consume a cross-dtype view accidentally.
- Raw-carrier consumers use an explicit, reviewable opt-in contract.
- Documentation and positive/negative compilation tests match the contract.
- Target disassembly proves zero additional instructions for view creation.
- The issue/implementation links PTO-SPEC #162 and does not claim broader ISA
legality before that architecture decision is accepted.
Existing implementation context
Summary
Audit and tighten the existing
reinterpret_tile<NewDType>(src)API so it is azero-instruction, compiler-only Tile view rather than an implicit architectural
Tile-descriptor mutation.
The API already exists on
linx, together withdocs/tileop-usage/reinterpret-tile.md. The current implementation changes theview's public
DType, and downstream Tile operations obtain the PTO datatypeencoding from that new type. This is broader than the currently accepted PTO
architecture contract and is the concrete mismatch reported in
PTO-ISA/pto-spec#162.
This issue requests an API-contract correction and implementation. It does not
authorize weakening the PTO ASL exact-dtype checks to a byte-width comparison.
Why this is needed
The failing pattern is:
A zero-instruction C++ expression is not observable by hardware, gfrun, QEMU,
or the PTO ASL model. It therefore cannot silently relabel the architectural
Tile descriptor. Treating every same-width dtype as interchangeable would also
leave numeric interpretation, packed formats, scale-bearing formats, aliases,
definedness, and destination descriptor propagation unspecified.
Proposed API contract
1.
reinterpret_tileis a non-owning compiler viewKeep the public spelling:
The returned view MUST:
compactness, TileSizeCode, and definedness;
B.IOSbinding semantics areseparately designed.
The view type SHOULD expose both identities explicitly:
Do not represent these two meanings with one unqualified
DTypethat everyconsumer interprets as the architectural dtype. Add traits such as
is_reinterpreted_tile_view_v<T>,view_dtype_t<T>,backing_dtype_t<T>, andan unwrap/accessor for the exact backing Tile as needed by consumers.
2. Compile-time legality
The first supported form MUST require:
Equal bit width alone is not sufficient for all formats. Packed, scale-bearing,
or descriptor-sidecar formats MUST be rejected unless an accepted PTO contract
explicitly places the pair in a storage-compatible raw-carrier class.
Diagnostics MUST distinguish at least:
3. Consumers opt in; generic Tile APIs do not
reinterpret_tileMUST NOT automatically make the view legal for every APIthat accepts a Tile-shaped type.
Default numeric consumers—including arithmetic, matrix multiply, conversion,
comparison, reduction, and format/scale-sensitive operations—MUST use the
backing architectural dtype and MUST reject a cross-dtype reinterpret view
unless their accepted PTO contract explicitly says otherwise.
Raw-carrier consumers may opt in through a dedicated concept/trait. The initial
candidate family is the raw bitwise logical surface (
TAND,TOR,TXORandtheir scalar forms), but the exact whitelist and legal dtype pairs MUST follow
the accepted resolution of PTO-SPEC #162. Do not infer eligibility from equal
width alone.
For an opted-in raw operation:
ViewDTypecontrols only the API-level raw element grouping that the PTOcontract explicitly permits;
BackingDTyperemains the architectural descriptor identity;Tile<NewDType>destination is an ordinary NewDType Tile,not an implicit descriptor mutation of the source.
If PTO needs an operation that actually changes a live Tile descriptor without
numeric conversion, that must be a separate explicit architectural relabel or
bitcast operation. It is not part of this zero-instruction API.
4. Required API documentation
Update the reinterpret documentation to explain:
TCVTnumeric conversion;Remove or replace examples that imply a reinterpreted view is automatically
valid for
TMATMULor other numeric operations.Verification
Add tests that prove:
ViewDTypechanges whileBackingDType, storage carrier, shape, layout,TileSizeCode, identity, and bytes remain unchanged.
and no
TCVT, copy, memory transfer, or hidden relabel operation.diagnostics.
and rvalue sources fail at compile time.
deterministic lifetime contract.
traits and negative gates.
consumer in gfrun and QEMU without weakening ASL dtype legality.
Acceptance criteria
distinct concepts.
state.
legality before that architecture decision is accepted.
Existing implementation context
include/common/pto_tile.hppdocs/tileop-usage/reinterpret-tile.mdPTO-ISA/pto-spec#162