spitfire4794 commited on
Commit
57d2c8f
·
1 Parent(s): 28a1a01

Fix Space config: restore Docker SDK Dockerfile + frontmatter README

Browse files

The source-tree copy had clobbered both files (generic remote Dockerfile, CISM README without sdk frontmatter). This restores the Space entrypoint (fleet then serve /results on 7860) and the sdk: docker frontmatter.

Files changed (2) hide show
  1. Dockerfile +12 -21
  2. README.md +26 -193
Dockerfile CHANGED
@@ -1,20 +1,12 @@
1
- # CISM remote-autobench image: builds the native extension and runs the
2
- # full AutoBench matrix (all precisions x threads x spec K + HF baselines)
3
- # over a fleet of models. Results land in /results (mount a volume).
4
- #
5
- # Build: docker build -t cism-bench .
6
- # Full: docker run --rm -v $(pwd)/results:/results cism-bench
7
- # Quick: docker run --rm -v $(pwd)/results:/results cism-bench --quick
8
- # Custom: docker run --rm -v $(pwd)/results:/results cism-bench \
9
- # --models SupraLabs/Supra-Mini-v5-8M --out-dir /results --reps 1
10
- #
11
- # Notes:
12
- # - torch is installed CPU-only first (PyPI default would pull CUDA wheels);
13
- # the [reference] extra is then already satisfied and HF baselines run.
14
- # - The full 4-model fleet takes hours (inductor warmups + 72 cells x reps=3
15
- # per model). Use --quick for a smoke run (~minutes on one small model).
16
- # - Models download from the Hub on first run; mount an HF cache to reuse:
17
- # -v ~/.cache/huggingface:/root/.cache/huggingface
18
 
19
  FROM ubuntu:24.04
20
 
@@ -32,17 +24,16 @@ RUN python3 -m venv /opt/venv \
32
 
33
  WORKDIR /cism
34
 
35
- # Build deps first for layer caching; source last for fast rebuilds.
36
  COPY pyproject.toml README.md CMakeLists.txt ./
37
  COPY native/ native/
38
  COPY src/ src/
39
  COPY scripts/autobench_fleet.py scripts/autobench_fleet.py
 
40
 
41
  RUN pip install torch --index-url https://download.pytorch.org/whl/cpu \
42
  && pip install ".[test,server]" \
43
  && python -c "from cism import _native as n; print('kernel_variant:', n.kernel_variant())"
44
 
45
- VOLUME ["/results"]
46
 
47
- ENTRYPOINT ["python", "scripts/autobench_fleet.py"]
48
- CMD ["--out-dir", "/results"]
 
1
+ # CISM remote-autobench Space (CPU): builds the native extension, runs the
2
+ # full AutoBench fleet (all precisions x threads x spec K + HF baselines),
3
+ # then serves /results on 7860 so numbers stay browsable while the Space
4
+ # lives. Fleet selection without rebuild via Space Variables:
5
+ # CISM_MODELS (space-separated HF ids; default: 4-model fleet)
6
+ # CISM_OUT_DIR (default /results)
7
+ # Optional Secret for off-Space backup:
8
+ # HF_TOKEN (enables --upload-to below)
9
+ # CISM_UPLOAD_TO (dataset repo id; default spitfire4794/test1111111-results)
 
 
 
 
 
 
 
 
10
 
11
  FROM ubuntu:24.04
12
 
 
24
 
25
  WORKDIR /cism
26
 
 
27
  COPY pyproject.toml README.md CMakeLists.txt ./
28
  COPY native/ native/
29
  COPY src/ src/
30
  COPY scripts/autobench_fleet.py scripts/autobench_fleet.py
31
+ COPY entrypoint.sh ./
32
 
33
  RUN pip install torch --index-url https://download.pytorch.org/whl/cpu \
34
  && pip install ".[test,server]" \
35
  && python -c "from cism import _native as n; print('kernel_variant:', n.kernel_variant())"
36
 
37
+ EXPOSE 7860
38
 
39
+ ENTRYPOINT ["bash", "entrypoint.sh"]
 
README.md CHANGED
@@ -1,193 +1,26 @@
1
- # CISM
2
-
3
- Experimental native CPU inference with a Python SDK and OpenAI-compatible text
4
- server. Private development snapshot (`0.1.0.dev0`), **not the v0.1 beta yet**.
5
- No performance advantage over llama.cpp has been established.
6
-
7
- ## Implemented
8
-
9
- - Real C++20 autoregressive Llama/Qwen3 inference: RMSNorm, RoPE, GQA, SwiGLU,
10
- residuals, incremental KV, native greedy/top-k/top-p sampling.
11
- - Runtime-dispatched AVX2 FP32, weight-only INT8 and hybrid block-32 INT4 kernels,
12
- with scalar fallbacks. Activations remain FP32 in every mode.
13
- - Direct HF/local safetensors import, including BF16 conversion without PyTorch.
14
- - Python generation and bounded FIFO HTTP serving, SSE, usage, cancellation,
15
- optional bearer authentication, and strict unsupported-field errors.
16
- - One model and one active generation; single-threaded native execution.
17
-
18
- ## Build on Windows
19
-
20
- Install **Visual Studio 2022 Build Tools**, workload **Desktop development with
21
- C++**, including MSVC v143 x64/x86, Windows SDK, and C++ CMake tools.
22
- Use **Developer PowerShell for VS 2022**:
23
-
24
- ```powershell
25
- python -m venv .venv
26
- .venv\Scripts\python -m pip install ".[server,test]"
27
- .venv\Scripts\python -m pytest
28
- ```
29
-
30
- Python 3.11-3.13 is targeted. Build instructions above compile locally; prebuilt
31
- wheels are not distributed yet. No CUDA, MinGW, or full Visual Studio IDE needed.
32
-
33
- ## Build on Linux
34
-
35
- Install a C++20 compiler and Python development headers, then:
36
-
37
- ```bash
38
- python3 -m venv .venv
39
- .venv/bin/python -m pip install '.[server,test]'
40
- .venv/bin/python -m pytest
41
- ```
42
-
43
- Linux support is intended but must be validated on a Linux host before beta.
44
-
45
- ## Use
46
-
47
- ```python
48
- from cism import Engine
49
-
50
- engine = Engine.from_pretrained("SupraLabs/Supra-Mini-v5-8M", precision="int8")
51
- print(engine.info)
52
- print(engine.generate("The future of artificial intelligence is", max_new_tokens=32).text)
53
- ```
54
-
55
- ```text
56
- cism inspect SupraLabs/Supra-Mini-v5-8M
57
- cism generate SupraLabs/Supra-Mini-v5-8M --precision int8 --max-tokens 32
58
- cism bench SupraLabs/Supra-Mini-v5-8M --precision fp32 --runs 5
59
- cism serve SupraLabs/Supra-Mini-v5-8M --precision int8
60
- ```
61
-
62
- `--threads N` (all commands) runs decode with a persistent native worker pool;
63
- 2 threads is typically the sweet spot for cache-sized quantized models on
64
- desktop Zen 3 and is exposed per command. Matrix sizes below the parallel
65
- threshold stay on the calling thread regardless.
66
-
67
- `cism generate/bench --spec K` enables greedy prompt-lookup speculation
68
- (K in 2-8, requires temperature=0): an n-gram drafter proposes continuations
69
- from the token history and a GEMM verify pass accepts them in one weight
70
- stream. Output is identical to plain greedy decode. It pays off when the model
71
- streams from DRAM (larger than L3) and the text repeats prompt patterns; it
72
- gains little on cache-resident models or free-form text.
73
-
74
- `serve` accepts several models and routes requests by the `model` field through
75
- one shared FIFO worker, so only one generation runs at a time:
76
-
77
- ```text
78
- cism serve SupraLabs/Supra-Mini-v5-8M SupraLabs/Supra2-Medium-Base HuggingFaceTB/SmolLM2-135M --precision int8
79
- ```
80
-
81
- `--revision` pins a HF revision; resolved commits are reported in engine info.
82
- Use `--local-files-only` offline and `--trust-remote-code` only for trusted custom
83
- tokenizers. Native architecture support is never inferred from permission to run
84
- Python. Import caches use the HF snapshot cache; native packing currently repeats
85
- at model load rather than persisting a compiled artifact.
86
-
87
- ## HTTP
88
-
89
- Install the `server` extra. Default bind address: `127.0.0.1:8000`.
90
- Set `CISM_API_KEY` to require `Authorization: Bearer <key>`; unset/empty disables
91
- authentication. Run exactly one Uvicorn process.
92
-
93
- ```python
94
- from openai import OpenAI
95
-
96
- client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="unused")
97
- result = client.completions.create(
98
- model="SupraLabs/Supra-Mini-v5-8M",
99
- prompt="The future of artificial intelligence is",
100
- max_tokens=32,
101
- )
102
- print(result.choices[0].text)
103
- ```
104
-
105
- Endpoints: `/v1/completions`, `/v1/chat/completions`, `/v1/models`, `/health`,
106
- `/ready`. Chat requires a real tokenizer chat template; base models without one
107
- must use completions. Streaming supports `stream_options.include_usage`.
108
- `--queue-size` bounds active plus waiting/unconsumed requests (default 8).
109
- Unsupported request fields return an error; tools, JSON constraints, logprobs,
110
- embeddings, and Responses are **not implemented in this snapshot**.
111
-
112
- Over-budget `max_tokens` is clamped: generation runs until the model's context
113
- window fills and returns `finish_reason="length"` with accurate usage. Only a
114
- prompt that alone exceeds the model context is rejected. This limit is the
115
- checkpoint's trained `max_position_embeddings`, not a server preference.
116
-
117
- Stop strings are excluded from returned text. Usage counts sampled tokens,
118
- including stopping/EOS tokens. Chunked generation crosses the Python boundary in
119
- groups, except when stop strings require checking every token. Partial UTF-8 is
120
- held back during streaming. Custom tokenizers that rewrite already emitted text
121
- are explicitly rejected. Cancellation is cooperative; a matrix operation or
122
- allocation cannot be interrupted mid-operation.
123
-
124
- ## Web Tester
125
-
126
- The server serves a dependency-free test page at `http://127.0.0.1:8000/`.
127
- Pick any loaded model from `/v1/models`, choose completions or chat, set
128
- sampling parameters, and stream with live TTFT and tokens/s. Paste the API key
129
- if `CISM_API_KEY` is set; the page stores it only in your browser if you ask,
130
- and the server never embeds it in the HTML. All-whitespace results are labeled
131
- as greedy space-token loops.
132
-
133
- ## Memory And Cache Control
134
-
135
- x86 CPUs have no user-controllable way to pin L1/L2/L3 cache lines. While
136
- generating, weights stay cache-hot because the decoder rereads them constantly.
137
- During idle gaps, Windows, background processes, and other workloads evict
138
- lines, and nothing can forbid that. CISM therefore provides two real controls:
139
-
140
- - **Page locking.** `cism serve --lock-pages` (or `Engine.lock_pages()`) pins
141
- weight memory in physical RAM with `VirtualLock`/`mlock`, so the OS cannot
142
- page model memory to disk until `Engine.unlock_pages()`. The return value is
143
- the byte sum of successful OS calls; neighboring regions share pages, so
144
- lock/unlock counts are approximate. Verified on Windows: 8,022,880 of 8,022,784
145
- bytes locked for Supra-Mini-8M INT8.
146
- - **Keep-warm sweeps.** `cism serve --keep-warm SECONDS` (or
147
- `Engine.start_keep_warm(SECONDS)` / `stop_keep_warm()`) re-reads every weight
148
- byte on an interval while the engine is idle, refreshing cache residency.
149
- Sweeps pause during generation and stop when told; after stopping, hardware
150
- eviction proceeds naturally. `Engine.touch()` runs one sweep on demand.
151
-
152
- These reduce cold-start after idle; they do not reserve L3 or guarantee SRAM
153
- residency, and their effect should be measured, not assumed.
154
-
155
- ### Cache Report
156
-
157
- `cism cache-report MODEL` measures whether the cache actually matters for your
158
- model on this machine: a warm full-weight scan, a cold scan after evicting
159
- caches with a scrub buffer (`--scrub-mb`, about twice the L3 size), and the
160
- decode effective bandwidth (weight bytes x decode tok/s). It reports the
161
- warm/cold ratio, the residency verdict, and the decode bottleneck verdict
162
- (compute-bound, DRAM-streaming, or cache-bandwidth-limited). Definitive
163
- per-event counters (LLC misses) require external PMU tooling such as
164
- WindowsPerf or AMD uProf.
165
-
166
- ## Limits
167
-
168
- Only standard dense `LlamaForCausalLM` and `Qwen3ForCausalLM` with full attention,
169
- default split-half RoPE, SiLU MLP, and no biases are supported. Model-config limits
170
- are enforced; long-context extensions are not inferred. Original custom targets
171
- (Negative, CMA, Ember, Spark, Blaze) remain beta work, not Python fallbacks.
172
-
173
- Prefill is currently sequential, and there is no thread autotuner or persistent
174
- native pool. Weights, scales, KV,
175
- and scratch all compete for cache. CISM does not guarantee SRAM residency or
176
- reserve L3. The original weight-loop benchmark is not a decoder throughput test.
177
-
178
- See [the release plan](docs/ROADMAP.md) and [native details](native/README.md).
179
-
180
- ## Reference Validation
181
-
182
- Install the `reference` extra to compare against PyTorch/Transformers on CPU:
183
-
184
- ```text
185
- python scripts/validate_reference.py SupraLabs/Supra-Mini-v5-8M --precision fp32
186
- python scripts/validate_reference.py SupraLabs/Supra-Mini-v5-8M --precision int8
187
- python scripts/validate_reference.py veyra-ai/Veyra2-Blueberry-10M-Base --precision fp32
188
- ```
189
-
190
- Quantized numerical parity uses a reference reconstructed from the exact native
191
- quantization definition, not the original FP32 checkpoint. This tests kernel
192
- correctness, not preservation of model quality. Held-out quality reports and
193
- matched llama.cpp benchmarks remain release gates.
 
1
+ ---
2
+ title: Test1111
3
+ emoji: 📈
4
+ colorFrom: red
5
+ colorTo: yellow
6
+ sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ # CISM remote autobench
11
+
12
+ This Space builds the CISM native CPU inference engine and runs the full
13
+ AutoBench fleet on Space CPU: all four CISM precisions
14
+ (fp32/int8/hybrid-int4/hybrid-fp4) × thread sweep × spec-K sweep with
15
+ median-of-3 rigor + HF eager / dynamic-int8 / torch.compile baselines.
16
+
17
+ While the fleet runs, container logs stream per-cell progress. When each
18
+ model finishes, `<model>.json` plus `SUMMARY.md` appear here (this page serves
19
+ `/results`). Configure without rebuild via **Settings → Variables**:
20
+
21
+ - `CISM_MODELS` — space-separated HF ids (default: Supra Mini-8M, Supra-50M,
22
+ Surjo-50m, FWKV Myosotis-1-base)
23
+ - `CISM_OUT_DIR` — default `/results`
24
+
25
+ Optional **Secret** `HF_TOKEN` (+ Variable `CISM_UPLOAD_TO`) backs results up
26
+ to a dataset repo after the run.