UAIX.LmRuntime / Package guide

UAIX.LmRuntime.Gguf

Bounded GGUF parsing, strict validation, metadata, tensors, sharding, hashing, and mapped access.

Required For GGUF inspection and validation

UAIX.LmRuntime.Gguf

Bounded GGUF parsing, metadata and tensor catalogs, strict validation, sharding, hashing, and mapped tensor access.

Overview

GGUF parser, metadata model, tensor catalog, sharding, and validation for pure C# local LLM runtime packages.

Who should use it Applications that inspect or validate GGUF artifacts, tokenizer/model loaders, and low-level mapped-tensor consumers.
Execution status Managed bounded GGUF parsing, validation, sharding, hashing, metadata, tensor catalogs, and mapped access are represented in the supplied source.

Install

.NET CLI
dotnet add package UAIX.LmRuntime.Gguf
Project file
<PackageReference Include="UAIX.LmRuntime.Gguf" />

Version policy: The documentation deliberately omits UAIX.LmRuntime package version numbers. Resolve and pin versions through your normal dependency-management and lock-file process.

Direct package dependencies
UAIX.LmRuntime.Tensors Guide NuGet ↗

Package role and boundaries

Required For GGUF inspection and validation

  • You need to parse GGUF metadata and tensor descriptors without starting inference.
  • You need bounded strict validation, shard information, artifact classification, or SHA-256 identity.
  • You need mapped, segmented, or copied access to tensor payload bytes.

Boundary

  • Selecting a tokenizer, binding a LLaMA graph, or generating output by itself.
  • Treating all syntactically valid GGUF files as supported model architectures.

Bounded intake

GgufParseOptions places explicit limits on tensor counts, metadata counts, dimensions, strings, arrays, and nesting before dependent work proceeds.

Structure before architecture

GgufModel represents container metadata and tensor descriptors. A structurally valid file can still be unsupported by a tokenizer or model-family loader.

Mapped ownership

MappedGgufFile owns the mapping lifetime. Tensor spans and views must not outlive the owner, and callers should dispose the mapping deterministically.

Key types

These are the main public entry points. The generated reference below includes the documented public package surface.

Coding examples

Examples use the documented public package surface. Paths, identities, runtime identifiers, device evidence, and application policy remain host inputs.

Strictly validate a GGUF file

Return all structural validation errors without moving immediately into model execution.

GgufValidationExample.cs
using UAIX.LmRuntime.Gguf;

var options = new GgufParseOptions
{
    MaxTensorCount = 100_000,
    MaxMetadataCount = 100_000,
    MaxDimensionCount = 8,
    MaxStringBytes = 16 * 1024 * 1024,
    MaxArrayLength = 10_000_000,
    MaxArrayDepth = 8
};

GgufValidationReport report =
    GgufStrictValidator.Validate("models/model.gguf", options);

if (!report.IsValid)
{
    foreach (GgufValidationError error in report.Errors)
    {
        Console.Error.WriteLine(
            $"{error.Code}: {error.Message} @ {error.ByteOffset?.ToString() ?? "n/a"}");
    }

    return;
}

Console.WriteLine($"Tensors: {report.Model.Tensors.Count}");
Console.WriteLine($"Metadata entries: {report.Model.Metadata.Count}");

Inspect model metadata and tensors

Parse the container and enumerate the metadata/tensor catalog without materializing model weights.

GgufInspectionExample.cs
using UAIX.LmRuntime.Gguf;

GgufModel model = GgufReader.Read(
    "models/model.gguf",
    new GgufParseOptions());

Console.WriteLine($"Artifact kind: {model.ArtifactKind}");
Console.WriteLine($"GGUF container version: {model.Version}");
Console.WriteLine($"Tensor data offset: {model.TensorDataOffset}");
Console.WriteLine($"Alignment: {model.Alignment}");

if (model.TryGetString("general.name", out string? modelName))
{
    Console.WriteLine($"Model name: {modelName}");
}

foreach (GgufTensorDescriptor tensor in model.Tensors)
{
    Console.WriteLine(
        $"{tensor.Name}: {tensor.GgmlType}, " +
        $"{tensor.ElementCount:N0} elements, {tensor.ByteLength:N0} bytes");
}

Compute and compare a model identity

Calculate SHA-256 before accepting a local artifact into a trusted model catalog.

