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
drama: the backbone chain launches with programmatic dependent launch
Every backbone and GDN kernel waits on its predecessor before touching global memory, so it can launch as the one
before it drains. PDL is used only when both backbone images carry the drama_pdl marker, which Module.holds reads,
so an older or mixed prebuilt image set launches plain. tf-cuda-test drama-pdl checks that decision for the
embedded images and for a kernel directory.
  • Loading branch information
plotarmordev committed Oct 16, 2026
commit bef432bbb25ec39496d348c9eaa9c47c7d7f734e
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel
## Unreleased

- speech: `stream: true` with `response_format: pcm` streams HTTP/1.1 chunks while Drama 3 generates; incremental codec decode bit-identical to the whole decode (oracle-gated)
- speech: Drama 3 generates 1.66x faster on a GB10 (warm real-time factor 1.087 to 0.655 over the 23 warm items of a 48-request capture), with the audio of every normally finished reply byte for byte the same. The one-row backbone GEMVs stream their weights through a swizzled `cp.async` ring, add-norm, SwiGLU, MoE combine and attention glue are fused or pipelined in the same float order, the tower runs its one-row decode attention as a cluster kernel and samples with a radix select, and the backbone chain launches with programmatic dependent launch when both embedded kernel images carry the `drama_pdl` marker. The tower's one-row projections run on `drama_tower_gemv`, which reproduces cuBLASLt 130101's gemv summation; `Model.init` checks each projection against its actual cuBLASLt plan on probe rows and keeps cuBLASLt for any projection that differs by one bit, or on any other GPU or library.
- speech: a Drama 3 reply that reaches `max_frames` without an end of speech returns its clipped audio with HTTP 200, as the reference returns its capped replies, instead of a 500 without audio. A whole reply carries `X-Finish-Reason: stop` or `length`; a stream declares the trailer, and only a clipped stream ends with `X-Finish-Reason: length`, a normally finished one with the plain last chunk.
- Drama 3 loads in about 6 s instead of 53 s on a GB10: weights are read with direct I/O into staging pieces that never span two device allocations, and the codec initializes on its own thread while the backbone loads.

Expand Down
1 change: 1 addition & 0 deletions zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pub fn targets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.bu
runner.addImport("core", mods.core);
runner.addImport("lanes", mods.lanes);
runner.addImport("nemotron", mods.nemotron);
runner.addImport("drama", mods.drama);
const exlr8 = exlr8_build.coreAlias(b, target, optimize, mods.core);
runner.addImport("exlr8", exlr8);
const exlr8_tests = exlr8_build.testModules(b, target, optimize, exlr8);
Expand Down
23 changes: 23 additions & 0 deletions zig/kernels/cuda/drama_backbone.cu
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,28 @@ __device__ __forceinline__ uint32_t e4m3(float v, float inv) {
return static_cast<uint32_t>(__nv_cvt_float_to_fp8(c, __NV_SATFINITE, __NV_E4M3));
}

// Programmatic dependent launch: wait for the previous kernel's writes, then let the next launch start (sm_90+).
__device__ __forceinline__ void grid_dependency() {
#if __CUDA_ARCH__ >= 900
asm volatile("griddepcontrol.wait;\n" ::: "memory");
asm volatile("griddepcontrol.launch_dependents;\n" ::: "memory");
#endif
}

} // namespace drama

using namespace drama;

#if __CUDA_ARCH__ >= 900
// Marks an image whose kernels all begin with grid_dependency(); PDL runs only when both backbone images hold it.
extern "C" __device__ const int drama_pdl = 1;
#endif

