Skip to content

Instantly share code, notes, and snippets.

View kklemon's full-sized avatar

Kristian Klemon kklemon

  • Munich 🍺
  • 05:12 (UTC +02:00)
View GitHub Profile
@kklemon
kklemon / factorio-decipher.md
Created October 2, 2026 23:35
factorio-decipher.md

These are compressed handoff notes for a group of agents trying to get a Factorio factory ready to launch a rocket. They mix production planning, experiments, inventory accounting, and instructions about who may control the game.

The central distinction is “tested in a disposable copy” versus “actually accomplished in the live game.” Much of the repetition exists to keep those separate. The immediate crisis develops toward the end: a destroyed coal belt shuts down most steam power, and the agents eventually discover that construction robots cannot reach it.

I’m interpreting the supplied notes, without inspecting the referenced files. I’ve joined wrapped lines and abbreviated long hashes in the quotations.

Some recurring shorthand:

Shorthand Meaning
@kklemon
kklemon / rocm-onnx-migraphx-gfx1103.Dockerfile
Created April 3, 2026 12:17
rocm-onnx-migraphx gfx1103 dockerfile
# Multi-stage build for a ROCm + MIGraphX + ONNX Runtime image on Ubuntu 24.04.
#
# This Dockerfile intentionally uses:
# - A remote TheRock checkout as the ROCm source tree.
# - A separate AMDMIGraphX build, because this TheRock checkout does not
# currently build/install MIGraphX itself.
# - ONNX Runtime's MIGraphX execution provider, not the deprecated ROCm EP.
#
# Build example:
# docker build \
{
"version": "0.1.1",
"notes": "",
"platforms": {
"windows-x86_64": {
"signature": "",
"url": ""
},
"darwin-x86_64": {
"signature": "",
@kklemon
kklemon / demo.py
Last active December 5, 2024 08:42
FastAPI + SQLModel + LangChain + Structured Generation Demo
from contextlib import asynccontextmanager
import os
from fastapi import FastAPI
from langchain_openai import ChatOpenAI
from sqlmodel import Field, Session, SQLModel, create_engine, select
from pydantic.json_schema import SkipJsonSchema
# class BaseJoke(SQLModel):
# joke: str
@kklemon
kklemon / kiba_ligands.csv
Created September 29, 2024 15:09
kiba_ligands.csv
ligand_id smiles
CHEMBL1087421 COC1=C(C=C2C(=C1)CCN=C2C3=CC(=C(C=C3)Cl)Cl)Cl
CHEMBL1088633 COC1=C(C=C2C(=C1)CCN=C2C3=CC(=CC=C3)Cl)Cl
CHEMBL1090360 C1COCCN1C2=CC(=CC=C2)NC3=NC=CC(=N3)C4=C(N=C5N4C=CS5)C6=CC(=CC=C6)NC(=O)CC7=CC=CC=C7
CHEMBL1688215 C1=CC2=C(C=C1C3=NC(=NC=C3)N)NN=C2N
CHEMBL1765781 CNC1=NC(=CN=C1)C2=CNC(=O)C(=C2)NC(=O)C3=CC=C(C=C3)N4CCCC4CN5CCCC5
CHEMBL1788116 C1=CC=C2C(=C1)NC(=C(C#N)C3=NC(=NC=C3)NCCC4=CN=CC=C4)S2.C(=O)(C(F)(F)F)O.C(=O)(C(F)(F)F)O
CHEMBL1929238 CC(C)(C)C1=CC(=C(S1)NC(=O)NC2=C(C(=CC=C2)Cl)Cl)C(=O)N3CCC(=O)N(CC3)CCN(C)C
CHEMBL1933552 CC1CCC(CN1)N2CCC3(C2)CN(C4=CC=CC=C34)C(=O)C5=CC6=C(N5)C=C(C=C6)F
CHEMBL202930 COC1=C(C=CC(=C1)C2=CC3=C(C=C2)C(=CC4=CC=CN4)C(=O)N3)O
@kklemon
kklemon / mri_tensordicts.py
Last active February 1, 2024 08:50
Exemplary showcase implementation of MRI sequence handling with TensorDicts and memory mapped tensors
import torch
import nibabel as nib
import numpy as np
from tensordidct import TensorDict, MemmapTensor
files_by_modality = {
'flair': [...]
}
num_files = ...
@kklemon
kklemon / flash-attention-2-transformer.py
Last active January 16, 2025 11:21
PyTorch Transformer API compatible wrapper around FlashAttention-2
import torch.nn as nn
import torch.nn.functional as F
class FlashAttentionTransformerEncoder(nn.Module):
def __init__(
self,
dim_model,
num_layers,
num_heads=None,
@kklemon
kklemon / pytorch_transformer_benchmark.py
Last active October 31, 2024 17:48
PyTorch Transformer Benchmark
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
bz = 128
seq_len = 512
d_model = 64
n_heads = 8
@kklemon
kklemon / dash_bio_residue_coloring.py
Created January 26, 2023 16:00
Sample code for residue coloring in a dash-bio 3d molecule view
"""
Sample code for residue coloring in a dash-bio 3d molecule view
Requirements:
- dash
- dash-bio
- numpy
- biopython
pip install dash dash-bio numpy biopython
@kklemon
kklemon / iterable_dataset_dist.py
Last active February 24, 2025 06:16
PyTorch IterableDataset implementation with multiprocessing and distributed training support
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.utils.data import IterableDataset, DataLoader
class DistributedIterableDataset(IterableDataset):
"""
Example implementation of an IterableDataset that handles both multiprocessing (num_workers > 0)