Alcides Fonseca

40.197958, -8.408312

Network being dropped on a ASUS Strix X670OE-E motherboard

So I found some logs that the network PCIe device was being dropped in Ubuntu 22.04.

igc (...) eno1: PCIe link lost, device now detached

After looking it up, I reached the conclusion that that particular chip overheats, which causes the kernel to drop the device.

Other than adding a heatsink, the solution is to change the OS configuration, so you make it slower, so it doesn’t overhead:

  • Adding these two kernel parameters: pcie_port_pm=off pcie_aspm.policy=performance
  • Disabling a bunch of TCP features: sudo ethtool --offload eno1 rx off tx off. I personally find this option a bit scary, so I ended up reversing it.

Functional Programming in Python 3.12

Oskar Wickström shows off recent Python features (generics + pattern matching) that make writing Python more similar to ML, Haskell, Rust or Scala. If you need to support old versions of Python, you will have to wait a couple years before you use proper generics syntax (although you can use the TypeVar class).


def print_tree[T](tree: RoseTree[T]):
    trees = [(tree, 0)]
    while trees:
        match trees.pop(0):
            case Branch(branches), level:
                print(" " * level * 2 + "*")
                trees = [(branch, level + 1) for branch in branches] + trees
            case Leaf(value), level:
                print(" " * level * 2 + "- " + repr(value))

Statically Typed Functional Programming with Python 3.12

Improve file transfer speed between Macs and Synology

To improve the file transfer speed between macOS and Synology, you should do the following:

  • On Synology, go to Control Panel/File Services/SMB and under Advanced Settings upgrade the minimum SMB version from 1 to 2. This might prevent old devices from connecting, but can improve the speed of modern devices.
  • On macOS, disable packet signing.

The Alternative Implementation Problem

Hopefully, at this point, you see where I’m going with this. What I’ve concluded, based on experience, is that positioning your project as an alternative implementation of something is a losing proposition. It doesn’t matter how smart you are. It doesn’t matter how hard you work. The problem is, when you build an alternative implementation, you’ve made yourself subject to the whims of the canonical implementation. They have control over the direction of the project, and all you can do is try to keep up. In the case of JITted implementations of traditionally interpreted languages, there’s a bit of a weird dynamic, because it’s much faster to implement new features in an interpreter. The implementers of the canonical implementation may see you as competition they are trying to outrun. You may be stuck trying to ice skate uphill.

Maxime Chevalier-Boisvert

This is surely true in Python or Lua, but I believe it might not necessarily be the case for Java (where there is a specification, and enough effort by the industry to create alternative implementations). But I agree in general, unless you have something unique (like Android support, despite Dalvik being stuck on Java 8 for ages), which both IronPython and Jython didn’t have — I guess there is no general need for accessing the .NET and JVM runtimes from dynamic languages.

ChatGPT in Papers

Google Scholar for certainly, here is turns up a huge number of academic papers that include parts that were evidently written by ChatGPT—sections that start with “Certainly, here is a concise summary of the provided sections:” are a dead giveaway.

Simon Willison

Peer review isn’t built to handle the flood of AI content, especially as not all of it will be obvious, and not all will be malicious (lots of scholars pay editors to help make their writing better, now they will use chat).

Ethan Mollick

Misha Teplitskiy

The AI boom will soon crash

Put in the simplest way: Things have been too good for too long in InvestorWorld: low interest, high profits, the unending rocket rise of the Big-Tech sector, now with AI afterburners. Wile E. Coyote hasn’t actually run off the edge of the cliff yet, but there are just way more ways for things to go wrong than right in the immediate future.

Money Bubble by Tim Bray

Tim (correctly) points out that when investors throw money at things that are not well understood (.com, web2.0, blockchain, AI), it will eventually disappoint and crash the markets. Enjoy it while you can.

Mamba: The Easy Way

Today, basically any language model you can name is a Transformer model. OpenAI’s ChatGPT, Google’s Gemini, and GitHub’s Copilot are all powered by Transformers, to name a few. However, Transformers suffer from a fundamental flaw: they are powered by Attention, which scales quadratically with sequence length. Simply put, for quick exchanges (asking ChatGPT to tell a joke), this is fine. But for queries that require lots of words (asking ChatGPT to summarize a 100-page document), Transformers can become prohibitively slow. […] Mamba appears to outperform similarly-sized Transformers while scaling linearly with sequence length.

Mamba: The Easy Way, by Jack Cook

A wonderful explanation of the architectural differences in mamba and how it is much faster than existing transformer implementations. May require some CNN/RNN background to fully understand.

Power Metal Data Analysis

Bands from Spain, Germany and Finland have an average of more than 1600 words vocabulary; in comparison native countries like UK, US and Scotland have an average of 925, 1383 and 1501 words respectively, The most metal words are deliverance, defender, honour, forevermore, realm and the least are shit, baby, fuck, girl, verse. The most negative song is Condemned To Hell by Gamma Ray and the most positive There’s Something In The Skies by Dark Moor.

Power Metal: is it really about dragons? by Matt D.

I really wish there was code available, because I think the 58 bands provide a quite limited dataset, and I’m curious about my own Power Metal collection.

Bloom Filters Explained

While this looks almost identical to a Set, there are some key differences. Bloom filters are what’s called a probabalistic data structure. Where a Set can give you a concrete “yes” or “no” answer when you call contains, a bloom filter can’t. Bloom filters can give definite “no“s, but they can’t be certain about “yes.”

Bloom Filters by Sam Rose

Setting up SLURM for Single-Node usage in Ubuntu 22.04

SLURM is one of the most popular schedulers for clusters and High-Performance Computing (HPC). It takes care of two tasks. Firstly, it prevents everyone from starting processes on the same machine in a way that none of the processes can run successfully (due to not enough RAM, Disk or CPU time). Secondly, it allows to submit a set of programs to multiple computers automatically.

Typically, SLURM is used in a single, weaker computer (called the login node). Users submit jobs (a single program that can be executed many times, in parallel) and these jobs are scheduled in more power machines, which the user has no access to (for consistency sake).

These instructions are for the case where you want SLURM controlling a single computer (node). This is useful when you do not have a cluster, but a single powerful machine. Many of the instructions are taken from How to quickly set up Slurm on Ubuntu 20.04 for single node workload scheduling.

Install SLURM

sudo apt update -y
sudo apt install slurmd slurmctld -y
sudo mkdir /etc/slurm-llnl/
sudo chmod 777 /etc/slurm-llnl
sudo mkdir /var/lib/slurm-llnl/
sudo mkdir /var/log/slurm-llnl/
sudo chmod 777 /var/lib/slurm-llnl/
sudo chmod 777 /var/log/slurm-llnl/

And update the permissions to your liking.
Then we need to create two files: /etc/slurm-llnl/slurm.conf and /etc/slurm/slurm.conf. They should be the same, but they are in two different locations because of the multimode support (not in use in our scenario). As such, I end up creating a soft link between the two:

sudo ln -s /etc/slurm-llnl/slurm.conf /etc/slurm/slurm.conf

Now we edit the contents of /etc/slurm/slurm.conf and of /etc/slurm/gres.conf to the following:

Note that this configuration sets up two Nvidia A30 GPUs. If you have no Nvidia GPUs, then you can delete gres.conf and remove Gres=gpu:2,mps:200 from slurm.conf.

Now you can start the slurm processes (one to manage the execution, the other to manage the queues):

sudo service slurmctld restart && sudo service slurmd restart

To troubleshoot, you should check the following files: /var/log/slurm-llnl/slurmd.log and /var/log/slurm-llnl/slurmctld.log.

The European AI act, and how to ensure properties of AI?

During my current visit to UCL’s SOLAR group, I attended this week’s SSE Seminar on the challenges posed by the AI Act, presented by Paolo Falcarin.

The European Union Artificial Intelligence act is EU’s first attempt of regulating AI products and services. It defines different requirements based on the risk level of the application (ranges between high, medium and low).

In particular, high-risk usage (healthcare, toys, security, …) have stricter requirements. To begin with, they need to be registered in an European database, and frequently updated as the implementation or requirements change. Furthermore, the service or product should be documented, should be traceable, transparent, secure and overridable by humans. Despite these requirements, there is no clear definition, or path forward on how these properties can be ensured, especially when applications are closed-source and frequently trained and updated. One of the challenges we addressed in CAMELOT was how to build interprable Machine Learning models. We explored the use of Genetic Programming and Domain-Specific Languages to create inherently interpretable models. My research team is continuing exploring that possibility.

General-Purpose models have a special categorization within the AI act: Providers of general-purpose models (think OpenAI or Google) must provide a good understanding of the capabilities and limitations, comply with European copyright law, and provide a sufficiently detailed summary about the content used for training of the general-purpose model, following a given template.

Despite all the effort in understanding the potential of deep neural networks, and generative models in particular, it is not clear year what exactly are the capabilities or limitations of what they can produce. Without a clear standard of what is expected, organizations might be able to completely ignore this requirement.

As an example, take the Gandalf AI game, in which you can (easily) trick the LLM into telling you the password of the next level, even though it was instructed not to. Even with the aditional blocks introduced by each level, it is still easy to win the game. This is the state of the art in protecting LLMs from producing a known output. On a larger scale, an earlier version of Microsoft’s AI-powered Bing also generated output that went against the policies it was purposely trained against.

As for the copyright compliance, this goes in direct conflict with what OpenAI is defending. In fact, using copyrighted materials for free in the context of learning is allowed by European law. As such, it is not clear what this article entails in practice. My guess is that this is going to require a reform on the copyright law, possible to distinguish human versus automated learning. Otherwise, models this efficient may never (legally) exist again. This is something the law and computer science communities should debate before politicians take the initiative.

Finally, general-purpose AI with systemic risks (probably all of Large Language Models) have stricter restrictions: they need to evaluate models based on standardised protocols and tools, documenting adversarial testing of the model. While there are good practices for evaluating models, I do not believe the community will agree on an universal metric for general-purpose AI, and different metrics will arise.

Overall, I think it is positive that the EU is trying to regulate the use of AI. Unfortunately, I think it is a lost battle, as the technology is very new and evolves at a very high pace (something that beaurocracy might slow down). I defend that the EU should invest more on the evaluation and monitoring of AI, maybe more than on its development. After all, we cannot compete with the likes of NVIDIA, OpenAI/Microsoft, Google, Apple or Amazon, since they aquire all the relevant hardware before Europe does. Not even Intel or TSMC investing in Europe will allow us to beat US companies (or adjacent universities) in AI research. However, we can beat them in studying the societal impact of AI.

Windows 11 manages power depending on clean energy availability

Starting with this build, we are introducing the Power Grid Forecast API. This API empowers app developers to optimize app behavior, minimizing environmental impact by shifting background tasks to times when more renewable energy is available in the local electrical grid.
Announcing Windows 11 Insider Preview Build 26052 (via Terence Eden)

Guilherme, Paulo and I submitted a proposal of a similar service (but for server workloads, where it makes more sense) back in 2020 for an EDP competition. It was not fancy enough as it was mostly transparent (the API was a job queue).

Our team is working on making energy usage first-class in programming languages, so developers have a better understanding of their impact when making design decisions.

A Golden Era of Blogging

“It reminds me a lot of how blogging changed around 2005-2009, when ad money came pouring in, and while it was great for bloggers that previously were just publishing for the heck of it (myself included), eventually the money tainted the process as many people rushed to improve their bottom line, often at the expense of whole reason they created their sites.” — Today’s YouTubers are repeating the mistakes of yesterday’s bloggers by Matt Haughey

Love, passion, and curiosity — more than money — fuel the majority of posts that show up in my RSS feed every day and I love it.
Forget the days of Google Reader, now is a golden era of blogging.

A Golden Era of Blogging by Jim Nielsen

I have always only subscribed to passion-driven blogs, and not for profit endeavors (RedMonk maybe being the exception). But you do see the trend on Youtube as the quality decreases as YouTubers become need-to-pay-my-employees sized.

Portable EPUBs

A simple answer is to improve the PDF format. After all, we already have billions of PDFs — why reinvent the wheel?

— Will Crichton, in Portable EPUBs

I’ve met Will last year during SPLASH and besides having awesome game host presentation skills, he is also very passionate about this topic. LaTeX was made for a world where paper is king. But I don’t read papers in paper anymore, I read them on my laptop, frequently on external screens. Sometimes even on my phone. And let me tell you that most of the time I have to pan around to read a single line. We desperately need responsive layouts in most written form. eBooks got it right (but not all books were ported properly, and some will never be, and that’s okay).

[1]

I’ve learned a lot from his post, mainly about the advanced PDF capabilities that open-source software usually doesn’t support. You wouldn’t even need to extend the PDF format.

He proposes that the best practical solution is to use self-contained ePUB written in a safe subset of HTML, CSS and Javascript. His notion of safe is left too much for interpretation to my liking, but the overall idea is a good one.

And while ACM is looking into improving the status of accessibility in PDF papers and whitelisting packages that support HTML exporting, antagonizing computer scientists have relied on advanced macros for decades, ArXiV did without asking anyone’s permission.

I’m still not sure that an HTML-based format is the solution. I don’t think we have the proper authoring tools. Yes, we have TinyMCE and friends, but that has limited support for templating. Heck, even Microsoft FrontPage would give you better control over the layout, at the cost of unreadable source code. But designers want Adobe Indesign and QuarkXPress so they can have some control about pagination and whitespace. Maybe we need a new generation of those tools that also targets responsive HTML views?

But what doesn’t convince me the most is HTML, CSS and Javascript evolutions. Those are languages that have and will continue to evolve at a faster pace than PDF or Postscript. I argue for the tradeoff of having a very basic layout and content language with Active-X plugins that authors can use, at the cost of being lost in time, just like those awesome little Flash games that no-one can play anymore.

1 Curiously, I couldn’t hot link this image from his own post, probably due to the way the ePUB is being dynamically uncompressed.

The risks of open sourcing (imaginary) government LLMs

Let’s take a theoretical example. Suppose the Government trains an AI to assess appeals to, say, benefits sanctions. An AI is fed the text of all the written appeals and told which ones are successful and which ones aren’t. It can now read a new appeal and decide whether it is successful of not. Now let’s open source it.

Terrence Eden

Terrence explores the repercussions of open sourcing the training data, the training code and the trained weights of government data. I suggest reading the whole article, especially given that many Portuguese administrative organizations offer ChatGPT-based help.

How to generate random numbers in your head

Choose a 2-digit number, say 23, your “seed”.
Form a new 2-digit number: the 10’s digit plus 6 times the units digit.
The example sequence is 23 –> 20 –> 02 –> 12 –> 13 –> 19 –> 55 –> 35 –> …
and its period is the order of the multiplier, 6, in the group of residues relatively prime to the modulus, 10. (59 in this case).
The “random digits” are the units digits of the 2-digit numbers, ie, 3,0,2,2,3,9,5,… the sequence mod 10.

George Marsaglia via Hillel Wayne

The value of OpenSource

We estimate the supply-side value of widely-used OSS is $4.15 billion, but that the demand-side value is much larger at $8.8 trillion. We find that firms would need to spend 3.5 times more on software than they currently do if OSS did not exist. […] Further, 96% of the demand-side value is created by only 5% of OSS developers.

The Value of Open Source Software, Harvard Business School Strategy Unit, via Simon Willison

FFI troubleshoot in Haskell

When installing Haskell’s HLint via:

stack install hlint

