Spaces:
Running
on
Zero
Running
on
Zero
Brainstorming backup
Browse files
app.py
CHANGED
@@ -61,6 +61,21 @@ compiled_model: AOTICompiledModel | None = None
|
|
61 |
|
62 |
@spaces.GPU
|
63 |
def run_model():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
global compiled_model
|
65 |
if compiled_model is None:
|
66 |
compiled_model = torch._inductor.aoti_load_package(package_path)
|
|
|
61 |
|
62 |
@spaces.GPU
|
63 |
def run_model():
|
64 |
+
# TODO: compiled model loading should actually go in worker init ...args: (path, weights)
|
65 |
+
# Something like: @spaces.GPU(aoti_load=(package_path, weights))
|
66 |
+
# It will probably solve the Driver runtime error when idle-reusing
|
67 |
+
# And avoids manually handling state with global
|
68 |
+
# Ou autrement :
|
69 |
+
# pipeline.transformer = ZeroGPUCompiledModel(pt2_path, weights)
|
70 |
+
# Puis les instances de ZeroGPUCompiledModel sont chargées automatiquement pendant le worker init
|
71 |
+
# C'est encore mieux ça (je crois que c'était l'idée que j'avais de base)
|
72 |
+
# Une inferface encore plus high-level ce serait :
|
73 |
+
# pipeline.transformer = ZeroGPUCompile(pipeline.transformer, kwargs=example_kwargs)
|
74 |
+
# Et la compilation avec @spaces.GPU, le packaging, les wiehgts séparées, etc.
|
75 |
+
# Tout ça serait géré automatiquement
|
76 |
+
# Bon mais faut laisser plusieurs niveaux d'abstraction je pense
|
77 |
+
# Et peut-être commencer par le low-level (voire pas d'helper du tout et tout en mode manuel mais pour le moment j'ai une driver context runtime error)
|
78 |
+
# Je vais quand-même pouvoir trouver un niveau d'abstraction idéal
|
79 |
global compiled_model
|
80 |
if compiled_model is None:
|
81 |
compiled_model = torch._inductor.aoti_load_package(package_path)
|