Skip to content

Recording artifacts

This page describes the files and data generated by Mneme during kernel recording and replay.


Example of artifacts collected during recording:

Below you can see some artifact files generated by a recording run performed by (mneme record):

./record-example-dir/
├── 15941914485064662553.json
├── DeviceState.epilogue.15941914485064662553.16313427880266313990.mneme
├── DeviceState.prologue.15941914485064662553.16313427880266313990.mneme
└── RecordedIR_15941914485064662553.bc
Mneme generates files of the following types: 1. Record Database: A JSON file describing the recorded kernel and associates metadata 2. GPU device memory state: Binary blobs describing the memory state of the GPU 3. LLVM IR: File(s) containing the LLVM IR of the recorded kernel(s).


Recording database

Each invocation of mneme record produces one or more recording database (s), each represented by a JSON file. The recording database file is named using the format <static-hash>.json, where the static hash is a numeric identifier that uniquely represents the source code of a single GPU kernel. The database serves as the entry point for replay and tuning workflows.

The database describes: - the recorded kernel, - the LLVM IR required for replay, - the recorded execution instances of that kernel, and - how often each launch configuration of the kernel was launched.

A kernel gets a database once at least one of its launches is recorded. A kernel that is never recorded, for example because MNEME_SKIP_RECORDINGS or the filter file's skip exceeds its number of launches, leaves no files. The databases are written after each recorded launch and once more when the application exits, so the launch counts cover the whole run. If the application crashes, the databases keep the counts from the last recorded launch.


Example

Below is an example of a recording database generated by mneme record:

{
  "DemangledName": "void vecAdd_test<long>(long*, long*, unsigned long)",
  "KernelName": "_Z11vecAdd_testIlEvPT_S1_m",
  "StaticHash": 15941914485064662553,
  "Modules": [
    "RecordedIR_15941914485064662553.bc"
  ],
  "TotalLaunches": 7,
  "instances": {
    "16313427880266313990": {
      "GridDims": { "x": 40000, "y": 1, "z": 1 },
      "BlockDims": { "x": 256, "y": 1, "z": 1 },
      "SharedMem": 0,
      "Prologue": "DeviceState.prologue.*.mneme",
      "Epilogue": "DeviceState.epilogue.*.mneme",
      "Occurrences": 5
    }
  }
}

Top-level fields

  • KernelName: Mangled name of the recorded GPU kernel.
  • DemangledName: Human-readable name of the kernel, useful for inspection and debugging.
  • StaticHash: A stable numeric identifier uniquely representing the kernel’s source code.
  • Modules: LLVM IR modules (.bc) required to replay and recompile the kernel.
  • SourceFile: Absolute path of the file that defines the kernel, taken from line-table debug info. It is omitted, together with the other Source* fields, when the recorded module has no debug info; with --copy-source, the recorder then warns once per run and suggests compiling with -gline-tables-only.
  • SourceLine, SourceEndLine: First and last line of the kernel definition, inclusive and 1-based. The end line is the last line that generated code. Both are present whenever SourceFile is.
  • SourceMD5: MD5 checksum of SourceFile. It is the checksum recorded at compile time when debug info provides one, so it identifies the exact revision the line numbers refer to.
  • SourceCopy: Copy of SourceFile in the record directory, written only with --copy-source. The copy is skipped when the file no longer matches SourceMD5.
  • TotalLaunches: Number of times the kernel was launched during recording, including launches that were not recorded. Launches of configurations that were never recorded appear only here, so TotalLaunches minus the Occurrences of all instances is the number of launches without a recorded configuration. In scoped filter mode, this includes launches outside an enabled scope. Absent in databases recorded by older Mneme versions.
  • TimingSource: Timer that measured the launch durations, currently always profiler. Present only with kernel timing.
  • TotalTimeNs: Summed GPU duration, in nanoseconds, of the timed launches counted in TotalLaunches. TotalTimeNs minus the TimeNs.Sum of all instances is the time spent in launches without a recorded configuration. Present only with kernel timing.
  • instances: A mapping from instance identifiers to recorded kernel executions. Each instance corresponds to a specific dynamic execution context.

Kernel instances (instances)

A mapping from instance identifiers to recorded kernel executions. Each instance corresponds to a specific dynamic execution context.

