← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / scientific-agent-skills / skills / get-available-resources / references / resource_semantics.md

Resource Semantics

Research and behavior cut-off: 2026-07-23. See sources.md for the official documentation used.

Core rule: inventory is not entitlement

Never treat a host-wide count as a promise that the current process can use it. Interpret usable resources as the intersection of independently observed constraints:

  1. host inventory;
  2. process affinity or processor-group scope;
  3. cgroup/container constraints;
  4. scheduler allocation;
  5. accelerator visibility and device permissions; and
  6. application runtime compatibility.

Missing evidence means unknown, not unlimited. Scheduler variables can describe an allocation without proving that affinity or cgroup enforcement is enabled. Conversely, a cgroup or affinity mask can be stricter than the scheduler request.

CPU

Physical and logical CPUs

The detector reports host logical and physical counts separately. It never derives physical cores from a logical count.

Affinity, cpusets, and quotas

For a cpu.max ratio of 1.5, the snapshot reports capacity_cores: 1.5 and a conservative CPU-bound worker ceiling of 1. A workload may choose more threads for latency hiding, but it should expect throttling and must not describe those threads as 1.5 physical cores.

Python worker pools

Use the workload planner's worker and threads-per-worker values as conservative ceilings, then benchmark a real representative workload. Do not run a synthetic stress test merely to discover capacity.

Memory

Host and effective memory

The detector keeps host total/available values, cgroup values, scheduler values, and the conservative effective values distinct. A point-in-time "available" value can change immediately and is not a reservation.

macOS unified memory

On Apple silicon, CPU and integrated GPU share unified memory. Do not add a fictional GPU VRAM amount to system RAM. The snapshot marks the memory model as unified_cpu_gpu and leaves dedicated GPU memory null. Metal framework support and model/operator support still require application-specific checks.

Accelerators

Accelerator usability has separate layers:

  1. Hardware or management visibility — a management query returns a device.
  2. Allocation visibility — scheduler and named visibility variables permit a device or a subset.
  3. Device permission — the process/container can open the required device interfaces.
  4. Driver/runtime compatibility — driver, CUDA/ROCm/Metal runtime, and framework versions are compatible.
  5. Workload compatibility — the requested operation and data type are implemented on that backend.

nvidia-smi success confirms NVIDIA management visibility only. It does not prove that CUDA libraries exist or are compatible. NVIDIA documents driver and runtime compatibility as a separate requirement.

AMD SMI or ROCm SMI success likewise does not prove HIP/ROCm runtime usability. New deployments should prefer amd-smi; rocm-smi is retained as a read-only fallback. On Linux, AMD recommends ROCR_VISIBLE_DEVICES; on Windows it recommends HIP_VISIBLE_DEVICES.

An Apple integrated GPU is a Metal candidate, not a CUDA GPU. AMD GPUs are ROCm candidates, not CUDA GPUs. Neural engines, TPUs, FPGAs, and other accelerators must also remain distinct from CUDA devices if another inventory source adds them.

The detector reads only these accelerator variable names and redacts their values:

Counts derived from those values are only upper bounds. Environment variables are not a security boundary and can be reset by an application; device namespace/cgroup controls are stronger isolation.

Slurm and other schedulers

The detector allowlists named Slurm variables and never dumps the environment. It records field names, parsed bounded counts, and memory quantities, but not job IDs, GPU UUIDs, node names, submit hosts, or paths.

Important scopes:

Slurm CPU confinement requires site configuration such as task affinity or task/cgroup with core constraints. Memory requests are not strictly enforced unless the site enables an enforcement mechanism. Use affinity and cgroup observations as enforcement evidence; do not trust visible node inventory.

For other schedulers, use their documented allocation API or variables and the same rule: allocation metadata and kernel enforcement are different facts. Do not guess from generic environment names.

Containers and OCI

Docker containers have no CPU or memory limit by default. When configured, Docker maps CPU and memory flags to cgroup controls. OCI runtime configuration also defines CPU, memory, and device constraints.

Inside a container:

Always report observed cgroup controls and uncertainty. A container marker without a finite cgroup value does not imply a finite limit.

Disk

Capacity, free blocks, user-writable blocks, path permission, filesystem quota, and actual ability to complete a write are different:

The detector does not create a probe file. It redacts the absolute working path and labels the scope as the working filesystem.