GgufHashExample.cs
using UAIX.LmRuntime.Gguf;

public static class GgufIdentityVerifier
{
    /// <summary>
    /// Computes the current GGUF digest and rejects an artifact that does not match the trusted identity.
    /// </summary>
    /// <param name="modelPath">The local GGUF path to hash.</param>
    /// <param name="expectedSha256">The expected 64-character SHA-256 digest.</param>
    /// <returns>The normalized digest computed from the current file bytes.</returns>
    public static string VerifySha256(
        string modelPath,
        string expectedSha256)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(modelPath);
        ArgumentException.ThrowIfNullOrWhiteSpace(expectedSha256);

        string actualSha256 = GgufHashingReader.ComputeSha256(modelPath);

        if (!string.Equals(
                actualSha256,
                expectedSha256,
                StringComparison.OrdinalIgnoreCase))
        {
            throw new InvalidDataException(
                "The GGUF artifact hash does not match the trusted identity.");
        }

        return actualSha256;
    }
}

Read a mapped float32 tensor

Keep the mapped file alive while reading a tensor view and copy values only when the caller needs an owned array.

MappedTensorExample.cs
using System.Linq;
using UAIX.LmRuntime.Gguf;
using UAIX.LmRuntime.Tensors;

GgufModel model = GgufReader.Read(
    "models/model.gguf",
    new GgufParseOptions());

GgufTensorDescriptor descriptor = model.Tensors
    .First(tensor => tensor.GgmlType == GgmlTensorType.F32);

using var mapped = new MappedGgufFile(model);

MappedTensorView view = mapped.CreateTensorView(
    descriptor,
    descriptor.Dimensions);

var reader = new Float32TensorReader(view);
float firstValue = reader.ReadElement(0);
float[] ownedValues = reader.ToArray();

Console.WriteLine($"First value: {firstValue}");
Console.WriteLine($"Copied values: {ownedValues.Length}");

Generated API reference

Expand a type to review its documented public fields, properties, constructors, methods, parameter descriptions, and return descriptions.

GgufArtifactKindUAIX.LmRuntime.Gguf 5 members

Identifies the likely role of a GGUF artifact.

Field BaseModel

Base model artifact.

Field VocabOnly

Vocabulary-only artifact.

Field LoraSidecar

LoRA sidecar artifact.

Field MultimodalProjectorSidecar

Multimodal projector sidecar artifact.

Field MultiTokenPredictionSidecar

Multi-token-prediction sidecar artifact.

GgufByteOrderUAIX.LmRuntime.Gguf 3 members

Identifies the byte order used by a GGUF artifact.

Field Auto

Detect the byte order from the version field and reject ambiguous headers.

Field LittleEndian

Interpret multi-byte values as little-endian.

Field BigEndian

Interpret multi-byte values as big-endian.

GgufDiagnosticUAIX.LmRuntime.Gguf 3 members

Represents a structured GGUF parser diagnostic.

Property Code

Gets the stable diagnostic code.

Property Message

Gets the diagnostic message.

Property ByteOffset

Gets the byte offset associated with the diagnostic when known.

GgufParseResultUAIX.LmRuntime.Gguf 3 members

Represents a non-throwing GGUF parse result.

Property Model

Gets the parsed model when parsing succeeded.

Property Diagnostics

Gets parser diagnostics.

Property Succeeded

Gets a value indicating whether parsing succeeded without diagnostics.

GgufFormatExceptionUAIX.LmRuntime.Gguf 3 members

Represents a GGUF format violation with a stable code and byte offset.

Method GgufFormatException(string,string,System.Nullable<ulong>,System.Exception)

Initializes a new GgufFormatException instance with validated dependencies and operational bounds.

code
The stable machine-readable diagnostic code used to classify the failure without relying on localized message text.
message
The display-safe diagnostic message describing the failure without embedding prompt text, generated text, credentials, or private file contents.
byteOffset
The zero-based byte offset into the relevant source or destination; range validation occurs before access.
innerException
The underlying exception preserved for diagnostic chaining, or null when no lower-level failure is available.
Property Code

Gets the stable diagnostic code.

Property ByteOffset

Gets the byte offset associated with the violation when known.

GgufDumpWriterUAIX.LmRuntime.Gguf 1 member

Writes human-readable GGUF metadata and tensor catalog dumps.

