Spaces:
Running on L40S
Running on L40S
Enable torch compile for action viewer
Browse files
cosmos-framework/cosmos_framework/data/vfm/action/action_viz/app.py
CHANGED
|
@@ -773,7 +773,7 @@ def launch_action_viz(config: AppConfig) -> None:
|
|
| 773 |
dataset_split="full",
|
| 774 |
dataset_selector=loaded.adapter.dataset_selector,
|
| 775 |
dataset_kwargs=loaded.adapter.entry.dataset_kwargs,
|
| 776 |
-
use_torch_compile=
|
| 777 |
)
|
| 778 |
status_text.content = f"*Generating {generation_id}...*"
|
| 779 |
|
|
|
|
| 773 |
dataset_split="full",
|
| 774 |
dataset_selector=loaded.adapter.dataset_selector,
|
| 775 |
dataset_kwargs=loaded.adapter.entry.dataset_kwargs,
|
| 776 |
+
use_torch_compile=_env_enabled("ACTION_VIZ_USE_TORCH_COMPILE", default=True),
|
| 777 |
)
|
| 778 |
status_text.content = f"*Generating {generation_id}...*"
|
| 779 |
|
cosmos-framework/cosmos_framework/data/vfm/action/action_viz/local_worker.py
CHANGED
|
@@ -38,6 +38,13 @@ ACTION_NORMALIZATION_STATS_PATH = Path(__file__).with_name("normalization_stats.
|
|
| 38 |
PERSISTENT_RUNNER_ROOT = Path(os.environ.get("ACTION_VIZ_PERSISTENT_RUNNER_ROOT", "/tmp/action_viz_persistent_runner"))
|
| 39 |
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
class LocalGenerationWorker:
|
| 42 |
"""Generation worker that runs cosmos-framework in this Viser process."""
|
| 43 |
|
|
@@ -814,7 +821,7 @@ class _PersistentFrameworkRunner:
|
|
| 814 |
checkpoint_path=checkpoint_path,
|
| 815 |
output_dir=runner_output_dir,
|
| 816 |
parallelism_preset="latency",
|
| 817 |
-
use_torch_compile=
|
| 818 |
guardrails=False,
|
| 819 |
max_num_seqs=1,
|
| 820 |
)
|
|
|
|
| 38 |
PERSISTENT_RUNNER_ROOT = Path(os.environ.get("ACTION_VIZ_PERSISTENT_RUNNER_ROOT", "/tmp/action_viz_persistent_runner"))
|
| 39 |
|
| 40 |
|
| 41 |
+
def _env_enabled(name: str, default: bool) -> bool:
|
| 42 |
+
value = os.environ.get(name)
|
| 43 |
+
if value is None:
|
| 44 |
+
return default
|
| 45 |
+
return value.strip().lower() in {"1", "true", "yes", "on"}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
class LocalGenerationWorker:
|
| 49 |
"""Generation worker that runs cosmos-framework in this Viser process."""
|
| 50 |
|
|
|
|
| 821 |
checkpoint_path=checkpoint_path,
|
| 822 |
output_dir=runner_output_dir,
|
| 823 |
parallelism_preset="latency",
|
| 824 |
+
use_torch_compile=_env_enabled("ACTION_VIZ_USE_TORCH_COMPILE", default=True),
|
| 825 |
guardrails=False,
|
| 826 |
max_num_seqs=1,
|
| 827 |
)
|
start.sh
CHANGED
|
@@ -23,6 +23,7 @@ export ACTION_VIZ_GENERATE_IMAGE_SIZE="${ACTION_VIZ_GENERATE_IMAGE_SIZE:-480}"
|
|
| 23 |
export ACTION_VIZ_GENERATE_NUM_FRAMES="${ACTION_VIZ_GENERATE_NUM_FRAMES:-24}"
|
| 24 |
export ACTION_VIZ_GENERATE_NUM_STEPS="${ACTION_VIZ_GENERATE_NUM_STEPS:-30}"
|
| 25 |
export ACTION_VIZ_PERSISTENT_RUNNER="${ACTION_VIZ_PERSISTENT_RUNNER:-1}"
|
|
|
|
| 26 |
export PYTORCH_CUDA_ALLOC_CONF="${PYTORCH_CUDA_ALLOC_CONF:-expandable_segments:True}"
|
| 27 |
|
| 28 |
if [[ -z "${ACTION_VIZ_CHECKPOINT_LOCAL_PATH:-}" && -z "${ACTION_VIZ_MODEL_MOUNT_PATH:-}" ]]; then
|
|
@@ -55,6 +56,7 @@ echo "ACTION_VIZ_GENERATE_IMAGE_SIZE=${ACTION_VIZ_GENERATE_IMAGE_SIZE}"
|
|
| 55 |
echo "ACTION_VIZ_GENERATE_NUM_FRAMES=${ACTION_VIZ_GENERATE_NUM_FRAMES}"
|
| 56 |
echo "ACTION_VIZ_GENERATE_NUM_STEPS=${ACTION_VIZ_GENERATE_NUM_STEPS}"
|
| 57 |
echo "ACTION_VIZ_PERSISTENT_RUNNER=${ACTION_VIZ_PERSISTENT_RUNNER}"
|
|
|
|
| 58 |
echo "PYTORCH_CUDA_ALLOC_CONF=${PYTORCH_CUDA_ALLOC_CONF}"
|
| 59 |
echo "BRIDGE_LEROBOT_ROOT=${BRIDGE_LEROBOT_ROOT}"
|
| 60 |
echo "COSMOS_VIEWER_ON_DEMAND_VIDEO=${COSMOS_VIEWER_ON_DEMAND_VIDEO}"
|
|
|
|
| 23 |
export ACTION_VIZ_GENERATE_NUM_FRAMES="${ACTION_VIZ_GENERATE_NUM_FRAMES:-24}"
|
| 24 |
export ACTION_VIZ_GENERATE_NUM_STEPS="${ACTION_VIZ_GENERATE_NUM_STEPS:-30}"
|
| 25 |
export ACTION_VIZ_PERSISTENT_RUNNER="${ACTION_VIZ_PERSISTENT_RUNNER:-1}"
|
| 26 |
+
export ACTION_VIZ_USE_TORCH_COMPILE="${ACTION_VIZ_USE_TORCH_COMPILE:-1}"
|
| 27 |
export PYTORCH_CUDA_ALLOC_CONF="${PYTORCH_CUDA_ALLOC_CONF:-expandable_segments:True}"
|
| 28 |
|
| 29 |
if [[ -z "${ACTION_VIZ_CHECKPOINT_LOCAL_PATH:-}" && -z "${ACTION_VIZ_MODEL_MOUNT_PATH:-}" ]]; then
|
|
|
|
| 56 |
echo "ACTION_VIZ_GENERATE_NUM_FRAMES=${ACTION_VIZ_GENERATE_NUM_FRAMES}"
|
| 57 |
echo "ACTION_VIZ_GENERATE_NUM_STEPS=${ACTION_VIZ_GENERATE_NUM_STEPS}"
|
| 58 |
echo "ACTION_VIZ_PERSISTENT_RUNNER=${ACTION_VIZ_PERSISTENT_RUNNER}"
|
| 59 |
+
echo "ACTION_VIZ_USE_TORCH_COMPILE=${ACTION_VIZ_USE_TORCH_COMPILE}"
|
| 60 |
echo "PYTORCH_CUDA_ALLOC_CONF=${PYTORCH_CUDA_ALLOC_CONF}"
|
| 61 |
echo "BRIDGE_LEROBOT_ROOT=${BRIDGE_LEROBOT_ROOT}"
|
| 62 |
echo "COSMOS_VIEWER_ON_DEMAND_VIDEO=${COSMOS_VIEWER_ON_DEMAND_VIDEO}"
|