Better Go concurrency, Rust in Chromium, Tracr, RL in Minecraft- CS News #2
Welcome to CS News #2!
The CS newsletter helps you keep track of the latest news in different technology domains like AI, Security, Software development, Blockchain/P2P and discover new interesting projects and techniques!
✨ Project Highlight: conc, safer and simpler Golang concurrency management
conc
v0.1.0 has been released 2 weeks ago and aims to provide better structured concurrency for go programs.
Even if golang go routines are quite straightforward to use compared to other programming languages, they are still some caveats:
cleaning up go routines is often a pain and can be forgotten
managing panics occurring inside routines often requires too much boilerplate code
go routines related code is often too verbose and not that easy to read / maintain
Conc solves this in 3 ways:
First, make it harder to leak goroutines: with conc all goroutines have an explicit owner (a conc.WaitGroup)
that should ensure its goroutines exit properly. This way, concurrency is always scoped and easier to clean up.
func main() {
var wg conc.WaitGroup
defer wg.Wait()
startTheThing(&wg)
}
func startTheThing(wg *conc.WaitGroup) {
wg.Go(func() { ... })
}
Then, handle panics gracefully: the owner of a conc
goroutine will panic if any of its goroutines panicked when its Wait
function is called. The panic stracktrace are forwarded to the panic value so that no information is lost in the process.
func main() {
var wg conc.WaitGroup
wg.Go(doSomethingThatMightPanic)
// panics with a nice stacktrace
wg.Wait()
}
Finally, focus on simplicity and less verbosity, like in this example to concurrently map a slice:
// using stdlib
func concMap(
input []int,
f func(int) int,
) []int {
res := make([]int, len(input))
var idx atomic.Int64
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for {
i := int(idx.Add(1) - 1)
if i >= len(input) {
return
}
res[i] = f(input[i])
}
}()
}
wg.Wait()
return res
}
// using conc
func concMap(
input []int,
f func(int) int,
) []int {
return iter.Map(input, f)
}
v1.0 (production readiness) of this project is currently planned for March 2023.
⚙️ Rust is coming to Chromium
Google announced that they are setting up a Rust toolchain to the Chromium build system to start including Rust code to Chrome binary.
Chromium is currently developed in C++ and its team expect to use Rust to:
"provide a simpler (no IPC) and safer (less complex C++ overall, no memory safety bugs in a sandbox either) way to satisfy the rule of two, in order to speed up development (less code to write, less design docs, less security review)”
improve the security of Chrome with less memory safety bugs
The Chromium team will focus on making Interop between C++ and Rust easier and more seamless while helping the Rust ecosystem through funding and contributions.
⛏💎 DreamerV3 : RL Strikes Back!
DeepMind released DreamerV3, a new reinforcement algorithm that claim to being able to collect diamonds in Minecraft without humane knowledge.
Collecting diamonds in Minecraft is a well-known challenge that’s hard to solve, even more for Reinforcement Learning agent as rewards are really sparsed and long to achieve.
To achieve those results, DeepMind built its algorithm into two parts, a word model learning and an actor-critic model.
The World Model Learning is built in six different parts :
An Encoder : Encoding the observation space into a discrete latent space
A Decoder : Reconstructing the observation space based on the discrete latent space
A Sequence Model : Predicting the next recurrent state based on the previous recurrent state, the latent space and the action taken.
A Dynamics Predictor : Reconstructing the discrete latent space based on recurrent state
A Reward and a Continue Predictors : One predicting the future reward and the other predicting wether the environment continue.
The Actor-Critic Learning part is pretty classic and straight-forward, the observation is provided to the encoder which returns the latent space, we pass it to the sequence model along with the recurrent state and the action taken, which returns a new recurrent state. With the dynamics predictor we can re-create the new latent space based on the recurrent state and so on. At each steps the reward and continue predictor is used to select which action to take.
Side note : One thing DreamerV3 has been criticized for is increasing the speed of block mining. This is part of the challenge of Minecraft, thus it seems unfair to compare DreamerV3 with other algorithms that have not made this change.
If you want to know more, here is the link to the paper.


🕵🏼♂️ Tracr : Hand-writing Transformer models
Tracr, also released by DeepMind, enlarge the field of model’s interpretability by being a tool allowing users “to create models that implement a known mechanism”. As the resulting model implement an already defined mechanism we can use it as a ground truth to compare it to output generated by the interpretability tool. We can see this as creating a benchmark to validate interpretability tools.
Tracr can be seen as a “compiler” for translating RASP programs into transformer model weights. User write the target operation using a modified version of RASP, the use craft to create its intermediate representation and finally retrieve the model’s weights and layers.
To know more about Tracr, its usage and limitations, read the paper.
Interesting stuff
AlpineJs: a rugged, minimal framework for composing JS behavior in your markup.
Faster virtual machines: Speeding up programming language execution
ORBIT: A Unified Simulation Framework for Interactive Robot Learning Environments
One Embedder, Any Task: Instruction-Finetuned Text Embeddings
ChatGPT knows Elon Musk is Twitter’s CEO, despite saying its learning cutoff was in 2021
Let’s discuss!
Follow on twitter @CobolStone
Join the community discord