Each entry under instances corresponds to the same kernel but to a different dynamic execution context, typically resulting from different launch configurations or runtime parameters. In Mneme terminology, such executions are identified by distinct dynamic hashes. Every dynamic hash is described by: - launch configuration (grid and block dimensions), - shared memory size, - paths to device memory snapshots, and - occurrence count: the number of launches with this configuration over the whole run, including launches that were skipped, fell outside an enabled scope, or happened after it was recorded. - with kernel timing, the GPU durations of these launches: - TimedLaunches: number of those launches that were timed. It is less than Occurrences when a launch could not be timed, for example because it was captured into a graph. - TimeNs: Sum, Min, and Max of their durations in nanoseconds. Omitted while TimedLaunches is 0. - RecordedLaunchTimeNs: duration of the launch whose snapshots were recorded. It is also included in TimeNs. Omitted when that launch was not timed.

These instance identifiers are used directly by the mneme replay command via the -rid option.

Kernel timing

Setting MNEME_KERNEL_TIMING=profiler (or 1) while recording adds the GPU duration of every launch counted in TotalLaunches to the database. off, 0, or unset disables timing, and any other value is rejected.

The durations come from the vendor profiler, rocprofiler-sdk on AMD and CUPTI on NVIDIA, which replay also uses to time kernels. A duration spans the dispatch from its start to its end timestamp, the same numbers rocprofv3 reports, so it excludes the host-side launch overhead and the time the launch waited in its stream. The database names the timer that measured its durations in TimingSource.

Mneme cannot use the vendor profiler when another tool such as rocprofv3 or Nsight Compute already does. Recording then stops with an error that gives the reason, rather than continuing without timing.

Launches on a stream that is being captured into a graph are counted but not timed, and launches of the graph are neither counted nor timed. Durations are collected asynchronously, so the databases written after each recorded launch can lack the most recent ones. The databases written at exit are complete: Mneme waits for all outstanding durations, up to 10 seconds, then warns about the launches it left untimed. Launches issued after that wait, for example from static destructors, are counted but not timed.

"TimingSource": "profiler",
"TotalTimeNs": 31160,
"instances": {
  "16313427880266313990": {
    "Occurrences": 3,
    "TimedLaunches": 3,
    "TimeNs": { "Sum": 18450, "Min": 5920, "Max": 6510 },
    "RecordedLaunchTimeNs": 6020,
    ...
  }
}

GPU Device Memory State

For each recorded kernel execution, Mneme captures the state of GPU device memory both before kernel launch (prologue state) and after kernel execution (epilogue state), and stores these states persistently.

At replay time, Mneme restores device memory to the recorded prologue state by remapping the recorded memory layout into the replay execution. The kernel is then executed in isolation, with the expectation that its execution transforms device memory to a state equivalent to the recorded epilogue state.

This mechanism enables faithful reproduction of kernel behavior and forms the foundation for replay, verification, and performance experimentation.

The prologue file contains a full serialized snapshot of GPU memory, global variables, metadata, and kernel argument mappings. By default, the epilogue file is stored as a binary diff against the matching prologue.

The default format is equivalent to:

mneme record --epilogue-format diff -- <application> [args...]

Epilogue snapshots can still be stored as full byte snapshots by recording with:

mneme record --epilogue-format bytes -- <application> [args...]

Use best to have Mneme store whichever concrete epilogue format is smaller for each recorded kernel instance:

mneme record --epilogue-format best -- <application> [args...]

Diff epilogues contain descriptors for the recorded globals and memory regions plus the changed byte ranges needed to reconstruct the post-kernel state. Using the diff format can save significant amounts of disk space if the kernels do not change much output data; it is less helpful for dense and/or in-place kernels.

Blob annotation metadata

Each recorded memory blob may carry optional annotation metadata attached by the application via mneme::annotate() before the kernel launch. When present, the metadata is serialized immediately after the blob's raw data in the following order:

Field Size Description
builtin 1 byte BuiltinDType enum value (scalar type)
threshold 8 bytes double — maximum acceptable error
threshold_kind 1 byte ThresholdKind enum (Absolute or Relative)
norm 1 byte Norm enum (None, L1, L2, Linf)
tag_len 8 bytes Length of the tag string (0 if absent)
tag variable UTF-8 tag string (omitted when tag_len is 0)

Buffers that were not annotated are recorded with zero-valued defaults (threshold = 0, norm = None), which preserves the traditional byte-exact comparison behavior.

See Usage → Verification for details on how this metadata is used during replay.


Recorded LLVM IR

Mneme stores the recorded kernel code as LLVM IR files (.bc), which are fully compatible with standard LLVM tooling. These files serve as the input to replay and tuning workflows and may be inspected or transformed directly using tools such as opt or custom LLVM passes.


Artifact lifecycle

Recorded artifacts follow a well-defined lifecycle:

  • created by mneme record
  • consumed by mneme replay
  • removed by mneme clean
  • relocated by mneme move and mneme copy