Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b731206
feat(hip): the model-free kernels on #463's runtime: attention, Delta…
BlivionIaG Oct 10, 2026
67d9479
feat(core): weight formats behind one interface, MLX affine 2- to 8-b…
BlivionIaG Oct 10, 2026
48abd99
feat(core): a kernel registry that picks a product's tile by tuned co…
BlivionIaG Oct 10, 2026
6254228
feat(hip): the MLX affine products: dot2 tiles, the gfx11 matrix-core…
BlivionIaG Oct 10, 2026
9b6b260
docs(hip): the device bitcode of Ubuntu's packaged HIP, and no rocWMM…
BlivionIaG Oct 11, 2026
1152c67
Merge branch 'hip-kernels-ops' into hip-kernels-affine
BlivionIaG Oct 11, 2026
df83c6f
Merge branch 'hip-kernels-ops' into hip-kernels-affine
BlivionIaG Oct 11, 2026
5d05894
chore(hip): gdn_prefill.hip drops the vLLM SPDX lines it kept from th…
BlivionIaG Oct 11, 2026
a579284
Merge branch 'hip-kernels-affine' into fam-new
BlivionIaG Oct 11, 2026
e6c11fb
feat(qwen3_5): the GPU backends' checkpoint loader, on the host
BlivionIaG Oct 10, 2026
eb9bd0f
fix(qwen3_5): un-center an MTP head shipped zero-centered
BlivionIaG Oct 11, 2026
4c231bf
feat(qwen3_5): the HIP config refuses what the kernels do not compute…
BlivionIaG Oct 11, 2026
02c1dd6
Merge remote-tracking branch 'upstream/main' into fam-r2
BlivionIaG Oct 12, 2026
57fadd1
feat(hip): the runtime pieces an engine uses beyond #463's model-free…
BlivionIaG Oct 10, 2026
211ea81
feat(hip): the kernels a tensor-parallel rank and the MTP head add
BlivionIaG Oct 10, 2026
42664f9
feat(qwen3_5): the Qwen3.5 / Qwen3.6 engine on HIP, its native server…
BlivionIaG Oct 10, 2026
3d9bd2e
feat(hip): one rank source: --speed-up is refused, the HIP engine's r…
BlivionIaG Oct 10, 2026
a25c8e2
feat(qwen3_5): the HIP prompt cache serves serial requests too
BlivionIaG Oct 10, 2026
3092774
test(qwen3_5): chat with the prompt cache equals chat without it thro…
BlivionIaG Oct 10, 2026
9a4e10f
feat(qwen3_5): a prompt runs 512-row chunks while other streams decode
BlivionIaG Oct 11, 2026
3f396fc
feat(hip): RDNA4 runs on the dot2 tiles; matrix=on is refused where n…
BlivionIaG Oct 11, 2026
fc795cb
test(qwen3_5): serve_rewind.py's docstring on one line, as the lean c…
BlivionIaG Oct 11, 2026
10f67d9
refactor(qwen3_5): the engine reaches the other ranks through hip/col…
BlivionIaG Oct 11, 2026
7f5fd5b
build(hip): the HIP server's CLI module takes EXLR8's import, as main…
BlivionIaG Oct 12, 2026
13961db
feat(hip): tensor parallelism over RCCL, behind hip/collective.zig
BlivionIaG Oct 11, 2026
ba0bc3c
feat(hip): the graph cache by shape in the hip module, for every HIP …
BlivionIaG Oct 12, 2026
905d9e9
feat(hip): a step recorded as graphs cut at its collectives, the coll…
BlivionIaG Oct 12, 2026
5480055
feat(hip): the graph cache over any replayable step, a caller's own k…
BlivionIaG Oct 12, 2026
ebe69eb
feat(qwen3_5): HIP rounds record split graphs: the collectives run be…
BlivionIaG Oct 12, 2026
10926cf
feat(qwen3_5): HIP rounds replay split graphs at any world size, RCCL…
BlivionIaG Oct 12, 2026
66d8a19
fix(qwen3_5): every rank sizes its streams for rank 0's window, so a …
BlivionIaG Oct 12, 2026
d47b0f8
perf(qwen3_5): the HIP loader drops each part's mapped pages once it …
BlivionIaG Oct 13, 2026
1ae1078
style(hip): the ops headers end without a blank line, as git diff --c…
BlivionIaG Oct 14, 2026
47612d0
Merge branch 'hip-kernels-ops' into qwen35-family (ops headers end wi…
BlivionIaG Oct 14, 2026
3850523
Merge branch 'qwen35-family' into qwen35-rccl (ops headers end withou…
BlivionIaG Oct 14, 2026
5537d6a
fix(hip): the paged prefill tile calls expf, as the flat tile does
BlivionIaG Oct 14, 2026
9178585
Merge branch 'hip-kernels-ops' into qwen35-family (the paged prefill …
BlivionIaG Oct 14, 2026
f5281d5
Merge branch 'qwen35-family' into qwen35-rccl (the paged prefill tile…
BlivionIaG Oct 14, 2026
d91b074
fix(hip): one fp32 DeltaNet recurrence at every length; the chunked p…
BlivionIaG Oct 14, 2026
1da7042
Merge branch 'hip-kernels-ops' into qwen35-family (one fp32 DeltaNet …
BlivionIaG Oct 14, 2026
205b800
Merge branch 'qwen35-family' into qwen35-rccl (one fp32 DeltaNet recu…
BlivionIaG Oct 14, 2026
1bdd859
refactor(hip): the policy's gdn switch goes with the chunked recurren…
BlivionIaG Oct 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(hip): the runtime pieces an engine uses beyond #463's model-free…
… set

The device count, a context's free and total memory (hipMemGetInfo, looked up on its own so the admission set
is unchanged), a buffer's base address, a pinned host buffer's sub-range and typed view, and raw.zig: device
copies, fills and pinned transfers on a forward's raw stream handle, none of them on the counting stream.
hip-gpu-test checks each on the GPU.
  • Loading branch information
BlivionIaG committed Oct 12, 2026
commit 57fadd18bbc55844fee97e5e81f9b052807277a4
52 changes: 52 additions & 0 deletions zig/src/hip/engine_runtime_tests.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//! The runtime pieces an engine uses beyond the model-free tests: device count, free memory, addresses, raw copies.
const std = @import("std");
const Runtime = @import("runtime.zig").Runtime;
const Context = @import("context.zig").Context;
const Stream = @import("stream.zig").Stream;
const DeviceBuffer = @import("memory.zig").DeviceBuffer;
const HostBuffer = @import("memory.zig").HostBuffer;
const raw = @import("raw.zig");
const counting = @import("launches/util.zig").counting;

test "device count and free memory, buffer addresses, pinned views and raw-stream copies and fills" {
var r = try Runtime.open();
defer r.close();
try std.testing.expect(try r.deviceCount() >= 1);
var ctx = try Context.init(&r, 0);
defer ctx.deinit();
const mem = try ctx.memInfo();
try std.testing.expect(mem.total > 0 and mem.free <= mem.total);
var stream = try Stream.init(&r);
defer stream.deinit();
const n = 4096;
var a = try DeviceBuffer.alloc(&r, n);
defer a.free();
var b = try DeviceBuffer.alloc(&r, n);
defer b.free();
try std.testing.expectEqual(@intFromPtr(a.ptr), a.base());
var host = try HostBuffer.alloc(&r, 2 * n);
defer host.free();
for (host.slice(u32), 0..) |*w, i| w.* = @intCast(i);
try std.testing.expectEqual(@as(usize, 2 * n / 4), host.slice(u32).len);
// a view of the second half goes up through the #463 API, comes back through a raw-stream download
try a.uploadAsync(0, host.view(n, 2 * n), stream);
try raw.copy(b, 16, a.base() + 32, n - 32, stream.handle);
try raw.fill8(a, 0xab, stream.handle);
try raw.download(b, 0, host.bytes[0..n], stream.handle);
try stream.synchronize();
const words = host.slice(u32);
for (words[4 .. n / 4 - 4], n / 4 + 8..) |w, want| try std.testing.expectEqual(@as(u32, @intCast(want)), w);
var back: [n]u8 = undefined;
try a.download(0, &back);
for (back) |x| try std.testing.expectEqual(@as(u8, 0xab), x);
try raw.fill32(a, 0x01020304, stream.handle);
try raw.upload(b, 0, host.bytes[n .. n + 8], stream.handle);
// the counting stream queues nothing
try raw.fill8(a, 0, counting);
try raw.copy(a, 0, b.base(), n, counting);
try stream.synchronize();
try a.download(0, &back);
for (std.mem.bytesAsSlice(u32, &back)) |w| try std.testing.expectEqual(@as(u32, 0x01020304), w);
try std.testing.expectError(error.Invalid, raw.copy(a, n - 4, b.base(), 8, stream.handle));
try std.testing.expectError(error.Invalid, raw.upload(a, n, host.bytes[0..1], stream.handle));
}
16 changes: 16 additions & 0 deletions zig/src/hip/memory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ pub const DeviceBuffer = struct {
self.* = undefined;
}

/// The device address of the first byte, as kernel arguments take it.
pub fn base(self: DeviceBuffer) u64 {
return @intFromPtr(self.ptr);
}

/// The device address `offset` bytes in, as kernel arguments and device copies take it; past the end is refused.
pub fn address(self: DeviceBuffer, offset: usize) runtime.Error!u64 {
if (offset > self.len) return error.Invalid;
Expand Down Expand Up @@ -171,6 +176,17 @@ pub const HostBuffer = struct {
return @intFromPtr(ptr);
}

/// Bytes `from..to` of this buffer, still pinned, for an async copy of part of it.
pub fn view(self: HostBuffer, from: usize, to: usize) HostBuffer {
return .{ .r = self.r, .bytes = self.bytes[from..to] };
}

/// The bytes as `T`s, the tail that does not fill one left out.
pub fn slice(self: HostBuffer, comptime T: type) []T {
const whole = self.bytes[0 .. self.bytes.len / @sizeOf(T) * @sizeOf(T)];
return @alignCast(std.mem.bytesAsSlice(T, @as([]align(@alignOf(T)) u8, @alignCast(whole))));
}

/// All streams using these bytes must have completed before release.
pub fn free(self: *HostBuffer) void {
_ = self.r.api.hipHostFree(self.bytes.ptr);
Expand Down
39 changes: 39 additions & 0 deletions zig/src/hip/raw.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Device copies and fills on a forward's raw stream handle; the counting stream runs none of them.
const abi = @import("abi.zig");
const runtime = @import("runtime.zig");
const DeviceBuffer = @import("memory.zig").DeviceBuffer;
const counting = @import("launches/util.zig").counting;

/// `n` bytes from device address `src` into `dst` at `offset`, queued on `stream`.
pub fn copy(dst: DeviceBuffer, offset: usize, src: u64, n: usize, stream: abi.Stream) runtime.Error!void {
if (offset > dst.len or n > dst.len - offset) return error.Invalid;
if (n == 0 or stream == counting) return;
try runtime.check(dst.r.api.hipMemcpyDtoDAsync(@ptrFromInt(dst.base() + offset), @ptrFromInt(src), n, stream));
}

/// Every byte of `b` set to `value`, queued on `stream`.
pub fn fill8(b: DeviceBuffer, value: u8, stream: abi.Stream) runtime.Error!void {
if (b.len == 0 or stream == counting) return;
try runtime.check(b.r.api.hipMemsetAsync(b.ptr, value, b.len, stream));
}

/// Every 32-bit word of `b` set to `value`, queued on `stream`.
pub fn fill32(b: DeviceBuffer, value: u32, stream: abi.Stream) runtime.Error!void {
if (b.len % 4 != 0) return error.Invalid;
if (b.len == 0 or stream == counting) return;
try runtime.check(b.r.api.hipMemsetD32Async(b.ptr, @bitCast(value), b.len / 4, stream));
}

/// Pinned host `bytes` into `dst` at `offset`, queued on `stream`; they stay unchanged until it completes.
pub fn upload(dst: DeviceBuffer, offset: usize, bytes: []const u8, stream: abi.Stream) runtime.Error!void {
if (offset > dst.len or bytes.len > dst.len - offset) return error.Invalid;
if (bytes.len == 0 or stream == counting) return;
try runtime.check(dst.r.api.hipMemcpyHtoDAsync(@ptrFromInt(dst.base() + offset), bytes.ptr, bytes.len, stream));
}

/// `out.len` bytes of `src` from `offset` into pinned host `out`, queued on `stream`.
pub fn download(src: DeviceBuffer, offset: usize, out: []u8, stream: abi.Stream) runtime.Error!void {
if (offset > src.len or out.len > src.len - offset) return error.Invalid;
if (out.len == 0 or stream == counting) return;
try runtime.check(src.r.api.hipMemcpyDtoHAsync(out.ptr, @ptrFromInt(src.base() + offset), out.len, stream));
}
7 changes: 7 additions & 0 deletions zig/src/hip/runtime.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ pub const Runtime = struct {
return std.mem.span(name);
}

/// The GPUs this process sees.
pub fn deviceCount(self: *const Runtime) Error!c_int {
var n: c_int = 0;
try check(self.api.hipGetDeviceCount(&n));
return n;
}

pub fn close(self: *Runtime) void {
self.lib.close();
self.* = undefined;
Expand Down
4 changes: 4 additions & 0 deletions zig/src/hip/runtime_tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,7 @@ test "memory info sees a new allocation" {
try std.testing.expectEqual(before.total, after.total);
try std.testing.expect(after.free + len <= before.free);
}

test {
_ = @import("engine_runtime_tests.zig");
}