// Semantic rows (ids in [lo, hi]): bf16(bf16(out + extra) * 0.70710677), as embed_backbone; other rows keep out.
extern "C" __global__ void __launch_bounds__(256) drama_semantic_mix(const int* ids, __nv_bfloat16* out,
const __nv_bfloat16* extra, int width,
int lo, int hi) {
grid_dependency();
const int r = blockIdx.x;
const int id = ids[r];
if (id < lo || id > hi) return;
Expand All @@ -84,6 +98,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_add_norm(const __nv_bflo
const __nv_bfloat16* w, __nv_bfloat16* y,
uint8_t* q, float* s, int width, float eps,
int first) {
grid_dependency();
__shared__ float square_sum;
const size_t base = static_cast<size_t>(blockIdx.x) * width;
const int t = threadIdx.x;
Expand Down Expand Up @@ -147,6 +162,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_gated_rms_128(
const __nv_bfloat16* y, long long y_ld,
const __nv_bfloat16* z, long long z_ld,
const __nv_bfloat16* w, __nv_bfloat16* out, float eps) {
grid_dependency();
const int sub = threadIdx.x & 15;
const int hd = (blockIdx.y * blockDim.x + threadIdx.x) / 16;
const long long row = blockIdx.x;
Expand Down Expand Up @@ -188,6 +204,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_gated_rms_128(
extern "C" __global__ void __launch_bounds__(256) drama_gdn_conv(const __nv_bfloat16* in, int ld_in,
const __nv_bfloat16* w, __nv_bfloat16* state,
__nv_bfloat16* out, int rows, int C) {
grid_dependency();
const int c = blockIdx.x * blockDim.x + threadIdx.x;
if (c >= C) return;
const float w0 = bf(w[4 * c]), w1 = bf(w[4 * c + 1]), w2 = bf(w[4 * c + 2]), w3 = bf(w[4 * c + 3]);
Expand All @@ -212,6 +229,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_gdn_conv(const __nv_bflo
extern "C" __global__ void __launch_bounds__(256) drama_gdn_conv_prefill(
const __nv_bfloat16* in, int ld_in, const __nv_bfloat16* w, __nv_bfloat16* state,
__nv_bfloat16* out, int rows, int C) {
grid_dependency();
const int c = blockIdx.x * blockDim.x + threadIdx.x;
if (c >= C) return;
const float w0 = bf(w[4 * c]), w1 = bf(w[4 * c + 1]), w2 = bf(w[4 * c + 2]), w3 = bf(w[4 * c + 3]);
Expand Down Expand Up @@ -244,6 +262,7 @@ extern "C" __global__ void __launch_bounds__(128) drama_gdn_recur(const __nv_bfl
const float* a_log, const float* dt_bias,
float* state, __nv_bfloat16* y, int rows, int nk,
int nv, float scale) {
grid_dependency();
constexpr int DK = 128, DV = 128, R = 8;
const int warp = threadIdx.x >> 5, lane = threadIdx.x & 31;
const int head = blockIdx.y;
Expand Down Expand Up @@ -324,6 +343,7 @@ extern "C" __global__ void __launch_bounds__(128) drama_gdn_recur(const __nv_bfl
// Router: softmax over 256 experts, top 8 (lower id on ties), renormalized to sum 1, in descending probability.
extern "C" __global__ void __launch_bounds__(256) drama_topk(const __nv_bfloat16* logits, int ld, int* ids, float* wts,
int top) {
grid_dependency();
__shared__ float scratch[32];
__shared__ float bv[8];
__shared__ int bi[8];
Expand Down Expand Up @@ -385,6 +405,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_topk(const __nv_bfloat16
// Group-128 FP8 quantization; the pinned JIT's fast-math 448 / amax multiplier stays local, with __fdividef.
extern "C" __global__ void __launch_bounds__(128) drama_act_quant(const __nv_bfloat16* x, int ld_x, uint8_t* q,
float* s, int K) {
grid_dependency();
const int r = blockIdx.x, warp = threadIdx.x >> 5, lane = threadIdx.x & 31;
const int group = blockIdx.y * 4 + warp;
if (group * 128 >= K) return;
Expand All @@ -410,6 +431,7 @@ extern "C" __global__ void __launch_bounds__(128) drama_act_quant(const __nv_bfl
extern "C" __global__ void __launch_bounds__(128) drama_silu_mul(const __nv_bfloat16* gu, int ld_gu, int routed,
uint8_t* hq, float* hs, const __nv_bfloat16* sgu,
int ld_sgu, __nv_bfloat16* h_out, int I) {
grid_dependency();
const int warp = threadIdx.x >> 5, lane = threadIdx.x & 31;
const int group = blockIdx.y * 4 + warp;
if (group * 128 >= I) return;
Expand Down Expand Up @@ -444,6 +466,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_moe_combine(const __nv_b
const __nv_bfloat16* x, const __nv_bfloat16* wg,
const __nv_bfloat16* shared, __nv_bfloat16* out,
int width) {
grid_dependency();
__shared__ float scratch[32];
const size_t r = blockIdx.x;
float part = 0.f;
Expand Down
2 changes: 2 additions & 0 deletions zig/kernels/cuda/drama_backbone_attention.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C" __global__ void __launch_bounds__(32) drama_attn_prep(const __nv_bflo
const float* inv_freq, __nv_bfloat16* q_out,
__nv_bfloat16* kc, __nv_bfloat16* vc, int pos0, int H,
int HK, float eps) {
grid_dependency();
constexpr int D = 256;
const int r = blockIdx.x, h = blockIdx.y, lane = threadIdx.x;
const int pos = pos0 + r;
Expand Down Expand Up @@ -65,6 +66,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_attention(const __nv_bfl
int HK, float scale, const __nv_bfloat16* qn_w,
const __nv_bfloat16* kn_w, const float* inv_freq,
float eps) {
grid_dependency();
constexpr int D = 256, NW = 8, U = 8;
__shared__ float sm_m[NW], sm_l[NW];
__shared__ float sm_o[NW][D];
Expand Down
16 changes: 16 additions & 0 deletions zig/kernels/cuda/drama_backbone_gemm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ __device__ __forceinline__ uint32_t word(const uint4& v, int i) {
return i == 0 ? v.x : i == 1 ? v.y : i == 2 ? v.z : v.w;
}

// PDL wait and trigger before other global access; the one-row GEMV queues its first weight stages before it.
__device__ __forceinline__ void grid_dependency() {
#if __CUDA_ARCH__ >= 900
asm volatile("griddepcontrol.wait;\n" ::: "memory");
asm volatile("griddepcontrol.launch_dependents;\n" ::: "memory");
#endif
}

// OUT 0: bf16; 2: fp32 holding the bf16-rounded value (a bf16 torch output read back as float).
template <int OUT>
__device__ __forceinline__ void store(void* y, size_t at, float v) {
Expand Down Expand Up @@ -165,6 +173,7 @@ __device__ __forceinline__ void gemv_bf16(const __nv_bfloat16* __restrict__ X, c
if (c < chunks) issue(c);
asm volatile("cp.async.commit_group;\n");
}
grid_dependency();
const bool live = g == 0; // the single row is A's row 0; rows 1..15 are zero as in gemm_bf16
float acc[4] = {0.f, 0.f, 0.f, 0.f};
for (int c = 0; c < chunks; ++c) {
Expand Down Expand Up @@ -281,10 +290,16 @@ __device__ __forceinline__ void expert_fp8(const uint8_t* __restrict__ A, int a_

} // namespace drama_gemm

#if __CUDA_ARCH__ >= 900
// Present only in images whose every kernel calls grid_dependency(), as in drama_backbone.cu.
extern "C" __device__ const int drama_pdl = 1;
#endif

#define DRAMA_GEMM(RT, NT) \
extern "C" __global__ void __launch_bounds__(32 * drama_gemm::WARPS) \
drama_gemm_bf16_r##RT##_n##NT##_o0(const __nv_bfloat16* X, int ldx, int M, const __nv_bfloat16* W, int N, \
int K, void* Y, int ldy) { \
drama_gemm::grid_dependency(); \
drama_gemm::gemm_bf16<RT, NT>(X, ldx, M, W, N, K, Y, ldy); \
}
DRAMA_GEMM(1, 1)
Expand All @@ -303,6 +318,7 @@ DRAMA_GEMV(2) // the semantic head: the last row, bf16-rounded logits widened t
extern "C" __global__ void __launch_bounds__(32 * drama_gemm::WARPS) drama_expert_fp8_n##NT##_m##MODE( \
const uint8_t* A, int a_div, const float* As, const uint8_t* W, const float* Ws, int N, int K, \
const int* items, const int* counts, const int* members, const float* rw, __nv_bfloat16* Y) { \
drama_gemm::grid_dependency(); \
drama_gemm::expert_fp8<NT, MODE>(A, a_div, As, W, Ws, N, K, items, counts, members, rw, Y); \
}
DRAMA_EXPERT(1, 0)
Expand Down
7 changes: 7 additions & 0 deletions zig/kernels/cuda/drama_gdn_chunk.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_gdn_chunk_append(const _
__nv_bfloat16* ba_cache, int at, int qkv_cols,
int ba_cols) {
using namespace drama_gdn_chunk;
grid_dependency();
const size_t r = blockIdx.x, c = at + r;
copy_row(qkv + r * ld_qkv, qkv_cache + c * qkv_cols, qkv_cols);
copy_row(ba + r * ld_ba, ba_cache + c * ba_cols, ba_cols);
Expand All @@ -146,6 +147,7 @@ extern "C" __global__ void __launch_bounds__(256) drama_gdn_chunk_l2norm(const _
__nv_bfloat16* qk, int rows, int nk,
float eps) {
using namespace drama_gdn_chunk;
grid_dependency();
const int nrow = rows * 2 * nk;
const int r = static_cast<int>(blockIdx.x) * 16 + (threadIdx.x >> 4);
const int col = (threadIdx.x & 15) * 8;
Expand All @@ -168,6 +170,7 @@ extern "C" __global__ void __launch_bounds__(64) drama_gdn_chunk_gate(const __nv
float* g, float* gc, float* beta, int rows,
int nv) {
using namespace drama_gdn_chunk;
grid_dependency();
__shared__ float total0;
const int h = blockIdx.y, i = threadIdx.x, lane = i & 31;
const int t = static_cast<int>(blockIdx.x) * BT + i;
Expand Down Expand Up @@ -201,6 +204,7 @@ extern "C" __global__ void __launch_bounds__(32) drama_gdn_chunk_kkt(const __nv_
const float* beta, __nv_bfloat16* A, int rows,
int nk, int nv) {
using namespace drama_gdn_chunk;
grid_dependency();
__shared__ float sA[BT][BT]; // gated, masked, beta-scaled lower blocks
__shared__ float sI[BT][BT]; // (I + A)^-1 blocks
__shared__ float sT[BC][BC]; // merge temporary
Expand Down Expand Up @@ -318,6 +322,7 @@ extern "C" __global__ void __launch_bounds__(128) drama_gdn_chunk_wu(const __nv_
__nv_bfloat16* w, __nv_bfloat16* u, int rows,
int nk, int nv) {
using namespace drama_gdn_chunk;
grid_dependency();
__shared__ unsigned short sAb[BT][BT];
__shared__ unsigned short sV[BT][D];
__shared__ unsigned short sK[BT][D];
Expand Down Expand Up @@ -372,6 +377,7 @@ extern "C" __global__ void __launch_bounds__(128) drama_gdn_chunk_h(const __nv_b
__nv_bfloat16* hout, __nv_bfloat16* vn, int rows,
int nk, int nv) {
using namespace drama_gdn_chunk;
grid_dependency();
constexpr int BV = 32;
__shared__ float sS[BV][D];
__shared__ unsigned short sH[BV][D];
Expand Down Expand Up @@ -455,6 +461,7 @@ extern "C" __global__ void __launch_bounds__(128) drama_gdn_chunk_o(const __nv_b
__nv_bfloat16* y, int rows, int emit_from, int nk,
int nv, float scale) {
using namespace drama_gdn_chunk;
grid_dependency();
constexpr int BV = 64;
__shared__ unsigned short sAo[BT][BT];
__shared__ float sG[BT];
Expand Down
Loading
Loading