Neural network training library for MoonBit
just # check + test (native)
just fmt # format code
just check # type check (native)
just test # run tests (native)
just info # generate mbti files (native)
just run --steps 1 --warmup 0 --repeat 1 --batch-size 1 --seq-len 8 --d-model 16 --heads 2 --layers 1 --d-ff 32moon run --target native src/transformer-bench -- --steps 40 --warmup 5just openwebtext-shard \
--input-dir ~/data/lm/openwebtext/plain_text \
--output-dir ~/data/lm/openwebtext_gpt2 \
--tokens-per-shard 8388608| Operation | numbt (ms) | NumPy (ms) | Notes |
|---|---|---|---|
| vec_add | <0.001 | <0.001 | Element-wise |
| vec_dot | <0.001 | <0.001 | BLAS sdot |
| vec_exp | <0.001 | 0.001 | vForce |
| vec_sort | <0.001 | 0.006 | vDSP_vsort |
| mat_matmul (128x784 @ 784x128) | ~0.02 | 0.019 | BLAS sgemm |
| fmat_inv (100x100) | <0.001 | 0.067 | LAPACK sgetrf/sgetri |
| fmat_svd (100x100) | <0.001 | - | LAPACK sgesvd |
| fmat_cholesky (100x100) | <0.001 | - | LAPACK spotrf |
| fmat_qr (100x100) | <0.001 | - | LAPACK sgeqrf |
uv run bench/numpy_bench.pypub struct BindGroupDescriptor {
layout : BindGroupLayout
entries : Array[BindGroupEntry]
label : String?
}pub struct BindGroupLayoutDescriptor {
entries : Array[BindGroupLayoutEntry]
label : String?
} derive(Eq, Show)pub struct ComputePipelineDescriptor {
layout : PipelineLayout
compute : ProgrammableStage
label : String?
}pub struct FragmentState {
shader_module : ShaderModule
entry_point : String
targets : Array[ColorTargetState]
}pub struct Limits {
max_texture_dimension_2d : Int
max_storage_buffer_binding_size : Int
max_uniform_buffer_binding_size : Int
max_bind_groups : Int
max_compute_workgroup_size_x : Int
max_compute_workgroup_size_y : Int
max_compute_workgroup_size_z : Int
max_compute_workgroups_per_dimension : Int
} derive(Eq, Show)pub struct RenderPipelineDescriptor {
layout : PipelineLayout
vertex : VertexState
fragment : FragmentState
primitive : PrimitiveState
label : String?
}pub struct RequestAdapterOptions {
power_preference : PowerPreference
force_fallback_adapter : Bool
} derive(Eq, Show)pub struct SamplerDescriptor {
mag_filter : FilterMode
min_filter : FilterMode
mipmap_filter : FilterMode
label : String?
} derive(Eq, Show)pub struct TextureDescriptor {
size : Extent3d
mip_level_count : Int
sample_count : Int
dimension : TextureDimension
format : TextureFormat
usage : Int
label : String?
} derive(Eq, Show)fn bind_group_descriptor(layout : BindGroupLayout, entries : Array[BindGroupEntry], label : String?) -> BindGroupDescriptorfn bind_group_layout_descriptor(entries : Array[BindGroupLayoutEntry], label : String?) -> BindGroupLayoutDescriptorfn bind_group_layout_entry(binding : Int, visibility : Int, ty : BindingType) -> BindGroupLayoutEntryfn buffer_descriptor(size : Int, usage : Int, mapped_at_creation : Bool, label : String?) -> BufferDescriptorfn compute_pipeline_descriptor(layout : PipelineLayout, compute : ProgrammableStage, label : String?) -> ComputePipelineDescriptorfn device_create_bind_group(device : Device, desc : BindGroupDescriptor) -> Result[BindGroup, WgpuError]fn device_create_bind_group_layout(device : Device, desc : BindGroupLayoutDescriptor) -> Result[BindGroupLayout, WgpuError]fn device_create_command_encoder(_device : Device, _desc : CommandEncoderDescriptor) -> Result[CommandEncoder, WgpuError]fn device_create_compute_pipeline(device : Device, desc : ComputePipelineDescriptor) -> Result[ComputePipeline, WgpuError]fn device_create_pipeline_layout(device : Device, desc : PipelineLayoutDescriptor) -> Result[PipelineLayout, WgpuError]fn device_create_render_pipeline(_device : Device, _desc : RenderPipelineDescriptor) -> Result[RenderPipeline, WgpuError]fn device_create_shader_module(device : Device, desc : ShaderModuleDescriptor) -> Result[ShaderModule, WgpuError]fn device_dispatch_compute(device : Device, pipeline : ComputePipeline, bind_group : BindGroup, dispatch_x : Int) -> Result[Unit, WgpuError]fn pipeline_layout_descriptor(bind_group_layouts : Array[BindGroupLayout], label : String?) -> PipelineLayoutDescriptor