Skip to content

Instantly share code, notes, and snippets.

View mratsim's full-sized avatar
:shipit:

Mamy Ratsimbazafy mratsim

:shipit:
  • Paris
View GitHub Profile
@mratsim
mratsim / tensorcery_compiler.nim
Created September 27, 2026 11:02
Experimental compiler approach for Tensor library
## Tattletale
## Copyright (c) 2026 Mamy André-Ratsimbazafy
## Licensed and distributed under either of
## * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
## * Apache v2 license (license terms in the root directory or at http://opensource.org/licenses/LICENSE-2.0).
## at your option. This file may not be copied, modified, or distributed except according to those terms.
## tensorcery_compiler, an exprgrad-style kernel DSL over the tensorcery engine.
## One loop-free algorithm statement plus a schedule block lower to a Metal
## kernel through a pass pipeline over a small nest IR.
@mratsim
mratsim / calibrate_software_engineer.yaml
Last active December 31, 2025 13:36
LLM calibration set for quantizing code-focused LLMs with AWQ
calibration_set:
_templates:
programming_languages: &programming_languages "Solve the following problem using {{ ['Zephyr', 'Prolog', 'Cobol', 'Apex', 'Crystal', 'Fortran', 'Nim', 'Delphi', 'Ada', 'Objective-C', 'VBA', 'Perl', 'Groovy', 'MATLAB', 'Solidity', 'Visual Basic', 'OCaml', 'Erlang', 'Julia', 'Lisp', 'F#', 'Clojure', 'GDScript', 'Scala', 'R', 'Haskell', 'Ruby', 'Elixir', 'Lua', 'Zig', 'Dart', 'Swift', 'Metal', 'PowerShell', 'PHP', 'Kotlin', 'C', 'Java', 'C++', 'C#', 'Bash/Shell', 'Go', 'Rust', 'TypeScript', 'HTML/CSS', 'SQL', 'JavaScript', 'Python', 'Lean', 'Coq', 'Pony', 'D', 'Racket', 'Haxe', 'x86-64 ASM', 'ARM-64 ASM', 'LLVM IR', 'GLSL', 'CUDA', 'Vulkan'][hash(row|string) % 60] }}\n***\n"
spoken_languages: &spoken_languages "Answer in {{ ['Arabic', 'Chinese', 'French', 'German', 'Hebrew', 'Hindi', 'Japanese', 'Korean', 'Portuguese', 'Russian', 'Spanish', 'Turkish'][hash(row|string) % 12] }}\n***\n"
max_seq_length: 8192
shuffle: true
seed: 42
datasets:
# Category Summary
import std/[cmdline, times, monotimes, random, sugar, os, typetraits]
const
EnableTests = false
EnableCount = not EnableTests and false
EnableBench = not EnableTests
template bench(repeat: int; init, body: untyped): untyped =
var minTime = initDuration(days = 2)
for i in 1 .. repeat:
## clang -D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -L/opt/rocm/lib -lamdhip64
# {.passC: "-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include".}
{.passL: "-L/opt/rocm/lib -lamdhip64".}
template CHECK_RET_CODE*(call, ret_code: untyped): void =
if (call) != ret_code:
echo "Failed in call: %s\n", astToStr(call)
quit 1
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 2 columns, instead of 1 in line 5.
EC ScalarMul 255-bit G1 (vartime reference DoubleAdd) ; ECP_ShortW_Jac[Fp[BLS12_381], G1] ; 10939.722 ops/s; 91410 ns/op; 301080 CPU cycles (approx)
EC ScalarMul 255-bit G1 (vartime wNAF-3) ; ECP_ShortW_Jac[Fp[BLS12_381], G1] ; 13986.601 ops/s; 71497 ns/op; 235493 CPU cycles (approx)
EC ScalarMul 255-bit G1 (vartime wNAF-4) ; ECP_ShortW_Jac[Fp[BLS12_381], G1] ; 14373.599 ops/s; 69572 ns/op; 229152 CPU cycles (approx)
EC ScalarMul 255-bit G1 (vartime wNAF-5) ; ECP_ShortW_Jac[Fp[BLS12_381], G1] ; 14523.484 ops/s; 68854 ns/op; 226787 CPU cycles (approx)
EC ScalarMul 255-bit G1 (vartime endomorphism + wNAF-3) ; ECP_ShortW_Jac[Fp[BLS12_381], G1] ; 21272.975 ops/s; 47008 ns/op; 154834 CPU cycles (approx)
EC ScalarMul 255-bit G1 (vartime endomorphism + wNAF-4) ; ECP_ShortW_Jac
@mratsim
mratsim / android-backup-apk-and-datas.md
Created September 23, 2023 21:25 — forked from AnatomicJC/android-backup-apk-and-datas.md
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

Fetch application APK

@mratsim
mratsim / trusted_setups.md
Last active May 16, 2023 21:30
A data serialization format for trusted setups for zero-knowledge cryptography
@mratsim
mratsim / macro_assembler_x86.nim
Created April 21, 2023 14:55
Compile-Time x86 ASM Assembler
# Constantine
# Copyright (c) 2018-2019 Status Research & Development GmbH
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import std/[macros, strutils, sets, hashes, algorithm]