-
Notifications
You must be signed in to change notification settings - Fork 7.2k
[data][llm][doc] Add in resiliency section and refine doc code #60594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ Modin | |
| [Mm]ultiget(s)? | ||
| ndarray(s)? | ||
| NLP | ||
| [Oo]mni | ||
| [Oo]utqueue(s)? | ||
| PDFs | ||
| PIL | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| """ | ||
|
|
||
| # __basic_llm_example_start__ | ||
| import os | ||
| import shutil | ||
| import ray | ||
| from ray.data.llm import vLLMEngineProcessorConfig, build_processor | ||
|
|
||
|
|
@@ -125,6 +127,66 @@ | |
| ) | ||
| # __s3_config_example_end__ | ||
|
|
||
| base_dir = "/tmp/llm_checkpoint_demo" | ||
| input_path = os.path.join(base_dir, "input") | ||
| output_path = os.path.join(base_dir, "output") | ||
| checkpoint_path = os.path.join(base_dir, "checkpoint") | ||
|
|
||
| # Reset directories | ||
| for path in (input_path, output_path, checkpoint_path): | ||
| shutil.rmtree(path, ignore_errors=True) | ||
| os.makedirs(path) | ||
|
|
||
| # __row_level_fault_tolerance_config_example_start__ | ||
| # Row-level fault tolerance configuration | ||
| config = vLLMEngineProcessorConfig( | ||
| model_source="unsloth/Llama-3.1-8B-Instruct", | ||
| concurrency=1, | ||
| batch_size=64, | ||
| should_continue_on_error=True, | ||
| ) | ||
| # __row_level_fault_tolerance_config_example_end__ | ||
|
|
||
| # __checkpoint_config_setup_example_start__ | ||
| from ray.data.checkpoint import CheckpointConfig | ||
|
|
||
| ctx = ray.data.DataContext.get_current() | ||
| ctx.checkpoint_config = CheckpointConfig( | ||
| id_column="id", | ||
| checkpoint_path=checkpoint_path, | ||
| delete_checkpoint_on_success=False, | ||
| ) | ||
| # __checkpoint_config_setup_example_end__ | ||
|
|
||
| # __checkpoint_usage_example_start__ | ||
| processor_config = vLLMEngineProcessorConfig( | ||
| model_source="unsloth/Llama-3.1-8B-Instruct", | ||
| concurrency=1, | ||
| batch_size=16, | ||
| ) | ||
|
|
||
| processor = build_processor( | ||
| processor_config, | ||
| preprocess=lambda row: dict( | ||
| id=row["id"], # Preserve the ID column for checkpointing | ||
| prompt=row["prompt"], | ||
| sampling_params=dict( | ||
| temperature=0.3, | ||
| max_tokens=10, | ||
| ), | ||
| ), | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| postprocess=lambda row: { | ||
| "id": row["id"], # Preserve the ID column for checkpointing | ||
| "answer": row.get("generated_text"), | ||
| }, | ||
jeffreywang-anyscale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| ds = ray.data.read_parquet(input_path) | ||
| ds = processor(ds) | ||
| ds.write_parquet(output_path) | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # __checkpoint_usage_example_end__ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checkpoint demo runs during module importHigh Severity The new checkpoint example executes at import time: it deletes and recreates |
||
|
|
||
|
|
||
| # __gpu_memory_config_example_start__ | ||
| # GPU memory management configuration | ||
| # If you encounter CUDA out of memory errors, try these optimizations: | ||
|
|
@@ -199,8 +261,8 @@ def create_embedding_processor(): | |
| ), | ||
| batch_size=8, | ||
| concurrency=1, | ||
| apply_chat_template=False, | ||
| detokenize=False, | ||
| chat_template_stage=False, | ||
| detokenize_stage=False, | ||
| ) | ||
|
|
||
|
|
||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.