Method Write(UAIX.LmRuntime.Gguf.GgufModel)

Creates a textual dump for a parsed GGUF model.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.

Returns: The text produced by GgufDumpWriter.Write for this contract: Creates a textual dump for a parsed GGUF model. The returned string is detached from mutable caller storage and is not persisted by the operation.

GgufMetadataAccessorsUAIX.LmRuntime.Gguf 6 members

Provides strongly typed accessors for GGUF metadata values.

Method TryGetBoolean(UAIX.LmRuntime.Gguf.GgufModel,string,bool&)

Tries to read a Boolean metadata value.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
value
When the method returns, contains the value produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains a Boolean value.

Method TryGetStringArray(UAIX.LmRuntime.Gguf.GgufModel,string,System.Collections.Generic.IReadOnlyList<string>&)

Tries to read a metadata string array.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
values
When the method returns, contains the values produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains only string elements.

Method TryGetSingleArray(UAIX.LmRuntime.Gguf.GgufModel,string,System.Collections.Generic.IReadOnlyList<float>&)

Tries to read a metadata single-precision floating point array.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
values
When the method returns, contains the values produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains numeric elements convertible to float.

Method TryGetInt32Array(UAIX.LmRuntime.Gguf.GgufModel,string,System.Collections.Generic.IReadOnlyList<int>&)

Tries to read a metadata 32-bit signed integer array.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
values
When the method returns, contains the values produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains integral elements convertible to int.

Method TryGetByteArray(UAIX.LmRuntime.Gguf.GgufModel,string,System.Collections.Generic.IReadOnlyList<byte>&)

Tries to read a metadata byte array.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
values
When the method returns, contains the values produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains integral elements convertible to bytes.

Method TryGetInt32(UAIX.LmRuntime.Gguf.GgufModel,string,int&)

Tries to read a metadata 32-bit signed integer scalar.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
value
When the method returns, contains the value produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains an integral value convertible to int.

GgufMetadataValueUAIX.LmRuntime.Gguf 4 members

Represents a typed GGUF metadata value.

Property Type

Gets the metadata value type.

Property Value

Gets the scalar value or a for arrays.

Method Create(UAIX.LmRuntime.Gguf.GgufMetadataValueType,object)

Creates the GGUF metadata value from the validated inputs required by GgufMetadataValue.

type
The type containing validated format or tokenizer metadata required by this operation.
value
The value input of type object? read by GgufMetadataValue.Create; it must satisfy the member-specific nullability, identity, range, and ownership rules before dependent work begins.

Returns: The metadata value, with ownership and disposal obligations defined by the returned type and the Create contract.

Method ToString

Returns the string representation of this value.

Returns: The text produced by GgufMetadataValue.ToString for this contract: Returns the string representation of this value. The returned string is detached from mutable caller storage and is not persisted by the operation.

GgufMetadataArrayUAIX.LmRuntime.Gguf 3 members

Represents a typed GGUF metadata array.

Property ElementType

Gets the element type.

Property Items

Gets the array values.

Method ToString

Returns a concise description of this array.

Returns: The text produced by GgufMetadataArray.ToString for this contract: Returns a concise description of this array. The returned string is detached from mutable caller storage and is not persisted by the operation.

GgufMetadataValueTypeUAIX.LmRuntime.Gguf 13 members

Identifies GGUF metadata value types.

Field UInt8

8-bit unsigned integer.

Field Int8

8-bit signed integer.

Field UInt16

16-bit unsigned integer.

Field Int16

16-bit signed integer.

Field UInt32

32-bit unsigned integer.

Field Int32

32-bit signed integer.

Field Float32

32-bit floating point.

Field Bool

Boolean.

Field String

UTF-8 string.

Field Array

Typed array.

Field UInt64

64-bit unsigned integer.

Field Int64

64-bit signed integer.

Field Float64

64-bit floating point.

GgufModelUAIX.LmRuntime.Gguf 15 members

Represents a parsed GGUF artifact catalog and metadata dictionary.

Property Path

Gets the source file path.

Property Version

Gets the GGUF format version.

Property ByteOrder

Gets the resolved byte order used by the artifact.

Property FileLength

Gets the source file length captured during parsing.

Property Metadata

Gets the parsed metadata dictionary.

Property Tensors

