Commit ·
ee2c158
1
Parent(s): b2d7c0e
Prepare Space for aim4composites T4 deployment
Browse files- DEPLOYMENT.md +51 -0
- EMAIL_TO_DR_LI.md +28 -0
- README.md +17 -8
- app.py +7 -4
- requirements.txt +0 -1
DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face migration notes
|
| 2 |
+
|
| 3 |
+
This repository was pulled from:
|
| 4 |
+
|
| 5 |
+
- source Space: `https://huggingface.co/spaces/ChemFM/MaterialInverseDesignDemo`
|
| 6 |
+
|
| 7 |
+
Target destination:
|
| 8 |
+
|
| 9 |
+
- destination org: `https://huggingface.co/aim4composites`
|
| 10 |
+
|
| 11 |
+
## What changed for `Nvidia T4 small`
|
| 12 |
+
|
| 13 |
+
- README front matter now recommends `suggested_hardware: t4-small`
|
| 14 |
+
- `spaces` was removed from `requirements.txt` because this deployment is intended for a dedicated GPU Space rather than ZeroGPU
|
| 15 |
+
- the app text no longer describes the Space as ZeroGPU-only
|
| 16 |
+
- runtime knobs were added so the thermoforming step can be tuned without code edits:
|
| 17 |
+
- `MG_DEFAULT_N_GENERATE`
|
| 18 |
+
- `MG_MAX_GENERATE`
|
| 19 |
+
- `MG_THERMO_RESTARTS`
|
| 20 |
+
- `MG_THERMO_EPOCHS`
|
| 21 |
+
|
| 22 |
+
## Recommended Hugging Face Space settings
|
| 23 |
+
|
| 24 |
+
1. Create a new Gradio Space under `aim4composites`.
|
| 25 |
+
2. Push this repository to that new Space.
|
| 26 |
+
3. In the Space hardware settings, choose `Nvidia T4 small`.
|
| 27 |
+
4. Leave storage at the default unless larger artifacts are added later.
|
| 28 |
+
5. After credits are added, restart the Space and verify logs show CUDA is available.
|
| 29 |
+
|
| 30 |
+
## Suggested first validation pass
|
| 31 |
+
|
| 32 |
+
1. Open the Space and load the default test condition.
|
| 33 |
+
2. Run material inverse design with the default `3` candidates.
|
| 34 |
+
3. Select the top-ranked design.
|
| 35 |
+
4. Run thermoforming once with a small target example.
|
| 36 |
+
5. Confirm:
|
| 37 |
+
- the app starts successfully
|
| 38 |
+
- candidate generation completes
|
| 39 |
+
- thermoforming completes
|
| 40 |
+
- no out-of-memory or timeout errors appear in the logs
|
| 41 |
+
|
| 42 |
+
## Optional runtime tuning if the Space feels slow
|
| 43 |
+
|
| 44 |
+
Set these Space variables:
|
| 45 |
+
|
| 46 |
+
- `MG_DEFAULT_N_GENERATE=2`
|
| 47 |
+
- `MG_MAX_GENERATE=4`
|
| 48 |
+
- `MG_THERMO_RESTARTS=6`
|
| 49 |
+
- `MG_THERMO_EPOCHS=300`
|
| 50 |
+
|
| 51 |
+
If runtime remains comfortably fast, increase these gradually.
|
EMAIL_TO_DR_LI.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Subject: Request to enable Hugging Face credits for `aim4composites` Space deployment
|
| 2 |
+
|
| 3 |
+
Hi Dr. Li,
|
| 4 |
+
|
| 5 |
+
I migrated the `ChemFM/MaterialInverseDesignDemo` Hugging Face Space code so it is ready to be deployed under the `aim4composites` organization and configured for `Nvidia T4 small`.
|
| 6 |
+
|
| 7 |
+
The target hardware we plan to use is:
|
| 8 |
+
|
| 9 |
+
- `Nvidia T4 small`
|
| 10 |
+
- `4 vCPU`
|
| 11 |
+
- `15 GB RAM`
|
| 12 |
+
- `16 GB VRAM`
|
| 13 |
+
- currently listed by Hugging Face at `$0.40/hour`
|
| 14 |
+
|
| 15 |
+
At the moment, I cannot fully validate the hosted deployment because the `aim4composites` organization does not yet have credits available for paid GPU hardware.
|
| 16 |
+
|
| 17 |
+
Could you please purchase or enable enough Hugging Face credits for the organization so we can:
|
| 18 |
+
|
| 19 |
+
1. assign `Nvidia T4 small` to the new Space,
|
| 20 |
+
2. launch the app under the target hardware,
|
| 21 |
+
3. run one end-to-end validation pass, and
|
| 22 |
+
4. confirm the final deployment is stable.
|
| 23 |
+
|
| 24 |
+
Once the credits are available, I can test the Space immediately and report back on startup, inference, and thermoforming performance.
|
| 25 |
+
|
| 26 |
+
Best,
|
| 27 |
+
|
| 28 |
+
[Your Name]
|
README.md
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
---
|
| 2 |
-
title: Quarter V5 Inverse Design
|
| 3 |
sdk: gradio
|
|
|
|
| 4 |
app_file: app.py
|
|
|
|
|
|
|
| 5 |
pinned: false
|
| 6 |
---
|
| 7 |
|
| 8 |
-
# Quarter V5 Inverse Design
|
| 9 |
|
| 10 |
-
Local Gradio-first scaffold for
|
|
|
|
| 11 |
|
| 12 |
Key points:
|
| 13 |
|
|
@@ -16,17 +20,22 @@ Key points:
|
|
| 16 |
- keeps `vxy` and `vyx` as `2`-input requirements
|
| 17 |
- generates `3` candidates and selects the closest one
|
| 18 |
- runs thermoforming from the selected design
|
| 19 |
-
- is
|
| 20 |
|
| 21 |
## Local run
|
| 22 |
|
| 23 |
```bash
|
| 24 |
-
|
| 25 |
-
/home/feiyang/miniconda3/envs/ChemFMNew/bin/python app.py
|
| 26 |
```
|
| 27 |
|
| 28 |
-
## Notes for HF Space deployment
|
| 29 |
|
| 30 |
-
- ZeroGPU is Gradio-only and requires the `spaces` package plus a `@spaces.GPU` wrapper on GPU work.
|
| 31 |
- This folder now bundles the quarter-v5 checkpoint, the minimal metadata/test files needed for inference, and the quarter simulation assets under `assets/`.
|
| 32 |
- Local absolute paths are optional overrides through `MG_CHECKPOINT_DIR`, `MG_DATA_DIR`, `MG_CURVE_DIR`, and `MG_QUARTER_DATA_GEN_DIR`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Quarter V5 Inverse Design
|
| 3 |
sdk: gradio
|
| 4 |
+
python_version: "3.10"
|
| 5 |
app_file: app.py
|
| 6 |
+
suggested_hardware: t4-small
|
| 7 |
+
startup_duration_timeout: 1h
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Quarter V5 Inverse Design
|
| 12 |
|
| 13 |
+
Local Gradio-first scaffold for migrating the Space from `ChemFM/MaterialInverseDesignDemo`
|
| 14 |
+
to `aim4composites` on Hugging Face GPU hardware.
|
| 15 |
|
| 16 |
Key points:
|
| 17 |
|
|
|
|
| 20 |
- keeps `vxy` and `vyx` as `2`-input requirements
|
| 21 |
- generates `3` candidates and selects the closest one
|
| 22 |
- runs thermoforming from the selected design
|
| 23 |
+
- is configured to run on a dedicated Hugging Face `Nvidia T4 small` Space
|
| 24 |
|
| 25 |
## Local run
|
| 26 |
|
| 27 |
```bash
|
| 28 |
+
python app.py
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
+
## Notes for HF Space deployment on `t4-small`
|
| 32 |
|
|
|
|
| 33 |
- This folder now bundles the quarter-v5 checkpoint, the minimal metadata/test files needed for inference, and the quarter simulation assets under `assets/`.
|
| 34 |
- Local absolute paths are optional overrides through `MG_CHECKPOINT_DIR`, `MG_DATA_DIR`, `MG_CURVE_DIR`, and `MG_QUARTER_DATA_GEN_DIR`.
|
| 35 |
+
- The Space recommends `t4-small` via `suggested_hardware`, but Hugging Face will not assign paid hardware automatically. The hardware still needs to be selected in the Space settings after credits are available.
|
| 36 |
+
- Thermoforming latency is mostly CPU-bound. Dedicated tuning knobs are exposed through:
|
| 37 |
+
- `MG_DEFAULT_N_GENERATE`
|
| 38 |
+
- `MG_MAX_GENERATE`
|
| 39 |
+
- `MG_THERMO_RESTARTS`
|
| 40 |
+
- `MG_THERMO_EPOCHS`
|
| 41 |
+
- Default settings are chosen to stay practical on `Nvidia T4 small` (`4 vCPU`, `15 GB RAM`, `16 GB VRAM`) while keeping the main inverse-design path on GPU.
|
app.py
CHANGED
|
@@ -60,9 +60,12 @@ CURVE_DIR = DEFAULT_CURVE_DIR
|
|
| 60 |
NORMALIZATION_METHOD = "zscore"
|
| 61 |
ANGLE_RESOLUTION = 1.0
|
| 62 |
DEFAULT_N_GENERATE = 3
|
| 63 |
-
MAX_N_GENERATE =
|
|
|
|
| 64 |
GPU_DURATION_SEC = int(os.environ.get("ZEROGPU_DURATION", "90"))
|
| 65 |
DEFAULT_TEST_INDEX = int(os.environ.get("MG_DEFAULT_TEST_INDEX", "512"))
|
|
|
|
|
|
|
| 66 |
MATERIAL_TYPE_NAMES = {0: "CPP", 1: "CHDPE", 2: "GPP", 3: "GHDPE"}
|
| 67 |
|
| 68 |
|
|
@@ -588,8 +591,8 @@ def ui_thermoforming(selected_label: str, payload: str, angle_a: float, angle_b:
|
|
| 588 |
ply_number=n_layers,
|
| 589 |
fiber_vf=float(selected["vf"]),
|
| 590 |
y_target=[float(angle_a), float(angle_b), float(angle_c), float(max_stress)],
|
| 591 |
-
n_restarts=
|
| 592 |
-
epochs=
|
| 593 |
)
|
| 594 |
warning_md = ""
|
| 595 |
if domain_issues:
|
|
@@ -627,7 +630,7 @@ def build_app():
|
|
| 627 |
with gr.Blocks(css=css) as demo:
|
| 628 |
gr.Markdown("# Quarter Material Inverse Design")
|
| 629 |
gr.Markdown(
|
| 630 |
-
"
|
| 631 |
"Requirement curves are defined first, then batched candidates are generated, "
|
| 632 |
"the closest design is selected, and thermoforming is run from that selected design."
|
| 633 |
)
|
|
|
|
| 60 |
NORMALIZATION_METHOD = "zscore"
|
| 61 |
ANGLE_RESOLUTION = 1.0
|
| 62 |
DEFAULT_N_GENERATE = 3
|
| 63 |
+
MAX_N_GENERATE = int(os.environ.get("MG_MAX_GENERATE", "6"))
|
| 64 |
+
DEFAULT_N_GENERATE = min(int(os.environ.get("MG_DEFAULT_N_GENERATE", str(DEFAULT_N_GENERATE))), MAX_N_GENERATE)
|
| 65 |
GPU_DURATION_SEC = int(os.environ.get("ZEROGPU_DURATION", "90"))
|
| 66 |
DEFAULT_TEST_INDEX = int(os.environ.get("MG_DEFAULT_TEST_INDEX", "512"))
|
| 67 |
+
THERMO_N_RESTARTS = int(os.environ.get("MG_THERMO_RESTARTS", "6"))
|
| 68 |
+
THERMO_EPOCHS = int(os.environ.get("MG_THERMO_EPOCHS", "300"))
|
| 69 |
MATERIAL_TYPE_NAMES = {0: "CPP", 1: "CHDPE", 2: "GPP", 3: "GHDPE"}
|
| 70 |
|
| 71 |
|
|
|
|
| 591 |
ply_number=n_layers,
|
| 592 |
fiber_vf=float(selected["vf"]),
|
| 593 |
y_target=[float(angle_a), float(angle_b), float(angle_c), float(max_stress)],
|
| 594 |
+
n_restarts=THERMO_N_RESTARTS,
|
| 595 |
+
epochs=THERMO_EPOCHS,
|
| 596 |
)
|
| 597 |
warning_md = ""
|
| 598 |
if domain_issues:
|
|
|
|
| 630 |
with gr.Blocks(css=css) as demo:
|
| 631 |
gr.Markdown("# Quarter Material Inverse Design")
|
| 632 |
gr.Markdown(
|
| 633 |
+
"Dedicated-GPU Gradio app for the quarter-v5 model. "
|
| 634 |
"Requirement curves are defined first, then batched candidates are generated, "
|
| 635 |
"the closest design is selected, and thermoforming is run from that selected design."
|
| 636 |
)
|
requirements.txt
CHANGED
|
@@ -5,6 +5,5 @@ numpy
|
|
| 5 |
pandas
|
| 6 |
openpyxl
|
| 7 |
pyyaml
|
| 8 |
-
spaces
|
| 9 |
torch==2.8.0
|
| 10 |
tqdm
|
|
|
|
| 5 |
pandas
|
| 6 |
openpyxl
|
| 7 |
pyyaml
|
|
|
|
| 8 |
torch==2.8.0
|
| 9 |
tqdm
|