Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
881ccca
cuda: a process-wide cap on DeviceBuffer and pinned HostBuffer bytes
plotarmordev Oct 16, 2026
b00dd4e
drama: the temporal codebook tower
plotarmordev Oct 16, 2026
c8af505
drama: the speech codec, with codec.pth read without Python
plotarmordev Oct 16, 2026
e192c0f
engine_api: speech requests, speech info and a submit_speech hook
plotarmordev Oct 16, 2026
ab45904
native: Drama 3 (fish_omni) on CUDA
plotarmordev Oct 16, 2026
7553d00
server: POST /v1/audio/speech
plotarmordev Oct 16, 2026
8ba4307
tests: Drama 3 backbone and tower oracles, replays and stage traces
plotarmordev Oct 16, 2026
20249e9
drama: incremental codec decode, bit-identical to the whole decode
plotarmordev Oct 16, 2026
93fcaab
tests: Drama 3 codec oracle, replays and stage trace
plotarmordev Oct 16, 2026
d84284d
engine_api: audio events, so a speech engine can publish PCM while it…
plotarmordev Oct 16, 2026
71c31a9
build: Drama 3 backbone and tower kernels, the drama module, the nati…
plotarmordev Oct 16, 2026
588f1f1
server: stream: true on /v1/audio/speech sends raw PCM chunks as they…
plotarmordev Oct 16, 2026
d8c6a47
drama: the backbone's one-row GEMM stages its weights through shared …
plotarmordev Oct 16, 2026
10796d4
build: the Drama 3 codec kernels and the codec tool steps
plotarmordev Oct 16, 2026
8bc6814
tests: tf-drama-codec-stream-oracle, whole against chunked codec decodes
plotarmordev Oct 16, 2026
40c7c87
core: a direct read the file system refuses goes through the page cache
plotarmordev Oct 16, 2026
23a7fcc
cuda: Module.holds, whether a loaded image defines a device global
plotarmordev Oct 16, 2026
6f85731
drama: the Drama 3 text backbone on CUDA
plotarmordev Oct 16, 2026
05a715f
drama: one-row backbone GEMVs stream weights through a swizzled cp.as…
plotarmordev Oct 16, 2026
9dc8202
drama: add-norm fused with the routed experts' FP8 activation quantiz…
plotarmordev Oct 16, 2026
705541c
drama: one SwiGLU launch for the routed and shared experts
plotarmordev Oct 16, 2026
08291b5
drama: MoE combine on 8-wide vectors
plotarmordev Oct 16, 2026
641b18b
drama: decode attention keeps the next keys' loads in flight
plotarmordev Oct 16, 2026
01b7f3b
drama: the tower's one decode row attends as a thread-block cluster
plotarmordev Oct 16, 2026
b89dc67
drama: checkpoint weights stream onto the GPU with direct I/O in file…
plotarmordev Oct 16, 2026
0f9345e
speech: a Drama 3 reply that reaches max_frames returns its clipped a…
plotarmordev Oct 16, 2026
9b3934c
drama: one-row attention runs its Q/K norm and RoPE prologue in the s…
plotarmordev Oct 16, 2026
ea06b8b
drama: the tower samples with a stable radix sort
plotarmordev Oct 16, 2026
68aeb3e
drama: the codec builds its weights on its own thread while the backb…
plotarmordev Oct 16, 2026
2757724
drama: the tower's one-row projections on drama_tower_gemv, in cuBLAS…
plotarmordev Oct 16, 2026
fdee05c
Merge upstream main (6ee828c2) into feat/drama3-cuda
plotarmordev Oct 17, 2026
0f81a2b
Merge align/920-merge-main (upstream main 6ee828c2) into feat/drama3-…
plotarmordev Oct 17, 2026
15bceca
Merge align/921-merge-main (upstream main 6ee828c2) into fix/drama3-c…
plotarmordev Oct 17, 2026
64e8ff8
Merge align/922-merge-main (upstream main 6ee828c2) into perf/drama3-…
plotarmordev Oct 17, 2026
2d9232a
Merge align/923-merge-main (upstream main 6ee828c2) into perf/drama3-…
plotarmordev Oct 17, 2026
42c548c
Merge align/924-merge-main (upstream main 6ee828c2) into perf/drama3-…
plotarmordev Oct 17, 2026
96f2b38
Merge align/925-merge-main (upstream main 6ee828c2) into perf/drama3-…
plotarmordev Oct 17, 2026
b56fc8c
drama: below sm_90 the tower's decode row runs drama_attention, and i…
plotarmordev Oct 17, 2026
996637c
Merge align/924-merge-main into perf/drama3-load: the tower's sm_90 c…
plotarmordev Oct 17, 2026
4d3c4f5
Merge align/925-merge-main into perf/drama3-tower-gemv: the tower's s…
plotarmordev Oct 17, 2026
65cd256
engine_api and native/cuda.zig back under 600 lines: speech and visio…
plotarmordev Oct 17, 2026
f5aa7a5
Merge align/920-merge-main into feat/drama3-streaming: speech and vis…
plotarmordev Oct 17, 2026
fd87532
Merge align/921-merge-main into fix/drama3-clipped-replies: speech an…
plotarmordev Oct 17, 2026
572afe3
Merge align/922-merge-main into perf/drama3-backbone-one-row: speech …
plotarmordev Oct 17, 2026
1ecf53b
Merge align/923-merge-main into perf/drama3-tower-decode: speech and …
plotarmordev Oct 17, 2026
bd11ba4
Merge align/924-merge-main into perf/drama3-load: speech and vision t…
plotarmordev Oct 17, 2026
f495030
Merge align/925-merge-main into perf/drama3-tower-gemv: speech and vi…
plotarmordev Oct 17, 2026
118086a
core: lane tests ignore the speech audio event
plotarmordev Oct 17, 2026
4d41f5a
Merge align/921-merge-main into fix/drama3-clipped-replies: lane test…
plotarmordev Oct 17, 2026
2b27b19
Merge align/922-merge-main into perf/drama3-backbone-one-row: lane te…
plotarmordev Oct 17, 2026
e45d71b
Merge align/923-merge-main into perf/drama3-tower-decode: lane tests …
plotarmordev Oct 17, 2026
809e103
Merge align/924-merge-main into perf/drama3-load: lane tests ignore t…
plotarmordev Oct 17, 2026
0ed8946
Merge align/925-merge-main into perf/drama3-tower-gemv: lane tests ig…
plotarmordev Oct 17, 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
tests: Drama 3 backbone and tower oracles, replays and stage traces
Drivers that check the native backbone and tower against captured reference tensors, replay single operators
against them, and trace each stage for attribution, plus tf-cuda-test drama-conv and drama-qk on synthetic rows.
None of them runs as part of the host tests.
  • Loading branch information