Gets the tensor catalog.

Property TensorDataOffset

Gets the absolute tensor-data section start offset.

Property Alignment

Gets the tensor-data alignment.

Property Shard

Gets shard metadata.

Property ArtifactKind

Gets the inferred artifact kind.

Method Load(string,UAIX.LmRuntime.Gguf.GgufParseOptions)

Loads the GGUF model from a verified local source into GgufModel.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.
options
The optional GgufParseOptions controlling Load; null selects the documented defaults, supplied limits are validated before allocation, and the instance is not mutated.

Returns: The parsed model catalog, with ownership and disposal obligations defined by the returned type and the Load contract.

Method TryGetString(string,string&)

Tries to get a string metadata value.

key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
value
When the method returns, contains the value produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and contains a string.

Method TryGetUInt32(string,uint&)

Tries to get an unsigned 32-bit metadata value.

key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
value
When the method returns, contains the value produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and can be converted to an unsigned 32-bit integer.

Method TryGetSingle(string,float&)

Tries to get a single-precision metadata value.

key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.
value
When the method returns, contains the value produced by the operation when successful; otherwise contains the type's default value.

Returns: True when the key exists and can be converted to a single-precision value.

Method TryGetTensor(string,UAIX.LmRuntime.Gguf.GgufTensorDescriptor&)

Tries to resolve a tensor descriptor by its exact GGUF name.

name
The exact ordinal name used for catalog lookup, canonical hashing, or diagnostic labeling as defined by the containing member.
tensor
When the method returns, contains the tensor produced by the operation when successful; otherwise contains the type's default value.

Returns: True when try get tensor succeeds for the supplied values; otherwise, false.

GgufParseOptionsUAIX.LmRuntime.Gguf 7 members

Defines safety limits for GGUF parsing.

Property ByteOrder

Gets the requested GGUF byte order. Auto uses the version-field heuristic.

Property MaxTensorCount

Gets the maximum supported tensor count.

Property MaxMetadataCount

Gets the maximum supported metadata key-value count.

Property MaxDimensionCount

Gets the maximum supported dimension count per tensor.

Property MaxStringBytes

Gets the maximum metadata string byte length.

Property MaxArrayLength

Gets the maximum metadata array length.

Property MaxArrayDepth

Gets the maximum recursive array depth.

GgufReaderUAIX.LmRuntime.Gguf 2 members

Reads and validates GGUF model artifacts.

Method Read(string,UAIX.LmRuntime.Gguf.GgufParseOptions)

Reads a GGUF artifact from disk without copying tensor payloads to managed memory.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.
options
The optional GgufParseOptions controlling Read; null selects the documented defaults, supplied limits are validated before allocation, and the instance is not mutated.

Returns: The GgufModel result produced by GgufReader.Read for this contract: Reads a GGUF artifact from disk without copying tensor payloads to managed memory. It is published only after all documented validation and ownership transitions succeed.

Method TryRead(string,UAIX.LmRuntime.Gguf.GgufParseOptions)

Parses a GGUF artifact and returns structured diagnostics instead of throwing for format failures.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.
options
The optional GgufParseOptions controlling TryRead; null selects the documented defaults, supplied limits are validated before allocation, and the instance is not mutated.

Returns: True when the GGUF parse result is produced successfully; otherwise, false and no successful result is published.

GgufShardInfoUAIX.LmRuntime.Gguf 3 members

Describes sharding metadata found in a GGUF artifact.

Property ShardIndex

Gets the shard index when present.

Property ShardCount

Gets the shard count when present.

Property IsSharded

Gets a value indicating whether sharding metadata was found.

GgufTensorDescriptorUAIX.LmRuntime.Gguf 7 members

Describes a tensor stored in a GGUF artifact without copying its payload.

Property Name

Gets the tensor name.

Property Dimensions

Gets tensor dimensions in GGUF order.

Property GgmlType

Gets the GGML storage type.

Property ElementCount

Gets the logical element count.

Property RelativeOffset

Gets the relative tensor offset from the tensor data section.

Property AbsoluteOffset

Gets the absolute file offset for this tensor.

Property ByteLength

Gets the physical tensor byte length.

GgufValidationReportUAIX.LmRuntime.Gguf 3 members

Represents the result of strict GGUF validation.

Property IsValid

Gets a value indicating whether validation succeeded.

