Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 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
bef432b
drama: the backbone chain launches with programmatic dependent launch
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
7c9fd59
Merge align/926-merge-main (upstream main 6ee828c2) into perf/drama3-pdl
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
bc31ec2
Merge align/926-merge-main into perf/drama3-pdl: the tower's sm_90 cl…
plotarmordev Oct 17, 2026
4d3c4f5
Merge align/925-merge-main into perf/drama3-tower-gemv: the tower's s…
plotarmordev Oct 17, 2026
2d62476
CHANGELOG: the tower's cluster decode attention runs from sm_90 on, t…
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
f64f02d
Merge align/926-merge-main into perf/drama3-pdl: speech and vision ty…
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
d986914
Merge align/926-merge-main into perf/drama3-pdl: lane tests ignore th…
plotarmordev Oct 17, 2026
9d6a54c
drama: backbone attention runs the reference's 64-key softmax tiles
plotarmordev Oct 17, 2026
d2734fd
Merge align/927-merge-main into align/attention-tiles: lane tests ign…
plotarmordev Oct 17, 2026
391c64c
changelog: drop the attention tiles' speed sentence, no change measur…
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: tf-drama-codec-stream-oracle, whole against chunked codec decodes
Decodes the same frame codes whole and in the host's chunk policy, one frame at a time and in irregular chunks,
each over NaN-poisoned scratch, and requires every chunked decode to equal the whole decode.
  • Loading branch information