plotarmordev committed Oct 16, 2026
commit 8ba4307c4e4ee260957e3bdad6b792e73088593d
92 changes: 92 additions & 0 deletions zig/tests/cuda/drama_backbone_oracle.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//! Runs the production backbone across chunk sizes and reset on 2..512 u32 text tokens; the caller owns the GPU.
const std = @import("std");
const builtin = @import("builtin");
const cuda = @import("cuda");
const drama = @import("drama");
const width = 2048;
const candidate_count = 4097;

fn runChunks(model: *drama.backbone.Model, stream: cuda.Stream, tokens: []const u32, chunk: usize, hidden: []u16, logits: []f32) !void {
try model.reset(stream);
var at: usize = 0;
while (at < tokens.len) {
const end = @min(at + chunk, tokens.len);
const output = try model.run(stream, .prefill, tokens[at..end], null);
try output.hidden.download(0, std.mem.sliceAsBytes(hidden[at * width .. end * width]));
if (end == tokens.len) try output.semantic_logits.download(0, std.mem.sliceAsBytes(logits));
at = end;
}
for (hidden) |bits| {
const value: f32 = @bitCast(@as(u32, bits) << 16);
if (!std.math.isFinite(value)) return error.NonFiniteBackboneHidden;
}
for (logits) |value| if (!std.math.isFinite(value)) return error.NonFiniteBackboneLogits;
}

