Skip to content

feat(pyxlog): add typed host row bridge - #288

Open
levi770 wants to merge 1 commit into
codex/pyxlog-file-compilefrom
codex/pyxlog-host-row-bridge
Open

feat(pyxlog): add typed host row bridge#288
levi770 wants to merge 1 commit into
codex/pyxlog-file-compilefrom
codex/pyxlog-host-row-bridge

Conversation

@levi770

@levi770 levi770 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Context

Mistaber needs a production Pyxlog worker that can compile a frozen XLOG source tree once, load per-context facts without PyTorch/DLPack as an ambient dependency, execute the exact deterministic hot loop under the strict D2H gate, capture transfer counters before export, and only then download lexical results.

The existing public relation-session surface required caller-owned DLPack capsules. That is appropriate for tensor integrations but forces an unrelated tensor runtime into a small isolated symbolic worker. This PR adds a narrow typed lexical row seam while preserving CUDA-resident evaluation.

This is a stacked PR:

Changes

  • Add LogicRelationSession.put_relation_rows(name, rows) for all XLOG scalar types.
  • Validate compiled relation arity and lexical values before committing a relation replacement.
  • Reject non-finite f32/f64 values and non-canonical boolean spellings.
  • Intern symbol values through XLOG core and upload typed column bytes through CudaKernelProvider::create_buffer_from_slices.
  • Add LogicRelationSession.export_relation_rows(name) for deterministic typed lexical export after the strict measurement window.
  • Resolve exported symbol IDs through the checked symbol table and fail closed on unknown IDs.
  • Add Python stubs and a standalone GPU test that does not import PyTorch.

GPU evidence

Authorized host: RTX PRO 4500 Blackwell, CUDA 13.0.

Development build:

Finished release profile [optimized] target(s) in 2m 06s
Built wheel: pyxlog-0.12.0-cp312-cp312-manylinux_2_34_x86_64.whl
2 passed in 0.94s

Exact pushed commit verification:

commit a5d31b0227ef423e45ed121b21c1ee42361d5213
Finished release profile [optimized] target(s) in 1m 45s
Built wheel: pyxlog-0.12.0-cp312-cp312-manylinux_2_34_x86_64.whl
2 passed in 1.26s

The host-row test covers symbol, u32, u64, i32, i64, f32, f64, and bool; rejects wrong arity, non-finite floats, and invalid booleans; then verifies:

htod_bytes=0
htod_calls=0
dtoh_bytes=0
dtoh_calls=0
deterministic_d2h_violation_count=0

inside the measured evaluate() window. The strict gate is explicitly disabled only before final lexical export.

Local verification

cargo fmt --all -- --check
cargo check -p pyxlog --locked
python -m ruff check python/tests/test_pyxlog_compile_file.py python/tests/test_pyxlog_host_rows.py
python -m compileall -q crates/pyxlog/python/pyxlog python/tests/test_pyxlog_compile_file.py python/tests/test_pyxlog_host_rows.py
git diff --check

All passed.

Claim boundary

This PR proves zero tracked host transfers and zero strict-D2H violations only for the measured deterministic evaluation window in the focused GPU test. Relation upload occurs before counters are reset. Lexical export occurs after the gate is disabled. This PR does not claim zero transfer for compilation, setup, final observation export, probabilistic execution, or neural execution.

Review focus

  • Atomicity of lexical parsing before relation replacement commit.
  • Scalar width and symbol interning/resolution behavior.
  • Correct separation of setup, measured evaluation, and final export.
  • Whether the new API is sufficiently narrow for non-tensor isolated workers.

Stack topology

This PR is the third layer of the Pyxlog/runtime stack. It depends on #287 and #286; review and merge order is #286 -> #287 -> #288 -> #289.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant