# 3. 데이터 준비

S3에 데이터를 업로드하면 FSx for Lustre의 `/fsx/datasets/`에 자동으로 동기화됩니다. 이 섹션에서는 GR00T N1.7 Fine-tuning에 사용할 LeRobot v2 형식 데이터셋을 준비합니다.

***

## FSx for Lustre와 Data Repository Association

**FSx for Lustre란?**

FSx for Lustre는 AWS가 제공하는 **고처리량 병렬 파일 시스템**으로, 기계학습 및 고성능 컴퓨팅(HPC) 워크로드를 위해 설계되었습니다.

* **고속 처리**: 수백 GB/s의 처리량으로 대용량 데이터셋을 빠르게 읽고 쓸 수 있습니다.
* **병렬 I/O**: 여러 노드가 동시에 같은 파일에 접근할 수 있습니다 (POSIX 호환).
* **데이터 분산**: 대용량 파일이 클러스터의 여러 노드에 자동으로 분산되어 각 노드에서 병렬로 처리됩니다.

**Data Repository Association (DRA)란?**

DRA는 FSx for Lustre와 S3 간의 자동 동기화 메커니즘입니다:

* **자동 Import**: S3 버킷의 새로운 파일과 변경된 파일이 자동으로 FSx로 동기화됩니다.
* **자동 Export**: FSx에서 생성한 결과 파일이 자동으로 S3에 업로드됩니다 (선택 사항).
* **백그라운드 작업**: DRA는 백그라운드에서 동작하므로 학습 작업에 영향을 주지 않습니다.
* **비용 최적화**: S3는 저렴한 장기 스토리지, FSx는 빠른 임시 스토리지로 역할을 나누어 비용을 절감합니다.

**동기화 흐름:**

```
로컬 → S3 업로드 → FSx (DRA 자동 동기화) → Head Node에서 읽기/처리
```

***

## GR00T N1.7 개요

**GR00T N1.7**은 NVIDIA의 생성형 로봇 운영 체계(Generalist Robot Operating System Transformer)의 1.7 버전으로, 다양한 로봇 형태에 대응하는 통합 기반 모델입니다.

* **고급 행동 인식**: 더 정밀한 세밀 제어와 멀티모달 입력 처리
* **확장성**: 다양한 센서 구성과 로봇 형태에 대응
* **개선된 Fine-tuning**: LeRobot v2 형식의 데이터로 효율적인 적응 학습 가능

***

### 3.1 LeRobot v2 데이터 형식

GR00T 모델은 [LeRobot v2 형식](https://huggingface.co/docs/lerobot/dataset_format)의 데이터셋을 사용합니다. 이 형식은 로봇 행동 데이터를 표준화된 구조로 저장합니다:

```
/fsx/datasets/groot/<robot_name>/
├── meta/
│   ├── info.json          # 데이터셋 메타 정보
│   ├── episodes/          # 에피소드별 프레임 범위 (parquet 형식)
│   │   └── chunk-000/
│   │       └── episode_000000.parquet
│   └── tasks.parquet      # 태스크 설명
├── data/
│   ├── chunk-000/
│   │   ├── file-000.parquet       # 상태/액션 데이터
│   │   ├── file-001.parquet
│   │   └── file-002.parquet
│   └── ...
└── videos/
    └── observation.images.top/
        └── chunk-000/
            └── file-000.mp4       # 카메라 영상
```

**주요 필드 설명:**

| 필드                                        | 설명                               | 예시                                                                   |
| ----------------------------------------- | -------------------------------- | -------------------------------------------------------------------- |
| `meta/info.json`                          | 데이터셋 전체 설정 (로봇 이름, 샘플링 속도, 관절 수) | `{"robot_type": "aloha", "fps": 50}`                                 |
| `episodes/`                               | 각 에피소드의 프레임 범위 및 메타 (parquet 형식) | `episode_index, length, task_index` 컬럼                               |
| `tasks.parquet`                           | 각 에피소드의 태스크 설명                   | `task_index, task` 컬럼                                                |
| `data/chunk-xxx/episode_xxxxxx.parquet`   | 타임스텝별 센서 데이터 및 제어 신호. 각 행은 한 프레임 | `{timestamp, joint_positions, joint_velocities, gripper_state, ...}` |
| `videos/chunk-xxx/.../episode_xxxxxx.mp4` | 각 센서로부터 수집한 영상 데이터               | RGB 이미지 또는 깊이 영상                                                     |

**parquet 파일 컬럼 예시:**

```
observations.state.joint_positions    # 각 관절의 위치 (shape: [6,])
observations.state.joint_velocities   # 각 관절의 속도 (shape: [6,])
observations.images.top               # 상단 카메라 RGB 이미지
observations.images.wrist             # 손목 카메라 RGB 이미지
actions.joint_targets                 # 목표 관절 위치 (shape: [6,])
actions.gripper_targets               # 그리퍼 제어 신호 (0.0~1.0)
```

***

### 3.2 데이터 업로드 (S3 → FSx 자동 동기화)

로컬 또는 CloudShell에서 S3에 데이터를 업로드합니다:

```bash
BUCKET="hyperpod-data-hyperpod-<userId>-<ACCOUNT_ID>-us-east-1"

# 데이터셋 업로드
aws s3 cp ./my-dataset/ s3://${BUCKET}/datasets/groot/my-robot/ --recursive
```

**예상 출력:**

```
upload: ./my-dataset/meta/info.json to s3://hyperpod-data-hyperpod-.../datasets/groot/my-robot/meta/info.json
upload: ./my-dataset/data/chunk-000/episode_000000.parquet to s3://...
...
```

{% hint style="info" %}
S3 버킷 이름은 CDK 출력의 `S3BucketName`에서 확인할 수 있습니다.
{% endhint %}

***

### 3.3 FSx 동기화 확인

S3에 업로드 후 수분 내에 FSx에 동기화됩니다. Head Node에서 확인:

```bash
# Head Node에서 실행 (수분 대기)
ls /fsx/datasets/groot/my-robot/
```

**예상 출력:**

```
data  meta  videos
```

**상세 확인:**

```bash
# meta 파일 확인
ls /fsx/datasets/groot/my-robot/meta/
# episodes  info.json  stats.json  tasks.parquet

# 데이터 파일 확인
ls /fsx/datasets/groot/my-robot/data/chunk-000/
# file-000.parquet  file-001.parquet  file-002.parquet

# 영상 파일 확인
ls /fsx/datasets/groot/my-robot/videos/observation.images.top/chunk-000/
# file-000.mp4
```

{% hint style="warning" %}
**DRA 동기화 특성:**

* **새로운 파일과 수정된 파일**: 자동으로 동기화됩니다 (수초\~수분)
* **파일 삭제**: S3에서 파일을 삭제해도 FSx의 파일은 즉시 반영되지 않을 수 있습니다
* **기존 파일의 부분 수정**: DRA는 파일 단위로 동기화하므로, 매우 큰 파일의 일부만 수정해도 전체 파일이 다시 동기화됩니다

따라서 대용량 데이터 전송 시에는 차라리 여러 개의 작은 파일로 나누어 업로드하는 것이 효율적입니다.
{% endhint %}

***

### 3.4 빠른 테스트: 내장 데모 데이터 사용

Isaac-GR00T 저장소에 포함된 DROID 샘플 데이터를 사용하면 별도 다운로드 없이 바로 학습을 테스트할 수 있습니다:

```bash
# 내장 데모 데이터 확인
ls /fsx/scratch/Isaac-GR00T/demo_data/droid_sample/
# data/  meta/  videos/
```

데이터셋을 `/fsx/datasets/groot/` 경로에 복사하여 사용할 수도 있습니다:

```bash
mkdir -p /fsx/datasets/groot
cp -r /fsx/scratch/Isaac-GR00T/demo_data/droid_sample /fsx/datasets/groot/demo_data
```

{% hint style="info" %}
학습 sbatch 스크립트는 기본적으로 `/fsx/datasets/groot/demo_data` 경로를 사용합니다. 별도 복사 없이 `DATASET_PATH=/fsx/scratch/Isaac-GR00T/demo_data/droid_sample`로 직접 지정해도 됩니다.
{% endhint %}

### 3.5 HuggingFace에서 GR00T 호환 데이터셋 다운로드

Head Node에서 HuggingFace Hub의 공개 데이터셋을 직접 다운로드할 수도 있습니다:

```bash
# 가상환경 활성화 후 실행
source /fsx/envs/gr00t/bin/activate

# 내장 데이터셋 복사 (가장 빠름)
python3 /fsx/scratch/aws-physical-ai-recipes/training/hyperpod/examples/vla/download_dataset.py --name droid_sample

# HuggingFace에서 aloha 데이터셋 다운로드
python3 /fsx/scratch/aws-physical-ai-recipes/training/hyperpod/examples/vla/download_dataset.py --name aloha
```

다른 데이터셋 옵션:

```bash
# pusht 데이터셋
python3 /fsx/scratch/aws-physical-ai-recipes/training/hyperpod/examples/vla/download_dataset.py --name pusht

# 커스텀 HuggingFace 데이터셋
python3 /fsx/scratch/aws-physical-ai-recipes/training/hyperpod/examples/vla/download_dataset.py \
  --repo-id lerobot/xarm_lift_medium_human \
  --output /fsx/datasets/groot/xarm
```

**대체 데이터셋 옵션:**

HuggingFace에서 제공하는 다른 LeRobot v2 형식 데이터셋들:

| 데이터셋               | repo\_id                                | 설명                 |
| ------------------ | --------------------------------------- | ------------------ |
| ALOHA (Simulation) | `lerobot/aloha_sim_transfer_cube_human` | 시뮬레이션 큐브 픽킹 (초보자용) |
| ALOHA (Real)       | `lerobot/aloha_real_1_episodes`         | 실제 ALOHA 로봇        |
| Pusht              | `lerobot/pusht_sim`                     | 탁자 밀기 작업           |
| Xarm               | `lerobot/xarm_lift_medium_human`        | Xarm 7 로봇          |

***

### 3.6 데이터 검증

데이터셋이 올바른 LeRobot v2 형식인지 확인합니다:

```bash
source /fsx/envs/gr00t/bin/activate

python3 /fsx/scratch/aws-physical-ai-recipes/training/hyperpod/examples/vla/prepare_dataset.py \
  --dataset-path /fsx/datasets/groot/demo_data \
  --validate
```

**예상 출력:**

```
Dataset: /fsx/datasets/groot/demo_data
Validating LeRobot v2 format...
  ✓ All checks passed
  Episode shards: 1
  Data shards: 3
  Video files: 1
```

***

### 3.7 학습 준비 완료 확인

GR00T 학습을 시작하기 전에 최종 확인:

```bash
# 데이터셋 전체 크기 확인
du -sh /fsx/datasets/groot/aloha/

# FSx 여유 공간 확인 (데이터셋보다 충분한지)
df -h /fsx/
```

**예상 출력:**

```
du -sh: 450M

df -h:
Filesystem            Size  Used Avail Use% Mounted on
10.0.x.x@tcp:/fsx   1.2T  500M  1.2T  1% /fsx
```

{% hint style="info" %}
다음 단계: [4. VLA 학습 실행](/physical-ai-on-aws/physical-ai-on-aws-guide/hyperpod-distributed-training/4.-vla-training.md)에서 GR00T N1.7 Fine-tuning 작업을 SLURM으로 제출합니다.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hi-space.gitbook.io/physical-ai-on-aws/physical-ai-on-aws-guide/hyperpod-distributed-training/3.-data-preparation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
