[GH-ISSUE #6695] [Bug] PTX target inventory ignores later .target directives #4071

Closed
opened 2026-10-31 00:46:34 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @coygeek on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/6695

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

Evidence, artifacts, or reconstruction

Observed behavior

Production shared-service reproduction: PTX declaring sm_80 followed by sm_90 is inventoried as sm_80, with complete payload coverage. Filtering for sm_90 excludes its kernel. Enclosing that payload in a fatbin declaring sm_90 produces a false target conflict.

Reproduction

From the specified checkout with locked dependencies installed, save this as /tmp/rea-ptx-target/repro.mts and run node --import ./node_modules/tsx/dist/loader.mjs /tmp/rea-ptx-target/repro.mts /tmp/rea-ptx-target/input. This exact reduced script was executed once against actual files and the real application service, in scratch:

import { mkdir, writeFile } from 'node:fs/promises';
import { resolve, join } from 'node:path';
import { pathToFileURL } from 'node:url';
const load = (p: string) => import(pathToFileURL(resolve(p)).href);
const { GpuCodeObjectsProvider } = await load('src/gpu/GpuCodeObjectsProvider.ts');
const { GpuCodeObjectsService } = await load('src/application/gpu/GpuCodeObjectsService.ts');
const { cudaFixture } = await load('tests/fixtures/gpu/codeObjects.ts');
const root = resolve(process.argv[2]);
await mkdir(root, { recursive: true });
const ptx = Buffer.from('.version 8.8\n.target sm_80\n.address_size 64\n' +
                        '.target sm_90\n.visible .entry k() { ret; }\n');
const cases = [
  ['standalone', ptx, undefined],
  ['filtered', ptx, ['sm_90']],
  ['fatbin', cudaFixture('none', [{kind: 1, target: 90, bytes: ptx}]), undefined],
] as const;
for (const [name, bytes, targets] of cases) {
  const path = join(root, name + '.bin');
  await writeFile(path, bytes);
  const service = new GpuCodeObjectsService(new GpuCodeObjectsProvider());
  try {
    const result = await service.inspect({path, analysis: 'kernels',
      detail: 'complete', ...(targets ? {targets} : {})});
    if (!result.ok) throw result.error;
    const r = result.value.normalized_result;
    console.log(JSON.stringify({name, objects: r.objects.map(o => ({
      target:o.target, payload_target:o.payload_target,
      target_consistency:o.target_consistency, inspection:o.inspection})),
      kernels:r.kernels.map(k => k.name)}));
  } finally { await service.close(); }
}

Expected behavior

Account for subsequent .target directives when reporting target requirements and selecting payloads. For these baseline architectures, the effective requirement is sm_90. NVIDIA's archived PTX ISA 8.8 specification explicitly permits multiple directives and assigns requirements from the highest architecture. REA's pinned contract distinguishes inventory and payload targets and reports actual conflicts.

Impact and scope

Wrong target facts can omit matching kernels and mislead compatibility analysis. Both standalone PTX and a benign uncompressed fatbin reproduced this. Unfiltered inspection retains kernel k and the complete original PTX, allowing manual target inspection. Real-producer prevalence is NOT_ENOUGH_INFO.

REA version

Main revision 8c4f96ef4759fd78da66c4b9726825ca71d7ee0c, package metadata 6.7.0. Main-only finding: published tag rea-agents-6.7.0 points to 27dc42d10249f0410904a75c0997842eb03b931c and has no src/gpu implementation. No released-package reproduction is claimed.

Runtime and platform

Node.js v24.22.1; Linux x86_64; repository-pinned tsx and locked dependencies. No external provider or GPU runtime.

Target and artifact context

Benign PTX ISA 8.8 with two baseline target directives and one ret-only kernel; the enclosing fixture uses the repository's CUDA fatbinary writer.

Interface

Other

Earliest failure stage

Capture or observation

Relevant output or evidence

Selected stdout:

standalone: target=sm_80 payload_target=sm_80 inspection=complete kernels=[k]
filtered:   target=sm_80 inspection=not-selected kernels=[]
fatbin:     target=sm_90 payload_target=sm_80 target_consistency=conflict

The earlier five-case service probe reproduced these cases once each; a single-target sm_90 control returned sm_90 and kernel k. A second directive placed after an earlier entry was also ignored. The reduced script independently reproduced all three once.

Typed outcome or recovery expected

Preserve all target declarations and their effective requirement; avoid false conflicts and silently excluding a matching payload.

Analysis or suspected cause

Source-derived: readPtxTarget returns immediately after its first recognized target and also stops at the first entry/function. Standalone inventory and decoded fatbin comparison consume this value.

Additional context

Open/closed searches covered PTX target, PTX multiple, and readPtxTarget. Closed #6494 and #6625 concern target synonyms; #6618 concerns fatbin suffixes. None covers multiple directives. Observed production-boundary execution, not source-only reasoning or a mocked provider. Public CLI/MCP, compiler acceptance, GPU execution, and other platforms were not tested; input validity follows the archived specification. No builds, suites, or changes.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: Valid multi-target PTX receives the wrong target, loses its kernel under the matching filter, and produces a false enclosing-fatbin conflict in actual shared-service calls.
  • Workaround status: available
  • Workaround basis: Unfiltered inspection returned kernel k and retained the complete original PTX, whose directives can be inspected manually; this does not correct the erroneous target field.
Originally created by @coygeek on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/6695 ## Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ## Area Evidence, artifacts, or reconstruction ## Observed behavior Production shared-service reproduction: PTX declaring `sm_80` followed by `sm_90` is inventoried as `sm_80`, with complete payload coverage. Filtering for `sm_90` excludes its kernel. Enclosing that payload in a fatbin declaring `sm_90` produces a false target conflict. ## Reproduction From the specified checkout with locked dependencies installed, save this as `/tmp/rea-ptx-target/repro.mts` and run `node --import ./node_modules/tsx/dist/loader.mjs /tmp/rea-ptx-target/repro.mts /tmp/rea-ptx-target/input`. This exact reduced script was executed once against actual files and the real application service, in scratch: ```ts import { mkdir, writeFile } from 'node:fs/promises'; import { resolve, join } from 'node:path'; import { pathToFileURL } from 'node:url'; const load = (p: string) => import(pathToFileURL(resolve(p)).href); const { GpuCodeObjectsProvider } = await load('src/gpu/GpuCodeObjectsProvider.ts'); const { GpuCodeObjectsService } = await load('src/application/gpu/GpuCodeObjectsService.ts'); const { cudaFixture } = await load('tests/fixtures/gpu/codeObjects.ts'); const root = resolve(process.argv[2]); await mkdir(root, { recursive: true }); const ptx = Buffer.from('.version 8.8\n.target sm_80\n.address_size 64\n' + '.target sm_90\n.visible .entry k() { ret; }\n'); const cases = [ ['standalone', ptx, undefined], ['filtered', ptx, ['sm_90']], ['fatbin', cudaFixture('none', [{kind: 1, target: 90, bytes: ptx}]), undefined], ] as const; for (const [name, bytes, targets] of cases) { const path = join(root, name + '.bin'); await writeFile(path, bytes); const service = new GpuCodeObjectsService(new GpuCodeObjectsProvider()); try { const result = await service.inspect({path, analysis: 'kernels', detail: 'complete', ...(targets ? {targets} : {})}); if (!result.ok) throw result.error; const r = result.value.normalized_result; console.log(JSON.stringify({name, objects: r.objects.map(o => ({ target:o.target, payload_target:o.payload_target, target_consistency:o.target_consistency, inspection:o.inspection})), kernels:r.kernels.map(k => k.name)})); } finally { await service.close(); } } ``` ## Expected behavior Account for subsequent `.target` directives when reporting target requirements and selecting payloads. For these baseline architectures, the effective requirement is `sm_90`. NVIDIA's [archived PTX ISA 8.8 specification](https://docs.nvidia.com/cuda/archive/12.9.1/parallel-thread-execution/index.html#ptx-module-directives-target) explicitly permits multiple directives and assigns requirements from the highest architecture. REA's [pinned contract](https://github.com/morluto/rea/blob/8c4f96ef4759fd78da66c4b9726825ca71d7ee0c/docs/gpu-code-objects.md#L23-L33) distinguishes inventory and payload targets and reports actual conflicts. ## Impact and scope Wrong target facts can omit matching kernels and mislead compatibility analysis. Both standalone PTX and a benign uncompressed fatbin reproduced this. Unfiltered inspection retains kernel `k` and the complete original PTX, allowing manual target inspection. Real-producer prevalence is NOT_ENOUGH_INFO. ## REA version Main revision `8c4f96ef4759fd78da66c4b9726825ca71d7ee0c`, package metadata 6.7.0. Main-only finding: published tag `rea-agents-6.7.0` points to `27dc42d10249f0410904a75c0997842eb03b931c` and has no `src/gpu` implementation. No released-package reproduction is claimed. ## Runtime and platform Node.js v24.22.1; Linux x86_64; repository-pinned tsx and locked dependencies. No external provider or GPU runtime. ## Target and artifact context Benign PTX ISA 8.8 with two baseline target directives and one `ret`-only kernel; the enclosing fixture uses the repository's CUDA fatbinary writer. ## Interface Other ## Earliest failure stage Capture or observation ## Relevant output or evidence Selected stdout: ```text standalone: target=sm_80 payload_target=sm_80 inspection=complete kernels=[k] filtered: target=sm_80 inspection=not-selected kernels=[] fatbin: target=sm_90 payload_target=sm_80 target_consistency=conflict ``` The earlier five-case service probe reproduced these cases once each; a single-target `sm_90` control returned `sm_90` and kernel `k`. A second directive placed after an earlier entry was also ignored. The reduced script independently reproduced all three once. ## Typed outcome or recovery expected Preserve all target declarations and their effective requirement; avoid false conflicts and silently excluding a matching payload. ## Analysis or suspected cause Source-derived: [`readPtxTarget`](https://github.com/morluto/rea/blob/8c4f96ef4759fd78da66c4b9726825ca71d7ee0c/src/gpu/PtxKernels.ts#L519-L544) returns immediately after its first recognized target and also stops at the first entry/function. Standalone inventory and decoded fatbin comparison consume this value. ## Additional context Open/closed searches covered `PTX target`, `PTX multiple`, and `readPtxTarget`. Closed #6494 and #6625 concern target synonyms; #6618 concerns fatbin suffixes. None covers multiple directives. Observed production-boundary execution, not source-only reasoning or a mocked provider. Public CLI/MCP, compiler acceptance, GPU execution, and other platforms were not tested; input validity follows the archived specification. No builds, suites, or changes. ## Triage assessment - Impact level: P2 - Assessment status: supported - Impact basis: Valid multi-target PTX receives the wrong target, loses its kernel under the matching filter, and produces a false enclosing-fatbin conflict in actual shared-service calls. - Workaround status: available - Workaround basis: Unfiltered inspection returned kernel k and retained the complete original PTX, whose directives can be inspected manually; this does not correct the erroneous target field.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4071
No description provided.