#pragma once #include "ling3/gdn_step.h" #include #include #include #include #include namespace ling3 { // Complete, portable numerical state, independent of a decoder's live buffers. // Not a chat history or a suspended sampler. Treat published states as immutable. struct AttentionState { GdnState gdn; std::array, 3> conv; std::vector keys, values; std::size_t bytes() const; }; struct DecoderState { std::string signature; std::size_t position = 0; std::vector layers; std::size_t bytes() const; }; // Versioned little-endian format, per-buffer CRC, bounded allocations. Loading // validates every layer before the engine can mutate any live numerical state. void ValidateDecoderState(const DecoderState & state, std::string_view signature, std::size_t capacity); void WriteDecoderState(const DecoderState & state, const std::filesystem::path & path); DecoderState ReadDecoderState(const std::filesystem::path & path, std::string_view signature, std::size_t capacity); } // namespace ling3