Skip to content

hrx: the AMDGPU HAL decides APU-ness from a bit this ROCr leaves clear (0x2), so host+device-local memory types are refused on Strix Halo #840

Closed
1bit-MONSTER/hrx-system
#9

Description

@bong-water-water-bong

hrx: the AMDGPU HAL decides APU-ness from a bit this ROCr leaves clear, so host+device-local memory types are refused on Strix Halo

From the memory lane's device work at the pinned pair (hrx-system 82804197bc, fork d8bd0ff6052a) on strixhalo
(RYZEN AI MAX+ 395 / Radeon 8060S, gfx1151, 120 GiB UMA, 1 GiB VRAM carve-out). Everything below is measured on this box
with ~/amd-oss/hrx-study/tools/hsa_probe.c (TheRock SDK libhsa rocm-10.3.0a20261031) unless a path:line is given.
Raw probe output: ~/amd-oss/hrx-study/evidence/memory/hsa-probe-20261102-0943.log.

What the attribute returns

AGENT gfx1151 (device GPU)
  HSA_AMD_AGENT_INFO_SVM_DIRECT_HOST_ACCESS = 0
  HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES      = 0x2 (AGENT_IS_APU=0)

0x2 is undefined by the header shipped with that libhsa: hsa_ext_amd.h:1044-1050 defines the whole
hsa_amd_agent_memory_properties_t enum as one member, HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU = (1 << 0). There is
exactly one hsa_ext_amd.h on this box (checked by find), so this is not a header-version mixup. At the same time
rocminfo on the same agent prints Memory Properties: APU
(~/amd-oss/hrx-study/evidence/memory/rocminfo.txt:12), i.e. ROCr itself considers the agent an APU by another route
(libhsa also carries hsakmt_device_is_apu_by_node_id).

What the HAL concludes

physical_device.c:455-469 decodes exactly bit 0 of that attribute:

uint8_t memory_properties[8] = {0};
iree_hsa_agent_get_info(..., HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES, memory_properties);
*out_agent_is_apu = hsa_flag_isset64(memory_properties, HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU);

hsa_flag_isset64(value, f) is value[0] & 1 (hsa_ext_amd.h:110-114), so with 0x2 the HAL records
agent_is_apu = false → device_local.unified_memory = false for a unified-memory APU.

The two consequences, both in allocator.c

  1. Host+device-local requests are refused instead of landing on host_fine — :739-741
    (requires_host_local && requires_device_local && !unified_memory → return false) and :753-758
    (requires_host_access && requires_device_local, no device_fine host access, !unified_memory → return false).
    On a real APU both should take the host_fine branch two lines further down.
  2. expand_unified_memory_type adds nothing, so no device_fine heap is published
    (device_fine_available at :1106-1111). Note this second effect is independently caused here: publication also
    requires has_uniform_device_fine_direct_host_access (:170-186 → svm.direct_host_access, :157-168), and that
    measured 0 on this box in both SVM modes. So device_fine is absent regardless of the APU bit; only (1) is
    attributable to the bit alone.

Why this is reported as a latent gap, not a live breakage

It is not reachable from libhrx: libhrx resolves a buffer's memory type to one of five slab source pools first
(mem_pool_backing.c:334-344 — any HOST_LOCAL bit → HOST source, any DEVICE_UNCACHED bit → UNCACHED_DEVICE,
otherwise DEVICE; every other bit is ignored) and each pool derives its own memory type, so the memory-type refusals in
allocator.c are direct-HAL-caller-only paths. Confirmed by measurement: a libhrx probe allocating with
HOST_LOCAL|DEVICE_LOCAL (0x72) and HOST_VISIBLE|HOST_COHERENT|DEVICE_LOCAL (0x36) succeeds in both SVM modes
(evidence/memory/hrx-place-20261102-1212.log). So no current llama run is affected; a HAL caller that asks for
host+device-local memory on this box just gets INVALID_ARGUMENT/UNAVAILABLE where the hardware is in fact unified.

