"the amts" (the animation motion transfer system),
is a video diffusion transformer based on a research paper that implements
a ttt-video-dit architecture written in C99 and CUDA, to focus on lowering runtime,
and removing outsourcing and lowering crew-count for animation;
i started it because i wanted to control the drawings, the designs,
the timing and the movement styles used;
diffusion helps lower costs for video editing, special effects, animation, rendering,etc.
but existing video models don't bring precise control without using external tools,
and many have too many dependencies
other things i've been learning at this time
also include kernel engineering, the model versus the actual inference,
and more --
the program includes 24 header-only C99 modules,
each with a CPU implementation that acts as the oracle;
6 CUDA translation units behind one fixed op ABI;
no malloc anywhere in the library, because the arena and the
caller own every byte; and a checkpoint container of my own (.AMTSCKPT)
so that fp8 and fp4 weights carry their scales in the same file
as the weights.
the discipline for the system is the following:
every claim has to be gated by something that can fail.
the build refuses with -ffast-math and -DNDEBUG
instead of remembering not to pass them;
the tests run under AddressSanitizer and UndefinedBehaviorSanitizer;
the kernels are compared against PyTorch-captured fixtures;
each CUDA compile is gated on its ptxas report for one explicit card;
and a checker fails the build when this design document and the source
disagree about what exists.
here is the arena allocator, which is the whole memory story in
about thirty lines, alignment computed against the real base address,
with every overflow guarded and failure returning NULL:
static inline void* anim_arena_alloc(AnimArena* arena, size_t size, size_t alignment) {
uintptr_t base;
size_t mask;
size_t padding;
size_t aligned;
if (arena == NULL || arena->data == NULL || alignment == 0
|| (alignment & (alignment - 1)) != 0)
return NULL;
base = (uintptr_t)arena->data;
mask = alignment - 1;
if (arena->used > SIZE_MAX - (size_t)(base & mask)) return NULL;
padding = (alignment - ((size_t)(base & mask) + arena->used) % alignment) % alignment;
if (arena->used > SIZE_MAX - padding) return NULL;
aligned = arena->used + padding;
if (aligned > arena->capacity || size > arena->capacity - aligned) return NULL;
arena->used = aligned + size;
if (arena->used > arena->high_water) arena->high_water = arena->used;
return arena->data + aligned;
}
here's another table, derived from the code,
some figures are hypothetical because they haven't been fully tested:
| header-only C99 modules | 24 |
| CUDA translation units | 6 |
| op ABI rows (CPU oracle + device impl each) | 19 |
| lines in src and tools | 42,933 |
| tokens per frame at 480p-class latent | 1,350 |
| video tokens, 3-second clip | 17,550 |
| keys per query token (local attention window) | 17,550 |
| device memory the score tensor would need if materialised (bf16, per layer, per direction) | 27.5 GiB |
| TTT state, fp32, whole model | 533,643,264 B |
the engine is being tested in stages with gcp rentals,
and the costs for testing have been super cheap with my setup,
for only cents so far;
what's needed next
is creating diffusion loras based on movement styles
elements of it can be read and ran here:
amts/.
(this link might be malfunctioning on the current server)
if you want to talk more about the details,
the kernels, the container format, etc.,
or how it could help with your business,
message me on x @ tebillusassort