notes from the margins
and yes, it is not very good, but SOTA for something. There are many like it, but this one is mine.
I recently found myself with some time and Modal credits, so I decided to train an LLM from scratch. While I had the pleasure of being involved in post-training (and a tiny bit of pre-training) and eval of models in the past years, I wanted to see if I can do it myself end to end. The outcome is Malama, named after the beach where I was thinking through most of the decisions for it. It is a 1B parameter model that uses the GLM tokenizer and Kimi Delta Attention alongside full attention and was pretrained on 100B tokens before running SFT and RL on coding problems. This set of choices probably does not make sense for a commercial effort but it was not really the goal to build a practical model. Malama is fundamentally undertrained for its size as I spent credits on the end to end process rather than optimizing for pretraining. It was a lot of fun, especially exploring different avenues.

I was able to make it competitive on the HumanEval and MBPP benchmarks (for its size). On coding (LiveCodeBench) it trails recent models even though this is the niche it was trained on. The training mostly relied on existing datasets, especially from NVIDIA. I admit, I was looking at some distillation by proxy in the form of incorporating open source repositories that had signs of recent contribution by frontier models. Especially for the SFT stage I used larger open source models (Qwen3-30B-A3B, DeepSeek V4 Flash, and public DeepSeek-R1 datasets) to provide reasoning trajectories, and Qwen3-30B-A3B to filter problems for the RL stage, where rewards came from running unit tests in a sandbox.

The exercise really emphasized the importance of good high quality data, especially ones that contain a lot of information per token. I tried myself to add to the public collection of datasets and scraped together about 1B tokens of EU published documents, but I found that they make the model actually worse not better. Most of the documents are semi-autogenerated and have a lot of low information boilerplate. In hindsight this is not very surprising. It updated my bias that critical breakthroughs in the next years will not come from novel architecture or techniques but from finding high quality pools of data that are information dense or increasing sample efficiency on existing data.
Doing some initial size and training token estimates and then seeing it come through in the training run felt like training models is a lot more science than art.

It was a delight how agents were able to help me formulate experiments and side quests, and run them quickly on Modal. For example, I was able to play around with making an earlier version a looped model - there was no benefit, as the problems are currently still in the pretraining phase rather than in the reasoning changes. Models are also insanely good at writing custom kernels given a verification function to improve speed in all parts of the process.
Besides the choice of data, architecture and training regimes, a decent part of the time was spent on fixing various problems with resuming and parallelizing training runs. I consider myself lucky that everything fit on an 8xH100 box and I did not worry about training across multiple hosts. Maintaining and fixing the training runs felt very similar to large scale data processing pipelines that I spent a lot of my early career dealing with.
I deliberately wanted training to be defined as workflows of the form:
as to be able to explore the space of ideas, which meant taking on a bunch of complexity enabling the work to fit together.

Seeing the model go from gibberish to slowly forming sentences and more complex answers as the parameter and pretraining token count increased felt like noise coalescing into a beautiful picture. Both attention and state space models feel like very pure articulations of reasoning. Especially state space models to me are one of the most clear mathematical definitions of memory / state and I was delighted to find how KDA is a descendant of SSMs and attention.
To me, training an LLM was unexpectedly beautiful.
Thank you to Modal for providing credits and more importantly easy to use infrastructure and for the many people working on open source LLMs that have contributed to the shared understanding of how to create these models, especially the new crop of open source neo labs (Thinking Machines, Mirendil, Recursive, Ricursive, Flapping Airplanes, and Open Athena / Marin).
Here are two unedited passing generations from Malama v0.0.1 (taken from the evaluation logs in jfrick/lm-exploration-results). You can also try prompting Malama v0.0.1 and earlier checkpoints in the playground.
abc387_b — easy)Prompt: Given an integer X, find the sum of all integers in the 9×9 multiplication table that are not equal to X.
<think>)Okay, I need to solve this problem. Let me read the question carefully.
The problem is about 9x9 multiplication table. Each cell has i*j. I need to find the sum of all numbers in the grid that are not equal to X. So, if X is present in the grid, I subtract all occurrences of X from the total sum of all numbers, then add the rest. Wait, no. Wait the problem says: "sum of those that are not X". So total_sum_total = sum of all 81 numbers in the grid. Then subtract the sum of all cells that have value X. So the answer is (total_sum_total - sum_of_X_cells) ?
Yes, that makes sense. So first, I need to calculate the total sum of all 81 numbers in the grid. Then subtract the sum of all numbers in cells where the value is X.
...
Testing sample 1: when X=1, the code loops i from 1-9, j from 1-9.
Only cell (1,1) has val=1. So sum_x += 1. All other cells are not 1. So total_sum is 81 + 7*18 = 81 + 126 = 202? Wait maybe not. Let me compute the total_sum.
Wait perhaps not. The sample 1's explanation says the answer is 2024, which suggests that the total_sum is 2024 + 1 = 2025? No. Wait sample 1's explanation says sum of all except 1 is 2024. So total_sum must be 2025 (sum of 1 is 1, so 2025-1=2024). So yes, the code's answer is correct.
Thus, the code seems to handle all samples correctly.
Edge cases: when X is not in the grid. For example, X=11. Then sum_x is 0. So answer is total_sum.
Another edge case: X=81. Then check if any cell has 81. But 9*9=81. So if X=81, then that cell (9,9) has value 81. So sum_x includes that. So answer is total_sum - 81.
Yes, the code handles that.
Thus, the Python code is as written above.
X = int(input())
total_sum = 0
sum_x = 0
for i in range(1, 10):
for j in range(1, 10):
val = i * j
total_sum += val
if val == X:
sum_x += val
answer = total_sum - sum_x
print(answer)
HumanEval/4 — mean_absolute_deviation)Prompt: For a given list of input numbers, calculate the Mean Absolute Deviation around the mean of this dataset.
<think>)Okay, I need to write a Python function called mean_absolute_deviation that takes a list of numbers and computes the mean absolute deviation. Let me think about the steps here.
So, the problem says for each number in the list, I have to compute the absolute difference between each number and the mean of all the numbers. Then take the average of those absolute differences. Wait, maybe not. Wait the formula is something like the average of the absolute deviations of each number from the mean value.
Alternatively maybe the steps are:
1. Compute the mean of all the numbers in the list.
2. Compute the sum of absolute differences between each number and the mean.
3. Divide that sum by the number of elements to get the average absolute deviation.
...
Testing the sample input: [1,2,3,4]
Mean is 2.5
Each number's difference: 1-2.5 is 1.5, absolute 1.5; 2-2.5 is 0.5, absolute 0.5; 3-2.5 is 0.5, absolute 0.5; 4-2.5 is 1.5. So sum is 1.5+0.5+0.5+1.5 = 4.0? Wait maybe not. Wait 1.5+0.5+0.5+1.5 = 4.0. Then divided by 4 gives 1.0. Which matches the sample output. So the code works for the sample.
Edge cases: like all numbers same. Like [5,5,5] mean 5, differences 0. So 0.0. Another case like [0,0,1] mean 0.5, differences 0.5, 0.5, sum 1.0 /3= 0.333333... which would be 0.3333333333.
Yes, the code seems right.
def mean_absolute_deviation(numbers):
if not numbers:
return 0.0
mean = sum(numbers) / len(numbers)
total_diff = 0
for num in numbers:
total_diff += abs(num - mean)
return total_diff / len(numbers)