hutash-inference 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: hutash-inference
3
+ Version: 0.2.5
4
+ Summary: Shared HTTP inference framework for Hutash models
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/Appsork/hutash
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: fastapi
9
+ Requires-Dist: uvicorn
10
+ Requires-Dist: python-multipart
11
+ Requires-Dist: accelerate>=0.28.0
12
+ Provides-Extra: image
13
+ Requires-Dist: pillow>=10.0.0; extra == "image"
@@ -0,0 +1,57 @@
1
+ # hutash_inference
2
+
3
+ Shared inference framework for Hutash model packages. A model package
4
+ supplies `manifest.yaml` and an `inference.py` with a `load()` and one
5
+ method per declared capability; this package supplies everything else —
6
+ FastAPI app, routing, input parsing, output encoding, park/unpark, and
7
+ the hardware workarounds below.
8
+
9
+ ## Hardware notes
10
+
11
+ ### GTX 16xx (compute capability 7.5) — fp16 convolution
12
+
13
+ GTX 16xx (compute capability 7.5) has a known fp16 convolution defect in
14
+ cuDNN. hutash_inference auto-disables cuDNN on these cards. This affects
15
+ image and video model generation only. LLMs and audio models are
16
+ unaffected.
17
+
18
+ The failure is silent rather than loud: cuDNN's half-precision
19
+ convolution returns NaN, the NaN propagates through the UNet into the
20
+ latents, the VAE decodes NaN to zeros, and the model answers `200 OK`
21
+ with a completely black image. fp16 *matmul* on the same card is correct,
22
+ which is why text and audio stacks never notice.
23
+
24
+ Measured on a GTX 1650, one 320×64×64 convolution:
25
+
26
+ | Path | absmax |
27
+ |------|--------|
28
+ | fp16 conv | `nan` |
29
+ | fp32 conv | 244.98 |
30
+ | fp16 conv, cuDNN off | 245.00 |
31
+
32
+ The last two agreeing is the reason for the fix: the arithmetic is
33
+ correct and only cuDNN's kernel is wrong, so disabling cuDNN restores
34
+ fp16 rather than giving precision up. Forcing fp32 would also work
35
+ numerically but doubles weight residency — roughly 3.4 GB for a Stable
36
+ Diffusion 1.5 UNet alone — which does not fit the 4 GB cards this
37
+ mostly affects.
38
+
39
+ Applied once per process from `Inference.__init__`, before any model's
40
+ `load()` runs, since it changes how every convolution afterwards is
41
+ computed. See `_apply_cudnn_fp16_workaround` in `base.py`.
42
+
43
+ **Known false positive.** The check is compute capability `(7, 5)`
44
+ exactly, which also matches the RTX 20 series (2060/2070/2080). Those
45
+ cards have tensor cores and correct fp16, so they lose cuDNN's faster
46
+ convolution kernels for no reason — a speed cost on a healthy card,
47
+ never a wrong result. Narrowing it means probing one convolution for
48
+ NaN at startup instead of reading a capability tuple.
49
+
50
+ ## Low VRAM mode
51
+
52
+ When the engine starts a model with a VRAM budget it sets
53
+ `HUTASH_VRAM_BUDGET_MB` and `HUTASH_MODEL_FRAMEWORK` in the model
54
+ process. `server.py` translates the budget into whatever knob the
55
+ framework understands — `device_map`/`max_memory` for HuggingFace,
56
+ `n_gpu_layers` for llama.cpp — so a model's `inference.py` needs no
57
+ Low-VRAM code of its own.
@@ -0,0 +1,65 @@
1
+ """Aura Inference Library
2
+
3
+ Shared framework for Aura model containers. Provides:
4
+ - Inference base class that all model inference classes inherit from
5
+ - @capability decorator for marking methods as HTTP endpoint handlers
6
+ - FastAPI server boilerplate
7
+ - I/O helpers (audio, image, video, file) — `encode_image` for image output,
8
+ `sniff_audio_suffix` / `sniff_image_format` / `sniff_video_format` for
9
+ what arrived
10
+ - Validation (model.yaml / manifest.json <-> inference.py compatibility)
11
+
12
+ See docs/strategy/model-ssot-architecture.md for architecture details.
13
+ """
14
+
15
+ from hutash_inference.base import (
16
+ IMAGE_FORMATS,
17
+ IMAGE_MEDIA_TYPES,
18
+ VIDEO_FORMATS,
19
+ VIDEO_INPUT_FORMATS,
20
+ VIDEO_MEDIA_TYPES,
21
+ Inference,
22
+ capability,
23
+ encode_image,
24
+ resolve_local_weights_dir,
25
+ sniff_audio_suffix,
26
+ sniff_image_format,
27
+ sniff_video_format,
28
+ )
29
+ from hutash_inference.errors import (
30
+ HutashInferenceError,
31
+ ValidationError,
32
+ ModelLoadError,
33
+ GenerationError,
34
+ )
35
+
36
+ # Kept in step with pyproject.toml BY HAND. 0.2.3 is UNRELEASED: PyPI serves
37
+ # 0.2.2, and every model pipeline installs `hutash-inference>=0.2.2` from PyPI,
38
+ # so a container runs the published release and not this tree. The source being
39
+ # ahead of the release is normal.
40
+ #
41
+ # This directory is the ONE tree of record as of 2026-09-07. It was previously
42
+ # two: an in-app copy under hutash-app/ that carried the image and video work,
43
+ # and this one, which carried `sniff_audio_suffix` and nothing else new. They
44
+ # were merged here and the in-app copy deleted, so publishing from anywhere
45
+ # else is no longer possible.
46
+ __version__ = "0.2.5"
47
+
48
+ __all__ = [
49
+ "Inference",
50
+ "capability",
51
+ "resolve_local_weights_dir",
52
+ "encode_image",
53
+ "sniff_audio_suffix",
54
+ "sniff_image_format",
55
+ "sniff_video_format",
56
+ "IMAGE_FORMATS",
57
+ "IMAGE_MEDIA_TYPES",
58
+ "VIDEO_FORMATS",
59
+ "VIDEO_INPUT_FORMATS",
60
+ "VIDEO_MEDIA_TYPES",
61
+ "HutashInferenceError",
62
+ "ValidationError",
63
+ "ModelLoadError",
64
+ "GenerationError",
65
+ ]