feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects (#14882)

* feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects

Replace the pending GPU object and parser ceilings in GpuCodeObjectsProvider
with domain-owned optional per-call parameters (max_object_bytes, max_work_bytes,
max_report_bytes, max_metadata_bytes, max_structure_bytes, max_parser_entries,
max_parser_visits, and max_token_bytes) reporting details.limit and
adjustable_budget, remove superseded hardcoded constants, and register only the
recursive container and AMDGPU MessagePack nesting caps as a fixed
representation allowance.

BREAKING CHANGE: inspect_gpu_code_objects adds optional per-call budget
parameters and reports details.limit with details.refusal.kind
"adjustable_budget" instead of "fixed_ceiling" on top-level object, work,
report, metadata, structure, and parser budget refusals.

* fix(gpu): clamp padding scans, classify multi-frame CCOB budget cuts, and keep max_work_bytes at 512 MiB

* fix(gpu): align --max-work-bytes help text, release partial decode before refill, and admit floats under small token budgets

* test(gpu): keep multi-frame CCOB v1 decoded size within cut budgets

* fix(gpu): report decoder inputExhausted to refill and bound trailing Zstandard frames

* fix(gpu): peek next Zstd frame, charge AMD structure reads to work budget, and keep 128-token PTX limit

* fix(gpu): fix CCOB refill work double-charge, meter section reads, decouple non-GPU recognition, and align frame/recovery bounds

* refactor(gpu): drop redundant lookahead on non-refill path and pin refill/readBounded regressions

* fix(gpu): keep standalone PTX peak heap at 1x, use explicit scan reads, forward CUDA cancel signal, and report max_report_bytes required_value

* fix(gpu): report lower-bound report bytes in reported_limits and enforce max_token_bytes on recognized PTX headers
This commit is contained in:
RRFZ authored and GitHub committed 2026-11-27 16:14:15 +00:00
1 parent 92b082bcaf
commit 2e59f08992
27 files changed
+3108 -271

No files matched your search

+26 -17
View File
@@ -189,8 +189,9 @@ Kernel representations have different meanings:
that is not an array, are `malformed`. Note failures preserve earlier parsed
declarations, including earlier pipelines, and the original failure reason.
Standalone PTX recognition scans up to 16 MiB, allowing leading comments and
whitespace, after which `.version` must be the first module token. Inventory and
Standalone PTX recognition scans up to `max_report_bytes` (default and maximum
16 MiB), allowing leading comments and whitespace, after which `.version` must
be the first module token. Inventory and
kernel inspection use strict UTF-8 and reuse a complete, valid scan. Invalid
encoding can leave a recognizable PTX object with an unknown target. A file
longer than the scan budget, including one that ends mid-character at the
@@ -250,23 +251,31 @@ workflow. Inventory then reads bounded native directories and bundle headers;
CCOB requires decompression to find its inner directory. Kernel analysis reads
selected payloads. `bytes_read` includes hashing and later descriptor reads.
| Resource | Limit |
| ---------------------------------------------------------------- | ------- |
| Active inspections | 1 |
| Each input or output buffer | 128 MiB |
| Payload input, decoded output and AMD note reads, per inspection | 512 MiB |
| Retained facts, including selected PTX | 16 MiB |
| Native tables; decoded section names (each) | 16 MiB |
| AMDGPU ELF note source bytes | 8 MiB |
| Standalone PTX recognition scan | 16 MiB |
| CUDA ELF record and symbol visits | 262,144 |
| CUDA ELF cumulative metadata section reads | 128 MiB |
| CUDA ELF temporary index facts (serialized-size accounting) | 16 MiB |
| Response page | 1 MiB |
| Resource | Default | Per-call parameter (range) |
| --------------------------------------------------------------------------------------------- | ------- | ----------------------------------- |
| Active inspections | 1 | Fixed (`measuredExhaustion`) |
| Each input or output buffer | 128 MiB | `max_object_bytes` (1..128 MiB) |
| Payload input, decoded output, native-section and AMDGPU note/structure reads, per inspection | 512 MiB | `max_work_bytes` (1..512 MiB) |
| Retained facts, including selected PTX and Clang directories | 16 MiB | `max_report_bytes` (1..16 MiB) |
| Native tables; decoded section names (each) | 16 MiB | `max_structure_bytes` (64..512 MiB) |
| AMDGPU ELF note source bytes | 8 MiB | `max_metadata_bytes` (1..8 MiB) |
| Standalone PTX recognition scan | 16 MiB | `max_report_bytes` (1..16 MiB) |
| Clang entries, PTX kernels/parameters, AMDGPU container entries | 65,536 | `max_parser_entries` (1..65,536) |
| Tokens per PTX parameter declaration | 128 | Fixed syntax limit |
| CUDA ELF record/symbol visits; AMDGPU aggregate values | 262,144 | `max_parser_visits` (1..262,144) |
| Clang bundle ID, PTX token, AMDGPU string/binary scalar | 65,536 | `max_token_bytes` (1..65,536) |
| CUDA ELF cumulative metadata section reads | 128 MiB | `max_object_bytes` (1..128 MiB) |
| CUDA ELF temporary index facts (serialized-size accounting) | 16 MiB | `max_report_bytes` (1..16 MiB) |
| Container / AMDGPU MessagePack nesting depth | 8 / 32 | Fixed (`representation` allowance) |
| Response page | 1 MiB | Fixed MCP response page budget |
Payload work is reserved before reading or allocating, and a capacity refusal
does not reread an aliased payload. AMD note discovery also bounds depth and
container and string allocations, and shares one 262,144-value allowance across
does not reread an aliased payload. Top-level container/report/directory/ID
refusals fail with `code: "resource_constraint"` and `details.limit`, while
per-object payload/metadata/visit/nesting limits retain sibling observations and
record `inspection: "capacity"` with the budget name in `limitations`. AMD note
discovery also bounds depth and container and string allocations, and shares the
per-call `max_parser_visits` allowance (default and maximum 262,144) across
all of a code object's notes, which also bounds the PAL pipeline facts expanded
from them; standalone AMD targets are read from those
notes before target selection, and kernel analysis reuses the parsed