Suggested direction (any one is enough)

  • Decode APU-ness the way ROCr does for rocminfo (ask hsakmt / do not depend on this attribute alone), or
  • treat an attribute value with no defined bit set as "unknown" and log it once, rather than silently concluding
    non-APU, and/or
  • relax (1) to a warning + host_fine routing, which is what a unified-memory APU physically is.

Cross-references: this is the same pin as engine#315 (SVM gate) and #680 (GTT ceiling). The probe and the reproduction
recipe are in ~/amd-oss/hrx-study/tools/hsa_probe.c; the surrounding analysis is FACTS-memory.md §1.1/§1.2/§7.1/§7.4
in the same directory.

Activity

  1. added
    bug
    hrx
    on Nov 2, 2026
  2. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    **Triaged — bucket A (provisional: it is latent, see the last section), owner the memory / hrx-study lane that filed it. Every claim checks out at the pin; the paths need the directory and two line numbers have drifted. Two things I can add: the consumer chain that makes "only consequence (1) is attributable to the bit" provable, and the fact that "decode it the way ROCr does" is not available in this tree.

    Verified at hrx-system 82804197bcbe (the engine's held pin)

    claim where, exactly
    the HAL decodes exactly bit 0 ✔ runtime/src/iree/hal/drivers/amdgpu/physical_device.c:456-469 — iree_hal_amdgpu_physical_device_query_agent_is_apu(), 8 bytes from HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES, then hsa_flag_isset64(...)
    the refusals ✔ runtime/src/iree/hal/drivers/amdgpu/allocator.c:743-745 (requires_host_local && requires_device_local && !unified_memory → return false) and :754-758 (requires_host_access && requires_device_local, no device_fine, !unified_memory → falls through) — the issue says :739-741 / :753-758, so 4 lines of drift on the first
    libhrx never reaches them ✔ libhrx/src/libhrx/mem_pool_backing.c:334-344 — the five-source resolution you quote: HOST_LOCAL → HOST, DEVICE_UNCACHED → UNCACHED_DEVICE, else DEVICE, every other bit ignored

    The chain that makes the attribution exact

    physical_device.c:456  query_agent_is_apu()         -> bit 0 of 0x2  -> false
    physical_device.c:537-556  .agent_is_apu = agent_is_apu ? 1u : 0u
    physical_device_capabilities.c:760  device_local.agent_is_apu ? 1u : 0u   <- the single consumer
                           -> unified_memory -> allocator.c:743-745 / :754-758
    

    Grepping the whole tree for is_apu|AGENT_IS_APU at this pin returns only that chain (plus its two unit-test sites), so your split is right and it is exactly one bit with one consumer: consequence (1) is the bit, consequence (2) needs svm.direct_host_access, which is the SVM_DIRECT_HOST_ACCESS = 0 you measured — a second, independently-cleared signal. Worth keeping in the issue because it means fixing APU-ness buys (1) only; device_fine stays absent on this box either way.

    What is not available: "decode it the way ROCr does"

    hsakmt_device_is_apu_by_node_id is a symbol inside libhsa, not in this tree — git grep in hrx-system finds no reference to it and no second APU decision anywhere. So of the three suggested directions only two are in-tree:

    1. undefined ⇒ unknown, logged once, and route conservatively — 0x2 has no defined bit (hsa_ext_amd.h's only member is 1 << 0), so "the attribute did not say" is the honest read; logging the raw value once is what would have made this visible instead of silent;
    2. relax (1) to host_fine when the agent declares unified memory by any means — but at this pin the only means the HAL has is the same attribute, so (2) depends on (1).
    3. "ask hsakmt" is out unless we call a libhsa symbol we do not currently bind; if that is on the table it is a libhsa-version dependency, i.e. its own decision.

    Bucket, and why provisional

    A by the rule (a lane owns the change and can prove it on this box), with the caveat you supplied: no current llama run is affected, because libhrx resolves to a source pool first. So it is not a live breakage and I am not pretending it blocks c20 — if the owner prefers latent-only rows out of the A count, this one moves to C and the counter drops by one; that is one word and I will do it.

    Next action, one: make the APU decision three-valued (definitely APU / definitely not / did not say) with the raw attribute value logged once, then route HOST_LOCAL|DEVICE_LOCAL to host_fine on this box; gate = the probe's two requests (0x72, 0x36) landing in host_fine with the log line naming 0x2, measured under one gpu-hold ticket with the #715 trio. No llama run needed.

    Links: #315 (closed — the SVM gate this sits beside), #680 (the GTT ceiling; same APU-detection blurs the memory accounting), #841 (same lane, same pin, the sibling accounting gap).

  3. bong-water-water-bong commented on Nov 3, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Measured on the same box while fixing this (THRX-COMPAT lane, overnight 2026-11-03). Two corrections, then the fix.

    1. hsa_flag_isset64 does not mask with its argument; it indexes a bit with it.

    static inline bool hsa_flag_isset64(uint8_t* value, uint32_t bit) {
      unsigned int index = bit / 8;
      unsigned int subBit = bit % 8;
      return value[index] & (1 << subBit);
    }

    HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU is a mask (1 << 0), so hsa_flag_isset64(properties, HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU) tests bit 1, not bit 0. The issue's reading (value[0] & 1) is not what the
    helper does.

    2. Because of that, the reported consequence does not happen on this box: the agent already decodes as an APU.
    A probe built against the pinned tree (hrx-system 82804197b, the same decode and allocator code), one gpu-hold
    ticket, no-SVM trio, HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES read exactly as the HAL reads it:

    HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES = 0x2 (AGENT_IS_APU bit 0 clear)
    HAL device_local.unified_memory      = 1
    allocate(HOST_LOCAL|DEVICE_LOCAL, 4 KiB) = OK, memory_type=0x76
    

    0x2 is bit 1, which is what the pre-fix code tests, so unified_memory = 1 and allocator.c's
    requires_host_local && requires_device_local && !unified_memory branch is not taken. ROCr and rocminfo use bit 1 the
    same way, so the whole stack is self-consistent at bit 1 on this machine.

    3. The real defect is the mirror image, and it is what the PR fixes. A runtime that answers with the documented
    0x1 was decoded as a discrete device - and only then do the allocator.c refusals bite. That cannot be produced
    by this ROCr, so it is pinned by a device-free unit test rather than by a device measurement:

    decode of the attribute word before after
    0x0 (discrete) false false
    0x1 (documented APU mask) false true
    0x2 (this ROCr on gfx1151) true true
    0x4, 0x80 (neither encoding) false false

    PR: 1bit-MONSTER/hrx-system#9 (1bit/840-apu-memory-properties, 6383e263) - accepts both encodings in a
    physical_device_capabilities.c helper, adds the unit test above and a live-device guard in allocator_test.cc that
    skips on a discrete agent. Leaving this issue open for the owner to close with the PR.

  4. bong-water-water-bong commented on Nov 6, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Resolved, with one measured qualification that this issue's premise deserves.

    The fix is shipped

    The qualification

    The port lane measured the symptom before the change and it does not reproduce on this ROCr: hsa_flag_isset64(value, HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU) indexes bit 1, and this ROCr signals APU with 0x2, so the existing code already decoded it as APU — unified_memory was already 1 and HOST_LOCAL|DEVICE_LOCAL allocations already succeeded at the previous pin. So this is a correctness/portability fix for a runtime that answers the documented 0x1, made explicit and test-covered, not a behaviour change on this box. If the refusal this issue reports is real somewhere else, it has another cause and this evidence is where to start.

    Closing on the landed decode + the gate; the per-run detail is in #1245 and the fork PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughrx

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions