Skip to content

Instantly share code, notes, and snippets.

import argparse
import random
import mlx.core as mx
import mlx.nn as nn
import numpy as np
from mlx.utils import tree_map
from mlx_lm.models.qwen3 import Model, ModelArgs
MODEL_LAYERS = 2
@xangma
xangma / n_params.py
Created February 24, 2026 20:40
307 params? Kinda?
import argparse
import hashlib
import random
import mlx.core as mx
import numpy as np
from mlx.utils import tree_map
from mlx_lm.models.qwen3 import Model, ModelArgs
MODEL_LAYERS = 2
import argparse
import random
import mlx.core as mx
import mlx.nn as nn
import numpy as np
from mlx.utils import tree_map
from mlx_lm.models.qwen3 import Model, ModelArgs
MODEL_LAYERS = 2

'Hi!'

"It's nice to meet you. Is there something I can help you with or would you like to chat?"

"Nice to meet you too! I'm doing well, thanks for asking. I don't have any specific tasks or questions at the moment, so a chat sounds lovely. How about we talk about something interesting? What's been the highlight of your day or week so far?"

"I'm glad you're open to a chat. As a digital AI assistant, I don't have personal experiences or emotions like humans do, but I've had some fascinating conversations with users recently. One topic that stood out was a discussion about the latest advancements in space exploration and the potential for human settlements on Mars. It's amazing to think about how far technology has come and what the future might hold. I'd love to explore more interesting topics with you, though! Are you interested in science, history, culture, or something else? We could talk about a recent book or movie you've enjoyed, or even share some fun facts or trivia. What sounds intriguing to you?

@xangma
xangma / gist:5bf5e43253315e3e03f4fd9c935e3205
Created October 9, 2024 02:24
Batch verification code
DATA_SIZE = 9999999
AVG_TIMES = 10
VERIFICATION_BATCHES = 10 # Number of batches to verify for correctness
MANUAL_VERIFICATION = True # Set to False to skip manual verification
result = []
for BATCH_SIZE in (4, 8, 64, 640, 6400, 64000):
for DROP_LAST in (True, False):
print(f"Batch size: {BATCH_SIZE}, Drop last: {DROP_LAST}")
@xangma
xangma / launch.json
Last active December 27, 2025 02:57
debugging mpirun with vscode - launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"compounds": [
{
"name": "Python: mpirun launch",
"configurations": [
"mpirun script.py",
01-10 00:24:59.544 5091 5255 I twitter.androi: Waiting for a blocking GC ProfileSaver
01-10 00:24:59.639 5091 5255 I twitter.androi: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 95.247ms
01-10 00:24:59.795 5340 5422 I android:browse: Waiting for a blocking GC ProfileSaver
01-10 00:24:59.809 5340 5422 I android:browse: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 13.545ms
01-10 00:25:00.030 5231 5231 I RenderThread: type=1400 audit(0.0:87156): avc: denied { read write } for path="/dev/mali0" dev="tmpfs" ino=11279 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1 app=com.android.systemui
01-10 00:25:00.158 5875 5875 I init : type=1400 audit(0.0:87157): avc: denied { execute } for name="vendor.samsung.hardware.radio.configsvc@1.0-service" dev="sda19" ino=136 scontext=u:r:init:s0 tcontext=u:object_r:vendor_file:s0 tclass=file permissive=1
01-10 00:25:00.158 5875 5875 I init : type=1400 audit(0.0:87158): avc: denied {
01-10 00:32:51.088 7736 7736 F linker : CANNOT LINK EXECUTABLE "/vendor/bin/hw/vendor.samsung.hardware.radio.configsvc@1.0-service": library "vendor.samsung.hardware.radio.configsvc@1.0.so" not found
01-10 00:32:51.240 31289 31291 D libgps : OnGpsExtensionMessage: message_id(1), data(0x73a38a8044), size(4304)
01-10 00:32:51.240 31289 31291 E libgps : Internal error in ../../../../home/ubuntu/workspace/brew_latte/45728_368628/customers/samsung/StarFlagtailandroid/delivery/libgps/libgps.cpp:185
01-10 00:32:51.241 31289 31291 D libgps : proxy__gnss_sv_status_cb: called. num_svs(11)
01-10 00:32:51.244 31289 31291 E libgps : IPC Communication Error, ../../../../home/ubuntu/workspace/brew_latte/45728_368628/allPartners/os/android/gps_interface/gpsi_client/GpsiClient.cpp:758 marshal_gps_location_cb
01-10 00:32:51.680 31293 31293 D gpsd : WakeLock(Acquire,SUPL)
01-10 00:32:51.674 4663 4663 I suspend@1.0-ser: type=1400 audit(0.0:87846): avc: denied { transfer } for scontext=u:r:system_suspend:s0 tcontext=u