Skip to content
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

Shared filesystem caching #272

Merged
merged 23 commits into from
Oct 18, 2024
Merged

Shared filesystem caching #272

merged 23 commits into from
Oct 18, 2024

Conversation

nstogner
Copy link
Contributor

@nstogner nstogner commented Oct 12, 2024

  • Implements the shared filesystem cache in proposal here
  • Add support for shared-filesystem caching
  • Manually tested with dynamically provisioned and pre-provisioned GCP Filestore instance (see GCP doc)
  • Add integration test for cache logic
  • Add e2e test that leverages a kind hostpath volume
  • Update docs
  • Add huggingface-loader image build
  • Add validation to make sure cacheProfile is not used outside of hf:// urls.
  • Add validation to make url and cacheProfile immutable
  • Add integration test for validation logic
  • Add tests validating that FasterWhisper engine works with cache.

Scope creep:

  • Added additional field validation (replicas, minReplicas, maxReplicas)

Followup later (Issues submitted):

  • Add test validating that Infinity engine works with cache.
  • Submit a followup Issue to update the huggingface model loader image to the one that is built


set -euxo pipefail

huggingface-cli download --local-dir $MODEL_DIR $MODEL_REPO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow up, we may need to do some smarter logic that ensures only required files get downloaded. For example, some repos have both safetensors and pytorch. I can tackle this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#274 Added

@nstogner nstogner changed the title WIP: Shared filesystem caching Shared filesystem caching Oct 17, 2024
Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I have not had the time to review everything but first impression is great! 💪
I want to give it another 👁️ tomorrow but don't feel blocked by me.

internal/k8sutils/jobs.go Outdated Show resolved Hide resolved
internal/modelcontroller/cache.go Outdated Show resolved Hide resolved
internal/modelcontroller/model_controller.go Outdated Show resolved Hide resolved
internal/modelcontroller/model_controller.go Outdated Show resolved Hide resolved
internal/modelcontroller/model_controller.go Outdated Show resolved Hide resolved
internal/modelcontroller/model_controller.go Outdated Show resolved Hide resolved
internal/modelcontroller/model_controller.go Show resolved Hide resolved
},
}); err != nil {
if !apierrors.IsNotFound(err) {
return fmt.Errorf("deleting job %q: %w", jobName, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personal preference: Good scenario for errors.Join() if there is a chance that any of the next deletes could succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cant think of many scenarios where a subsequent delete might succeed, I am going to leave as-is and allow exp-backoff of the Reconciler to take effect on this.

internal/modelcontroller/cache.go Show resolved Hide resolved
@nstogner nstogner added the enhancement New feature or request label Oct 18, 2024
@nstogner
Copy link
Contributor Author

@alpe Thanks for the review!

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more nits and comments.
I had no chance to try it but utack

internal/modelcontroller/cache.go Outdated Show resolved Hide resolved
internal/modelcontroller/cache.go Outdated Show resolved Hide resolved
internal/modelcontroller/cache.go Outdated Show resolved Hide resolved
internal/modelcontroller/cache.go Show resolved Hide resolved
Image: c.Image,
Args: args,
Env: env,
Resources: corev1.ResourceRequirements{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not setting the SecurityContext: r.ModelServerPods.ModelContainerSecurityContext here, like on the other engines. Is there a reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #278

test/integration/model_validation_test.go Outdated Show resolved Hide resolved
// ollama run nomic-embed-text hey
// Error: "nomic-embed-text" does not support generate
//
startupProbeScript += fmt.Sprintf(" && /bin/ollama run %s hi", m.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the purpose of this call is to verify the model is downloaded.
There is a simpler way to achieve the same:

./ollama show nomic-embed-text --modelfile

will return quicker with some metadata or fail with an error code when the server is not running or the model not available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #277 to track to avoid scope creep

@nstogner
Copy link
Contributor Author

@alpe Really appreciate the in-depth review. I addressed most comments and opened issues for others.

@nstogner nstogner merged commit 5e8f2c5 into main Oct 18, 2024
11 checks passed
@nstogner nstogner deleted the shared-filesystem-caching branch October 18, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants