Results on CuriousCodinghttps://curiouscoding.nl/categories/results/Recent content in Results on CuriousCodingHugoenSat, 05 Oct 2024 00:00:00 +0200A lemma on suffix array searchinghttps://curiouscoding.nl/posts/suffix-array-searching-lemma/Sat, 05 Oct 2024 00:00:00 +0200https://curiouscoding.nl/posts/suffix-array-searching-lemma/Table of Contents 1 Suffix arrays 2 Searching methods 2.1 Naive \(O(|P|\cdot \lg_2 n)\) search 2.2 Faster \(O(|P|\cdot \lg_2 n)\) search 2.3 LCP-based \(O(|P| + \lg_2 n)\) search 3 Analysing the faster search We’ll prove that using the “faster” binary search algorithm (see 2.2) that tracks the LCP with the left and right boundary of the remaining search interval has amortized runtime
\[ O\Big(\lg_2(n) + |P| + |P| \cdot \lg_2(Occ(P))\Big), \] when \(P\) is a randomly sampled fixed-length pattern from the text and \(Occ(P)\) counts the number of occurrences of \(P\) in the text.Computing random minimizers, fasthttps://curiouscoding.nl/posts/fast-minimizers/Fri, 12 Jul 2024 00:00:00 +0200https://curiouscoding.nl/posts/fast-minimizers/Table of Contents 1 Introduction 1.1 Results 2 Random minimizers 3 Algorithms 3.1 Problem statement Problem A: Only the set of minimizers Problem B: The minimizer of each window Problem C: Super-k-mers Which problem to solve Canonical k-mers 3.2 The naive algorithm Performance characteristics 3.3 Rephrasing as sliding window minimum 3.4 The queue Performance characteristics 3.5 Jumping: Away with the queue Performance characteristics 3.6 Re-scan Performance characteristics 3.7 Split windows Performance characteristics 4 Analysing what we have so far 4.A near-tight lower bound on minimizer densityhttps://curiouscoding.nl/posts/minimizer-lower-bound/Tue, 25 Jun 2024 00:00:00 +0200https://curiouscoding.nl/posts/minimizer-lower-bound/Table of Contents Succinct background Definitions Lower bounds A new lower bound Discussion Post scriptum Acknowledgement The results of this post are now available in a pre-print: DOI, PDF:
Kille, Bryce, Ragnar Groot Koerkamp, Drake McAdams, Alan Liu, and Todd Treangen. 2024. “A near-Tight Lower Bound on the Density of Forward Sampling Schemes.” Biorxiv. https://doi.org/10.1101/2024.09.06.611668.
In this post I will prove a new lower bound on the density of any minimizer or forward sampling scheme: \[ d(f) \geq \frac{\lceil\frac{w+k}{w}\rceil}{w+k} = \frac{\lceil\frac{\ell+1}{w}\rceil}{\ell+1}.Perfect NtHash for Robust Minimizershttps://curiouscoding.nl/posts/nthash/Sun, 31 Dec 2023 00:00:00 +0100https://curiouscoding.nl/posts/nthash/Table of Contents NtHash Minimizers Robust minimizers Is NtHash injective on kmers? Searching for a collision Proving perfection Alternatives SmHasher results TODO benchmark NtHash, NtHash2, FxHash NtHash NtHash (Mohamadi et al. 2016) is a rolling hash suitable for hashing any kind of text, but made for DNA originally. For a string of length \(k\) it is a \(64\) bit value computed as:
\begin{equation} h(x) = \bigoplus_{i=0}^{k-1} rot^i(h(x_i)) \end{equation}
where \(h(x_i)\) assigns a fixed \(64\) bit random value to each character, \(rot^i\) rotates the bits \(i\) places, and \(\bigoplus\) is the xor over all terms.PTRHash: Notes on adapting PTHash in Rusthttps://curiouscoding.nl/posts/ptrhash/Thu, 21 Sep 2023 00:00:00 +0200https://curiouscoding.nl/posts/ptrhash/Table of Contents Questions and remarks on PTHash paper Ideas for improvement Parameters Align packed vectors to cachelines Prefetching Faster modulo operations Store dictionary \(D\) sorted using Elias-Fano coding How many bits of \(n\) and hash entropy do we need? Ideas for faster construction Implementation log Hashing function Bitpacking crates Construction Fastmod TODO Try out fastdivide and reciprocal crates First benchmark Faster bucket computation Branchless, for real now! (aka the trick-of-thirds) Compiling and benchmarking PTHash Compact encoding Find the \(x\) differences FastReduce revisited TODO Is there a problem if \(\gcd(m, n)\) is large?Tensor embedding preserves Hamming distancehttps://curiouscoding.nl/posts/tensor-embedding-distance/Fri, 14 Oct 2022 00:00:00 +0200https://curiouscoding.nl/posts/tensor-embedding-distance/Table of Contents Definitions Proof of Lemma 1 TODO Proof of Lemma 2 This is a proof that Tensor Embedding (Joudaki, Rätsch, and Kahles 2020) with $ℓ^2$-norm preserves the Hamming distance.
This is in collaboration with Amir Joudaki.
\begin{equation*} \newcommand{\I}{\mathcal I} \newcommand{\EE}{\mathbb E} \newcommand{\var}{\operatorname{Var}} \end{equation*}
Definitions Notation The alphabet is \(\Sigma\), of size \(|\Sigma| = \sigma\). The set of indices is \(\I := \{(i_1, \dots, i_t) \in [n]^t: i_1 < \dots < i_t\}\).28000x speedup with Numba.CUDAhttps://curiouscoding.nl/posts/numba-cuda-speedup/Mon, 24 May 2021 00:00:00 +0200https://curiouscoding.nl/posts/numba-cuda-speedup/Table of Contents CUDA Overview Profiling Optimizing Tensor Sketch CPU code V0: Original python code V1: Numba V2: Multithreading GPU code V3: A first GPU version V4: Parallel kernel invocations V5: Single kernel with many blocks V6: Detailed profiling: Kernel Compute V7: Detailed profiling: Kernel Latency V8: Detailed profiling: Shared Memory Access Pattern V9: More work per thread V10: Cache seq to shared memory V11: Hashes and signs in shared memory V12: Revisiting blocks per kernel V13: Passing a tuple of sequences V14: Better hardware V15: Dynamic shared memory Wrap up Xrefs: r/CUDA, Numba discourse