Skip to content

D3D12 executor: re-measure a network larger than the default arena (Model L 4K native no longer falls back to HIP) - #195

Merged
phantoslayer21 merged 5 commits into
mainfrom
fix/182-hip-teardown
Nov 14, 2026
Merged

phantoslayer21 merged 5 commits into
mainfrom
fix/182-hip-teardown

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Fixes #182

Model L at 3840x2160 native now runs on the D3D12 executor and returns to baseline after destroy.

Cause

The memory is not held by a Model L allocation. The D3D12 executor makes the network's allocations twice: pass 1
measures the arena, pass 2 allocates exactly that size. Pass 1 ran in the default arena (WG_D3D12_ARENA_MB,
2560 MiB). Model L at 4K native needs 2738 MiB, so pass 1 ran out ("native D3D12 arena exhausted for 267386880 bytes;
WG_D3D12_ARENA_MB is 2560"), and the front end gave the context to the HIP executor.

HIP keeps memory until the process ends: its own instance, plus the pooled imported arena (633 MiB). This is HIP
runtime behaviour, documented in clean/FORMATS.md, "Context teardown and re-creation". That is the constant
+1419 MiB after every destroy in #182.

In the #85 records, every run that kept memory ran on executor hip, and every run that returned ran on
executor dx12. Model M "returned" only because it never needed HIP.

Change (clean/runtime/interop/executor_d3d12.cpp; no kernels touched)

  • When pass 1 runs out of the default arena, it measures again in a 4095 MiB arena, the largest (WG_D3D12_ARENA_MB's
    upper bound). Pass 2 then allocates exactly the measured size.
  • Not when WG_D3D12_ARENA_MB is set.
  • Contexts that fit the default arena, including all of Model M's, take the same path as before.
  • The retry and its outcome are logged, so a game log shows which executor ran and why:
    • D3D12 executor: the network does not fit the default arena (...); measuring again in a 4095 MiB arena
    • D3D12 executor: measured in the 4095 MiB arena: the network needs 2738 MiB; the D3D12 executor runs it in an arena of that size
    • or, on failure: measuring again in a 4095 MiB arena failed (...)
  • If the second measure also fails, the context still goes to HIP. After it is destroyed, the process keeps HIP's
    instance and the pooled imported arena until it ends, as FORMATS.md documents. This PR does not change that path.
  • clean/FORMATS.md: a paragraph on the arena measure, the retry, its log lines and the HIP fallback's residue.

Suggested title for #182: "Model L at 4K native falls back to HIP (arena measure in 2560 MiB)".

Record (clean/l/records/issue182_create_destroy_record.json)

GPU: RX 9070 XT (gfx1201). Harness: test_dll_d3d12 resize_real, 5 create/destroy cycles each, no resize.
Process memory: DXGI local segment, this process only. Built from this branch merged with main, one GPU run at a
time through gpu_slot.py. Models: synthetic files from the repository's generators; memory depends on the
network's shapes, not on the values.

Run Executor (5 cycles) Runtime-reported Peak growth After each of 5 destroys
Model L, 4K native dx12 ×5 (re-measured in 4095 MiB: needs 2738 MiB) 2739 MiB +2742 MiB +2, +2, +2, +2, +2 MiB
Model L, 4K Quality dx12 ×5 1441 MiB +1444 MiB +2 ×5
Model M, 4K native dx12 ×5 1590 MiB +1593 MiB +2 ×5
Model M, 4K Quality dx12 ×5 933 MiB +936 MiB +2 ×5
Control: Model L, 4K native, same build, WG_D3D12_ARENA_MB=2560 (no re-measure) hip ×5 3433 MiB +4230 MiB +1419 ×5 (pooled arena kept, 5 of 5)

Model M unchanged: no re-measure line in either Model M run, and the same runtime-reported memory as the #85
record (933 MiB at 4K Quality, 1590 MiB at 4K native).

The control reproduces #182 exactly (+1419 MiB, constant, HIP), so the fix is the only difference.

Tested / Not tested

  • Tested:
    • the GPU record above;
    • D3D12 kernels (69) and the runtime rebuilt on the merged tree;
    • leak scan 0 hits;
    • public gates pass, LOOK lines at main's baseline (42 / 29 / 111; none in this PR's files).
  • Not tested:
    • a game (owner away);
    • GPUs with less VRAM, where the 4095 MiB measuring arena may not fit. There the context goes to HIP as before,
      and the failure is logged.

… in a 4095 MiB arena (Fixes #182)

Model L at 3840x2160 native needs 2738 MiB of native D3D12 arena. The executor measured the network in the
default 2560 MiB arena, ran out, and handed the context to the HIP executor, whose process keeps HIP's instance
and the pooled imported arena after the context is destroyed (+1419 MiB, constant per cycle). The measure is
now repeated in a 4095 MiB arena (WG_D3D12_ARENA_MB's upper bound) when the default one runs out and
WG_D3D12_ARENA_MB is not set; the retry and its outcome are logged. Contexts that fit the default arena take
the same path as before.

Record: clean/l/records/issue182_create_destroy_record.json (5 create/destroy cycles each, Model L and Model M
at 4K native and 4K Quality: executor dx12 in every cycle, +2 MiB after every destroy; control with the retry
off: executor hip, +1419 MiB).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ncoder fusion); same figures

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 merged commit ac1183f into main Nov 14, 2026
9 checks passed
@phantoslayer21
phantoslayer21 deleted the fix/182-hip-teardown branch November 14, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime: Model L at 4K native falls back to HIP (D3D12 arena measured in 2560 MiB), which keeps ~1.4 GiB until exit

1 participant