Skip to content

fix(pjrt): centralize internal/cuda import in pjrt.go#68

Closed
dndungu wants to merge 4 commits intomainfrom
p2-buffers
Closed

fix(pjrt): centralize internal/cuda import in pjrt.go#68
dndungu wants to merge 4 commits intomainfrom
p2-buffers

Conversation

@dndungu
Copy link
Copy Markdown
Contributor

@dndungu dndungu commented Apr 4, 2026

Phase 2 PJRT pipeline: buffer management fixes.

dndungu added 4 commits April 2, 2026 15:14
Emit StableHLO MLIR text for structural operations:
- MatMul -> stablehlo.dot_general with batching/contracting dims
- Transpose -> stablehlo.transpose with permutation
- Reshape -> stablehlo.reshape with shape validation
- Concat -> stablehlo.concatenate along specified axis
- Slice -> stablehlo.slice with starts/limits/strides
- Gather -> stablehlo.gather with full dimension numbers

All emitters use SSANamer and FormatTensorType from types.go
and delegate shape inference to InferStructuralShape.
Implement Emitter struct that generates StableHLO MLIR text from
SSA inputs, shapes, and dtypes. Covers binary ops (add, subtract,
multiply, divide, power), unary ops (exponential, log, sine, cosine,
tanh, sqrt, rsqrt, negate), and scalar ops (MulScalar, AddScalar,
DivScalar) which emit constant + broadcast_in_dim + element-wise op.

Includes EmitOp dispatch function for use by the program assembler.
…fecycle)

T60.2.1: BufferFromHost wraps PJRT_Client_BufferFromHostBuffer with
Go type to PJRT element type mapping (F32, F64, F16, BF16, F8E4M3,
S32, S64, etc.), shape validation, and buffer donation support.

T60.2.2: ToHost/ToHostSlice wraps PJRT_Buffer_ToHostBuffer with
async readback and PJRT_Event_Await synchronization.

T60.2.3: Buffer metadata (Dtype, Shape, OnDeviceSizeInBytes, ReadyEvent)
and lifecycle (Close, Delete) with double-close no-op for finalizer safety.
Add ccall, dlopenPath, and dlsym forwarding functions in pjrt.go
so that buffer.go, client.go, and device.go do not import
internal/cuda directly. Only pjrt.go holds the cuda dependency.
@dndungu
Copy link
Copy Markdown
Contributor Author

dndungu commented Apr 4, 2026

Content already in main

@dndungu dndungu closed this Apr 4, 2026
@dndungu dndungu deleted the p2-buffers branch April 4, 2026 01:26
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