Skip to content

feat(gpu): inspect static CUDA and HIP code objects - #5813

Merged
gensokyo-dev merged 16 commits into
mainfrom
feat/5345-gpu-code-objects
Oct 21, 2026
Merged

gensokyo-dev merged 16 commits into
mainfrom
feat/5345-gpu-code-objects

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #5345. Inventory local CUDA/HIP targets, decode selected objects, and query kernel parameters/resources or retained PTX without sending the whole report to an agent.

Change and contract boundaries

  • Shared static readers/application service serve inspect-gpu-code-objects, inspect_gpu_code_objects and historical inspect_analysis_view kind gpu-code-objects.
  • ELF/PE hosts, CUDA fatbins/CUBIN/PTX and Clang HIP/CCOB bundles; CUDA raw LZ4/Zstd and CCOB zlib/Zstd. Parameter layouts, CUBIN physical registers, PTX virtual declarations and AMDGPU resources keep distinct meanings.
  • Exact target/object selection, field selection, batch IDs, paging and target aggregates. Positional IDs require the inventory SHA-256. Compact pages preserve identity, source coordinates and partial/unknown coverage; complete Evidence and PTX remain exportable after source removal.
  • One parsed owner for shared native directories and format facts. AMD target discovery reuses bounded parsed notes; tagged failures retain earlier facts. CUDA indexes coalesce scoped aliases/equal facts and share preallocation/work/read budgets. Historical indexes follow immutable Evidence lifetime; live files are freshly hashed and checked.
  • One active inspection; 128 MiB/input or output buffer, 512 MiB of payload input/decoded output/AMD note work, 16 MiB retained facts. Work is reserved before payload reads or allocation. CUDA metadata also bounds aggregate visits, reads and accounted index facts; the guide distinguishes serialized accounting from actual heap size.
  • Adds locked @msgpack/msgpack 3.1.3 with integrity-verified upstream license. Updates catalog ownership, authored skill and README links; generated outputs are excluded.

Contribution scope decision: not applicable to execution/injection/mutation/protection recovery. This capability reads caller-selected files and invokes no GPU tools or target code. Caller-directed Evidence exports use the existing local export workflow. No GPU execution, SASS disassembly or host launch correlation is claimed.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change target memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.

Evidence and validation

Verification record and linked receipts pin source trees, publisher hashes, commands, independent oracles, failed attempts and performance scope.

  • 251/251 post-header GPU/native cases passed across nine files, including shared Go/Rust/IL2CPP consumers, public CLI/MCP, lifecycle and provenance forgery. The final unknown-target summary/public-boundary run passed 46/46, and the current-base SDK-converted canonical schema suite passed 15/15.
  • npm run check and npm run docs:check passed, including five README cases. Latest static checks: 135.345 s / 266.563 CPU s / 5,371,879,424 sampled family RSS bytes; no resource guard stop.
  • Latest review qualification: 67/67 focused parser/boundary/lifecycle/public CLI/MCP cases, plus 3/3 source admission cases. NVIDIA ptxas accepts the pointer-parameter control; unknown PTX parameter/shared layouts now carry typed partial coverage from their parser. A sparse 128 MiB HIP payload with 12 aliases causes exactly 4 payload reads, then 8 capacity refusals without payload reads; compressed CUDA/CCOB controls refuse oversized output before reading input.
  • NVIDIA nvcc/cuobjdump and Clang/LLVM oracles cover nine real producer artifacts. Released Linux/Windows nvJPEG preserve 165 CUBIN hashes, 10 PTX byte identities and 3,720 native resource tuples; all 248 PTX register totals are independently checked, correcting 20 prior undercounts.
  • The latest released-DLL CLI comparison preserves all object/kernel factual fields and PTX bytes. Eight PTX objects/59 kernels now correctly disclose existing unknown pointer-parameter layouts as partial with explicit limitations; earlier complete-coverage claims for those objects are superseded. Nine real producer artifacts remain complete.
  • All 165 Windows CUBIN inner targets and raw headers match independent extraction: 110 OS ABI 0x33, 55 0x41, zero false conflicts. Unknown layouts retain their headers and partial coverage. Original envelope and payload targets stay separate; base-only agreement does not establish feature-profile compatibility.
  • Revised MCP tasks preserve the selected Linux sm_100 answer. Real public CLI controls also prove inventory-to-target selection through both HIP separator forms and an opaque-ID wrapper around the same real Clang ELF.

Windows artifacts were inspected on Linux: LLVM supplied PE coordinates and cuobjdump consumed the extracted fatbin. No Windows runtime claim. CCOB v2 Zstd has a real LLVM producer oracle; v1/v3/zlib have boundary fixtures. Legacy AMDGPU YAML remains unsupported.

Equivalent complete-report → selected-page MCP tasks: used declarations + primary calls 418,967 → 26,653 estimated tokens; full catalog + all six calls 1,493,041 → 1,100,727. Elapsed 21.307 → 24.604 s, CPU 23.538 → 26.454 s, sampled family RSS 1.147 → 1.341 GB. Tokenx estimates are not billing; initialization/JSON-RPC envelopes are excluded. Same-code workflow variants, fresh servers, uncontrolled OS caches/load: no general speed/CPU/memory improvement is claimed. All task receipts use two CPU affinities and an 8 GiB family guard.

Earlier main-baseline browser/optional-input assertion failures are linked in PR comments; upstream main has since fixed them. All required CI passed at predecessor 9767391; this review follow-up reruns CI. The GPU help-description CI bug and actionable review findings were fixed. The intermediate low-byte CUDA-header interpretation and its timings are explicitly invalidated in the record; qualified measurements use the corrected ABI-aware version. Earlier schema timeouts and the incomplete all-target transport-guard attempt remain recorded rather than counted as successful coverage.

  • Observed, derived and inferred claims remain distinguishable.
  • Artifact identity, provenance and failed attempts remain preserved.
  • Unsupported, incomplete and uncertain outcomes remain visible.

Author readiness

Human owner: @gensokyo-dev

The operator explicitly instructed ready review and authorized merge after verification. Automation does not assert the two unchecked personal-review declarations.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Concrete enhancement linked above; static contribution scope resolved.
  • One focused outcome and Conventional Commit title; additive API, no migration.
  • Changed behavior/failure paths tested; relevant docs/contracts/catalog ownership updated.
  • Representative CLI/MCP output and real-provider limitations recorded.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T10:37:15.286714Z 4f537f9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36b87ed459

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/cli/gpuCommands.ts Resolved
@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

CI baseline comparison: browser / real-browser failed with Page-scoped CDP disconnect was not reported as target_terminated at scripts/verify-real-browser.mjs:554 on both:

The same failure therefore exists without this GPU change. Browser implementation/verifier files are unchanged by this PR. GPU/native/public-workflow checks and independent real-artifact validation are recorded in the PR; remaining CI/review results are still pending. No browser fix is included here.

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge; no blocking issue remains.

Summary

Adds static CUDA/HIP inspection through shared CLI, MCP, and retained Evidence views.

  • Local GPU files reveal targets and selected kernel facts.
  • CLI and MCP callers can page retained GPU results.

This review checked source and regression assertions; it did not rerun tests. Whether another PR supersedes this one could not be checked because GitHub authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  CLI[CLI] --> Service[Shared inspection service]
  MCP[MCP tool] --> Service
  Service --> Inventory[Inventory targets and objects]
  Inventory --> Budget[Reserve input and output work]
  Budget --> Decode[Decode selected payloads]
  Decode --> Evidence[Retain facts, PTX, and coverage]
  Evidence --> Pages[Selected historical pages]
  Evidence --> Export[Evidence export]
Loading

Reviews (5) · Last reviewed commit: "docs(gpu): qualify payload admission and..." · Reviewed by Greptile

Comment thread src/gpu/GpuElfKernels.ts Resolved
Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/PtxKernels.ts Resolved
Comment thread src/cli/gpuCommands.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50af644061

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/GpuElfKernels.ts Resolved
@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

The second CI run found another independently reproduced main failure in tests/boundary/cli/cliInputSchemaRequired.test.ts: inspect-wasm-artifact options: advertised [], parser rejects [commandTimeoutMs].

The wasm command/schema and that test are unchanged by this PR. The confirmed GPU CLI help omission from the first run was fixed separately and all 10 product-catalog cases passed. Neither this wasm baseline issue nor the previously linked browser baseline failure is included in the GPU change. Fail-fast cancellation means the cancelled shards are not claimed as passing coverage.

@gensokyo-dev
gensokyo-dev force-pushed the feat/5345-gpu-code-objects branch from 50af644 to 313689e Compare October 21, 2026 08:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 313689ea69

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/ClangOffloadBundle.ts Resolved
@gensokyo-dev
gensokyo-dev force-pushed the feat/5345-gpu-code-objects branch from 313689e to 9767391 Compare October 21, 2026 10:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 976739104b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gpu/GpuInventory.ts Resolved
Comment thread src/gpu/GpuInventory.ts Resolved
@gensokyo-dev
gensokyo-dev merged commit efab044 into main Oct 21, 2026
43 of 46 checks passed
@gensokyo-dev
gensokyo-dev deleted the feat/5345-gpu-code-objects branch October 21, 2026 11:06
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
3 tasks done
@gensokyo-dev

Copy link
Copy Markdown
Collaborator Author

Merged as efab044f303ae3d957d977730bb1628063223236 (tree 24354fd7a9ec295f2ea9127d86b2232f6b1a6f21). All required CI and Greptile passed on head 4f537f9; no unresolved threads. Codex service still reports its latest review running, so no completed-Codex claim is made.

Post-merge verification checked all 81 feature paths: 80 exactly match the qualified head; the sole difference is the compatible upstream closeCliJavaScriptResources export in src/cli.ts. On the actual merge, all 69 focused GPU/parser/provider/public CLI/MCP/lifecycle cases passed across five files, including the 128 MiB HIP alias admission regression and compressed-input guards.

Executed: npm run test:focused -- src/gpu/PtxKernels.test.ts src/gpu/GpuInventory.test.ts tests/boundary/gpu/codeObjects.test.ts tests/acceptance/gpuCodeObjectsCli.test.ts tests/process-global/gpuFileLifetime.test.ts (Node 24.18.0, two CPU affinities, 3 GiB per-process heap). Task including artifact build: 133.577 s elapsed / 190.772 CPU s / 3,506,786,304 sampled process-family peak RSS bytes; no resource guard stop.

@morluto morluto added enhancement New feature or request provider: gpu Analysis provider / engine: gpu labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider: gpu Analysis provider / engine: gpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] First slice of #3674: inventory CUDA/HIP fat binaries in ELF/PE hosts and extract PTX and kernel facts

2 participants