Skip to content

feat(examples/ai-finetune)#182

Open
ab-alien-dev wants to merge 3 commits into
itamar/ai-gatewayfrom
alan/alien-321-add-alienai-examples
Open

feat(examples/ai-finetune)#182
ab-alien-dev wants to merge 3 commits into
itamar/ai-gatewayfrom
alan/alien-321-add-alienai-examples

Conversation

@ab-alien-dev

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds cross-cloud AI fine-tuning and tuned-model gateway routing.

  • Adds Bedrock, Vertex AI, and Azure Foundry fine-tuning clients and provider controllers.
  • Extends AI resource schemas, TypeScript builders, bindings, permissions, imports, and generated artifacts.
  • Adds an OpenAI-compatible fine-tuning/inference example and gateway routing for tuned artifacts.

Confidence Score: 2/5

The PR is not safe to merge until fine-tuning updates are reconciled correctly and AWS/Azure stop silently ignoring the requested tuning method.

Accepted configurations can report successful updates while retaining stale tuned artifacts and routes, and AWS or Azure deployments requesting DPO or LoRA can silently train with a different provider-default method.

crates/alien-core/src/resources/ai.rs, crates/alien-infra/src/ai/aws.rs, crates/alien-infra/src/ai/azure.rs, crates/alien-infra/src/ai/gcp.rs

Important Files Changed

Filename Overview
crates/alien-core/src/resources/ai.rs Adds the fine-tuning resource contract, but update validation permits configuration changes that no-op provider update handlers do not reconcile.
crates/alien-infra/src/ai/aws.rs Adds the Bedrock tuning state machine, but silently collapses all requested tuning methods to the same request and performs no-op updates.
crates/alien-infra/src/ai/azure.rs Adds Foundry account, tuning, and deployment phases, but does not forward or reject the requested tuning method.
crates/alien-infra/src/ai/gcp.rs Adds Vertex tuning with explicit unsupported-method rejection, though its no-op update path participates in the incomplete update-validation defect.
crates/alien-gateway/src/router.rs Adds exact-match tuned-model routing while preserving the existing curated catalog paths.
crates/alien-azure-clients/src/azure/openai_finetuning.rs Adds the Foundry data-plane client and scoped authentication, but its request shape has no field through which the selected tuning method can be expressed.
crates/alien-aws-clients/src/aws/bedrock.rs Adds signed Bedrock customization-job create and polling operations with structured status and error handling.
packages/core/src/ai.ts Adds the TypeScript fine-tuning builder and forwards all generated fine-tuning options into the resource configuration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Spec["AI finetune specification"] --> Controller{"Cloud controller"}
  Controller -->|AWS| Bedrock["Bedrock tuning job"]
  Controller -->|GCP| Vertex["Vertex tuning job"]
  Controller -->|Azure| Foundry["Foundry tuning job"]
  Bedrock --> Artifact["Tuned artifact / deployment"]
  Vertex --> Artifact
  Foundry --> Artifact
  Artifact --> Binding["AI binding with served and upstream IDs"]
  Binding --> Gateway["Gateway tuned-model route"]
  Gateway --> Inference["Provider inference endpoint"]
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
crates/alien-core/src/resources/ai.rs:216-225
**Fine-tuning updates retain stale state**

When an existing AI resource changes `trainingKey`, `method`, or `servedModelId`, or adds or removes `finetune`, this validation accepts the update while the provider update handlers return directly to `Ready` without reconciling the tuning job or binding. The deployment reports success but continues serving the previous tuned artifact under the previous route, and newly added fine-tuning is never performed.

### Issue 2 of 2
crates/alien-infra/src/ai/aws.rs:23-28
**Requested tuning method is discarded**

When an AWS or Azure AI resource requests DPO or LoRA, the AWS controller maps every method to the same request without technique-specific hyperparameters, while Azure submits only the base model and training file. The deployment can therefore complete using the provider-default technique instead of the method selected in the public configuration.

Reviews (1): Last reviewed commit: "feat(examples/finetune)" | Re-trigger Greptile

Comment on lines +216 to +225
if let (Some(old), Some(new)) = (&self.finetune, &new_ai.finetune) {
if old.base_model != new.base_model || old.training_data != new.training_data {
return Err(AlienError::new(ErrorData::InvalidResourceUpdate {
resource_id: self.id.clone(),
reason: "finetune 'baseModel' and 'trainingData' are immutable; \
create a new AI resource to retrain"
.to_string(),
}));
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Fine-tuning updates retain stale state

When an existing AI resource changes trainingKey, method, or servedModelId, or adds or removes finetune, this validation accepts the update while the provider update handlers return directly to Ready without reconciling the tuning job or binding. The deployment reports success but continues serving the previous tuned artifact under the previous route, and newly added fine-tuning is never performed.

Knowledge Base Used: Provisioning Infra: Reconciliation Engine and IaC Generators

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/alien-core/src/resources/ai.rs
Line: 216-225

Comment:
**Fine-tuning updates retain stale state**

When an existing AI resource changes `trainingKey`, `method`, or `servedModelId`, or adds or removes `finetune`, this validation accepts the update while the provider update handlers return directly to `Ready` without reconciling the tuning job or binding. The deployment reports success but continues serving the previous tuned artifact under the previous route, and newly added fine-tuning is never performed.

**Knowledge Base Used:** [Provisioning Infra: Reconciliation Engine and IaC Generators](https://app.greptile.com/alien/-/custom-context/knowledge-base/alienplatform/alien/-/docs/provisioning-infra.md)

How can I resolve this? If you propose a fix, please make it concise.

Comment thread crates/alien-infra/src/ai/aws.rs Outdated
Comment on lines +23 to +28
/// Bedrock `customizationType` for a supervised / preference / LoRA fine-tune.
/// Bedrock's public model-customization API exposes `FINE_TUNING`; the specific
/// technique (SFT vs DPO vs LoRA) is selected per base model via hyperparameters,
/// not a distinct customizationType, so all `FinetuneMethod` variants map here.
fn bedrock_customization_type(_method: FinetuneMethod) -> &'static str {
"FINE_TUNING"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Requested tuning method is discarded

When an AWS or Azure AI resource requests DPO or LoRA, the AWS controller maps every method to the same request without technique-specific hyperparameters, while Azure submits only the base model and training file. The deployment can therefore complete using the provider-default technique instead of the method selected in the public configuration.

Knowledge Base Used: Provisioning Infra: Reconciliation Engine and IaC Generators

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/alien-infra/src/ai/aws.rs
Line: 23-28

Comment:
**Requested tuning method is discarded**

When an AWS or Azure AI resource requests DPO or LoRA, the AWS controller maps every method to the same request without technique-specific hyperparameters, while Azure submits only the base model and training file. The deployment can therefore complete using the provider-default technique instead of the method selected in the public configuration.

**Knowledge Base Used:** [Provisioning Infra: Reconciliation Engine and IaC Generators](https://app.greptile.com/alien/-/custom-context/knowledge-base/alienplatform/alien/-/docs/provisioning-infra.md)

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant