Opinion by Judge ALARCON; Dissent by Judge FERNANDEZ.
ALARCON, Circuit Judge:John W. Windham (“Windham”), a California state prisoner, appeals pro se from the denial of his federal petition for a writ of habeas corpus filed pursuant to 28 U.S.C. § 2254. He asserts deprivations of rights protected under the Fifth, Sixth, Eighth and Fourteenth Amendments. After summarizing the relevant facts, we address each of these contentions separately. We affirm in part and vacate and remand in part with directions for the district court to afford the petitioner a chance to demonstrate cause for defaulting his federal constitutional right and any prejudice that has resulted.
I
Windham and Barry . Dewayne Woods (“Woods”) were convicted after trial by jury of murder in the first degree, attempted murder, and two counts of assault with a firearm. The jury also found that Woods personally used a firearm in the commission of the charged offenses and separately found that a principal in the offenses charged against Windham was armed with a firearm.
During the relevant period, Susan Allen (“Allen”) and her sister, Trudy Johnson (“Johnson”), lived together in an apartment on LaSandia Way in Sacramento. Mayse Walker (“Walker”) was a friend of Allen’s son. Approximately two weeks before Christmas Day in 1989, Walker brought four automobile tires to Allen’s apartment. He asked her if he could store them in her apartment. Allen agreed.
On or about December 18, 1989, Walker shot Jerry Barkus (“Barkus”) in the foot. Eugene Woods and Windham were with Bar-kus when he was shot.
Herbert James (“James”), Allen’s neighbor, testified that late in the evening, on December 26, 1989 he observed a man in a red ski mask beat up a neighbor named Magoo. Several men were watching. The man in the red ski mask, whom James subsequently identified as co-defendant Woods, had a large pistol. After the beating, sometime between 11:00 p.m. and 12:00 p.m., four of the men proceeded to Allen’s apartment. Woods kicked open the front door. He and *1096the others entered the apartment. Windham remained outside, approximately 500 feet from the apartment.
Once inside, the intruders demanded to know Walker’s whereabouts. During the intrusion, Johnson was shot in the foot. Alien was forced to lie on the floor with a gun held to her head. Upon their departure, the assailants took two of Walker’s tires from Johnson’s bedroom. After the men left, Allen called the police.
James testified that he followed the men as they left Allen’s apartment to a building at 86 Caselli Circle. He observed the men removing their masks. He recognized Windham, Woods, Barkus, and Eugene Woods.
During the assault on Alen and Johnson, James McMahon and Craig Chmelik (“Chme-lik”) were visiting James McMahon’s brother, Michael McMahon, at his apartment at 92 Caselli Circle. They observed four or five men who appeared to be carrying gold-rimmed tires. The men carrying the tires yelled at James McMahon. He responded by raising his hands to indicate his lack of involvement in what was happening. Michael McMahon told his brother to leave. He assumed James McMahon would leave with Chmelik, who was already in his Mustang automobile.
James McMahon got into Chmelik’s Mustang. At that point, four or five men emerged from the side of a building. As Chmelik put the Mustang in motion, James McMahon saw Woods “whip” out a “great big handgun.” Woods fired his weapon six times. Two shots hit Chmelik in the chest. They were fatal. Two of the shots hit James McMahon’s leg.
Windham and Woods went to the home of Eugenia Adams (“Adams”) between 1:15 a.m. and 2:00 a.m. on December 27, 1989. Woods secreted a .44 magnum revolver under Adams’s refrigerator. Windham and Woods dropped bullet shells into the toilet in Adams’s apartment. Police officers seized the revolver later that day. It was the firearm used in committing the crimes against Chmelik and James McMahon.
II
Windham contends that the prosecutor engaged in a pattern of discrimination to exclude black women from the jury because of their race and gender.
We review de novo the denial of a state prisoner’s petition for habeas corpus pursuant to 28 U.S.C. § 2254. See Eslaminia v. White, 136 F.3d 1234, 1236 (9th Cir.1998). Typically, in reviewing a state trial court’s judgment in a habeas corpus proceed ing, trial errors affecting constitutional rights are subject to a harmless error analysis. See Brecht v. Abrahamson, 507 U.S. 619, 638, 113 S.Ct. 1710, 123 L.Ed.2d 353 (1993). However, equal protection violations in the selection of a jury are not subject to the harmless error analysis. See Turner v. Marshall, 121 F.3d 1248, 1254 n. 3 (9th Cir.1997) (citing Gray v. Mississippi, 481 U.S. 648, 668, 107 S.Ct. 2045, 95 L.Ed.2d 622 (1987)).
In the brief Windham filed in the district court in support of his petition for a writ of habeas corpus, he contended that the prosecutor improperly exercised peremptory challenges against black women because of their, race and gender. Windham did not raise a federal constitutional challenge based on gender discrimination in the state trial court. During the jury selection process, Mr. Richard L. Reese, counsel for Barkus, made a motion that the court reject the prosecutor’s request that Jacquelyn Sanders, an Arican American, be excused, or in the alternative, that a mistrial be declared because
I believe that the District Attorney is systematically using his peremptory challenges to exclude a particular class, that is blacks, of course. The Court can take judicial notice that the four defendants in this case are, in fact, black. As the jury is constituted right now, the District Attorney has excluded three blacks. Three of those people are blacks, and I think [ ] prima facie showing here is that he is using this to systematically exclude blacks from this jury.
(emphasis added.) Mr. John I. Soika, counsel for Windham, joined in Mr. Reese’s motion.
Following Mr. Reese’s statement of his motion, the trial court asked the prosecutor to comment. The prosecutor responded as follows:
*1097I want to point out that there are presently three jurors on the panel out of 12 whom are blacks, and they remain on the panel throughout this.
My first challenge was a young white man. I had my own reasons to challenge him.
[Peggy Jo Robinson] was a juror who was familiar with not only the area involved, but also through her daughters had heard of the case, its causes and whatever else. That might have turned out to be helpful to the People, I don’t know, but I’d rather she rely on the courtroom and not some impression she received elsewhere.
So I think it’s understandable that I had a good independent reason for exercising that.
The other two people, I would like to see men, but this one seat seems to pick on women. That’s all.
After Mr. Reese explained the relief he was requesting, the prosecutor argued as follows:
Well I see the reason for the motion. I don’t think that they have sustained their burden. We are really down to [ ] blacks out of five peremptory challenges. I gave certainly an excellent, I think, undeniable reason for Ms. Robinson, and we still have remaining on the jury three blacks, so I don’t think that there is any showing of what is required.
Mr. Reese responded: “I think there’s been a prima facie showing just by exclusion of three blacks out of five [peremptory challenges].”
The trial court denied the motion in the following words:
The District Attorney has challenged five jurors, three of the jurors were black women. One for Ms. Robinson. I’m completely satisfied that it had a basis other than based on [sic] assumption that a black juror would perhaps favor the defendants in this case.
It is required if the burden of proof shifts, of course, the District Attorney is required to show reasonable explanation for his challenges.
At this stage, I am not prepared to find or to infer discriminatory purpose which is what is required to shift the burden.
It is early in the selection. Basically, what we have come down to is five challenges, two of which, the only reason given is, they were women and he wanted men; so I’m going to deny the motion at this time.
Of course, you’re allowed to renew it if you feel the facts justify it as we proceed.
When the jury selection process was completed, two black women and one black man served on the jury. After the alternate jurors were selected, Mr. Reese renewed his motion for a mistrial and asked the court to note that the three women excused by the prosecutor “were all black individuals.” Mr. Reese did not contend that the prosecutor excused the jurors because of their gender.
In denying the motion, the court stated: “I do not feel the Defense has met the burden of showing purposeful discrimination and attempt to eliminate jurors, just because of [sic] preconceived notion that they would be voting based on race alone in accordance with both [People v. Wheeler, 22 Cal.3d 258, 148 Cal.Rptr. 890, 583 P.2d 748 (1978), and Batson v. Kentucky, 476 U.S. 79, 106 S.Ct. 1712, 90 L.Ed.2d 69 (1986) ].”
Windham and Woods filed an appeal before the Court of Appeal of the State of California from the judgment of conviction. Before that court, Woods argued for the first time that the prosecutor’s desire for more men on the jury “erroneously showed an intent to discriminate against another suspect classification not suggested by his trial counsel: black women, or women in general.” (emphasis added). In his brief on direct appeal, Windham “join[ed] in this argument in its entirety.”
The Court of Appeal declined to consider Windham’s gender discrimination contention. The Court of Appeal held: “This claim is barred procedurally because that ground of objection was not raised in the trial court.” People v. Barry DeWayne Woods and John Willie Windham, 8 Cal.App.4th 1570, 11 Cal.Rptr.2d 231 (1992) (“Woods and Wind-ham”). The Court of Appeal also commented as follows: “In any event, at the time of the motion, the panel consisted of nine women and three men. The prosecutor’s evident desire for the panel to more closely *1098approximate the population as a whole cannot be equated with impermissible group bias.” Id. The Court of Appeal cited People v. Hayes, 52 Cal.3d 577, 276 Cal.Rptr. 874, 802 P.2d 376 (1990), in support of its conclusion that the gender discrimination claim was procedurally barred. In Hayes, the California Supreme Court was also faced with a claim that the prosecutor improperly used peremptory challenges for a discriminatory purpose that had not been raised before the trial court. Id. The Supreme Court of California held that the claim was procedurally barred. It reasoned as follows:
A party that believes the opposing party is improperly using peremptory challenges for a discriminatory purpose must raise a timely challenge and make a prima facie case. Once a prima facie case has been shown, the burden shifts to the other party to demonstrate that the peremptory challenges were exercised on a neutral basis related to the particular ease to be tried.
In this case, defendant did not raise a timely challenge in the trial court on the ground that the prosecutor was exercising peremptory challenges to improperly exclude Spanish-surnamed persons from the jury. Although some of the peremptory challenges to which defendant raised Wheeler objections were exercised against Spanish-surnamed individuals the record indicates that in each instance the objection was directed to the individual’s attitude toward the death penalty rather than to his or her ethnicity. The claim of improper use of peremptory challenges to exclude Spanish-surnamed persons is, therefore, procedurally barred for failure to raise a timely challenge in the trial court.
Id. at 604-05, 276 Cal.Rptr. at 889, 802 P.2d at 392 (internal citations omitted).
The California Court of Appeal also rejected Windham’s contention that the removal of three African Americans constituted a prima facie showing that the prosecutor exercised his peremptory challenges for the discriminatory purpose of removing prospective jurors because of their race. See Woods and Windham, No. C010320 (Cal.Ct.App. Aug. 24, 1992) (unpublished).
Windham filed a petition for a writ of habeas corpus before the California Supreme Court. He asserted that “[ajfter the third black woman was excused by the prosecutor, then the defense made a Wheeler motion on the ground that the prosecution was improperly excusing blacks from the jury. Petitioner joined in the motion.” Windham argued separately that “[ojbjecting to a juror because she is a woman is just-as improper as objecting because she is black.”
The California Supreme Court summarily denied Windham’s petition, citing In re Waltreus, 62 Cal.2d 218, 225, 42 Cal.Rptr. 9, 397 P.2d 1001 (1965). In Waltreus, the California Supreme Court held that ai'guments rejected on direct appeal cannot ordinarily be raised in a petition for a writ of habeas corpus. Id.
In its answer to Windham’s federal habeas corpus petition, the State argues that because Windham failed to make a prima facie case that the prosecutor peremptorily challenged prospective jurors on the basis of ethnicity, “the state prosecutor was not obligated to articulate his reasons for peremptorily excluding the three Black women prospective jurors.” The State did not discuss Windham’s separate claim that the prosecutor violated the Equal Protection Clause by excluding prospective jurors because of their gender. The State did not assert that the gender discrimination claim was procedurally barred by an adequate and independent state ground.
In his findings and recommendations to the district court, the magistrate judge recommended that the finding of the trial court that the prosecutor exercised his challenges “on reasons other than an assumption that the challenged black jurors would favor the defendant” should not be disturbed. The magistrate judge limited his review to the objection presented to the state trial judge that the prosecutor’s exercise of his peremptory challenges discriminated against blacks. The magistrate judge did not consider the California Court of Appeal’s ruling that the gender discrimination claim was procedurally barred because it was not presented to the trial court. After reviewing the record, the district court adopted the magistrate judge’s findings and recommendations in full without *1099discussing the merits of any of Windham’s contentions.
In reviewing Windham’s equal protection contention, we will first consider whether the district court erred in concluding that the record supported the state trial court’s finding that Windham failed to sustain his burden of making a prima facie showing that the prosecutor had a discriminatory purpose in excluding black jurors through the exercise of his peremptory challenges. In Bat-son, thé United States Supreme Court held that the exercise of peremptory challenges in selecting a petit jury based solely on race violated the Equal Protection Clause. 476 U.S. at 96, 106 S.Ct. 1712.
To establish a prima facie case of purposeful racial discrimination, a defendant must interpose an objection on the ground that the prosecutor has exercised peremptory challenges against prospective jurors because of their race. A defendant must articulate facts and other relevant circumstances that raise an inference that the prosecutor exercised peremptory challenges “to exclude the veniremen from the petit jury on account of their race.” Id. at 80, 106 S.Ct. 1712.
“In deciding whether the defendant has made the requisite showing, the trial court should consider all relevant circumstances.” Id. at 96, 106 S.Ct. 1712. If the district court determines that a prima facie showing has been made, “the burden shifts to the State to come forward with a neutral explanation for challenging black jurors.” Id. at 97, 106 S.Ct. 1712.
Windham’s defense counsel joined in the objection of a codefendant who asserted that “the District Attorney is systematically using his peremptory challenges to exclude a particular class ... that he is using [his peremptory challenges] to systematically exclude blacks from this jury.” The state trial judge found that the defense had not carried its burden of presenting a prima facie case that the prosecutor had exercised his peremptory challenges “based on an assumption that a black juror would perhaps favor the defendants in this case.” The relevant circumstances before the court when it made this finding included the fact that the prosecutor had previously accepted three black jurors. These jurors survived the selection process and were members of a jury that entered a unanimous guilty verdict against Windham. The court also accepted the prosecutor’s explanation that he had exercised his peremptory challenges solely because he wanted to see more men on the jury, and not because the jurors were black. At the time the defense objected to the prosecutor’s challenge on the basis of racial discrimination, nine of the twelve prospective jurors in the box were women. The trial court could have reasonably inferred from this circumstance that the prosecutor’s purpose was not to excuse blacks, but instead, to attempt to have a jury panel that more closely represented the proportionate distribution of men and women in the community.
After the court denied the defendants’ motion to reject the prosecution’s exercise of his peremptory challenge to Ms. Sanders, the defense exercised several other peremptory challenges. The prosecutor did not exercise any of his remaining peremptory challenges. At the time the defense renewed its motion for a mistrial, twenty-five percent of the jurors sworn to try the case were black.
The Supreme Court instructed in Batson that “[s]ince the trial judge’s findings in the context under consideration here largely will turn on the evaluation of credibility, a reviewing court ordinarily should give those findings great deference.” 476 U.S. at 98 n. 21, 106 S.Ct. 1712. The defense did not present any evidence to support its contention that the prosecutor used his peremptory challenges “to systematically exclude blacks from the jury.” The factors considered by the trial court lead to a contrary conclusion. The prosecutor had previously accepted three black jurors. They had been sworn and were part of the petit jury when the motion for a mistrial was renewed. The trial court found credible the prosecutor’s explanation that he was not attempting to exclude blacks on account of their race. Windham has failed to demonstrate that the prosecutor exercised his peremptory challenges to prevent blacks from serving on the jury because of their race.
We next turn to Windham’s claim that the prosecutor violated the principles announced in Batson by exercising his peremptory chai-*1100lenges to exclude women from the jury panel because of their gender. This issue was not presented to the trial court. As discussed above, the defense challenged the prosecutor’s exercise of his peremptory challenges solely on the ground that his purpose was to exclude black jurors because each of the defendants was black.
The State not only failed to assert the defense of procedural default in the district court, it did not refer to this doctrine in the brief it filed in this court. We must decide whether we have the discretion to do so on our motion.
In Trest v. Cain, 522 U.S. 87, 118 S.Ct. 478, 139 L.Ed.2d 444 (1997), the Supreme Court reiterated the principle that the defense of procedural default is waived by a State if it is not raised and presented in the district court. Id. at-, 118 S.Ct. at 480. The narrow question presented in Trest v. Cain was whether a United States Court of Appeals is required to consider the question of procedural default sua sponte. The Court rejected the State’s argument that a “habeas court” must raise this issue on its own motion once it has noticed the possibility of a procedural default. See Id. The Court declined to resolve the inter-circuit conflict regarding whether a “habeas court may consider a procedural default that the State at some point has waived, or failed to raise.” Id.
In Boyd v. Thompson, 147 F.3d 1124 (9th Cir.1998), we held that a district court may raise the defense of procedural default sua sponte if to do so serves the interests of justice, comity, federalism, and judicial efficiency. Id. at 1127. We are persuaded that under the circumstances presented in this record, it would further these same interests to exercise our discretion to apply the procedural default bar to a consideration of the merits of Windham’s claim that the prosecutor intentionally exercised peremptory challenge against potential jurors solely because of their gender.
In Engle v. Isaac, 456 U.S. 107, 102 S.Ct. 1558, 71 L.Ed.2d 783 (1982), the Supreme Court explained the harm that can flow from a failure to recognize a state court’s application of its own procedural rules to federal constitutional claims not properly raised in a trial court.
Finally, the Great Writ imposes special costs on our federal system. The States possess primary authority for defining and enforcing the criminal law. In criminal trials they also hold the initial responsibility for vindicating constitutional rights. Federal intrusions into state criminal trials frustrate both the States’ sovereign power to punish offenders and their good-faith attempts to honor constitutional rights.
In Wainwright v. Sykes, we recognized that these costs are particularly high when a trial default has barred a prisoner from obtaining adjudication of his constitutional claim in the state courts. In that situation, the trial court has had no opportunity to correct the defect and avoid problematic retrials. The defendant’s counsel, for whatever reasons, has detracted from the trial’s significance by neglecting to raise a claim in that forum. The state appellate courts have not had a chance to mend their own fences and avoid federal intrusion. Issuance of a habeas writ, finally, exacts an extra charge by undercutting the States ability to enforce its procedural rules. These considerations supported our Sykes ruling that, when a procedural default bars state litigation of a constitutional claim, a state prisoner may not obtain federal habe-as relief absent a showing of cause and actual prejudice.
Id. at 128-29, 102 S.Ct. 1558. (Internal citation and footnote omitted).
In Coleman v. Thompson, 501 U.S. 722, 111 S.Ct. 2546, 115 L.Ed.2d 640 (1991), the Court again stressed the necessity for the application of the procedural default rule in reviewing habeas corpus petitions filed by a state prisoner.
A habeas petitioner who has defaulted his federal claims in state court meets the technical requirements for exhaustion; there are no state remedies any longer “available” to him. See 28 U.S.C. § 2254(b); Engle v. Isaac, 456 U.S. 107, 125-26, n. 28, 102 S.Ct. 1558, 71 L.Ed.2d 783 (1982). In the absence of the independent and adequate state ground doctrine in federal habeas, habeas petitioners would *1101be able to avoid the exhaustion requirement by defaulting their federal claims in state court. The independent and adequate state ground doctrine ensures that the States’ interest in correcting their own mistakes is respected in all federal habeas eases.
Id. at 732, 111 S.Ct. 2546.
Windham’s failure to raise the gender discrimination claim during the jury selection process, by making a proper objection and a prima facie showing of purposeful gender discrimination, deprived the trial court of the opportunity to take remedial action to preserve the equal protection rights of potential women jurors. In addition, the prosecutor was not given the opportunity to carry his burden of providing a gender-neutral explanation.
It would be violative of comity and “our federalism” for this court to hold that the State of California violated the Equal Protection Clause by purposefully discriminating against women because of their gender when that issue was never presented to the trial court. We believe this is an appropriate case to exercise our discretion to decline to permit a defendant, represented by counsel at trial, to fail to raise an issue before the trial judge, await the outcome of the jury’s deliberations, and then seek federal habeas corpus relief, after the state’s highest court has declined to reach the merits of his federal constitutional claim because it is procedurally barred by state law. This stratagem, if successful, would prevent a trial judge from taking steps to make sure that a state defendant’s federal constitutional rights are preserved, and to fashion an appropriate remedy. We cannot participate in this form of “sandbagging” a state’s judicial system.
Because procedural bar was not raised by the State as a defense regarding this issue, however, Windham did not have the opportunity to attempt to persuade the district court of the cause for his default and any prejudice that may have flowed from the alleged constitutional deprivation, nor was he made aware that he could present facts, if any exist, to demonstrate that he has suffered a miscarriage of justice. See Boyd v. Thompson, 147 F.3d at 1128. Therefore, we must remand this matter to the district court to give Windham an opportunity to present a cause and prejudice justification for his procedural default.
Ill
Windham contends that his Fifth and Fourteenth Amendment rights to due process were violated because the evidence was insufficient to support a finding of murder and attempted murder. Federal habeas corpus relief is available to a petitioner who claims that the evidence was insufficient to support his or her conviction only where, considering the trial record in the light most favorable to the prosecution, “no rational trier of fact could have found proof of guilt beyond a reasonable doubt.” Jackson v. Virginia, 443 U.S. 307, 324, 99 S.Ct. 2781, 61 L.Ed.2d 560 (1979). This standard is applied with reference to the substantive elements of the criminal offense as defined by state law. See id. at 324 n. 16, 99 S.Ct. 2781.
The prosecutor sought Windham’s conviction under the theory that he aided and abetted the assaults on Allen and Johnson, and that the murder of Chmelik and attempted murder of James McMahon were the natural and probable consequences of those assaults. Under California law, “[t]he test for an aider and abettor’s liability for collateral criminal offenses ... depends upon all of the facts and circumstances surrounding the particular defendant’s conduct.” People v. Nguyen, 21 Cal.App.4th 518, 535, 26 Cal.Rptr.2d 323 (1993). The natural and probable consequences doctrine uses an objective test. Liability “is measured by whether a reasonable person in the defendant’s position would have or should have known that the charged offense was a reasonably foreseeable consequence of the act aided and abetted.” Id. at 535, 26 Cal.Rptr.2d 323.
Viewing the evidence in the light most favorable to the prosecution, we hold that sufficient evidence was introduced at trial to support the jury’s finding of the attempted murder of McMahon and the murder of Chmelik. Windham was with Barkus when Walker, a rival gang member, shot Barkus in the foot. Within two weeks of this incident, Windham accompanied co-defendant *1102Woods and several other men, who were armed, to the home of Allen’and Johnson in an attempt to locate Walker. Windham stood outside the apartment while Woods and the other men assaulted Allen and Johnson in their attempt to discover Walker’s whereabouts. Following the assaults, the men carried tires from Allen’s and Johnson’s apartment. The group came upon Chmelik and James McMahon. Woods fired six rounds into Chmelik’s car killing Chmelik and injuring James McMahon.
A rational trier of fact could conclude that Windham served as the lookout for the armed assault on Allen and the shooting of Johnson. A rational trier of fact could conclude that a reasonable person in Windham’s position would have reasonably foreseen that Woods, having assaulted two women in an attempt to locate a rival gang member, would commit murder and attempted murder in his efforts to avenge the injury to his friend. The evidence was sufficient for a rational jury to find that Windham aided and abetted the criminal assaults on Allen and Johnson and that the murder of Chmelik and attempted murder of McMahon were the natural and probable consequences of those assaults.
IV
Windham contends that his Sixth Amendment right to confront adverse witnesses was violated when the preliminary hearing testimony of two witnesses, Jonathan Reed (“Reed”) and Eugenia Adams (“Adams”), was read to the jury after both were found to be unavailable.
The “main and essential purpose” of the Sixth Amendment right to confrontation “is to secure for the opponent the opportunity of cross-examination.” Delaware v. Van Arsdall, 475 U.S. 673, 678, 106 S.Ct. 1431, 89 L.Ed.2d 674 (1986). However, “[a] defendant’s confrontation right ... is not absolute.” Dres v. Campoy, 784 F.2d 996, 998 (9th Cir.1986). The prior testimony of a witness is admissible at trial if it meets a two-prong test. First, the prosecutor must prove that the witness is unavailable to testify at trial. Second, the defendant must have had the opportunity to cross-examine the witness at the prior hearing. See id. at 999.
Windham argues that the trial court erred in finding that Reed was unavailable because the State did not demonstrate that it used reasonable diligence in attempting to locate him. The United States Supreme Court has held that “a witness is not ‘unavailable’ for purposes of the ... exception to the confrontation requirement unless the prose-cutorial authorities have made a good-faith effort to obtain his presence at trial.” Barber v. Page, 390 U.S. 719, 724-25, 88 S.Ct. 1318, 20 L.Ed.2d 255 (1968). We review de novo whether the Supreme Court’s standards for unavailability have been met. See Dres, 784 F.2d at 998 (citing U.S. v. McConney, 728 F.2d 1195, 1201 (9th Cir.1984)).
The record demonstrates that the prosecutor made a good-faith effort to locate Reed. At the preliminary hearing, Reed was ordered to remain in contact with the Sacramento County District Attorney’s office. The prosecutor, Deputy District Attorney Kenneth Reeves, issued a subpoena on July 31, 1990 to compel Reed to testify. Reeves and Reed met on one occasion, after the subpoenas were issued to discuss Reed’s proposed testimony. At that time, Reed represented that he would be at the address set forth in the subpoena. He also agreed to appear at trial as a prosecution witness.
As the date for trial approached, the District Attorney’s office attempted to contact Reed by telephone on three occasions without success. The District Attorney’s office also contacted Reed’s parole officer. A bench warrant was issued for Reed’s arrest.
Reeves assigned a criminal investigator from the District Attorney’s office to locate Reed. The investigator searched for Reed at his home, his parent’s home, and other places Reed was known to frequent. He also checked to see if Reed was listed as an accident casualty. In addition,-a detective of the City of Sacramento Police Department was enlisted to help locate Reed. These attempts to locate Reed demonstrate that the prosecutor exercised due diligence. The admission of Reed’s testimony at the preliminary hearing did not deprive Windham of his right to confrontation.
*1103Windham also contends that his Sixth Amendment right to confront adverse witnesses was violated by the admission of Adams’s preliminary hearing testimony. The trial court received this testimony after ruling that Adams was unavailable due to her assertion of her Fifth Amendment right against self-incrimination.
Windham did not raise this contention in his habeas petition to the district court. In that petition, Windham objected to the instruction given to the jury regarding inferences to be drawn from Adams’ failure to testify. Windham did not object, however, to the trial court’s determination that Adams was unavailable because of her assertion of her constitutional right to remain silent or to the court’s decision to admit Adams’s preliminary hearing testimony. Because Windham raises this issue for the first time on appeal, we will not address his contention that his Sixth Amendment right to confront witness Adams was violated. See Belgarde v. Montana, 123 F.3d 1210, 1216 (9th Cir.1997) (“Habeas claims that are not raised in the petition before the district court are not cognizable on appeal”).
V
Windham contends that he was denied his due process right to a fundamentally fair trial when the trial court admitted evidence tending to support the prosecution’s “gang involvement theory.” We have no authority to review alleged violations of a state’s evidentiary rules in a federal habeas proceeding. See Jammal v. Van de Kamp, 926 F.2d 918, 919 (9th Cir.1991). Our role is limited to determining whether the admission of evidence rendered the trial so fundamentally unfair as to violate due process. See Reiger v. Christensen, 789 F.2d 1425, 1430 (9th Cir.1986). The admission of “other acts” evidence, which a defendant contends is unduly prejudicial, will violate due process only when “there are no permissible inferences the jury may draw from the evidence.” Jammal, 926 F.2d at 920. Thus, whether or not the admission of evidence is contrary to a state rule of evidence, a trial court’s ruling does not violate due process unless the evidence is “of such quality as necessarily prevents a fair trial.” Kealohapauole v. Shimoda, 800 F.2d 1463, 1465 (9th Cir.1986).
Windham objects to the admission of the testimony of Detective Angel Delgadillo and Jonathan Reed. The trial court allowed the prosecution to introduce the testimony of Detective Delgadillo, a member of the Sacramento City Police Department Street Gang Unit, as a “gang expert.” Detective Delga-dillo testified that there were several factions of the gangs known as “Crips” and “Bloods” in the area where the crimes took place. Ninety-five percent of these gang members are black. Most are male. Detective Delga-dillo stated that gangs engage in “paybacks,” or retributive behavior, against rival gangs when one of their cohorts is wronged. Detective Delgadillo also testified regarding Woods’s membership in the Crips gang. While Delgadillo was on the stand, the prosecutor introduced a photo album belonging to Woods which was inscribed “Crip Fo Life” and which contained other writings and photos indicating Woods’s gang affiliation. No evidence was introduced that Windham was a member of the Crips.
Windham also argues that the trial court erred by admitting Jonathan Reed’s preliminary hearing testimony that he was present when Walker shot Barkus in the foot, and that Eugene Woods and Windham were also present. Windham claims that this evidence unduly prejudiced the jury.
The prosecutor introduced evidence of Woods’s involvement in the Crips gang in order to prove that the motive for the assaults on Allen and Johnson was to retaliate against Walker, a member of the Bloods, for his attack on Barkus, a member of the Crips. The trial court ruled that the evidence was relevant since retaliation by gang members for attacks by rival gang members was central to the prosecution’s theory of the case. The California Court of Appeal agreed. It held that “evidence that Woods was a member of a gang was relevant to prove his identity as a perpetrator and to establish his motive for committing the offenses.” Woods and Windham, No. C010320 (Cal.Ct.App. Aug. 24, 1992) (unpublished). The California Court of Appeal concluded that the trial court did not abuse its discretion in finding that the probative value of this evidence of *1104motive and identity outweighed its prejudicial effect. See id.
Windham was prosecuted as an accomplice of Woods. Detective Delgadillo’s testimony regarding Woods’s motive was admissible to demonstrate Windham’s motive for participating in the alleged crimes. Reed’s testimony was sufficient to create a reasonable inference regarding Windham’s motive in accompanying his codefendants as they searched for Walker and assaulted Allen and Johnson. This inference was “relevant to a fact of consequence” (i.e., the motive of the defendant) and did not “lead only to impermissible inferences about the defendant’s character.” McKinney v. Rees, 993 F.2d 1378 (9th Cir.1993). Therefore, the admission of the testimony regarding Woods’s gang involvement and Windham’s presence during the shooting assault on Barkus did not violate Windham’s right to due process.
VI
Windham asserts that certain of the trial court’s instructions deprived him of due process. First, he contends that the court erred in instructing the jury that a person charged as an aider and abettor of a crime that his confederates planned to commit is also liable for any other crime that was the natural and probable consequence of the originally contemplated crime.1
Windham contends that the natural and probable consequences doctrine set forth in CALJIC 3.02 created a mandatory presumption in this case that he was an aider and abettor and shifted from the State its burden of proving each element of an offense. He relies on Sandstrom v. Montana, 442 U.S. 510, 99 S.Ct. 2450, 61 L.Ed.2d 39 (1979). His reliance on Sandstrom is misplaced. Wind-ham has confused the requirement that an aider and abettor intend to commit the contemplated crime, with the vicarious liability imposed on an aider and abettor for the acts of his cohorts that are the natural and probable consequences of the crime originally contemplated.
In Sandstrom, the defendant was charged with murder. Over objection, the jury was instructed that “[t]he law presumes that a person intends the ordinary consequences of his voluntary acts.” Id. at 513, 99 S.Ct. 2450. The court reversed because it concluded that “a reasonable juror could easily have viewed such an instruction as mandatory.” Id. at 515, 99 S.Ct. 2450. In Sandstrom, the Court did not have before it the question of an aider and abettor’s liability for the acts of a confederate that were not originally agreed upon, but which are the natural and probable consequences of such conduct. Moreover, the instruction given to the jury did not shift the burden from the prosecutor of proving the requisite intent for the contemplated offense, a felonious assault.
The jury was properly instructed that if it was persuaded beyond a reasonable doubt that Windham was guilty as an aider and abettor of the contemplated felonious assaults that were committed against members of a rival gang, he would also be liable for the natural and probable consequences of those acts. The trial court did not err in reading CALJIC 3.02 to the jury.
Windham also maintains that the trial court erred in its instruction on the refusal of a witness to testify. The trial court gave the following instruction to the jury: “When a witness refuses to testify to any matter, relying on the constitutional privilege against self-incrimination, you must not draw from the exercise of such privilege any inference as to the believability of the witness or as to the guilt or innocence of the defendant.”
Windham does not contend that this instruction misstates the law. Instead, he argues that the trial court should have given a modified instruction that incorporated the reasoning of the California Court of Appeal *1105for the Second District in People v. Garner, 207 Cal.App.3d 935, 255 Cal.Rptr. 257 (1989). In that matter the court held that CALJIC 2.25 was “entirely unwarranted in the present unique context.” Id. at 938, 255 Cal.Rptr. 257.
' In Gamer, the only evidence presented by the prosecution in a homicide case was an autopsy report and the transcript of the testimony of the sole witness produced at the preliminary hearing. Id. at 937, 255 Cal.Rptr. 257. The witness refused to testify at trial. He informed the prosecutor that he had lied when he identified the defendant at the preliminary hearing. He advised the prosecutor that he would not testify because it would permit the prosecutor to charge him with perjury. See id. at 938, 255 Cal.Rptr. 257. The witness testified under oath in an in-eamera proceeding that he had lied at the preliminary hearing. The prosecutor asked the court to permit the witness to assert his privilege outside the presence of the jury. The trial court denied the prosecutor’s motion. The court allowed the witness to refuse to testify, or to submit to cross-examination concerning his reason for asserting his right to remain silent. See id. at 939, 255 Cal.Rptr. 257.
After the witness’s testimony was read, the court immediately gave the jury the same instruction given to the jury in the instant matter. That admonition was later repeated when the court gave its final instructions to the jury. See id.
In his opening argument, the prosecutor argued that the jury should not consider the invocation of the Fifth Amendment in weighing the witness’s credibility. He repeated this point in his closing argument. See id. The court concluded in Garner that the refusal of the witness to testify, and “the court’s repeated CALJIC No. 2.25 admonitions effectively precluded the jury from determining when, if ever, the one witness against him was speaking truthfully.” Id. at 941, 255 Cal.Rptr. 257. In reversing the conviction, the Gamer court did not rely on the confrontation clause of the Fifth Amendment or any federal decision. In reviewing Windham’s conviction on direct appeal, the California Court of Appeal for the Third Appellate District distinguished Gamer. It summarized its analysis of this issue in these words: “Because of the strong evidence of guilt and the multiple reasons possible for Adams’ decision to assert the privilege, any error in giving CALJIC No. 2.25 was harmless beyond a reasonable doubt.” Woods and Windham, No. C010320 (Cal.Ct.App., Aug. 24,1992) (unpublished).
In the matter before this court, Eugenia Adams testified at the preliminary hearing. Before trial, she told members of the defense team that she had lied at the preliminary hearing out of fear of reprisal from the district attorney’s office. She stated that she feared that she would lose custody of her children had she failed to identify Windham. She refused to testify at trial pursuant to the Fifth Amendment. '
The relevant facts in the Gamer case are readily distinguishable from those present in Windham’s appeal. Here, the defendants presented evidence to impeach Adams’s testimony implicating Windham. A defense investigator testified that Adams told him that a person named Sean Franklin brought the gun to her residence. Thus, unlike the situation in Gamer, the jury received evidence that directly contradicted Adams’s preliminary hearing testimony. Another important distinction is that in Gamer, only one witness’s testimony implicated the defendant. In the matter sub judice, other witnesses connected Windham to the crimes.
The record also shows that Adams told a defense investigator the day before trial that she had been threatened with respect to her proposed testimony, and that someone had fired a shot at her home. Here, unlike the circumstances in Gamer, there is more than one explanation for Adams’s refusal to testify-
A petitioner seeking habeas corpus relief must demonstrate that the alleged error had a substantial and injurious effect or influence in determining the jury’s verdict. See Brecht v. Abrahamson, 507 U.S. at 619, 637, 113 S.Ct. 1710, 123 L.Ed.2d 353 (1993). Windham has failed to demonstrate that the giving of CALJIC 2.25 had a substantial influence on the jury’s verdict.
Windham further asserts that the state trial court erred when it failed to in*1106struct the jury sua sponte on all lesser included offenses of murder in the first degree, and that this omission violated his Sixth and Fourteenth Amendment rights to a jury trial and due process. We disagree. Under the law of this circuit, the failure of a state trial court to instruct on lesser included offenses in a non-capital case does not present a federal constitutional question. See Turner v. Marshall, 63 F.3d 807, 819 (9th Cir.1995).
Additionally, Windham seeks reversal on the ground that the trial court’s jury instructions omitted the defendant’s theory of the case. This issue was not raised in Windham’s habeas corpus petition. Therefore, this claim is not cognizable on appeal. See Belgarde v. Montana, 123 F.3d at 1216.
VII
Windham alleges that his Eighth Amendment right against cruel and unusual punishment was violated on three grounds: (1) some of his codefendants were acquitted; (2) the jury would have convicted him of the lesser included offenses if not for so many trial errors; and (3) he was nineteen years old at the time the crime was committed. Windham relies solely on the California Supreme Court’s decision in People v. Dillon, 34 Cal.3d 441, 194 Cal.Rptr. 390, 668 P.2d 697 (1983), in support of his Eighth Amendment challenge. In Dillon, however, the California Supreme Court based its decision on its own prior case law and its interpretation of the California Constitution. Id. at 478-82, 194 Cal.Rptr. 390, 668 P.2d 697. In reviewing a state prisoner’s challenge to his conviction, we must apply federal law. See Frias v. Wilson, 373 F.2d 61, 62 (9th Cir.1967) (“Of course a state court may apply more liberal standards than those declared by the Supreme Court; however, the issue in a federal court remains whether judged by federal standards a petitioner was accorded the minimum guarantees afforded by the United States Constitution.”).
We review a contention that a punishment violates the Eighth Amendment’s ban against cruel and unusual punishment de novo. See Eslaminia, 136 F.3d at 1236. The Eighth Amendment of the federal constitution does not contain a proportionality guarantee. See Harmelin v. Michigan, 501 U.S. 957, 965, 111 S.Ct. 2680, 115 L.Ed.2d 836 (1991); United States v. Dubose, 146 F.3d 1141, 1146 (9th Cir.1998). However, a criminal sentence is deemed unconstitutional if it is extreme and grossly disproportionate to the crime for which the defendant has been convicted. See Dubose, 146 F.3d at 1147 (citing Harmelin, 501 U.S. at 1001, 111 S.Ct. 2680); Belgarde, 123 F.3d at 1215. The constitutionality of a sentence is determined by analyzing three factors: (1) the gravity of the offense and the harshness of the penalty; (2) the comparison with the sentences imposed on other criminals in the same jurisdiction; and (3) where appropriate, the comparison with sentences imposed for commission of the same crime in other jurisdictions. See United States v. McDougherty, 920 F.2d 569, 576 (9th Cir.1990) (citing Solem v. Helm, 463 U.S. 277, 290-92, 103 S.Ct. 3001, 77 L.Ed.2d 637 (1983)).
“The type of harm is measured by whether the crime was violent in nature and whether the offense was directed at a person or at property.” Cocio v. Bramlett, 872 F.2d 889, 892 (9th Cir.1989). Windham was convicted of murder, attempted murder, and assault with a firearm.
In Rummel v. Estelle, 445 U.S. 263, 100 S.Ct. 1133, 63 L.Ed.2d 382 (1980), the Court noted that “[o]utside the context of capital punishment, successful challenges to the proportionality of particular sentences have been exceedingly rare.” Id. at 272, 100 S.Ct. 1133. The Court has determined that Rummel “stands for the proposition that federal courts should be ‘reluctan[t] to review legislatively mandated terms of imprisonment.’ ” Hutto v. Davis, 454 U.S. 370, 374, 102 S.Ct. 703, 70 L.Ed.2d 556 (1982), citing Rummel, 445 U.S. at 274, 100 S.Ct. 1133. See also Gore v. U.S., 357 U.S. 386, 392, 78 S.Ct. 1280, 2 L.Ed.2d 1405 (1958).
Under California law, the punishment for all persons convicted of second-degree murder is fifteen years to life. Cal. Pen.Code § 190. “Generally, as long as the sentence imposed on the defendant does not exceed statutory limits, we will not overturn it on eighth amendment grounds.” United States v. Zavala-Serra, 853 F.2d 1512, 1518 (9th Cir.1988). In light of the fact that Windham *1107aided and abetted the killing of another human being, and that he received the same sentence imposed on all persons in California who commit second-degree murder, his sentence of fifteen years to life was not cruel and unusual.
VIII
Windham also contends that the California Court of Appeal did not adopt an appropriate remedy for the trial court’s erroneous instruction to the jury that an aider and abettor could not be convicted of second-degree murder where the perpetrator has been convicted of first-degree murder. Because the California Court concluded that the trial court’s instruction was erroneous, it reduced Windham’s first-degree murder conviction to second-degree murder and adjusted his sentence to 15 years to life. Under California law, an appellate court “may reverse, affirm, or modify a judgment ... appealed from, or reduce the degree of the offense. ...” Cal.Penal Code § 1260 (emphasis added).
Habeas corpus relief is “unavailable for alleged eiTor in the interpretation or application of state law.” Middleton v. Cupp, 768 F.2d 1083, 1085 (9th Cir.1985). Whether the California Court of Appeal erred in its application of section 1260 is a question of state law that we cannot review.
CONCLUSION
Windham has urged us to reverse because he contends that the cumulative effect of the alleged errors set forth in his petition compel the granting of habeas corpus relief in this matter. Windham has failed to demonstrate that the State deprived him of any of his federal constitutional rights. We decline to reach the merits of his gender discrimination claim because it is procedurally barred. However, because Windham has not had the opportunity to attempt to demonstrate the cause for his default and any prejudice that has resulted, we direct the district court to afford him the opportunity to do so prior to determining whether it should reach the merits of his gender discrimination claim.
AFFIRMED in part, VACATED in part with directions.
. The trial court instructed the jury as follows on the natural and probable consequences doctrine as then contained in CALJIC 3.02:
One who aids and abets is not only guilty of the particular crime that to his knowledge his confederates are contemplating committing, but he is also liable for the natural and probable consequences of any criminal act that he knowingly and intentionally aided and abetted. You must determine whether the defendant is guilty of the crime originally contemplated, and, if so, whether the crime charged in Counts One and Two was a natural and probable consequence of such originally contemplated crime.
CALJIC 3.02 was revised in 1992.