﻿# HIP virtual memory: reserving an address does not map or authorize its backing

Follow HIP virtual-memory reservations, allocation handles, mappings and per-location access as distinct states with separate cleanup and support checks.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-hip-vmm-reservation-map-access-stages/
Language: en

## Name the resource that was created

A custom allocator reserves a large virtual range and reports success, but a kernel cannot yet use it. The [HIP virtual-memory guide](https://rocmdocs.amd.com/projects/HIP/en/latest/how-to/hip_runtime_api/memory_management/virtual_memory.html) separates address reservation from backing allocation and mapping. Reservation establishes an address interval. It does not prove that device memory backs every byte in that interval or that a selected GPU may access it. Treat these as states with different owners.

## Respect the allocation granularity

Before creating and mapping backing storage, query the required granularity for the intended allocation properties. Size and alignment choices must satisfy the documented interface rather than an assumed host-page size. A convenient model-block size is an application quantity; mapping granularity is a runtime constraint. Preserve both values and the rounding policy. Otherwise a buffer manager can claim precise logical capacity while its actual mapped range is invalid or larger than its accounting assumes.

## Set access deliberately

The [VMM API reference](https://rocmdocs.amd.com/projects/HIP/en/latest/reference/hip_runtime_api/modules/memory_management/virtual_memory_reference.html) provides separate reservation, creation, mapping and access functions. A mapping associates backing with a virtual address, while access descriptors specify permitted locations. Inspect the device actually executing the kernel instead of assuming that successful mapping automatically authorizes every GPU in the host. The [HIP type declarations](https://rocm.docs.amd.com/projects/HIP/en/latest/doxygen/html/group___global_defs.html) identify allocation and access descriptor structures used by that contract.

## Unwind partial construction accurately

If access setup fails after backing is mapped, cleanup must reflect the resources already created. Track reservation ownership, backing handles and mapped intervals independently. Stop outstanding users before invalidating their range. Releasing one handle should not be casually described as equivalent to unmapping every address or freeing the reservation. Design failure paths alongside the successful path, because a partial setup failure can otherwise leave a leak that only appears after repeated allocator retries.

## Validate support before building a policy

The reference distinguishes implementation status across platforms and returns unsupported errors for relevant operations. Query capabilities and check every operation on the installed stack; header declarations alone are insufficient. Use a small supported mapping fixture before building a large expandable model arena. Related guides on [reproducible environments](/journal/software-stack-reproducibility/) and [HIP portability](/journal/learn-hip-launch-portability/) supply context. VMM adds explicit resource stages, not a guarantee of extra physical capacity or automatic multi-device memory sharing.
