-
Notifications
You must be signed in to change notification settings - Fork 1
Add Pathways Integration #31
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7453b29
initial pathways integration
divyashreepathihalli 20a54ab
add pathways example
divyashreepathihalli 01ac7b7
fix core
divyashreepathihalli 3a69ed8
code reformat
divyashreepathihalli 08881d9
auto detect lws version
divyashreepathihalli 8085ae3
code reformat
divyashreepathihalli 2769b1f
address gemini comment
divyashreepathihalli d4e97b6
address Gemini comment
divyashreepathihalli 83eca73
address comments
divyashreepathihalli 50cf0c2
code reformat
divyashreepathihalli b010eb6
map internal APIs to standard Multi-Host Eenv specs
divyashreepathihalli 364d81d
address jeff's comment
divyashreepathihalli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import os | ||
|
|
||
| os.environ["KERAS_BACKEND"] = "jax" | ||
|
|
||
| import keras | ||
| import numpy as np | ||
| from keras import layers | ||
|
|
||
| import keras_remote | ||
|
|
||
|
|
||
| # A simple model that will be executed remotely on pathways | ||
| @keras_remote.run(accelerator="v5litepod-1", backend="pathways") | ||
| def train_simple_model(): | ||
| print("Running Pathways job on JAX Backend!") | ||
|
|
||
| # Create a simple dataset | ||
| x = np.random.rand(1000, 10) | ||
| y = np.random.randint(0, 2, size=(1000, 1)) | ||
|
|
||
| # A simple sequential model | ||
| model = keras.Sequential( | ||
| [ | ||
| keras.Input(shape=(10,)), | ||
| layers.Dense(32, activation="relu"), | ||
| layers.Dense(16, activation="relu"), | ||
| layers.Dense(1, activation="sigmoid"), | ||
| ] | ||
| ) | ||
|
|
||
| model.compile( | ||
| optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"] | ||
| ) | ||
|
|
||
| print("Model Architecture:") | ||
| model.summary() | ||
|
|
||
| # Train the model | ||
| print("\nStarting Training...") | ||
| history = model.fit(x, y, epochs=5, batch_size=32, validation_split=0.2) | ||
|
|
||
| print("\nTraining completed successfully on Pathways!") | ||
| return history.history | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| print("Submitting Pathways training job...") | ||
| result_history = train_simple_model() | ||
| print("Final validation accuracy:", result_history["val_accuracy"][-1]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, there are no user code changes to run on Pathways within their remote function? All it needs is
backend="pathways"? That's pretty coolThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah if it is None. It auto detects if the user requested for a multi node TPU and picks the pathways backend