Property Errors

Gets validation errors with byte offsets when known.

Property Model

Gets the parsed model when validation succeeded.

GgufValidationErrorUAIX.LmRuntime.Gguf 3 members

Represents a GGUF validation error.

Property Code

Gets the diagnostic code.

Property Message

Gets the diagnostic message.

Property ByteOffset

Gets the byte offset associated with the error, if known.

GgufStrictValidatorUAIX.LmRuntime.Gguf 1 member

Validates GGUF artifacts without claiming execution parity.

Method Validate(string,UAIX.LmRuntime.Gguf.GgufParseOptions)

Validates the supplied path and the supplied options against the invariants required by GgufStrictValidator.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.
options
The optional GgufParseOptions controlling Validate; null selects the documented defaults, supplied limits are validated before allocation, and the instance is not mutated.

Returns: The GgufValidationReport result produced by GgufStrictValidator.Validate for this contract: Validates the supplied path and the supplied options against the invariants required by GgufStrictValidator. It is published only after all documented validation and ownership transitions succeed.

GgufShardResolverUAIX.LmRuntime.Gguf 1 member

Resolves GGUF shard files adjacent to a root artifact.

Method ResolveShards(string)

Resolves likely shard paths for a GGUF model path.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.

Returns: An ordered read-only IReadOnlyList<string> result from GgufShardResolver.ResolveShards: Resolves likely shard paths for a GGUF model path. Mutable internal collection aliases are not exposed through the returned contract.

GgufTensorPayloadViewUAIX.LmRuntime.Gguf 3 members

Represents a zero-copy tensor payload range inside a GGUF file.

Property AbsoluteOffset

Gets the absolute file offset.

Property LengthBytes

Gets the payload byte length.

Method FromTensor(UAIX.LmRuntime.Gguf.GgufTensorDescriptor)

Creates a payload view from a tensor descriptor.

tensor
The validated GGUF tensor descriptor whose dimensions, offsets, storage type, and byte length drive the operation.

Returns: The GgufTensorPayloadView result produced by GgufTensorPayloadView.FromTensor for this contract: Creates a payload view from a tensor descriptor. It is published only after all documented validation and ownership transitions succeed.

GgufArtifactClassifierUAIX.LmRuntime.Gguf 1 member

Classifies GGUF artifacts from metadata.

Method Classify(UAIX.LmRuntime.Gguf.GgufModel)

Classifies the GGUF artifact kind from validated metadata and tensor-layout evidence.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.

Returns: The GgufArtifactKind result produced by GgufArtifactClassifier.Classify for this contract: Classifies the GGUF artifact kind from validated metadata and tensor-layout evidence. It is published only after all documented validation and ownership transitions succeed.

GgufMetadataKeyPolicyUAIX.LmRuntime.Gguf 1 member

Validates GGUF metadata key syntax.

Method Validate(string)

Validates the supplied key against the invariants required by GgufMetadataKeyPolicy.

key
The exact ordinal metadata or catalog key used for lookup; the operation does not normalize or retain a mutable alias of the key.

Returns: The GgufValidationError? result produced by GgufMetadataKeyPolicy.Validate for this contract: Validates the supplied key against the invariants required by GgufMetadataKeyPolicy. It is published only after all documented validation and ownership transitions succeed.

GgufHashingReaderUAIX.LmRuntime.Gguf 1 member

Computes integrity hashes for GGUF and related model artifacts.

Method ComputeSha256(string)

Computes the SHA-256 hash of a file.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.

Returns: The text produced by GgufHashingReader.ComputeSha256 for this contract: Computes the SHA-256 hash of a file. The returned string is detached from mutable caller storage and is not persisted by the operation.

GgufJsonDumpWriterUAIX.LmRuntime.Gguf 1 member

Writes machine-readable GGUF dump JSON.

Method Write(UAIX.LmRuntime.Gguf.GgufModel)

Writes a stable JSON dump for a parsed GGUF model.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.

Returns: The text produced by GgufJsonDumpWriter.Write for this contract: Writes a stable JSON dump for a parsed GGUF model. The returned string is detached from mutable caller storage and is not persisted by the operation.

IMappedModelFileUAIX.LmRuntime.Gguf 6 members

Defines bounded, zero-copy access to tensor payloads in a mapped model artifact.

Property Model

