← Back to demos

AI Accelerator Time Calculator

A matrix multiply (GEMM) time estimator for the Majestic AI accelerator server running at 1 GHz, with BF16 and FP8 support.

Available as an interactive HTML dashboard and a Python CLI/library.


Files

FileDescription
accelerator_calculator.htmlInteractive browser dashboard
accelerator_calculator.pyPython port — CLI + importable library
calculator_tests.htmlBrowser-based unit tests

Hardware Architecture

CORE → MIND → HEX → majestic_tile → AIU → SERVER
LevelCount (per parent)SRAMNotes
CORE4 per MINDAtomic compute unit
MIND4 per HEXHolds 2 tiles (2A + 2B + 2C)
HEX12 per majestic_tile12 MB4 MINDs × 2 tiles = 8 tiles
majestic_tile4 per AIU144 MB HEX + 48 MB SXM48 MINDs · 192 COREs
AIU12 per server576 MB HEX + 192 MB SXM192 MINDs · 768 COREs
SERVER6,912 MB HEX + 2,304 MB SXM2,304 MINDs · 9,216 COREs

Memory Layout per Tile

For a GEMM A[M×K] × B[K×N] = C[M×N] tiled with tile_m × tile_n:

BufferFormulaType
A tiletile_m × K × bytes_per_elemBF16 (2 B) or FP8 (1 B)
B tiletile_N × K × bytes_per_elemBF16 (2 B) or FP8 (1 B)
C tiletile_m × tile_N × 4FP32 accumulator

Hierarchy

Per tile:   A  +  B  +  C
Per MIND:   2A +  2B +  2C       (TILES_PER_MIND = 2)
Per HEX:    8A +  8B +  8C       (4 MINDs × 2 tiles = 8 tiles, must fit in 12 MB)

HTML Dashboard

Open accelerator_calculator.html in any modern browser — no server required.

Inputs:

Outputs:


Python

Requirements

Python 3.8+ — standard library only (no dependencies).

Run as CLI

# defaults: M=K=N=256, tile=256x256, BF16/BF16, 12 AIUs
python3 accelerator_calculator.py

# custom configuration
python3 accelerator_calculator.py \
    --M 4096 --K 4096 --N 4096 \
    --tile_m 256 --tile_n 256 \
    --type_a BF16 --type_b FP8 \
    --avail_aius 8

All CLI options

ArgumentDefaultDescription
--M256Rows of A
--K256Inner dimension
--N256Cols of B
--tile_m256Tile height
--tile_n256Tile width
--type_aBF16A matrix type (BF16 or FP8)
--type_bBF16B matrix type (BF16 or FP8)
--avail_aius12AIUs allocated to this task

Import as library

from accelerator_calculator import compute, print_results

# run computation
r = compute(M=1024, K=2048, N=1024, tile_m=256, tile_n=256,
            type_a='BF16', type_b='FP8', avail_aius=12)

# pretty-print
print_results(r)

# access individual values
print(r['ns_total'])        # total time in nanoseconds
print(r['hex_total'])       # total HEX memory required in bytes
print(r['n_passes'])        # number of server passes
print(r['speedup'])         # speedup vs serial

Key functions

FunctionDescription
bytes_per_elem(dtype)BF16→2, FP8→1
get_macs_per_cycle(K, dtype)Interpolated MACs/cycle from benchmark table
tile_a_mem(tile_m, K, type_a)A tile size in bytes
tile_b_mem(tile_n, K, type_b)B tile size in bytes
tile_c_mem(tile_m, tile_n)C tile size in bytes (FP32)
mind_mem_total(...)Total memory per MIND (2 tiles: 2A+2B+2C)
hex_mem_total(...)Total memory per HEX (8 tiles) vs 12 MB SRAM
compute(M, K, N, ...)Full estimation — returns result dict
print_results(r)Pretty-print all results to stdout

Unit Tests

Open calculator_tests.html in a browser to run all tests.

Tests cover:


Scheduling Model

Tiles are assigned to MINDs using fill-first locality:

fill 4 MINDs per HEX → fill 12 HEXes per majestic_tile → fill 4 majestic_tiles per AIU

Performance Model

ParameterValue
Clock1 GHz
Memory bandwidth256 GB/s
Compute typeFP8 if either A or B is FP8, else BF16
Timing modelcompute + BW, no overlap (pessimistic)

MACs/cycle is interpolated from an empirical benchmark table measured at M=N=256 with K ranging 64–7872.