I was getting the following error:


base-compat-batteries            > [  2 of 118] Compiling Control.Concurrent.Compat.Repl.Batteries                                          
hashable                         >                                                                                                          
hashable                         > /private/var/folders/3g/7tpj8zwx14qddcr3bt_w8jnr0000gn/T/stack-e594623fe9dbdb84/hashable-1.3.5.0/In file included from /var/folders/3g/7tpj8zwx14qddcr3bt_w8jnr0000gn/T/ghc52550_0/ghc_20.c:4:0: error:
hashable                         >                                                                                                          
hashable                         >                                                                                                          
hashable                         > In file included from /Users/alcides/.stack/programs/aarch64-osx/ghc-9.0.2/lib/ghc-9.0.2/lib/../lib/aarch64-osx-ghc-9.0.2/rts-1.0.2/include/ffi.h:66:0: error:
hashable                         >                                                                                                          
hashable                         >                                                                                                          
hashable                         > /Users/alcides/.stack/programs/aarch64-osx/ghc-9.0.2/lib/ghc-9.0.2/lib/../lib/aarch64-osx-ghc-9.0.2/rts-1.0.2/include/ffitarget.h:6:10: error:
hashable                         >      fatal error: 'ffitarget_arm64.h' file not found                                                     
hashable                         >   |                                                                                                      
hashable                         > 6 | #include "ffitarget_arm64.h"                                                                         
hashable                         >   |          ^                                                                                           
hashable                         > #include "ffitarget_arm64.h"                                                                             
hashable                         >          ^~~~~~~~~~~~~~~~~~~                                                                             
hashable                         > 1 error generated.                                                                                       
hashable                         > `gcc' failed in phase `C Compiler'. (Exit code: 1)   

The problem is that my clang was installed via home-brew. As such, there were a few missing paths. The solution was to run the following to find the location of this header:

find / -iname ffitarget_arm64.h

My output was:

find: /usr/sbin/authserver: Permission denied
find: /Library/Application Support/Apple/Screen Sharing/Keys: Permission denied
find: /Library/Application Support/Apple/ParentalControls/Users: Permission denied
find: /Library/Application Support/Apple/AssetCache/Data: Permission denied
find: /Library/Application Support/Apple/Remote Desktop/Task Server: Permission denied
find: /Library/Application Support/Apple/Remote Desktop/Client: Permission denied
find: /Library/Application Support/ApplePushService: Permission denied
find: /Library/Application Support/com.expressvpn.ExpressVPN/data: Permission denied
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/ffi/ffitarget_arm64.h
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/include/ffi/ffitarget_arm64.h
...

Now you need to pick the first one (second to last line in the previous output) as copy the path up to include (inclusive). Now use it in the following line, or add it to your ~/.zshrc.

C_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/

Thank your family with Backups

It’s thanksgiving time in the US and we’re nearing Xmas time in many other places. I would recommend setting up backups for your loved ones as a wonderful and thoughtful gift.

Last month I had to deal with the loss of a relative’s entire photo library. She copied all the loose photos in ~/Pictures to Apple Photo’s (and therefore to ~/Pictures/Photos.photolibrary/) and, once she was done, she selected everything inside the Pictures folder, and deleted them. And to be sure, she also emptied her trashcan.

Because I hadn’t set up a backup for this particular machine, I had to spend two weekends recovering all deleted photos among many trash lost in the remains of the HDD. For this purpose, I recommend Disk Drill.

As for Backups, I really recommend Backblaze, as it automatically backups all files to their cloud. You have optional encryption (which I don’t use, so I can access the file explorer on their website, to do selective backups). It’s a solution for non-technical folks that happens in the background with no need for user action. They might need your help to do a restore, but that’s very acceptable in my opinion. It has saved me several times for my own laptop.

If you are using this for a more technical use, you should be aware that by default, it does not back up large files like virtual machines or disk images. You should change this in the settings. Having said this, I also keep one time machine in an external disk, and another one in my NAS.