Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 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
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
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
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
118086a
core: lane tests ignore the speech audio event
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