plotarmordev committed Oct 16, 2026
commit 8bc6814afca277058e6ec5a24bce52d0ec69e1a2
10 changes: 10 additions & 0 deletions zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
}) });
const install_oracle = b.addInstallArtifact(codec_oracle, .{ .dest_dir = .{ .override = .{ .custom = "oracle/bin" } } });
b.step("drama-codec-oracle", "Build the production-codec numerical oracle driver; does not run a GPU").dependOn(&install_oracle.step);
const codec_stream_oracle = b.addExecutable(.{ .name = "tf-drama-codec-stream-oracle", .root_module = b.createModule(.{
.root_source_file = b.path("zig/tests/cuda/drama_codec_stream_oracle.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.strip = strip,
.imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "drama", .module = mods.drama } },
}) });
const install_stream_oracle = b.addInstallArtifact(codec_stream_oracle, .{ .dest_dir = .{ .override = .{ .custom = "oracle/bin" } } });
b.step("drama-codec-stream-oracle", "Build the chunked-versus-whole codec driver; does not run a GPU").dependOn(&install_stream_oracle.step);
const codec_rvq_replay = b.addExecutable(.{ .name = "tf-drama-codec-rvq-replay", .root_module = b.createModule(.{
.root_source_file = b.path("zig/tests/cuda/drama_codec_rvq_replay.zig"),
.target = target,
Expand Down
106 changes: 106 additions & 0 deletions zig/tests/cuda/drama_codec_stream_oracle.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//! Whole and chunked codec decodes of 1024 frame codes, each chunk over NaN-poisoned scratch; GPU lock is the caller's.
const std = @import("std");
const builtin = @import("builtin");
const cuda = @import("cuda");
const drama = @import("drama");

const Allocator = std.mem.Allocator;

const frames = 1024;
const samples_per_frame = 2048;
const lengths = [_]usize{ 1, 2, 7, 128, 1024 };

const Schedule = struct { name: []const u8, chunks: []const usize };

/// The host's policy (1, then 4s), one frame at a time, the gate lengths as chunk ends, one call, irregular sizes.
fn schedules(a: Allocator) ![5]Schedule {
var host: std.ArrayList(usize) = .empty;
var done: usize = 1;
try host.append(a, 1);
while (done < frames) : (done += host.items[host.items.len - 1]) try host.append(a, @min(4, frames - done));
var irregular: std.ArrayList(usize) = .empty;
var state: u32 = 20261015;
done = 0;
while (done < frames) : (done += irregular.items[irregular.items.len - 1]) {
state = state *% 1664525 +% 1013904223;
try irregular.append(a, @min(1 + (state >> 8) % 300, frames - done));
}
const every = try a.alloc(usize, frames);
@memset(every, 1);
return .{
.{ .name = "host-1-then-4", .chunks = host.items },
.{ .name = "every-frame", .chunks = every },
.{ .name = "gate-lengths", .chunks = &.{ 1, 1, 5, 121, frames - 128 } },
.{ .name = "one-call", .chunks = &.{frames} },
.{ .name = "irregular", .chunks = irregular.items },
};
}

pub fn main(init: std.process.Init) !u8 {
const a = init.arena.allocator();
const io = init.io;
const args = try init.minimal.args.toSlice(a);
if (args.len != 4) {
std.debug.print("usage: tf-drama-codec-stream-oracle CHECKPOINT CODES_U32LE OUTPUT_DIRECTORY\n", .{});
return 2;
}
if (builtin.cpu.arch.endian() != .little) return error.UnsupportedHostEndian;
var bytes: [frames * 10 * 4 + 1]u8 align(@alignOf(u32)) = undefined;
const input = try std.Io.Dir.cwd().openFile(io, args[2], .{});
defer input.close(io);
if (try input.readPositionalAll(io, &bytes, 0) != frames * 10 * 4) return error.Expected1024Frames;
const code_bytes = bytes[0 .. frames * 10 * 4];
const codes = std.mem.bytesAsSlice([10]u32, @as([]align(@alignOf(u32)) u8, code_bytes));
var digest: [32]u8 = undefined;
std.crypto.hash.sha2.Sha256.hash(code_bytes, &digest, .{});
var dir = try std.Io.Dir.cwd().openDir(io, args[3], .{});
defer dir.close(io);

const pcm = try init.gpa.alloc(f32, frames * samples_per_frame);
defer init.gpa.free(pcm);
_ = 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 codec = try drama.codec.Model.init(init.gpa, io, &ctx, args[1], "", .{ .max_frames = frames });
defer codec.deinit();

var name: [64]u8 = undefined;
for (lengths) |n| {
if (try codec.decode(stream, codes[0..n], pcm) != n * samples_per_frame) return error.UnexpectedSampleCount;
const file = try std.fmt.bufPrint(&name, "whole-{d}.f32", .{n});
try dir.writeFile(io, .{ .sub_path = file, .data = std.mem.sliceAsBytes(pcm[0 .. n * samples_per_frame]), .flags = .{ .exclusive = true } });
}
const plan = try schedules(a);
for (plan) |s| {
@memset(pcm, std.math.nan(f32));
codec.begin();
var end: usize = 0;
const began = std.Io.Clock.awake.now(io).toNanoseconds();
for (s.chunks) |n| {
for (codec.acts) |b| try b.fill8(0xff, stream.handle); // FP16 0xffff is NaN
try codec.audio_dev.fill8(0xff, stream.handle);
end += n;
if (try codec.advance(stream, codes[0..end], pcm) != end * samples_per_frame) return error.UnexpectedSampleCount;
}
if (end != frames) return error.IncompleteSchedule;
const elapsed = std.Io.Clock.awake.now(io).toNanoseconds() - began;
const file = try std.fmt.bufPrint(&name, "chunked-{s}.f32", .{s.name});
try dir.writeFile(io, .{ .sub_path = file, .data = std.mem.sliceAsBytes(pcm), .flags = .{ .exclusive = true } });
std.debug.print("schedule={s} chunks={d} elapsed_s_including_poison={d:.6}\n", .{ s.name, s.chunks.len, @as(f64, @floatFromInt(elapsed)) / 1e9 });
}

var manifest: std.ArrayList(u8) = .empty;
try manifest.print(a, "{{\"codes_sha256\": \"{s}\", \"frames\": {d}, \"lengths\": [1, 2, 7, 128, 1024], \"schedules\": [", .{ std.fmt.bytesToHex(digest, .lower), frames });
for (plan, 0..) |s, i| {
try manifest.print(a, "{s}\n {{\"name\": \"{s}\", \"chunks\": [", .{ if (i == 0) "" else ",", s.name });
for (s.chunks, 0..) |n, j| try manifest.print(a, "{s}{d}", .{ if (j == 0) "" else ", ", n });
try manifest.appendSlice(a, "]}");
}
try manifest.appendSlice(a, "\n]}\n");
try dir.writeFile(io, .{ .sub_path = "manifest.json", .data = manifest.items, .flags = .{ .exclusive = true } });
return 0;
}
Loading