Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Hermann-SW / mi50_rt_graph.py
Last active October 31, 2026 15:53
multiple Instinct MI50 real time GPU% graphing
#!/usr/bin/env python3
""" multiple Instinct MI50 real time GPU% graphing """
import glob
import os
import time
from collections import deque
import matplotlib.pyplot as plt
from matplotlib import animation
def is_amd_vega20(ddir):
@Hermann-SW
Hermann-SW / bench5.md
Last active October 31, 2026 00:06
llama-bench of Kolibri-1 78B model on workstation with 5 AMD Instinct MI50 GPUs with 32+4*16=96GB VRAM

≥239 tokens/s prompt processing
57.76 tokens/s token generation

hermann@7600x:~/llama.cpp$ ./bench5
ggml_cuda_init: found 5 ROCm devices (Total VRAM: 98224 MiB):
  Device 0: AMD Radeon Graphics, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 32752 MiB
  Device 1: AMD Instinct MI50/MI60, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 16368 MiB
  Device 2: AMD Instinct MI50/MI60, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 16368 MiB
 Device 3: AMD Instinct MI50/MI60, gfx906:sramecc+:xnack- (0x906), VMM: no, Wave Size: 64, VRAM: 16368 MiB
@Hermann-SW
Hermann-SW / chat_with_Kolibri1.md
Last active October 28, 2026 01:11
Kolibri1 running on 1x32GB+4x16GB Instinct MI50 GPUs example

prompt:

this code works, please explain:

Q=get_tqf(n1);
if(type(Q)!="t_MAT",return([]));
assert(qfeval(Q,x)==n1);
assert(matdet(Q)==1);

G=qflllgram(Q,flag=1);
@Hermann-SW
Hermann-SW / 4L.2.md
Created October 27, 2026 07:41
Argon.high response

Your intuition on the second point is spot-on: if $n$ is a product of many medium primes $3 < p_i < 2^{32}$, dropping only the single largest prime factor $q_r$ can leave the remaining product $\prod_{j=1}^{r-1} q_j$ as large as $2^{59}$, which completely breaks any naive fencepost mask inside 64 bits.

What rescues the 64-bit hint is a see-saw trade-off between the bit-length of the dropped largest prime ($\ge 64/r$ bits) and the number of LSB/MSB bits stripped from the remaining $r - 1$ odd primes ($r - 1$ bits). Below is the complete mathematical proof for Scheme B (uint64_t + uint16_t), the exact proof and construction of the 64-bit hint H given $n$, and the $O(1)$ incremental pushprime(p) / inc_last_prime_exponent(p) state machine.


1. Deep Dive & Proof of Bounds for Scheme B (uint64_t W + uint16_t shape_id)

In Scheme B, the 64-bit word W chains the odd prime factors $3 \le q_1 \le q_2 \le \dots \le q_r$ (sorted with multiplicity) by overlapping the MSB 1 of $q_{j-1}$ with th

@Hermann-SW
Hermann-SW / ecm.cpp
Created October 9, 2026 21:18
After longer discussion with Gemini on Lenstra's ECM factoring method I got sample code that worked ...
#include <iostream>
#include <vector>
#include <string>
#include <stdexcept>
#include <chrono>
#include <gmpxx.h>
#include <gmp.h>
class FactorFoundException : public std::exception {
public:
@Hermann-SW
Hermann-SW / ec_ipts.gp
Created October 9, 2026 18:36
Script to test differences on how SageMath and PARI/GP determine integral points on elliptic curves
sage(cmd) = eval(externstr(Str("sage -q -c \"", cmd, "\""))[1]);
ellintpoints(E) = {
sage(Str("print([[int(P[0]), int(P[1])] for P in EllipticCurve(",
E[1..5],").integral_points(both_signs=True)])"));
}
as=eval(getenv("as"));
E=ellinit(as);
print(" E[1..5]=",E[1..5]);
@Hermann-SW
Hermann-SW / integral_points_coefficients.gp
Created October 6, 2026 22:19
demonstrate how to call sagemath E.integral_points() from PARI/GP
sage(cmd) = eval(externstr(Str("sage -q -c \"", cmd, "\""))[1]);
ellintpoints(E) = {
sage(Str("print([[int(P[0]), int(P[1])] for P in EllipticCurve(",
E[1..5],").integral_points()])"));
}
xy=eval(getenv("xy"));
[y1,x1]=xy;
[x2,y2]=xy;x2*=-1;
@Hermann-SW
Hermann-SW / is_prime_u32.cpp
Created September 20, 2026 08:50
100% deterministic Miller-Rabin primality test for N < 2^32
#include <iostream>
#include <cstdint>
#include <gmpxx.h>
#include <cassert>
#include <omp.h>
// Single-round Miller-Rabin test using GMP modular exponentiation
inline bool miller_rabin_test(uint32_t n, uint32_t a, uint32_t d, int s) {
mpz_class base(a), exp(d), mod(n), x;
@Hermann-SW
Hermann-SW / build_graph.py
Last active October 26, 2026 21:44
Latex labels for Graphviz (work in progress)
This Python script became obsolete with this new repo:
https://github.com/Hermann-SW/graphviz_latex_pipeline
Because that repo's texdot.py compiles the LaTeX in each node or edge separately, with the real LaTeX.
You can still access this gist's Python code by opening the file at earlier revisions.
@Hermann-SW
Hermann-SW / gfx900_multi_precision_bench.cpp
Last active August 29, 2026 12:37
INT16 add and mul as well as FP16 fma benchmark for gfx900 GPUS
/*
f=gfx900_multi_precision_bench
hipcc -O3 --offload-arch=gfx900 $f.cpp -o $f
*/
#include <hip/hip_runtime.h>
#include <hip/hip_fp16.h>
#include <iostream>
#include <iomanip>
#include <vector>