Gets the parsed GGUF model catalog associated with the mapping.

Property FileLength

Gets the mapped file length in bytes.

Method GetTensorBytes(UAIX.LmRuntime.Gguf.GgufTensorDescriptor)

Gets a synchronous read-only span over one tensor payload.

tensor
The validated GGUF tensor descriptor whose dimensions, offsets, storage type, and byte length drive the operation.

Returns: A read-only span valid until this mapping is disposed.

Method GetTensorMemory(UAIX.LmRuntime.Gguf.GgufTensorDescriptor)

Gets a read-only memory view over one tensor payload.

tensor
The validated GGUF tensor descriptor whose dimensions, offsets, storage type, and byte length drive the operation.

Returns: A read-only memory view whose owner remains the mapped file.

Method TryGetTensorMemory(string,System.ReadOnlyMemory<byte>&)

Attempts to get a read-only memory view by tensor name.

tensorName
The exact ordinal GGUF tensor catalog name used for lookup and diagnostics.
memory
When the method returns, contains the memory produced by the operation when successful; otherwise contains the type's default value.

Returns: True when try get tensor memory succeeds for the supplied values; otherwise, false.

Method GetMemorySegments(ulong,ulong,int)

Creates bounded read-only memory windows for a validated mapped-file range.

absoluteOffset
The zero-based absolute offset into the relevant source or destination; range validation occurs before access.
byteLength
The bounded payload length in bytes used to validate offsets and prevent arithmetic overflow before slicing mapped storage.
maximumSegmentByteCount
The positive maximum byte count per returned segment.

Returns: Ordered borrowed segments whose combined length equals byteLength.

MappedGgufFileUAIX.LmRuntime.Gguf 14 members

Owns a read-only operating-system mapping of a GGUF artifact and exposes bounded tensor payload views.

The mapping is the sole owner of the acquired unmanaged pointer. Returned spans and memory views borrow that pointer and become invalid immediately after . Public entry points verify that descriptors belong to the parsed catalog before pointer arithmetic occurs.

Method MappedGgufFile(string,UAIX.LmRuntime.Gguf.GgufParseOptions)

Opens, validates, and maps a GGUF file read-only.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.
options
The optional GgufParseOptions controlling MappedGgufFile; null selects the documented defaults, supplied limits are validated before allocation, and the instance is not mutated.
Method MappedGgufFile(UAIX.LmRuntime.Gguf.GgufModel)

Maps a GGUF file using an already validated catalog.

model
The parsed GGUF model whose validated metadata and tensor catalog are consumed by this operation.
Property Model

Gets the immutable GGUF catalog that was validated before the operating-system mapping was opened.

Property FileLength

Gets the mapped file length captured from the validated catalog.

Property IsDisposed

Gets a value indicating whether the mapping has been disposed.

Method GetTensorBytes(UAIX.LmRuntime.Gguf.GgufTensorDescriptor)

Gets a synchronous borrowed span over one catalog tensor payload.

tensor
The descriptor that must match the mapping's authoritative tensor catalog.

Returns: A read-only span whose lifetime cannot exceed the current synchronous call chain.

Method GetTensorMemory(UAIX.LmRuntime.Gguf.GgufTensorDescriptor)

Gets a borrowed memory object over one catalog tensor payload.

tensor
The descriptor that must match the mapping's authoritative tensor catalog.

Returns: A read-only memory view backed directly by the operating-system mapping.

Method TryGetTensorMemory(string,System.ReadOnlyMemory<byte>&)

Tries to resolve a named tensor and create a borrowed mapped-memory view.

tensorName
The exact ordinal GGUF tensor catalog name used for lookup and diagnostics.
memory
Receives the borrowed tensor memory when the tensor exists; otherwise receives empty memory.

Returns: True when the tensor exists and a view was created; otherwise false.

Method GetMemorySegments(ulong,ulong,int)

Splits a validated mapped-file range into bounded borrowed memory segments.

absoluteOffset
The absolute file offset at which the first segment begins.
byteLength
The total number of bytes represented by all returned segments.
maximumSegmentByteCount
The positive upper bound for each managed segment descriptor.

Returns: Ordered borrowed memory segments that exactly cover the requested range.

Method GetBytes(ulong,ulong)

Gets a read-only span over a validated file range.

