Skip to content

Instantly share code, notes, and snippets.

View hsqStephenZhang's full-sized avatar
🎯
Focusing

z combinator hsqStephenZhang

🎯
Focusing
View GitHub Profile
@hsqStephenZhang
hsqStephenZhang / read_dyn.mim
Created October 30, 2026 15:13
repro of runtime extent in joachim's bugfix/bufferize-dynamic branch
plugin core;
plugin tensor;
plugin mem;
fun extern probe {n: Nat} (a: «n; I32»): I32 =
return (%tensor.get @(I32, 1, n) (a, %core.idx n 0 0));
con extern main (m: %mem.M 0, argc: I32, argv: %mem.Ptr (%mem.Ptr (I8, 0), 0), return: Cn [%mem.M 0, I32]) =
let n = %core.nat.add (%core.bitcast Nat argc, 4);
let a = %tensor.repeat @(I32, 1) 4 n (11I32, 22I32, 33I32, 44I32);
@hsqStephenZhang
hsqStephenZhang / macos-finder-quick-action-verification.md
Created July 22, 2026 20:36
cardinal finder service verification

macOS Finder Quick Action Verification

This document verifies that Cardinal's macOS packaging exposes and installs the Finder Quick Action through both the DMG and Homebrew Cask paths.

Scope

The Finder integration is an Automator Quick Action, not a Finder Sync extension. The workflow opens Cardinal through the public URL scheme:

@hsqStephenZhang
hsqStephenZhang / prost-reflect-optimization-plan.md
Created July 19, 2026 11:43
prost-reflect 优化计划:descriptor 编译、专用 decoder 与列式直写

prost-reflect 优化计划

1. 背景与目标

prost-reflect 面向运行时未知 schema,核心路径是 DynamicMessage::decode。它无法直接使用静态 prost::Message derive 生成的 merge_raw、字段顺序预测和 canonical key redirect,因此优化重点应从“编译期生成 Rust 类型”转向“descriptor 加载后编译专用 decoder”。

总体目标:保持现有反射 API 和所有权语义,在 schema 稳定复用时减少 descriptor 查找、动态分派、临时 Value 和 repeated/map 分配。

2. 基线与测量

@hsqStephenZhang
hsqStephenZhang / prost-hyperpb-optimization-summary.md
Last active July 19, 2026 12:56
Prost 解码器的 HyperPB 风格优化总结

Prost 解码器的 HyperPB 风格优化总结

背景

本次工作将 HyperPB“利用 schema 静态信息缩短 protobuf 热路径”的思路应用到 Rust prost。目标是在保留可变 Message、通用 Buf、分段输入和错误语义的前提下,将 schema、canonical key、常见字段顺序和 packed 元素宽度提前 partial evaluate 到生成代码中。

已实现的优化

1. 连续 slice fast path

@hsqStephenZhang
hsqStephenZhang / t_pipelined_performance_test_and_reproduction.md
Last active July 17, 2026 09:14
Tilelang `T.Pipelined` Performance Test Results and Reproduction on A100

T.Pipelined Performance Test Results and Reproduction Guide

Test Objective

For the same FP16 GEMM kernel, keep the block size and thread count fixed, and vary only T.Pipelined(..., num_stages=0/1/2/3) to observe when software pipelining delivers measurable performance gains.

The benchmark script is available at bench.py.

Test Environment

@hsqStephenZhang
hsqStephenZhang / leetcode_inspect.rs
Last active July 14, 2026 12:25
leetcode inspection for fun
impl Solution {
// it's a hack target on [two sums](https://leetcode.com/problems/two-sum/)
// you may change the signature and return value to match the leetcode question you are working on.
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
println!("module_path!() = {}", module_path!());
println!("line!() = {}", line!());
println!("exe: {:?}", std::env::current_exe());
println!("cwd: {:?}", std::env::current_dir());
@hsqStephenZhang
hsqStephenZhang / test_llama_export.py
Last active July 9, 2026 10:04
torch-mlir export llama
import torch
from transformers import AutoModelForCausalLM, LlamaConfig
import torch_mlir.fx as fx
from torch._subclasses.fake_tensor import FakeTensorMode
from torch.utils._mode_utils import no_dispatch
print("Configuring tiny Llama model...")
config = LlamaConfig(
vocab_size=1000,
hidden_size=128,
@hsqStephenZhang
hsqStephenZhang / triu_e2e_test.md
Last active July 7, 2026 12:00
end to end test for

source

  1. save the following content to path/to/triu.mlir
module {
  func.func @main(%arg0: !torch.vtensor<[4,4],f32>) -> !torch.vtensor<[4,4],f32> {
    %int1 = torch.constant.int 1
    %0 = torch.aten.triu %arg0, %int1 : !torch.vtensor<[4,4],f32>, !torch.int -> !torch.vtensor<[4,4],f32>
    return %0 : !torch.vtensor<[4,4],f32>
@hsqStephenZhang
hsqStephenZhang / iree_24261_flow.mlir
Last active July 6, 2026 14:20
iree issue 24261 generated mlir
module attributes {stream.affinity.default = #hal.device.affinity<@__device_0>} {
util.global private @__device_0 = #hal.device.target<"local", [#hal.executable.target<"llvm-cpu", "embedded-elf-x86_64", {cpu = "generic", cpu_features = "", data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", iree.encoding.resolver = #iree_cpu.cpu_encoding_resolver<>, max_stack_allocation_size = 32768 : i64, native_vector_size = 16 : i64, target_triple = "x86_64-unknown-unknown-eabi-elf"}>]> : !hal.device
flow.executable private @test$async_dispatch_0 {
flow.executable.export public @test$async_dispatch_0_elementwise_broadcast workgroups() -> (index, index, index) {
%c1 = arith.constant 1 : index
flow.return %c1, %c1, %c1 : index, index, index
}
builtin.module {
func.func @test$async_dispatch_0_elementwise_broadcast(%arg0: !iree_tensor_ext.dispatch.tensor<readonly:tensor<2xi64>>, %arg1: !iree_tensor_ext.dispatch.tensor<writeonly:tensor<i64>>) {