Skip to content

Instantly share code, notes, and snippets.

View gary149's full-sized avatar

Victor Muštar gary149

View GitHub Profile
@gary149
gary149 / hf-spaces-agent-quickstart-compact.md
Last active June 25, 2026 18:01
HF Spaces Agent Quickstart (Compact) — distilled load-bearing rules for agents; full reference: https://gist.github.com/gary149/2aba2962375fa9ca56bb9ef53f00b73d

HF Spaces Agent Quickstart (Compact)


DO / NEVER

DO: Iterate ON the Space. Push early, verify against live URL. Stream logs. Read logs first, act once, make one targeted fix. Use cheapest iteration rung. Set all three cache env vars at module top, before any import. Measure @spaces.GPU(duration=) empirically. Call c.view_api() before any predict() call. python3 -m py_compile app.py is the maximum local check before pushing. Always ship 3–5 curated gr.Examples and cache them (cache_examples=True, cache_mode="lazy", with fn=/outputs= set) — find good inputs, not placeholders.

NEVER: Sleep-poll. Build mock modes, SKIP_MODEL_LOAD env vars, Playwright harnesses, or local Gradio servers. Restart before reading the error. Issue concurrent uploads. Restart while uploading. Stack restarts while runtime.sha is still flipping. Use integer device IDs (.to(0), device_map={"": 0}, set_device(0)). Pin torch or torchaudio. Proxy another community ZeroGPU Space via `gradio_c

@gary149
gary149 / ds4-kv-cache-explained.md
Created May 7, 2026 19:54
How ds4.c rethinks the KV cache: standard KV vs MLA vs disk-tier prefix caching

How ds4.c rethinks the KV cache

A long-form explanation of how transformer KV caching normally works, and the two layered ideas — Multi-head Latent Attention in DeepSeek V4 Flash, and disk-tier prefix caching in ds4.c — that together turn "every cold start re-prefills your 25k-token system prompt" into "you pay that cost once, ever."

What a "normal" KV cache is and why it exists

@gary149
gary149 / ds4-pi-onboarding.md
Created May 7, 2026 18:21
Run DeepSeek V4 Flash locally with ds4.c + Pi (10-min onboarding)

Local DeepSeek V4 Flash with ds4.c + Pi

A 10-minute setup to run DeepSeek V4 Flash (284B MoE, 1M context) locally as your Pi coding-agent backend. Uses ds4.c as the inference server and Pi as the agent.

What you need

  • Mac with Apple Silicon and ≥128 GB unified memory (M3 Max / M4 Max / M-Ultra).
  • ~100 GB free disk (81 GB for the q2 GGUF + headroom for the disk KV cache).
@gary149
gary149 / bench_cpu.py
Created May 6, 2026 07:46
Gemma 4 E4B-it: transformers MPS vs llama.cpp Metal on M4 Max
import time
import torch
from transformers import AutoProcessor, AutoModelForCausalLM
TARGET_MODEL_ID = "google/gemma-4-E4B-it"
MAX_NEW_TOKENS = 256
DEVICE = "cpu"
print(f"Using device: {DEVICE} | threads={torch.get_num_threads()}")

Session 95920b6f — Deploying chromadb/context-1 on HF Dedicated Endpoints

Goal

Research chromadb/context-1 (a 20B MoE retrieval model based on openai/gpt-oss-20b) and deploy an optimized HF Dedicated Endpoint for it.


Did it use the HF Endpoint Deploy CLI?

No. The hf CLI was installed and available — Claude used it for hf whoami and repo operations — but it was unaware that hf endpoints deploy exists. Instead, it went straight to hand-crafted curl calls against https://api.endpoints.huggingface.cloud/v2/, reverse-engineering the JSON schema by inspecting existing endpoints.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Super Platformer Adventure</title>
<style>
body {
margin: 0;
padding: 0;
@gary149
gary149 / agent loop
Created March 11, 2025 15:54 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet
import pygame
import sys
import math
import numpy as np
# Initialize pygame
pygame.init()
# Constants
WIDTH, HEIGHT = 800, 600

Text Generation Inference

Text Generation Inference (TGI) is a powerful toolkit for serving and optimizing open-source Large Language Models (LLMs). It powers production applications at Hugging Face (like HuggingChat and the Inference API) by combining:

  • High-performance inference with support for multiple architectures (Llama, Falcon, StarCoder, BLOOM, GPT-NeoX, etc.).
  • Batching, streaming, quantization, and other performance features for efficient GPU utilization.
  • Production-ready metrics and tracing (OpenTelemetry, Prometheus).

Below, you'll find how to install, configure, and use TGI to quickly serve your models.

# \*mizu

## Phase 1 — ELIGIBILITY

Enables *mizu.js* rendering for the element and its children.

```html
<main *mizu>   <!--...--> </main>