absoluteOffset
The zero-based absolute offset into the relevant source or destination; range validation occurs before access.
byteLength
The bounded payload length in bytes used to validate offsets and prevent arithmetic overflow before slicing mapped storage.

Returns: The bounded ReadOnlySpan<byte> view produced by MappedGgufFile.GetBytes: Gets a read-only span over a validated file range. Its lifetime and ownership remain tied to the owner identified by the containing type; no out-of-range region is exposed.

Method CopyBytes(ulong,System.Span<byte>)

Copies a validated mapped-file range into a caller-owned destination.

absoluteOffset
The zero-based absolute offset into the relevant source or destination; range validation occurs before access.
destination
The caller-owned destination buffer that receives the result; required capacity is validated before any write occurs.
Method CopyTensorBytes(UAIX.LmRuntime.Gguf.GgufTensorDescriptor,System.Span<byte>)

Copies a complete tensor payload into a caller-owned destination.

tensor
The validated GGUF tensor descriptor whose dimensions, offsets, storage type, and byte length drive the operation.
destination
The caller-owned destination buffer that receives the result; required capacity is validated before any write occurs.
Method CreateTensorView(UAIX.LmRuntime.Gguf.GgufTensorDescriptor,System.Collections.Generic.IReadOnlyList<ulong>)

Creates a read-only typed tensor view whose lifetime is owned by this mapping.

tensor
The validated GGUF tensor descriptor whose dimensions, offsets, storage type, and byte length drive the operation.
logicalDimensions
Optional logical row-major dimensions; storage dimensions are used when omitted.

Returns: The borrowed mapped tensor view, with ownership and disposal obligations defined by the returned type and the CreateTensorView contract.

Method Dispose

Releases the acquired view pointer, operating-system mapping handles, and source file handle.

IReadOnlyTensorViewUAIX.LmRuntime.Gguf 8 members

Defines a read-only tensor view backed by validated model storage.

Property Descriptor

Gets the authoritative GGUF tensor descriptor.

Property StorageDimensions

Gets dimensions in GGUF storage order.

Property LogicalDimensions

Gets normalized logical row-major dimensions.

Property DataType

Gets the runtime data type.

Property ByteOrder

Gets the GGUF byte order.

Property IsDisposed

Gets whether the backing owner has been disposed.

Method GetMemory

Gets a borrowed read-only memory view over the tensor payload.

Returns: The memory region containing the memory, bounded to the validated range owned by the result.

Method GetSpan

Gets a synchronous borrowed span over the tensor payload.

Returns: The bounded ReadOnlySpan<byte> view produced by IReadOnlyTensorView.GetSpan: Gets a synchronous borrowed span over the tensor payload. Its lifetime and ownership remain tied to the owner identified by the containing type; no out-of-range region is exposed.

MappedTensorViewUAIX.LmRuntime.Gguf 9 members

Carries validated tensor geometry and a borrowed read-only view into a mapped GGUF file.

Method MappedTensorView(UAIX.LmRuntime.Gguf.MappedGgufFile,UAIX.LmRuntime.Gguf.GgufTensorDescriptor,System.Collections.Generic.IReadOnlyList<ulong>)

Initializes a new MappedTensorView instance with validated dependencies and operational bounds.

owner
The mapped model-file owner that keeps the tensor payload alive for the lifetime of the created view.
descriptor
The validated tensor descriptor retained by the view; its offsets and lengths remain bounded by the mapped file.
logicalDimensions
The logical dimensions sequence used by this operation; its required length, ordering, and element bounds are validated before access.
Property Descriptor
Property StorageDimensions
Property LogicalDimensions
Property DataType
Property ByteOrder
Property IsDisposed
Method GetMemory

Retrieves the memory from the current MappedTensorView state after validating the requested access.

Returns: The memory region containing the memory, bounded to the validated range owned by the result.

Method GetSpan

Retrieves the span from the current MappedTensorView state after validating the requested access.

Returns: The bounded ReadOnlySpan<byte> view produced by MappedTensorView.GetSpan: Retrieves the span from the current MappedTensorView state after validating the requested access. Its lifetime and ownership remain tied to the owner identified by the containing type; no out-of-range region is exposed.

Float32TensorReaderUAIX.LmRuntime.Gguf 5 members

Reads float32 values from a validated tensor view with explicit GGUF byte-order handling.

