experimental/packed_trit_vector.hppThis RFC stabilizes the packed trit vector substrate used by SWAR and SIMD execution.
It defines:
The goal is to stop treating the packed-trit substrate as an implementation detail while higher-level backends depend on it as if it were already stable.
Today, both SWAR and SIMD surfaces rely on types currently rooted in:
t81::experimental::PackedTritVectort81::experimental::ComputeTritVectorThat creates a governance mismatch:
Without a stable packed trit vector contract:
T81 SHALL introduce a stable packed-trit surface under a governed namespace.
The stable surface MUST provide:
The experimental namespace may remain temporarily as a compatibility shim, but it must no longer be the constitutional source of truth.
The packed-trit interface MUST define one canonical encoding for governed trit vectors.
For the current surface, that means:
The interface MUST explicitly state:
The stable interface MUST guarantee:
It MUST NOT guarantee:
The interface MUST define which operations are:
In-place operations MUST preserve canonical encoding invariants.
Raw kernel entry points MUST either:
The distinction must be explicit in the API.
The stable interface MUST specify deterministic validation behavior for:
Validation failures MUST be represented by deterministic error values, not undefined behavior.
If packed-trit vectors are serialized across module boundaries, the stable interface MUST define:
If the packed representation is used only internally for execution, the RFC MUST still define canonical in-memory byte meaning so backend equivalence can be tested against it.
The stable packed-trit interface is the shared substrate for:
Any backend operating on packed-trit storage MUST consume the same canonical packed layout.
Backend-specific reinterpretations are forbidden on the deterministic surface.
Dispatch thresholds belong to backend RFCs, not to the packed-trit interface itself.
This RFC governs representation and manipulation semantics, not optimization policy.
Promotion to a stable packed-trit interface SHOULD follow this path:
experimentalNo semantic rewrite is required during namespace promotion.
This RFC is ready for accepted when all of the following are true:
experimental aliasesThis RFC may introduce a compatibility layer and eventual deprecation path for direct external use of experimental/packed_trit_vector.hpp.
No direct regression is intended.
A stable substrate may improve optimization work by freezing invariants instead of rediscovering them across layers.
A stable validation contract reduces UB and malformed-input ambiguity in backend-sensitive code.
experimentalRejected because SWAR and SIMD are already being promoted above it.
Rejected because they already share representation assumptions.
Rejected because mutation and validation semantics are part of the determinism contract.
All acceptance criteria are satisfied as of this date.
AC1 — Stable type outside experimental namespace:
t81::ComputeTritVector and t81::PackedTritVector are the governed stable
aliases at include/t81/packed_trit_vector.hpp. The implementation in
t81::experimental is the backing detail; the public surface is t81::.
vm/tensor_helpers.cpp, vm/jit/jit_compiler.cpp, and all four benchmark files
were updated to use t81::ComputeTritVector / t81::PackedTritVector directly.
AC2 — Canonical encoding and tail-byte rules documented:
spec/tisc-spec.md §5.2.2 (“Normative Packed-Trit Encoding (RFC-0044)”) now
documents the 2-bit encoding table (00=Z, 01=P, 11=N, 10=forbidden), LSB-first
byte layout, 4 trits/byte, zero-extension of trailing bits, and the
deterministic byte-count formula ⌈trit_count / 4⌉.
AC3 — SWAR and SIMD headers use stable substrate:
include/t81/swar/swar.hpp includes "t81/packed_trit_vector.hpp" (stable shim).
include/t81/tritwise/tritwise.hpp likewise uses the stable surface for dispatch.
No SWAR or SIMD public header imports experimental directly.
AC4 — Invalid-pattern handling executable and covered by tests:
test_rfc0044_invalid_pattern_rejection() was added to tests/cpp/test_swar.cpp.
It verifies: from_packed rejects the 10 bit pattern in trit 0 and trit 1;
rejects non-zero tail padding for a 3-trit vector; accepts valid bytes and
round-trips correctly; to_trits() only produces {-1, 0, +1}.
AC5 — VM helpers depend on stable surface:
vm/tensor_helpers.cpp now uses using t81::ComputeTritVector; (stable alias).
vm/jit/jit_compiler.cpp now includes t81/packed_trit_vector.hpp explicitly
and uses t81::ComputeTritVector throughout.
spec/rfcs/RFC-0040-swar-formalization.mdspec/rfcs/RFC-0041-simd-formalization.mdspec/rfcs/RFC-0049-canonical-ternary-arithmetic-semantics.mdinclude/t81/packed_trit_vector.hppinclude/t81/experimental/packed_trit_vector.hppinclude/t81/swar/swar.hppinclude/t81/simd/simd.hppvm/tensor_helpers.cppvm/jit/jit_compiler.cpptests/cpp/test_swar.cpp