pub fn main(init: std.process.Init) !u8 {
const args = try init.minimal.args.toSlice(init.arena.allocator());
if (args.len != 4) {
std.debug.print("usage: tf-drama-backbone-oracle CHECKPOINT TOKENS_U32LE OUTPUT_DIRECTORY\n", .{});
return 2;
}
if (builtin.cpu.arch.endian() != .little) return error.UnsupportedHostEndian;
var bytes: [512 * 4 + 1]u8 align(@alignOf(u32)) = undefined;
const file = try std.Io.Dir.cwd().openFile(init.io, args[2], .{});
defer file.close(init.io);
const count = try file.readPositionalAll(init.io, &bytes, 0);
if (count < 8 or count > 512 * 4 or count % 4 != 0) return error.ExpectedTwoTo512Tokens;
const tokens = std.mem.bytesAsSlice(u32, @as([]align(@alignOf(u32)) u8, bytes[0..count]));
var out = try std.Io.Dir.cwd().openDir(init.io, args[3], .{});
defer out.close(init.io);
const baseline = try init.gpa.alloc(u16, tokens.len * width);
defer init.gpa.free(baseline);
const actual = try init.gpa.alloc(u16, tokens.len * width);
defer init.gpa.free(actual);
var baseline_logits: [candidate_count]f32 = undefined;
var logits: [candidate_count]f32 = undefined;
_ = try cuda.setAllocationLimit(54 * (1 << 30));
var driver = try cuda.Driver.open();
defer driver.close();
var ctx = try cuda.Context.init(&driver, 0);
defer ctx.deinit();
var stream = try cuda.Stream.init(&driver, true);
defer stream.deinit();
var model = try drama.backbone.Model.init(init.gpa, init.io, &ctx, args[1], "", .{ .context = 512, .max_rows = 128 });
defer model.deinit();
for (tokens) |token| if (token >= model.semantic_start and token <= model.semantic_end) return error.TextFixtureMustNotContainSemanticTokens;
var all_equal = true;
var name_buffer: [128]u8 = undefined;
for ([_]usize{ 1, 7, 128 }) |chunk| {
const started = std.Io.Clock.awake.now(init.io).toNanoseconds();
try runChunks(&model, stream, tokens, chunk, actual, &logits);
const elapsed = std.Io.Clock.awake.now(init.io).toNanoseconds() - started;
var name = try std.fmt.bufPrint(&name_buffer, "native-chunk-{d}-hidden.bf16", .{chunk});
try out.writeFile(init.io, .{ .sub_path = name, .data = std.mem.sliceAsBytes(actual) });
name = try std.fmt.bufPrint(&name_buffer, "native-chunk-{d}-semantic.f32", .{chunk});
try out.writeFile(init.io, .{ .sub_path = name, .data = std.mem.sliceAsBytes(&logits) });
if (chunk == 1) {
@memcpy(baseline, actual);
baseline_logits = logits;
}
var hidden_differences: usize = 0;
for (baseline, actual) |a, b| if (a != b) {
hidden_differences += 1;
};
const head_equal = std.mem.eql(u8, std.mem.sliceAsBytes(&baseline_logits), std.mem.sliceAsBytes(&logits));
all_equal = all_equal and hidden_differences == 0 and head_equal;
std.debug.print("rows={d} chunk={d} elapsed_s={d:.6} hidden_bit_differences={d} semantic_logits_bit_equal={}\n", .{
tokens.len, chunk, @as(f64, @floatFromInt(elapsed)) / 1e9, hidden_differences, head_equal,
});
}
// Repeat the exact last execution after reset; chunk consistency and reset are separate invariants.
@memcpy(baseline, actual);
baseline_logits = logits;
try runChunks(&model, stream, tokens, 128, actual, &logits);
const reset_equal = std.mem.eql(u16, baseline, actual) and std.mem.eql(u8, std.mem.sliceAsBytes(&baseline_logits), std.mem.sliceAsBytes(&logits));
var metadata: [512]u8 = undefined;
const text = try std.fmt.bufPrint(&metadata, "{{\"rows\":{d},\"hidden_width\":{d},\"eos\":{d},\"semantic_start\":{d},\"semantic_end\":{d},\"chunk_bit_exact\":{},\"reset_bit_exact\":{}}}\n", .{ tokens.len, width, model.eos, model.semantic_start, model.semantic_end, all_equal, reset_equal });
try out.writeFile(init.io, .{ .sub_path = "native-metadata.json", .data = text });
const used = cuda.usage(false);
std.debug.print("reset_bit_exact={} cuda_bytes={d} pinned_bytes={d}\n", .{ reset_equal, used.device, used.host });
return if (all_equal and reset_equal) 0 else 1;
}
Loading