Refactor generated kernels behind one native manifest - #17
Merged
Conversation
Problem: PrivateUse1 rename and device-module registration occurred outside the restart-only boundary even though earlier native and compiler registration had already mutated process-global state. Ownership: downstream torch-xdna initialization and tests only; no PyTorch, driver, firmware, or runtime changes. Boundary: keep the existing registration order, classify post-mutation rename/device-module failures as process-fatal, and require a fresh process rather than claiming rollback. Test Plan: python -m pytest -q tests/test_strategy_b_initialization.py tests/test_initialization_contracts.py (17 passed); python -m ruff check torch_xdna/__init__.py tests/test_strategy_b_initialization.py; python -m ruff format --check torch_xdna/__init__.py tests/test_strategy_b_initialization.py; git diff --check. Physical Evidence: not required; registration ordering and injected failures are hardware-free process semantics. Limitations: irreversible process-global mutations are not rolled back; callers must discard a process after a reported late initialization failure. AI-assisted development: Codex assisted implementation and validation; the human maintainer remains responsible for review and acceptance.
Problem: the two approved generated add and matmul receipts used parallel final-ABI and operation shapes, obscuring their shared launch contract. Ownership: downstream torch-xdna legacy receipt normalization and hardware-free contract tests. Boundary: preserve both approved receipt wire formats and identities, project them into immutable typed operation and final-ABI views, and derive direct-three-BO eligibility. This does not introduce a general receipt wire format or authorize a third kernel family. Test Plan: python -m pytest -q tests/test_compiler_contracts.py tests/test_generated_contract_schema.py (110 passed); python -m ruff check torch_xdna/_generated_contract_schema.py tests/test_generated_contract_schema.py; python -m ruff format --check torch_xdna/_generated_contract_schema.py tests/test_generated_contract_schema.py; python -m mypy --strict --follow-imports=skip torch_xdna/_generated_contract_schema.py; python -m py_compile torch_xdna/_generated_contract_schema.py tests/test_generated_contract_schema.py; git diff --check. Physical Evidence: not required; this commit preserves the exact qualified receipt bytes and device-artifact identities and is not yet wired into runtime admission. Limitations: the two legacy receipt codecs remain the authoritative wire formats; a future family needs a reviewed codec or a separate common-wire migration. AI-assisted development: Codex assisted design, implementation, and validation; the human maintainer remains responsible for review and acceptance.
Problem: Generated add and matmul ABI facts were duplicated across native capability, runtime, and Python binding code, with operation-specific field inference. Ownership: Downstream torch-xdna native capability, direct-BO runtime, packaging, and contract tests. Boundary: Introduce one closed C++ declaration table for the two physically approved generated families. Capability, runtime, and bindings consume the exact family, receipt, artifact profile, operation payload, and named final-ABI bindings. No operator, shape, dtype, stream, or launch surface is added. Test Plan: - python -m pytest -q tests/test_generated_kernel_manifest_cpp.py tests/test_native_capability_cpp.py tests/test_generated_elf_native_contract.py - python -m pytest -q tests/test_bootstrap_script.py::test_source_distribution_build_does_not_require_xrt - python -m ruff check . - python -m ruff format --check . - git diff --check Results: The integrated focused contract set passed 345 tests; the source-distribution subset passed 4 tests; Ruff, formatting, and diff checks passed. Physical Evidence: Not rerun for this isolated commit. The native source identity changes, so a source-exact targeted add and matmul smoke remains mandatory before the branch can merge. Limitations: The table authorizes only exact BF16[1024] add and BF16 [128,64]@[64,128] matmul receipts. It is not a general generated-kernel wire or capability claim. AI-assisted development: Codex assisted with implementation and tests. The human maintainer remains responsible for review and approval.
Problem: Python artifact admission, compiler profiles, source symbols, and native launch bindings maintained separate add-versus-matmul tables and could drift after native state or cache mutation. Ownership: Downstream torch-xdna compiler contracts, artifact cache, initialization, and adapter metadata. Boundary: Add one closed two-family Python manifest, exact-match its complete native-approved receipt, ABI, operation, and artifact-profile identity before cache construction, and route admission/source metadata through it. Legacy receipt bytes and device-artifact identities remain unchanged. The normalized legacy schema remains inspection-only and is not promoted to a general wire format. Test Plan: - python -m pytest -q tests/test_generated_kernel_manifest.py tests/test_compiler_artifacts.py tests/test_generated_kernel_registry.py tests/test_strategy_b_initialization.py tests/test_triton_adapter.py - python -m pytest -q tests/test_generated_kernel_manifest_cpp.py tests/test_native_capability_cpp.py - python -m mypy --follow-imports=skip --ignore-missing-imports --strict torch_xdna/_generated_kernel_manifest.py torch_xdna/_compiler_artifacts.py torch_xdna/_generated_kernel_registry.py torch_xdna/_triton_adapter.py - python -m ruff check . - python -m ruff format --check . - git diff --check Results: The integrated focused contract set passed 345 tests. Strict typing passed for the complete 20-module CI set; Ruff, formatting, and diff checks passed. Physical Evidence: Not rerun for this isolated adapter commit. Source-exact targeted generated-add and matmul smokes remain required for the completed stack because native and wrapper identities change. Limitations: Only the exact approved BF16 add and matmul families are represented. A future family still requires a reviewed receipt codec or separately versioned common-wire migration and independent physical qualification. AI-assisted development: Codex assisted with implementation and tests. The human maintainer remains responsible for review and approval.
Problem: Generated BF16 add and matmul wrappers used different graph-identity implementations and repeated operation-to-kernel routing tables, making cache invalidation and later family review inconsistent. Ownership: Downstream torch-xdna Inductor scheduling, wrapper generation, compiler-cache identity, tests, and alpha documentation. Boundary: Introduce one versioned binary contiguous generated-graph identity, require a real scheduler-stage native capability decision, resolve wrapper and launch metadata through the approved manifest, and preserve the legacy INT32 identity. The identity remains static, synchronous, inference-only, binary, no-alias, no-broadcast, and no-runtime-scalar. Test Plan: - python -m pytest -q tests/test_compiler_cache.py tests/test_inductor_adapter.py - python -m pytest -q tests/test_generated_kernel_manifest.py tests/test_compiler_artifacts.py tests/test_generated_kernel_registry.py tests/test_strategy_b_initialization.py tests/test_triton_adapter.py - python -m ruff check . - python -m ruff format --check . - python -m mypy --follow-imports=skip --ignore-missing-imports --strict torch_xdna/_compiler_cache.py - git diff --check Results: The final focused integration set passed 345 tests, including a real SchedulerNode-to-wrapper identity path. Independent review passed 337 tests and found no fail-open or authority-drift blocker. Ruff, formatting, typing, and diff checks passed. Physical Evidence: Not rerun for this isolated wrapper commit. Exact source-built add and matmul physical smokes are required before merge. Limitations: This is not a general N-ary graph schema. Unary, reduction, runtime-scalar, dynamic, aliased, non-contiguous, stream, training, and autograd identities remain unsupported. AI-assisted development: Codex assisted with implementation and tests. The human maintainer remains responsible for review and approval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Boundary
This does not add an operator, shape, dtype, stream, dynamic-shape, training, or autograd capability. The common normalized schema is an inspection view for the two legacy receipt formats, not a general third-family admission wire. Future generated families still require reviewed codec and physical qualification work.
AI-assisted development
Codex assisted with implementation, testing, and review. The human maintainer remains responsible for understanding and approving the change.