Method Float32TensorReader(UAIX.LmRuntime.Gguf.IReadOnlyTensorView)

Initializes a new Float32TensorReader instance with validated dependencies and operational bounds.

view
The bounded tensor view whose descriptor, shape, byte order, and mapped payload are read without transferring ownership of the underlying mapping.
Property ElementCount

Gets the logical float32 element count.

Method ReadElement(int)

Reads one element by flat storage index.

index
The zero-based index; it must identify an existing position within the relevant validated range.

Returns: The float value computed by Float32TensorReader.ReadElement for this contract: Reads one element by flat storage index. Range, finite-value, and overflow checks are completed before the value is returned.

Method CopyTo(System.Span<float>)

Decodes every element into a caller-provided destination.

destination
The destination with room for every tensor element.
Method ToArray

Creates an explicit bounded managed copy for scalar reference execution.

Returns: A newly allocated float[] containing the ordered result of Float32TensorReader.ToArray: Creates an explicit bounded managed copy for scalar reference execution. The caller owns the returned array and later mutation cannot alter the source object.

SegmentedModelFileOptionsUAIX.LmRuntime.Gguf 1 member

Configures bounded segmented reads from a model file whose logical offsets remain unsigned 64-bit values.

Property MaximumSegmentByteCount

Gets the maximum bytes returned by one owned segment.

ModelFileSegmentUAIX.LmRuntime.Gguf 5 members

Owns one pooled, bounded model-file segment returned by .

The segment owns an lease. Consumers may retain only while this instance is alive and must dispose the segment exactly once when the bytes are no longer needed.

Property Offset

Gets the unsigned logical file offset represented by this segment.

Property Length

Gets the number of valid bytes in the segment.

Property IsDisposed

Gets whether the pooled segment has been released.

Property Memory

Gets the read-only segment bytes while this owner remains alive.

Method Dispose

Returns the rented byte array to the shared pool and invalidates Memory.

SegmentedModelFileReaderUAIX.LmRuntime.Gguf 7 members

Reads bounded windows from a local model file without representing the complete file as one managed span.

Logical positions remain unsigned 64-bit values until the final checked conversion required by the operating-system random-access API. Returned owned segments are copies in pooled memory; caller-provided spans remain caller owned. This class performs no network access and never follows URLs.

Method SegmentedModelFileReader(string,UAIX.LmRuntime.Gguf.SegmentedModelFileOptions)

Opens a local model file for deterministic random access.

path
The local file-system path processed by this operation; it must satisfy the containing component's path and scope policy.
options
The optional SegmentedModelFileOptions controlling SegmentedModelFileReader; null selects the documented defaults, supplied limits are validated before allocation, and the instance is not mutated.
Property Length

Gets the file length as an unsigned 64-bit value.

Property MaximumSegmentByteCount

Gets the maximum owned segment size.

Property IsDisposed

Gets whether the reader has released its file handle.

Method ReadExactly(ulong,System.Span<byte>)

Reads exactly into a caller-owned bounded destination.

offset
The zero-based offset into the relevant source or destination; range validation occurs before access.
destination
The caller-owned destination buffer that receives the result; required capacity is validated before any write occurs.
Method ReadSegment(ulong,int)

Reads the segment from the current binary source using the component's validated representation.

offset
The zero-based offset into the relevant source or destination; range validation occurs before access.
length
The length used to bound this operation; it must be nonnegative and within the supported range.

Returns: The ModelFileSegment result produced by SegmentedModelFileReader.ReadSegment for this contract: Reads the segment from the current binary source using the component's validated representation. It is published only after all documented validation and ownership transitions succeed.

Method Dispose

Releases resources owned by SegmentedModelFileReader and transitions it to the disposed state.

Frequently asked questions

What is the difference between Read and TryRead?

Read is the direct parse path and can throw for invalid input. TryRead returns a GgufParseResult containing success state, diagnostics, and the parsed model when available.

Does strict validation prove that the model can run?

No. It proves the checked container invariants. Tokenizer compatibility, architecture support, required tensors, storage layouts, and execution still need their own validation gates.

Can I hold a tensor span after disposing MappedGgufFile?

No. Treat every span, memory segment, and mapped tensor view as borrowing the mapping lifetime.

Does this package download models?

No. The caller supplies local paths and owns model acquisition, licensing review, and trust policy.